     1                                  ; ****************************************************************************
     2                                  ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.7
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; Last Update: 20/10/2023 (Previous: 30/08/2023)
     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                                  ; 29/08/2023 - TRDOS 386 v2.0.6
   179                                  	; 30/11/2020
   180                                  	; 29/11/2020 - TRDOS 386 v2.0.3
   181                                  
   182                                  struc PMInfo  ;  VESA VBE3 PMInfoBlock ('PMID' block)
   183                                  
   184 00000000 ????????                 .Signature:	resb 4  ; db 'PMID' ; PM Info Block Signature
   185 00000004 ????                     .EntryPoint:	resw 1	; Offset of PM entry point within BIOS
   186 00000006 ????                     .PMInitialize: resw 1	; Offset of PM initialization entry point
   187 00000008 ????                     .BIOSDataSel:	resw 1 	; Selector to BIOS data area emulation block
   188 0000000A ????                     .A0000Sel:	resw 1	; Selector to access A0000h physical mem
   189 0000000C ????                     .B0000Sel:	resw 1  ; Selector to access B0000h physical mem
   190 0000000E ????                     .B8000Sel:	resw 1	; Selector to access B8000h physical mem
   191 00000010 ????                     .CodeSegSel:	resw 1	; Selector to access code segment as data
   192 00000012 ??                       .InProtectMode: resb 1 ; Set to 1 when in protected mode
   193 00000013 ??                       .Checksum:	resb 1	; Checksum byte for structure
   194                                   .size:
   195                                  
   196                                  endstruc
   197                                   
   198                                  [BITS 16]       ; We need 16-bit intructions for Real mode
   199                                  
   200                                  [ORG 0] 
   201                                  	; 12/11/2014
   202                                  	; Save boot drive number (that is default root drive)
   203 00000000 8816[2865]              	mov	[boot_drv], dl ; physical drv number
   204                                  
   205                                  	; Determine installed memory
   206                                  	; 31/10/2014
   207                                  	;
   208 00000004 B801E8                  	mov	ax, 0E801h ; Get memory size 
   209 00000007 CD15                    	int	15h	   ; for large configurations
   210 00000009 7308                    	jnc	short chk_ms
   211 0000000B B488                    	mov	ah, 88h    ; Get extended memory size 
   212 0000000D CD15                    	int	15h
   213                                  	;	   
   214                                  	;mov	al, 17h	; Extended memory (1K blocks) low byte
   215                                  	;out	70h, al ; select CMOS register
   216                                  	;in	al, 71h ; read data (1 byte)
   217                                  	;mov	cl, al
   218                                  	;mov	al, 18h ; Extended memory (1K blocks) high byte
   219                                  	;out	70h, al ; select CMOS register
   220                                  	;in	al, 71h ; read data (1 byte)
   221                                  	;mov	ch, al
   222                                   	;      
   223 0000000F 89C1                    	mov	cx, ax
   224 00000011 31D2                    	xor	dx, dx
   225                                  chk_ms:
   226 00000013 890E[2465]              	mov	[mem_1m_1k], cx
   227 00000017 8916[2665]              	mov	[mem_16m_64k], dx
   228                                  	; 05/11/2014
   229                                  	;and	dx, dx
   230                                  	;jz	short L2
   231 0000001B 81F90004                        cmp     cx, 1024
   232                                  	;jnb	short L0
   233 0000001F 7351                    	jnb	short V0 ; 14/11/2020
   234                                  		 ; insufficient memory_error	
   235                                  		 ; Minimum 2 MB memory is needed... 
   236                                  	; 05/11/2014
   237                                  	; (real mode error printing)
   238 00000021 FB                      	sti
   239 00000022 BE[3600]                	mov	si, msg_out_of_memory
   240 00000025 BB0700                  	mov	bx, 7
   241 00000028 B40E                    	mov	ah, 0Eh	; write tty
   242                                  oom_1:
   243 0000002A AC                      	lodsb
   244 0000002B 08C0                    	or	al, al
   245 0000002D 7404                    	jz	short oom_2
   246 0000002F CD10                    	int	10h
   247 00000031 EBF7                    	jmp	short oom_1
   248                                  oom_2:
   249 00000033 F4                              hlt
   250 00000034 EBFD                    	jmp	short oom_2
   251                                  
   252                                  ; 20/02/2017
   253                                  ; 05/11/2014
   254                                  msg_out_of_memory:
   255 00000036 070D0A                  	db 	07h, 0Dh, 0Ah
   256 00000039 496E73756666696369-             db      'Insufficient memory !'
   256 00000042 656E74206D656D6F72-
   256 0000004B 792021             
   257 0000004E 0D0A                    	db	0Dh, 0Ah
   258                                  _int13h_48h_buffer: ; 07/07/2016
   259 00000050 284D696E696D756D20-     	db	'(Minimum 2MB memory is needed.)'
   259 00000059 324D42206D656D6F72-
   259 00000062 79206973206E656564-
   259 0000006B 65642E29           
   260 0000006F 0D0A00                   	db	0Dh, 0Ah, 0
   261                                  V0:
   262                                  	; 18/10/2023 - TRDOS 386 v2.0.7
   263                                  	; set video mode to 03h again 
   264                                  	; (to reset video bios data in ROMBIOS DATA AREA)
   265 00000072 B80300                  	mov	ax, 3
   266 00000075 CD10                    	int	10h
   267                                  	; copy IVT and ROMBIOS DATA AREA to VBE3 BIOS data area
   268 00000077 BF0097                  	mov	di, VBE3BIOSDATABLOCK>>4
   269 0000007A 8EC7                    	mov	es, di
   270 0000007C 31F6                    	xor	si, si
   271 0000007E 31FF                    	xor	di, di
   272 00000080 8EDE                    	mov	ds, si ; 0
   273 00000082 B90003                  	mov	cx, 300h ; 600h / 2
   274 00000085 F3A5                    	rep	movsw
   275 00000087 0E                      	push	cs
   276 00000088 1F                      	pop	ds
   277                                  	
   278                                  	; 15/12/2020
   279 00000089 8B36[2665]              	mov	si, [mem_16m_64k]
   280 0000008D 8936[040F]              	mov	[real_mem_16m_64k], si
   281                                  	; 15/11/2020
   282                                  	; 14/11/2020 (TRDOS 386 v2.0.3)
   283                                  	; check VESA (VBE) VIDEO BIOS version
   284                                  
   285 00000091 B8034F                  	mov	ax, 4F03h  ; Return current VBE mode
   286 00000094 CD10                    	int	10h
   287 00000096 83F84F                  	cmp	ax, 004Fh  ; successful (vbe) function call
   288                                  	;jne	short L0   ; not a VESA VBE compatible bios	
   289                                  	; 18/10/2023
   290 00000099 7565                    	jne	short V1   ; restore es
   291                                  
   292                                  	;mov	ah, 3
   293                                  	;;jmp	short V1	
   294                                  	
   295                                  	; 15/11/2020
   296 0000009B BBE097                  	mov	bx, VBE3INFOSEG  ; 97E0h for current version 
   297 0000009E 8EC3                    	mov	es, bx
   298 000000A0 31FF                    	xor	di, di
   299 000000A2 2666C70556424532        	mov	dword [es:di], 'VBE2' ; request VESA VBE3 info
   300                                  		; es:di = buffer address (512 bytes)
   301                                  	;mov	ax, 4F00h ; Return VBE controller information
   302 000000AA 86C4                    	xchg	al, ah
   303 000000AC CD10                    	int	10h
   304                                  	
   305                                  	; dx = cs
   306                                  	; es = VBE3INFOSEG (97E0h)
   307                                  	; di = 0
   308                                  	; ss = (endofkernelfile/16)+16
   309                                  	; sp = 0FFFEh
   310                                  
   311 000000AE 83F84F                  	cmp	ax, 004Fh
   312 000000B1 754D                    	jne	short V1 ; old vga bios (not VESA compatible)
   313                                  
   314                                  	; 15/11/2020
   315 000000B3 2666813D56455341        	cmp	dword [es:di], 'VESA'
   316 000000BB 7543                    	jne	short V1
   317                                  	
   318                                  	;mov	ax, [es:di+4]
   319                                  	;	; ax = vbe version in BCD format (0200h or 0300h)
   320                                  	;mov	[vbe3], ah ; version number (major) 	
   321                                  
   322                                  	; 15/11/2020
   323 000000BD 268A4505                	mov	al, [es:di+5]
   324                                  		; al = high byte of VBE version number (02h or 03h)
   325                                  
   326 000000C1 A2[7909]                	mov	[vbe3], al ; version number (major) 	
   327                                  			   ; 02h or 03h is expected
   328                                  	; 17/01/2021
   329                                  	; Read EDID
   330 000000C4 B301                    	mov	bl, 01h	; Read EDID
   331 000000C6 31C9                    	xor	cx, cx	; Controller unit number
   332                                  			; (00 = primary controller)
   333 000000C8 31D2                    	xor	dx, dx	; EDID block number = 0
   334 000000CA B8C097                  	mov	ax, VBE3MODEINFOSEG  ; 97C0h for current version
   335 000000CD 8EC0                    	mov	es, ax
   336 000000CF BF0001                  	mov	di, VBE3EDIDINFOBLOCK - VBE3MODEINFOBLOCK
   337                                  	; es:di = temporary address of 128 bytes EDID information 
   338 000000D2 B8154F                  	mov	ax, 4F15h ; VBE/DDC Services 
   339 000000D5 CD10                    	int	10h
   340                                  	;cmp	ax, 4Fh
   341                                  	;jne	short v2
   342 000000D7 A2[9141]                	mov	[edid], al ; 4Fh > 0	
   343                                  ;V2:
   344                                  	; 17/01/2021
   345 000000DA 31FF                    	xor	di, di
   346                                  	; 15/12/2020
   347                                  	; Get linear frame buffer info (for VESA VBE mode 118h)
   348                                  	;mov	si, VBE3MODEINFOSEG  ; 97C0h for current version
   349                                  	;mov	es, si
   350                                   	; di = 0
   351 000000DC B91841                  	mov	cx, 04118h  ; 1024*768, 24 bpp, LFB
   352 000000DF B8014F                  	mov	ax, 4F01h ; Return VBE mode information
   353 000000E2 CD10                    	int	10h
   354                                  	;cmp	ax, 4Fh
   355                                  	;jne	short V1
   356                                  	; 19/12/2020
   357                                  	;mov	si, [es:di+MODEINFO.PhysBasePtr+2]
   358                                  			; hw of LFB base address
   359                                  	; MODEINFO structure starts from offset -2
   360 000000E4 268B752A                	mov	si, [es:di+MODEINFO.PhysBasePtr] ; hw of LFB addr
   361 000000E8 8936[060F]              	mov	[def_LFB_addr], si ; k_LFB_size = 3145728 bytes
   362 000000EC 81EE0001                	sub	si, 256
   363                                  	
   364                                  	; 15/12/2020
   365                                  	; check memory and decrease it to 3.5 GB if it is 4GB
   366                                  	; (reserve upper memory for LFB)
   367 000000F0 8B3E[2665]              	mov	di, [mem_16m_64k]
   368 000000F4 893E[040F]              	mov	[real_mem_16m_64k], di
   369                                  
   370 000000F8 39F7                    	cmp	di, si
   371 000000FA 7604                    	jna	short V1
   372                                  
   373 000000FC 8936[2665]              	mov	[mem_16m_64k], si
   374                                  
   375                                  	; VESA VBE3 video hardware 
   376                                  	; (example: NVIDIA GEFORCE FX550, 256 MB)
   377                                  	; uses upper memory from 0D0000000h to 0DFFFFFFFh
   378                                  	
   379                                  	;;cmp	di, 0CF00h ; 3328 MB - 16MB
   380                                  	;jna	short V1  ; <= 3328 MB memory, it is not required
   381                                  			  ; decrease
   382                                  	;cmp	al, 3 
   383                                  	;jb	short V2 
   384                                  	; VESA VBE 3
   385                                  	;mov	word [mem_16m_64k], 0CF00h ; 3328 MB - 16MB
   386                                  	;jmp	short V1 	
   387                                  ;V2:
   388                                  	; VESA VBE 2
   389                                  	; Check Bochs/Qemu/VirtualBox Emulator
   390                                  	; LFB base address: 0E0000000h
   391                                  	;sub	ax, ax ; 0
   392                                  	;mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
   393                                  	;out	dx, ax ; VBE_DISPI_INDEX_ID register
   394                                  	;inc	dx
   395                                  	;in	ax, dx
   396                                  	;and	al, 0F0h
   397                                  	;cmp	ax, 0B0C0h
   398                                  	;jne	short V1
   399                                  	;
   400                                  	; BOCHS/QEMU/VIRTUALBOX
   401                                  	;mov	word [mem_16m_64k], 0DF00h ; 3584 MB - 16MB	
   402                                  V1:
   403 00000100 1E                      	push	ds
   404 00000101 07                      	pop	es ; restore extra data segment	
   405                                  L0:
   406                                  
   407                                  %include 'diskinit.s' ; 07/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - diskinit.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 09/08/2022 (Previous: 29/08/2020 - Kernel v2.0.4)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; diskinit.inc (10/07/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - DISKINIT.INC
    20                              <1> ; Last Modification: 12/07/2022 (Previous: 10/07/2015)
    21                              <1> 
    22                              <1> ; DISK I/O SYSTEM INITIALIZATION - Erdogan Tan (Retro UNIX 386 v1 project)
    23                              <1> 
    24                              <1> ; ///////// DISK I/O SYSTEM STRUCTURE INITIALIZATION ///////////////
    25                              <1> 
    26                              <1> 	; 09/08/2022
    27                              <1> 	; 08/08/2022
    28                              <1> 	; 14/07/2022 (TRDOS 386 v2.0.5)
    29                              <1> 	; 12/07/2022 (Retro UNIX 386 v1.2)
    30                              <1> 	; 29/08/2020
    31                              <1> 	; 17/07/2020
    32                              <1> 	; 14/07/2020 (TRDOS 386 v2.0.2)
    33                              <1> 	; 10/12/2014 - 02/02/2015 - dsectrm2.s
    34                              <1> ;L0:
    35                              <1> 	; 12/11/2014 (Retro UNIX 386 v1 - beginning)
    36                              <1> 	; Detecting disk drives... (by help of ROM-BIOS)
    37 00000102 BA7F00              <1> 	mov	dx, 7Fh
    38                              <1> L1:	
    39 00000105 FEC2                <1> 	inc	dl
    40 00000107 B441                <1> 	mov	ah, 41h ; Check extensions present
    41                              <1> 			; Phoenix EDD v1.1 - EDD v3
    42 00000109 BBAA55              <1> 	mov	bx, 55AAh
    43 0000010C CD13                <1> 	int 	13h
    44 0000010E 721A                <1> 	jc	short L2
    45                              <1> 
    46 00000110 81FB55AA            <1> 	cmp	bx, 0AA55h
    47 00000114 7514                <1> 	jne	short L2
    48 00000116 FE06[2B65]          <1> 	inc	byte [hdc]	; count of hard disks (EDD present)
    49 0000011A 8816[2A65]          <1>         mov     [last_drv], dl  ; last hard disk number
    50 0000011E BB[AE64]            <1> 	mov	bx, hd0_type - 80h
    51 00000121 01D3                <1> 	add	bx, dx	 
    52 00000123 880F                <1> 	mov	[bx], cl ; Interface support bit map in CX
    53                              <1> 			 ; Bit 0 - 1, Fixed disk access subset ready
    54                              <1> 			 ; Bit 1 - 1, Drv locking and ejecting ready
    55                              <1> 			 ; Bit 2 - 1, Enhanced Disk Drive Support
    56                              <1>                          ;            (EDD) ready (DPTE ready)
    57                              <1> 			 ; Bit 3 - 1, 64bit extensions are present
    58                              <1>                          ;            (EDD-3)
    59                              <1> 			 ; Bit 4 to 15 - 0, Reserved
    60 00000125 80FA83              <1> 	cmp	dl, 83h	 ; drive number < 83h
    61 00000128 72DB                <1> 	jb	short L1
    62                              <1> L2:
    63                              <1> 	; 23/11/2014
    64                              <1> 	; 19/11/2014
    65 0000012A 30D2                <1> 	xor	dl, dl  ; 0
    66                              <1> 	; 04/02/2016 (esi -> si)
    67 0000012C BE[2C65]            <1> 	mov	si, fd0_type
    68                              <1> L3:
    69                              <1> 	; 14/01/2015
    70 0000012F 8816[2965]          <1> 	mov	[drv], dl
    71                              <1> 	;
    72 00000133 B408                <1> 	mov 	ah, 08h ; Return drive parameters
    73 00000135 CD13                <1> 	int	13h	
    74 00000137 7210                <1> 	jc	short L4
    75                              <1> 		; BL = drive type (for floppy drives)
    76                              <1> 		; DL = number of floppy drives
    77                              <1> 		;		
    78                              <1> 		; ES:DI = Address of DPT from BIOS
    79                              <1> 		;
    80 00000139 881C                <1> 	mov	[si], bl ;  Drive type
    81                              <1> 			; 4 = 1.44 MB, 80 track, 3 1/2"
    82                              <1> 	; 14/01/2015
    83 0000013B E8DD01              <1> 	call	set_disk_parms
    84                              <1> 	; 10/12/2014
    85 0000013E 81FE[2C65]          <1> 	cmp	si, fd0_type
    86 00000142 7705                <1> 	ja	short L4
    87 00000144 46                  <1> 	inc	si ; fd1_type
    88 00000145 B201                <1> 	mov	dl, 1
    89 00000147 EBE6                <1> 	jmp	short L3
    90                              <1> L4:
    91 00000149 B27F                <1> 	mov	dl, 7Fh
    92                              <1> 	; 24/12/2014
    93 0000014B 803E[2B65]00        <1> 	cmp	byte [hdc], 0 ; EDD present or not ?	
    94                              <1> 	;ja	L10	  ; yes, all fixed disk operations
    95                              <1> 			  ; will be performed according to
    96                              <1> 			  ; present EDD specification
    97                              <1> 	; 14/07/2022
    98 00000150 7603                <1> 	jna	short L5
    99 00000152 E98B00              <1> 	jmp	L10
   100                              <1> 
   101                              <1> L5:
   102                              <1> 	; 17/07/2020
   103                              <1> 	; Note: Virtual CPU will not come here while 
   104                              <1> 	; running in QEMU, Bochs, VirtualBox emulators !!!
   105                              <1> 	
   106                              <1> 	; 17/07/2020
   107                              <1> 	; Older BIOS (INT 13h, AH = 48h is not available)
   108                              <1> 
   109 00000155 FEC2                <1> 	inc 	dl
   110 00000157 8816[2965]          <1>         mov     [drv], dl
   111 0000015B 8816[2A65]          <1>         mov     [last_drv], dl ; 14/01/2015
   112 0000015F B408                <1> 	mov 	ah, 08h ; Return drive parameters
   113 00000161 CD13                <1> 	int	13h	; (conventional function)
   114                              <1> 	;jc	L13	; fixed disk drive not ready
   115                              <1> 	; 14/07/2022
   116 00000163 7303                <1> 	jnc	short L6
   117 00000165 E9A501              <1> 	jmp	L13
   118                              <1> L6:
   119 00000168 8816[2B65]          <1>         mov     [hdc], dl ; number of drives
   120                              <1> 	;; 14/01/2013
   121                              <1> 	;;push	cx
   122 0000016C E8AC01              <1> 	call	set_disk_parms
   123                              <1> 	;;pop	cx
   124                              <1> 	;
   125                              <1> 	;;and	cl, 3Fh	 ; sectors per track (bits 0-6)
   126 0000016F 8A16[2965]          <1>         mov     dl, [drv]
   127 00000173 BB0401              <1> 	mov	bx, 65*4 ; hd0 parameters table (INT 41h)	
   128 00000176 80FA80              <1> 	cmp	dl, 80h
   129 00000179 7603                <1> 	jna	short L7
   130 0000017B 83C314              <1> 	add	bx, 5*4	 ; hd1 parameters table (INT 46h)
   131                              <1> L7:	
   132 0000017E 31C0                <1> 	xor	ax, ax
   133 00000180 8ED8                <1> 	mov	ds, ax
   134 00000182 8B37                <1>         mov     si, [bx]
   135 00000184 8B4702              <1>         mov     ax, [bx+2] 
   136 00000187 8ED8                <1> 	mov	ds, ax
   137 00000189 3A4C0E              <1>         cmp     cl, [si+FDPT_SPT] ; sectors per track 
   138                              <1> 	;jne	L12 ; invalid FDPT
   139                              <1> 	; 14/07/2022
   140 0000018C 7403                <1> 	je	short L7_8
   141 0000018E E97801              <1> 	jmp	L12
   142                              <1> L7_8:
   143 00000191 BF0000              <1> 	mov	di, HD0_DPT
   144 00000194 80FA80              <1> 	cmp	dl, 80h
   145 00000197 7603                <1> 	jna	short L8
   146 00000199 BF2000              <1> 	mov	di, HD1_DPT 
   147                              <1> L8:
   148                              <1> 	; 30/12/2014
   149 0000019C B80090              <1> 	mov	ax, DPT_SEGM
   150 0000019F 8EC0                <1> 	mov	es, ax
   151                              <1> 	; 24/12/2014
   152 000001A1 B90800              <1> 	mov	cx, 8
   153 000001A4 F3A5                <1> 	rep	movsw  ; copy 16 bytes to the kernel's DPT location
   154 000001A6 8CC8                <1> 	mov	ax, cs
   155 000001A8 8ED8                <1> 	mov	ds, ax
   156                              <1> 
   157                              <1> 	; 02/02/2015
   158                              <1> 	;mov	cl, [drv]
   159                              <1> 	;mov	bl, cl
   160                              <1> 	;mov	ax, 1F0h
   161                              <1> 	;and	bl, 1
   162                              <1> 	;jz	short L9
   163                              <1> 	;shl	bl, 4
   164                              <1> 	;sub	ax, 1F0h-170h
   165                              <1> 
   166                              <1> 	; 17/07/2020 
   167                              <1> 	; (Only 1F0h port address must be valid for old ROM BIOSes)
   168 000001AA B8F001              <1> 	mov	ax, 1F0h
   169 000001AD B3A0                <1> 	mov	bl, 0A0h
   170 000001AF 80FA80              <1> 	cmp	dl, 80h
   171 000001B2 7603                <1> 	jna	short L9
   172                              <1> 	; dl = 81h
   173 000001B4 80C310              <1> 	add	bl, 10h  ; slave disk
   174                              <1> 	;sub	ax, 1F0h-170h
   175                              <1> L9:
   176 000001B7 AB                  <1> 	stosw	; I/O PORT Base Address (1F0h, 170h)
   177 000001B8 050602              <1> 	add	ax, 206h
   178 000001BB AB                  <1> 	stosw	; CONTROL PORT Address (3F6h, 376h)	
   179 000001BC 88D8                <1> 	mov	al, bl  ; bit 4, master/slave disk bit
   180                              <1> 	;add	al, 0A0h ; 17/07/2020
   181 000001BE AA                  <1> 	stosb	; Device/Head Register upper nibble
   182                              <1> 	;
   183 000001BF FE06[2965]          <1> 	inc	byte [drv]
   184                              <1> 	;mov	bx, hd0_type - 80h
   185                              <1> 	;add	bx, cx
   186                              <1> 	; 09/08/2022 - BugFix
   187 000001C3 30FF                <1> 	xor	bh, bh
   188 000001C5 88D3                <1> 	mov	bl, dl
   189 000001C7 81C3[AE64]          <1> 	add	bx, hd0_type - 80h
   190 000001CB 800F80              <1> 	or      byte [bx], 80h  ; present sign (when lower nibble is 0)
   191 000001CE A0[2B65]            <1> 	mov	al, [hdc]
   192 000001D1 FEC8                <1> 	dec	al
   193                              <1> 	;jz	L13
   194                              <1> 	; 14/07/2022
   195 000001D3 7408                <1> 	jz	short L9_10
   196 000001D5 80FA80              <1> 	cmp	dl, 80h
   197                              <1>         ;jna	L5 ; Max. 2 hard disks  ; 17/07/2020
   198                              <1> 	; 14/07/2022
   199 000001D8 7703                <1> 	ja	short L9_10
   200 000001DA E978FF              <1> 	jmp	L5
   201                              <1> L9_10:
   202 000001DD E92D01              <1>         jmp     L13
   203                              <1> L10:
   204 000001E0 FEC2                <1> 	inc 	dl
   205                              <1> 	; 25/12/2014
   206 000001E2 8816[2965]          <1> 	mov	[drv], dl
   207 000001E6 B408                <1> 	mov 	ah, 08h ; Return drive parameters
   208 000001E8 CD13                <1> 	int	13h	; (conventional function)
   209                              <1> 	;jc	L13
   210                              <1> 	; 14/07/2022
   211 000001EA 72F1                <1> 	jc	short L9_10
   212                              <1> 	; 14/01/2015
   213                              <1> 	;mov	dl, [drv]
   214                              <1> 	; 09/08/2022
   215                              <1> 	;push	dx
   216 000001EC 51                  <1> 	push	cx
   217 000001ED E82B01              <1> 	call	set_disk_parms
   218 000001F0 59                  <1> 	pop	cx
   219                              <1> 	;pop	dx
   220                              <1> 	; 09/08/2022
   221 000001F1 8A16[2965]          <1> 	mov	dl, [drv]	
   222                              <1> 	; 06/07/2016 (BugFix for >64K kernel files)
   223                              <1> 	; 04/02/2016 (esi -> si)
   224                              <1> 	;mov	si, _end ; 30 byte temporary buffer address 	
   225                              <1> 	;		 ; at the '_end' of kernel.
   226                              <1> 	;mov	word [si], 30
   227                              <1> 	; 06/07/2016
   228 000001F5 BE[5000]            <1> 	mov	si, _int13h_48h_buffer
   229                              <1> 	; 09/07/2016
   230 000001F8 B81E00              <1> 	mov	ax, 001Eh
   231 000001FB 8824                <1> 	mov	[si], ah ; 0
   232 000001FD 46                  <1> 	inc	si
   233 000001FE 8904                <1> 	mov	[si], ax
   234                              <1>  	; word [si] = 30
   235                              <1> 	;
   236 00000200 B448                <1> 	mov	ah, 48h	 ; Get drive parameters (EDD function)
   237 00000202 CD13                <1> 	int	13h
   238                              <1> 	;jc	L13
   239                              <1> 	; 14/07/2022
   240 00000204 72D7                <1> 	jc	short L9_10
   241                              <1> 
   242                              <1> 	; 29/08/2020
   243                              <1> 	; 04/02/2016 (ebx -> bx)
   244                              <1> 	; 14/01/2015
   245 00000206 28FF                <1> 	sub	bh, bh
   246 00000208 88D3                <1> 	mov	bl, dl
   247                              <1> 	;sub	bl, 80h
   248                              <1> 	; 29/08/2020
   249 0000020A 81C3[AE64]          <1> 	add	bx, (hd0_type - 80h)
   250                              <1> 	;mov 	al, [bx]
   251 0000020E 8A07                <1> 	mov	al, [bx]
   252 00000210 0C80                <1> 	or	al, 80h
   253 00000212 8807                <1> 	mov 	[bx], al	
   254 00000214 81EB[2C65]          <1> 	sub	bx, hd0_type - 2 ; 15/01/2015
   255                              <1> 	;add	bx, drv.status
   256                              <1> 	;mov	[bx], al
   257                              <1> 	; 29/08/2020
   258 00000218 8887[4E65]          <1> 	mov	[bx+drv.status], al
   259                              <1> 	; 04/02/2016 (eax -> ax)
   260                              <1> 	;mov	ax, [si+16]
   261                              <1> 	; 14/07/2020
   262                              <1> 	;mov	di, [si+18] 
   263                              <1> 	;;test	ax, [si+18]
   264                              <1> 	;test	ax, di ; 14/07/2020
   265                              <1> 	;jz	short L10_A0h ; (!) ; 17/07/2020
   266                              <1> 			; 'CHS only' disks on EDD system 
   267                              <1> 			;  are reported with ZERO disk size
   268                              <1> 			; (if so, we must not overwrite
   269                              <1> 			; calculated disk size in 'set_disk_parms')
   270                              <1> 	; 29/08/2020
   271 0000021C 8B4410              <1> 	mov	ax, [si+16]
   272 0000021F 8B7C12              <1> 	mov	di, [si+18]
   273 00000222 09C0                <1> 	or	ax, ax
   274 00000224 7504                <1> 	jnz	short L10_LBA
   275 00000226 09FF                <1> 	or	di, di
   276 00000228 740B                <1> 	jz	short L10_A0h
   277                              <1> L10_LBA:
   278                              <1> 	;sub	bx, drv.status
   279 0000022A C1E302              <1> 	shl	bx, 2
   280                              <1> 	;add	bx, drv.size ; disk size (in sectors)
   281                              <1> 	;mov	[bx], ax
   282                              <1> 	; 29/08/2020
   283 0000022D 8987[3265]          <1> 	mov	[bx+drv.size], ax
   284                              <1> 	;mov	ax, [si+18]
   285                              <1> 	;;mov	[bx], ax
   286                              <1> 	;mov	[bx+2], ax ; BugFix ; 15/07/2020
   287                              <1> 	; 14/07/2020
   288                              <1> 	;mov	[bx+2], di ; 15/07/2020
   289                              <1> 	; 29/08/2020
   290 00000231 89BF[3465]          <1> 	mov	[bx+drv.size+2], di
   291                              <1> L10_A0h: 
   292                              <1> 	; 17/07/2020
   293                              <1> 	; Note: Virtual CPU will jump here from above (!) test
   294                              <1> 	;	while running in QEMU
   295                              <1> 
   296                              <1> 	; Jump here to fix a ZERO (LBA) disk size problem 
   297                              <1> 	; for CHS disks (28/02/2015)
   298                              <1> 	
   299                              <1> 	; 30/12/2014
   300 00000235 BF0000              <1> 	mov	di, HD0_DPT
   301 00000238 88D0                <1> 	mov	al, dl
   302 0000023A 83E003              <1> 	and 	ax, 3
   303 0000023D C0E005              <1> 	shl	al, 5 ; * 32
   304 00000240 01C7                <1> 	add 	di, ax
   305 00000242 B80090              <1> 	mov	ax, DPT_SEGM
   306 00000245 8EC0                <1> 	mov	es, ax
   307                              <1> 	;
   308 00000247 88E8                <1> 	mov	al, ch	; max. cylinder number (bits 0-7)
   309 00000249 88CC                <1> 	mov	ah, cl	
   310 0000024B C0EC06              <1> 	shr	ah, 6	; max. cylinder number (bits 8-9)
   311 0000024E 40                  <1>  	inc	ax	; logical cylinders (limit 1024)
   312 0000024F AB                  <1> 	stosw		
   313 00000250 88F0                <1> 	mov	al, dh	; max. head number
   314                              <1> 	;
   315 00000252 30F6                <1> 	xor	dh, dh  ; 29/08/2020 (dh = 0 is needed here)
   316                              <1> 	;
   317 00000254 FEC0                <1> 	inc	al
   318 00000256 AA                  <1> 	stosb		; logical heads (limits 256)
   319 00000257 B0A0                <1> 	mov	al, 0A0h ; Indicates translated table
   320 00000259 AA                  <1> 	stosb
   321 0000025A 8A440C              <1> 	mov	al, [si+12]
   322 0000025D AA                  <1> 	stosb		 ; physical sectors per track
   323 0000025E 31C0                <1>  	xor	ax, ax
   324                              <1> 	;dec	ax	 ; 02/01/2015 
   325 00000260 AB                  <1> 	stosw		 ; precompensation (obsolete)
   326                              <1> 	;xor	al, al	 ; 02/01/2015	
   327 00000261 AA                  <1> 	stosb		 ; reserved
   328 00000262 B008                <1> 	mov	al, 8	 ; drive control byte
   329                              <1> 		         ; (do not disable retries, 
   330                              <1> 			 ; more than 8 heads)
   331 00000264 AA                  <1> 	stosb
   332 00000265 8B4404              <1> 	mov	ax, [si+4]
   333 00000268 AB                  <1> 	stosw		 ; physical number of cylinders	
   334                              <1> 	;push	ax	 ; 02/01/2015
   335 00000269 8A4408              <1> 	mov	al, [si+8]
   336 0000026C AA                  <1> 	stosb		 ; physical num. of heads (limit 16)
   337 0000026D 29C0                <1> 	sub 	ax, ax
   338                              <1> 	;pop	ax	 ; 02/01/2015	
   339 0000026F AB                  <1> 	stosw		 ; landing zone (obsolete)
   340 00000270 88C8                <1> 	mov	al, cl	 ; logical sectors per track (limit 63)
   341 00000272 243F                <1> 	and 	al, 3Fh	
   342 00000274 AA                  <1> 	stosb
   343                              <1> 	;sub	al, al	 ; checksum
   344                              <1> 	;stosb
   345                              <1> 	;
   346 00000275 83C61A              <1> 	add	si, 26   ; (BIOS) DPTE address pointer
   347 00000278 AD                  <1> 	lodsw
   348 00000279 50                  <1> 	push	ax ; *	 ; (BIOS) DPTE offset
   349 0000027A AD                  <1> 	lodsw
   350 0000027B 50                  <1> 	push	ax ; **	 ; (BIOS) DPTE segment
   351                              <1> 	;
   352                              <1> 	; checksum calculation
   353 0000027C 89FE                <1> 	mov	si, di
   354 0000027E 06                  <1> 	push	es
   355 0000027F 1F                  <1> 	pop	ds
   356                              <1> 	;mov	cx, 16
   357 00000280 B90F00              <1> 	mov 	cx, 15
   358 00000283 29CE                <1> 	sub	si, cx
   359 00000285 30E4                <1> 	xor	ah, ah
   360                              <1> 	;del	cl
   361                              <1> L11:		
   362 00000287 AC                  <1> 	lodsb
   363 00000288 00C4                <1> 	add	ah, al
   364 0000028A E2FB                <1> 	loop	L11
   365                              <1> 	;
   366 0000028C 88E0                <1> 	mov	al, ah
   367 0000028E F6D8                <1> 	neg	al	; -x+x = 0
   368 00000290 AA                  <1> 	stosb		; put checksum in byte 15 of the tbl
   369                              <1> 	;
   370 00000291 1F                  <1> 	pop	ds ; **	; (BIOS) DPTE segment
   371 00000292 5E                  <1> 	pop	si ; *	; (BIOS) DPTE offset	
   372                              <1> 
   373                              <1> 	; 08/08/2022 (TRDOS 386 v2.0.5)
   374                              <1> 	; (Recent version of Retro UNIX 386 v1 'diskinit.s' file
   375                              <1> 	; -12/07/2022- does not contain following 2020 code) (*)
   376                              <1> 
   377                              <1> 	; 14/07/2020 (TRDOS 386 v2.0.2)
   378                              <1> 	; 0FFFFh:0FFFFh = invalid DPTE address
   379 00000293 8B0C                <1> 	mov	cx, [si]
   380 00000295 8B4402              <1> 	mov	ax, [si+2]
   381 00000298 21C1                <1> 	and	cx, ax
   382 0000029A 41                  <1> 	inc	cx 
   383 0000029B 7404                <1> 	jz	short L11c ; 0FFFFh:0FFFFh
   384 0000029D 0B04                <1> 	or	ax, [si]
   385 0000029F 752A                <1> 	jnz	short L11e ; <> 0
   386                              <1> L11c:
   387                              <1> 	; 17/07/2020
   388                              <1> 	; TRDOS 386 v2 DRVINIT assumptions:
   389                              <1> 	; (also by regarding QEMU, Bochs and VirtualBox settings)
   390                              <1> 	;	Hard disk 0 port address: 1F0h
   391                              <1> 	;	Hard disk 1 port address: 1F0h
   392                              <1> 	;	Hard disk 2 port address: 170h
   393                              <1> 	;	Hard disk 3 port address: 170h
   394                              <1> 
   395                              <1> 	; in QEMU, hda=hd0 (1F0h) and hdb=hd1 (1F0h) -IRQ14-
   396                              <1> 	;      and hdc=hd2 (170h) and hdd=hd3 (170h) -IRQ15-
   397                              <1> 
   398 000002A1 B8F001              <1> 	mov	ax, 1F0h
   399                              <1> 
   400                              <1> 	; 15/07/2020
   401                              <1> 	; 14/07/2020
   402                              <1> 	; Invalid DPTE address...
   403                              <1> 	; Default DPTE parms must be set for DISK_IO_CONT
   404                              <1> 	; (diskio.s)
   405                              <1> 	; 17/07/2020
   406                              <1> 
   407                              <1> 	;mov	bl, dl
   408                              <1> 	;and	bl, 1
   409                              <1> 	;jz	short L11d
   410                              <1> 
   411 000002A4 B3A0                <1> 	mov	bl, 0A0h
   412                              <1> 
   413 000002A6 F6C201              <1> 	test	dl, 1
   414 000002A9 7403                <1> 	jz	short L11g  ; Master (as default, for 80h & 82h))
   415                              <1> 	;shl	bl, 4 ; bl = 16 (bit 4 = 1 -> slave)
   416 000002AB 80C310              <1> 	add	bl, 10h  ; Slave (as default, for 81h & 83h)
   417                              <1> L11g:
   418                              <1> 	; 17/07/2020
   419 000002AE 80FA82              <1> 	cmp	dl, 82h	; Hard disk 3 or 4 ?
   420 000002B1 7203                <1> 	jb	short L11d ; Primary ATA channel (hd0, hd1)
   421                              <1> 			   ; (port address = 1F0h)
   422                              <1> 	
   423                              <1> 	; Secondary ATA channel (hd2, hd3)
   424                              <1> 	; (port address = 170h)
   425                              <1> 
   426 000002B3 2D8000              <1> 	sub	ax, 1F0h-170h
   427                              <1> L11d:
   428                              <1> 	; 14/07/2020
   429 000002B6 AB                  <1> 	stosw	; I/O PORT Base Address (1F0h, 170h)
   430 000002B7 050602              <1> 	add	ax, 206h
   431 000002BA AB                  <1> 	stosw	; CONTROL PORT Address (3F6h, 376h)	
   432 000002BB 88D8                <1> 	mov	al, bl  ; Master/Slave bit (0 = Master)
   433                              <1> 	; 17/07/2020
   434                              <1> 	;or	al, 0A0h ; CHS (LBA enable bit = 0)
   435                              <1> 			 ; (Bits 5&7, reserved bits  =  1)
   436 000002BD 30E4                <1> 	xor	ah, ah
   437                              <1> 	;stosb	; Device/Head Register upper nibble
   438 000002BF AB                  <1> 	stosw
   439 000002C0 30C0                <1> 	xor	al, al
   440 000002C2 B90500              <1> 	mov	cx, 5
   441 000002C5 F3AB                <1> 	rep	stosw ; clear remain part of the (fake) DPTE
   442 000002C7 0E                  <1> 	push	cs
   443 000002C8 1F                  <1> 	pop	ds
   444 000002C9 EB2E                <1> 	jmp	short L11f
   445                              <1> 
   446                              <1> 	; 08/08/2022 (TRDOS 386 v2.0.5)
   447                              <1> 	; (Recent version of Retro UNIX 386 v1 'diskinit.s' file
   448                              <1> 	; -12/07/2022- does not contain above 2020 code) (*)
   449                              <1> L11e:
   450                              <1> 	; 23/02/2015
   451 000002CB 57                  <1> 	push	di
   452                              <1> 	; ES:DI points to DPTE (FDPTE) location
   453                              <1> 	;;mov	cx, 8
   454                              <1> 	;mov	cl, 8
   455 000002CC B90800              <1> 	mov	cx, 8 ; 14/07/2020
   456 000002CF F3A5                <1> 	rep	movsw	
   457                              <1> 	;
   458                              <1> 	; 23/02/2015
   459                              <1> 	; (P)ATA drive and LBA validation
   460                              <1> 	; (invalidating SATA drives and setting
   461                              <1> 	; CHS type I/O for old type fixed disks)
   462 000002D1 5B                  <1> 	pop	bx
   463 000002D2 8CC8                <1> 	mov	ax, cs
   464 000002D4 8ED8                <1> 	mov	ds, ax
   465 000002D6 268B07              <1> 	mov	ax, [es:bx]
   466 000002D9 3DF001              <1> 	cmp	ax, 1F0h
   467 000002DC 7413                <1> 	je	short L11a
   468 000002DE 3D7001              <1> 	cmp	ax, 170h
   469 000002E1 740E                <1> 	je	short L11a
   470                              <1> 	; invalidation 
   471                              <1> 	; (because base port address is not 1F0h or 170h)
   472                              <1> 	;xor	bh, bh
   473                              <1> 	;mov	bl, dl
   474                              <1> 	; 29/08/2020
   475                              <1> 	;xor	dh, dh ; 0
   476 000002E3 89D3                <1> 	mov	bx, dx
   477                              <1> 	;sub	bl, 80h
   478                              <1> 	;mov	byte [bx+hd0_type], 0 ; not a valid disk drive !		
   479                              <1>         ;or	byte [bx+drv.status+2], 0F0h ; (failure sign)
   480                              <1> 	; 29/08/2020
   481 000002E5 C687[AE64]00        <1> 	mov	byte [bx+hd0_type-80h], 0
   482 000002EA 808F[D064]F0        <1> 	or	byte [bx+drv.status-7Eh], 0F0h
   483 000002EF EB0F                <1> 	jmp	short L11b
   484                              <1> L11a:	
   485                              <1> 	; LBA validation
   486 000002F1 268A4704            <1> 	mov	al, [es:bx+4] ; Head register upper nibble
   487 000002F5 A840                <1> 	test	al, 40h ; LBA bit (bit 6)
   488 000002F7 7507                <1> 	jnz	short L11b ; LBA type I/O is OK! (E0h or F0h)
   489                              <1> L11f:
   490                              <1> 	; force CHS type I/O for this drive (A0h or B0h)
   491                              <1> 	;sub	bh, bh
   492                              <1> 	;mov	bl, dl
   493                              <1> 	; 29/08/2020
   494                              <1> 	;xor	dh, dh ; 0
   495 000002F9 89D3                <1> 	mov	bx, dx
   496                              <1> 	;sub	bl, 80h ; 26/02/2015
   497                              <1>         ;and	byte [bx+drv.status+2], 0FEh ; clear bit 0
   498                              <1> 				; bit 0 = LBA ready bit
   499                              <1> 	; 29/08/2020
   500 000002FB 80A7[D064]FE        <1> 	and	byte [bx+drv.status-7Eh], 0FEh
   501                              <1> 	; 'diskio' procedure will check this bit !
   502                              <1> L11b:
   503 00000300 3A16[2A65]          <1> 	cmp	dl, [last_drv] ; 25/12/2014
   504 00000304 7307                <1>         jnb     short L13
   505 00000306 E9D7FE              <1>         jmp     L10
   506                              <1> 
   507                              <1> L12:
   508                              <1> 	; Restore data registers
   509 00000309 8CC8                <1> 	mov	ax, cs
   510 0000030B 8ED8                <1> 	mov	ds, ax	
   511                              <1> L13:
   512                              <1> 	; 13/12/2014
   513 0000030D 0E                  <1> 	push	cs
   514 0000030E 07                  <1> 	pop	es
   515                              <1> L14:
   516                              <1> 	; clear keyboard buffer
   517 0000030F B411                <1> 	mov 	ah, 11h
   518 00000311 CD16                <1> 	int 	16h
   519 00000313 7440                <1> 	jz 	short L16 ; no keys in keyboard buffer
   520 00000315 B010                <1> 	mov	al, 10h
   521 00000317 CD16                <1> 	int 	16h
   522 00000319 EBF4                <1> 	jmp 	short L14
   523                              <1> 
   524                              <1> set_disk_parms:
   525                              <1> 	; 08/08/2022 - TRDOS 386 v2.0.5
   526                              <1> 	; 09/05/2022 - Retro UNIX 386 v1.2
   527                              <1> 	; 29/08/2020 - TRDOS 386 v2.0.2
   528                              <1> 	; 04/02/2016 (ebx -> bx)
   529                              <1> 	; 10/07/2015
   530                              <1> 	; 14/01/2015
   531                              <1> 	;push	bx
   532 0000031B 28FF                <1> 	sub	bh, bh
   533 0000031D 8A1E[2965]          <1> 	mov	bl, [drv]
   534 00000321 80FB80              <1> 	cmp	bl, 80h
   535 00000324 7203                <1> 	jb	short sdp0
   536 00000326 80EB7E              <1> 	sub	bl, 7Eh
   537                              <1> sdp0:	
   538                              <1> 	;add	bx, drv.status
   539                              <1>   	;mov	byte [bx], 80h ; 'Present' flag
   540                              <1> 	; 29/08/2020
   541 00000329 C687[4E65]80        <1> 	mov	byte [bx+drv.status], 80h
   542                              <1> 	;
   543 0000032E 88E8                <1> 	mov	al, ch ; last cylinder (bits 0-7)
   544 00000330 88CC                <1> 	mov	ah, cl ; 
   545 00000332 C0EC06              <1> 	shr	ah, 6  ; last cylinder (bits 8-9)
   546                              <1> 	;sub	bx, drv.status
   547 00000335 D0E3                <1> 	shl	bl, 1
   548                              <1> 	;add	bx, drv.cylinders
   549 00000337 40                  <1> 	inc	ax  ; convert max. cyl number to cyl count
   550                              <1> 	;mov	[bx], ax
   551                              <1> 	; 08/08/2022
   552                              <1> 	; 29/08/2020
   553                              <1> 	;mov	[bx+drv.cylinders], ax
   554                              <1> 	;
   555 00000338 50                  <1> 	push	ax ; ** cylinders
   556                              <1> 	;sub	bx, drv.cylinders
   557                              <1> 	;add	bx, drv.heads
   558 00000339 30E4                <1> 	xor	ah, ah
   559 0000033B 88F0                <1> 	mov	al, dh ; heads
   560 0000033D 40                  <1> 	inc	ax
   561                              <1> 	;mov	[bx], ax
   562                              <1> 	; 08/08/2022
   563                              <1> 	; 29/08/2020
   564                              <1> 	;mov	[bx+drv.heads], ax
   565                              <1> 	;sub	bx, drv.heads
   566                              <1>         ;add	bx, drv.spt
   567 0000033E 30ED                <1> 	xor	ch, ch
   568 00000340 80E13F              <1> 	and	cl, 3Fh	; sectors (bits 0-6)
   569                              <1> 	;mov	[bx], cx
   570                              <1>         ; 08/08/2022
   571                              <1> 	; 29/08/2020
   572                              <1> 	;mov	[bx+drv.spt], cx
   573                              <1> 	;sub	bx, drv.spt
   574 00000343 D1E3                <1> 	shl	bx, 1
   575                              <1> 	;add	bx, drv.size ; disk size (in sectors)
   576                              <1> 	; LBA size = cylinders * heads * secpertrack
   577 00000345 F7E1                <1> 	mul	cx 
   578 00000347 89C2                <1> 	mov	dx, ax	; heads*spt
   579 00000349 58                  <1> 	pop	ax ; ** cylinders
   580                              <1> 	; 09/05/2022 (fd0&fd1 drv.size = cyls*spt*heads)
   581                              <1> 	;dec	ax ; 1 cylinder reserved (!?) ; (*)
   582 0000034A F7E2                <1> 	mul	dx ; cylinders * (heads*spt)
   583                              <1> 	;mov	[bx], ax
   584                              <1> 	;mov	[bx+2], dx
   585                              <1> 	; 29/08/2020
   586 0000034C 8987[3265]          <1> 	mov	[bx+drv.size], ax
   587 00000350 8997[3465]          <1> 	mov	[bx+drv.size+2], dx
   588                              <1> 	;
   589                              <1> 	;pop	bx
   590 00000354 C3                  <1> 	retn
   591                              <1> 
   592                              <1> L16:	; 28/05/2016
   408                                  
   409                                  	; 10/11/2014
   410 00000355 FA                           	cli	; Disable interrupts (clear interrupt flag)
   411                                  		; Reset Interrupt MASK Registers (Master&Slave)
   412                                  	;mov	al, 0FFh	; mask off all interrupts
   413                                  	;out	21h, al		; on master PIC (8259)
   414                                  	;jmp 	$+2  ; (delay)
   415                                  	;out	0A1h, al	; on slave PIC (8259)
   416                                  	;
   417                                  	; Disable NMI 
   418 00000356 B080                    	mov   	al, 80h 
   419 00000358 E670                    	out   	70h, al		; set bit 7 to 1 for disabling NMI
   420                                  	;23/02/2015
   421                                  	;nop			;
   422                                  	;in	al, 71h		; read in 71h just after writing out to 70h
   423                                  				; for preventing unknown state (!?)
   424                                  	;
   425                                   	; 20/08/2014
   426                                  	; Moving the kernel 64 KB back (to physical address 0)
   427                                  	; DS = CS = 1000h
   428                                  	; 05/11/2014
   429 0000035A 31C0                    	xor	ax, ax
   430 0000035C 8EC0                    	mov	es, ax ; ES = 0
   431                                  	;
   432                                  	; 04/07/2016 - TRDOS 386 (64K - 128K kernel)
   433 0000035E 31F6                          	xor	si, si
   434 00000360 31FF                    	xor	di, di
   435 00000362 B90040                  	mov	cx, 16384
   436 00000365 F366A5                  	rep	movsd
   437                                  	;
   438 00000368 06                      	push	es ; 0
   439 00000369 68[6D03]                	push	L17
   440 0000036C CB                      	retf
   441                                  L17:
   442 0000036D B90010                  	mov	cx, 1000h
   443 00000370 8EC1                    	mov	es, cx  ; 1000h 
   444 00000372 01C9                    	add	cx, cx
   445 00000374 8ED9                    	mov	ds, cx  ; 2000h
   446 00000376 29F6                    	sub	si, si
   447 00000378 29FF                    	sub	di, di
   448 0000037A B90040                  	mov	cx, 16384
   449 0000037D F366A5                  	rep	movsd
   450                                  	
   451                                  	; Turn off the floppy drive motor
   452 00000380 BAF203                          mov     dx, 3F2h
   453 00000383 EE                              out     dx, al ; 0 ; 31/12/2013
   454                                  
   455                                  	; Enable access to memory above one megabyte
   456                                  L18:
   457 00000384 E464                    	in	al, 64h
   458 00000386 A802                    	test	al, 2
   459 00000388 75FA                            jnz     short L18
   460 0000038A B0D1                    	mov	al, 0D1h	; Write output port
   461 0000038C E664                    	out	64h, al
   462                                  L19:
   463 0000038E E464                    	in	al, 64h
   464 00000390 A802                    	test	al, 2
   465 00000392 75FA                            jnz     short L19
   466 00000394 B0DF                    	mov	al, 0DFh	; Enable A20 line
   467 00000396 E660                    	out	60h, al
   468                                  ;L20:
   469                                  	;
   470                                  	; Load global descriptor table register
   471                                  
   472                                          ;mov     ax, cs
   473                                          ;mov     ds, ax
   474                                  
   475 00000398 2E0F0116[9864]                  lgdt    [cs:gdtd]
   476                                  
   477 0000039E 0F20C0                          mov     eax, cr0
   478                                  	;or 	al, 1	; 24/07/2023
   479 000003A1 40                      	inc     ax
   480 000003A2 0F22C0                  	mov     cr0, eax
   481                                  
   482                                  	; Jump to 32 bit code
   483                                  	
   484 000003A5 66                      	db 66h 			; Prefix for 32-bit
   485 000003A6 EA                      	db 0EAh 		; Opcode for far jump
   486 000003A7 [AD030000]              	dd StartPM 		; Offset to start, 32-bit
   487                                  				; (1000h:StartPM = StartPM + 10000h)
   488 000003AB 0800                    	dw KCODE		; This is the selector for CODE32_DESCRIPTOR,
   489                                  				; assuming that StartPM resides in code32
   490                                  
   491                                  ; 20/02/2017
   492                                  
   493                                  
   494                                  [BITS 32] 
   495                                  
   496                                  StartPM:
   497                                  	; Kernel Base Address = 0 ; 30/12/2013
   498 000003AD 66B81000                	mov ax, KDATA           ; Save data segment identifier
   499 000003B1 8ED8                            mov ds, ax              ; Move a valid data segment into DS register
   500 000003B3 8EC0                           	mov es, ax              ; Move data segment into ES register
   501 000003B5 8EE0                           	mov fs, ax              ; Move data segment into FS register
   502 000003B7 8EE8                          	mov gs, ax              ; Move data segment into GS register
   503 000003B9 8ED0                            mov ss, ax              ; Move data segment into SS register
   504 000003BB BC00000900                      mov esp, 90000h         ; Move the stack pointer to 090000h
   505                                  
   506                                  clear_bss: ; Clear uninitialized data area
   507                                  	; 11/03/2015
   508 000003C0 31C0                    	xor	eax, eax ; 0
   509 000003C2 B9F0660000              	mov	ecx, (bss_end - bss_start)/4
   510                                  	;shr	ecx, 2 ; bss section is already aligned for double words
   511 000003C7 BF[9E740100]            	mov	edi, bss_start	
   512 000003CC F3AB                    	rep	stosd  		
   513                                  
   514                                  memory_init:
   515                                  	; Initialize memory allocation table and page tables
   516                                  	; 24/07/2022 (TRDOS 386 v2.0.5)
   517                                  	; 18/04/2021 (TRDOS 386 v2.0.4)
   518                                  	; 16/11/2014
   519                                  	; 15/11/2014
   520                                  	; 07/11/2014
   521                                  	; 06/11/2014
   522                                  	; 05/11/2014
   523                                  	; 04/11/2014
   524                                  	; 31/10/2014 (Retro UNIX 386 v1 - Beginning) 
   525                                  	;
   526                                  ;	xor	eax, eax
   527                                  ;	xor 	ecx, ecx
   528 000003CE B108                    	mov	cl, 8
   529 000003D0 BF00001000              	mov	edi, MEM_ALLOC_TBL	
   530 000003D5 F3AB                    	rep	stosd		   ; clear Memory Allocation Table
   531                                  				   ; for the first 1 MB memory
   532                                  	;
   533 000003D7 668B0D[24650000]        	mov	cx, [mem_1m_1k]	   ; Number of contiguous KB between
   534                                  				   ; 1 and 16 MB, max. 3C00h = 15 MB.
   535                                  	;shr	cx, 2		   ; convert 1 KB count to 4 KB count
   536                                  	; 24/07/2022
   537 000003DE C1E902                  	shr	ecx, 2
   538 000003E1 890D[90770100]          	mov	[free_pages], ecx
   539 000003E7 668B15[26650000]        	mov	dx, [mem_16m_64k]  ; Number of contiguous 64 KB blocks
   540                                  				   ; between 16 MB and 4 GB.	
   541 000003EE 6609D2                  	or	dx, dx
   542 000003F1 7413                    	jz	short mi_0
   543 000003F3 6689D0                  	mov	ax, dx
   544 000003F6 C1E004                  	shl	eax, 4		   ; 64 KB -> 4 KB (page count)
   545 000003F9 0105[90770100]          	add	[free_pages], eax
   546 000003FF 0500100000              	add	eax, 4096	   ; 16 MB = 4096 pages
   547 00000404 EB06                    	jmp	short mi_1
   548                                  mi_0:
   549                                  	;mov	ax, cx
   550                                  	; 24/07/2022
   551 00000406 89C8                    	mov	eax, ecx
   552 00000408 66050001                	add	ax, 256		   ; add 256 pages for the first 1 MB		 
   553                                  mi_1:
   554 0000040C A3[8C770100]            	mov	[memory_size], eax ; Total available memory in pages
   555                                  				   ; 1 alloc. tbl. bit = 1 memory page
   556                                  				   ; 32 allocation bits = 32 mem. pages   
   557                                  	;
   558 00000411 05FF7F0000              	add	eax, 32767	   ; 32768 memory pages per 1 M.A.T. page 	
   559 00000416 C1E80F                  	shr	eax, 15		   ; ((32768 * x) + y) pages (y < 32768)
   560                                  				   ;  --> x + 1 M.A.T. pages, if y > 0
   561                                  				   ;  --> x M.A.T. pages, if y = 0
   562 00000419 66A3[A0770100]          	mov	[mat_size], ax	   ; Memory Alloc. Table Size in pages		
   563 0000041F C1E00C                  	shl	eax, 12		   ; 1 M.A.T. page = 4096 bytes
   564                                  	;			   ; Max. 32 M.A.T. pages (4 GB memory)
   565 00000422 89C3                    	mov	ebx, eax	   ; M.A.T. size in bytes
   566                                  	; Set/Calculate Kernel's Page Directory Address
   567 00000424 81C300001000            	add	ebx, MEM_ALLOC_TBL
   568 0000042A 891D[88770100]          	mov	[k_page_dir], ebx  ; Kernel's Page Directory address
   569                                  				   ; just after the last M.A.T. page
   570                                  	;
   571 00000430 83E804                  	sub	eax, 4		   ; convert M.A.T. size to offset value
   572 00000433 A3[98770100]            	mov	[last_page], eax   ; last page ofset in the M.A.T.
   573                                  	;			   ; (allocation status search must be 
   574                                  				   ; stopped after here)	
   575 00000438 31C0                    	xor	eax, eax
   576 0000043A 48                      	dec	eax		   ; FFFFFFFFh (set all bits to 1)	
   577                                  	;push	cx
   578                                  	; 18/04/2021
   579 0000043B 51                      	push	ecx
   580 0000043C C1E905                  	shr	ecx, 5		   ; convert 1 - 16 MB page count to 
   581                                  				   ; count of 32 allocation bits
   582 0000043F F3AB                    	rep	stosd
   583                                  	;pop	cx
   584                                  	; 18/04/2021
   585 00000441 59                      	pop	ecx
   586 00000442 40                      	inc	eax		   ; 0	
   587 00000443 80E11F                  	and	cl, 31		   ; remain bits
   588 00000446 7412                    	jz	short mi_4
   589 00000448 8907                    	mov	[edi], eax	   ; reset	
   590                                  mi_2:
   591 0000044A 0FAB07                  	bts	[edi], eax	   ; 06/11/2014		
   592 0000044D FEC9                    	dec	cl
   593 0000044F 7404                    	jz	short mi_3
   594 00000451 FEC0                    	inc	al
   595 00000453 EBF5                    	jmp	short mi_2
   596                                  mi_3:
   597 00000455 28C0                    	sub	al, al	   	   ; 0
   598 00000457 83C704                  	add	edi, 4		   ; 15/11/2014
   599                                  mi_4:
   600 0000045A 6609D2                  	or	dx, dx		  ; check 16M to 4G memory space	
   601 0000045D 7421                    	jz	short mi_6	  ; max. 16 MB memory, no more...
   602                                  	;	
   603 0000045F B900021000              	mov	ecx, MEM_ALLOC_TBL + 512 ; End of first 16 MB memory
   604                                  	;	
   605 00000464 29F9                    	sub	ecx, edi	  ; displacement (to end of 16 MB)
   606 00000466 7406                    	jz	short mi_5	  ; jump if EDI points to 
   607                                  				  ;         end of first 16 MB	
   608 00000468 D1E9                    	shr	ecx, 1		  ; convert to dword count
   609 0000046A D1E9                    	shr	ecx, 1		  ; (shift 2 bits right) 
   610 0000046C F3AB                    	rep 	stosd		  ; reset all bits for reserved pages
   611                                  				  ; (memory hole under 16 MB)
   612                                  mi_5:
   613 0000046E 6689D1                  	mov	cx, dx		  ; count of 64 KB memory blocks
   614 00000471 D1E9                    	shr	ecx, 1		  ; 1 alloc. dword per 128 KB memory
   615 00000473 9C                      	pushf			  ; 16/11/2014		
   616 00000474 48                      	dec	eax		  ; FFFFFFFFh (set all bits to 1)
   617 00000475 F3AB                    	rep	stosd
   618 00000477 40                      	inc	eax		  ; 0
   619 00000478 9D                      	popf			  ; 16/11/2014
   620 00000479 7305                    	jnc	short mi_6
   621 0000047B 6648                    	dec	ax		  ; eax = 0000FFFFh
   622 0000047D AB                      	stosd
   623 0000047E 6640                    	inc	ax		  ; 0		
   624                                  mi_6:
   625 00000480 39DF                    	cmp	edi, ebx	  ; check if EDI points to 	
   626 00000482 730A                    	jnb	short mi_7	  ; end of memory allocation table
   627                                  	;			  ; (>= MEM_ALLOC_TBL + 4906) 
   628 00000484 89D9                    	mov	ecx, ebx	  ; end of memory allocation table
   629 00000486 29F9                    	sub	ecx, edi	  ; convert displacement/offset
   630 00000488 D1E9                    	shr	ecx, 1		  ; to dword count 	 		
   631 0000048A D1E9                    	shr	ecx, 1		  ; (shift 2 bits right) 
   632 0000048C F3AB                    	rep 	stosd		  ; reset all remain M.A.T. bits
   633                                  mi_7:
   634                                  	; Reset M.A.T. bits in M.A.T. (allocate M.A.T. pages)
   635 0000048E BA00001000              	mov	edx, MEM_ALLOC_TBL
   636                                  	;sub	ebx, edx	  ; Mem. Alloc. Tbl. size in bytes
   637                                  	;shr	ebx, 12		  ; Mem. Alloc. Tbl. size in pages	
   638 00000493 668B0D[A0770100]        	mov	cx, [mat_size]	  ; Mem. Alloc. Tbl. size in pages
   639 0000049A 89D7                    	mov	edi, edx
   640 0000049C C1EF0F                  	shr	edi, 15		  ; convert M.A.T. address to
   641                                  				  ; byte offset in M.A.T.
   642                                  				  ; (1 M.A.T. byte points to 
   643                                  				  ;	      32768 bytes)
   644                                  				  ; Note: MEM_ALLOC_TBL address 
   645                                  				  ; must be aligned on 128 KB 
   646                                  				  ; boundary!
   647 0000049F 01D7                    	add	edi, edx	  ; points to M.A.T.'s itself	
   648                                  	; eax = 0
   649 000004A1 290D[90770100]          	sub	[free_pages], ecx ; 07/11/2014
   650                                  mi_8:
   651 000004A7 0FB307                  	btr	[edi], eax	  ; clear bit 0 to bit x (1 to 31)
   652                                  	;dec	bl
   653 000004AA FEC9                    	dec	cl
   654 000004AC 7404                    	jz	short mi_9
   655 000004AE FEC0                    	inc	al
   656 000004B0 EBF5                    	jmp	short mi_8
   657                                  mi_9:
   658                                  	;
   659                                  	; Reset Kernel's Page Dir. and Page Table bits in M.A.T.
   660                                  	;		(allocate pages for system page tables)
   661                                  
   662                                  	; edx = MEM_ALLOC_TBL
   663 000004B2 8B0D[8C770100]          	mov	ecx, [memory_size] ; memory size in pages (PTEs)
   664 000004B8 81C1FF030000            	add	ecx, 1023	 ; round up (1024 PTEs per table)	 	
   665 000004BE C1E90A                  	shr	ecx, 10		 ; convert memory page count to 
   666                                  				 ; page table count (PDE count)
   667                                  	;
   668 000004C1 51                      	push	ecx		 ; (**) PDE count (<= 1024)
   669                                  	;
   670 000004C2 41                      	inc	ecx		 ; +1 for kernel page directory	
   671                                  	;
   672 000004C3 290D[90770100]          	sub	[free_pages], ecx ; 07/11/2014
   673                                  	;
   674 000004C9 8B35[88770100]          	mov	esi, [k_page_dir] ; Kernel's Page Directory address
   675 000004CF C1EE0C                  	shr	esi, 12		 ; convert to page number
   676                                  mi_10:
   677 000004D2 89F0                    	mov	eax, esi	 ; allocation bit offset		 
   678 000004D4 89C3                    	mov	ebx, eax
   679 000004D6 C1EB03                  	shr	ebx, 3		 ; convert to alloc. byte offset
   680 000004D9 80E3FC                  	and	bl,  0FCh	 ; clear bit 0 and bit 1
   681                                  				 ;   to align on dword boundary
   682 000004DC 83E01F                  	and	eax, 31		 ; set allocation bit position 
   683                                  				 ;  (bit 0 to bit 31)
   684                                  	;
   685 000004DF 01D3                    	add	ebx, edx	 ; offset in M.A.T. + M.A.T. address 
   686                                  	;
   687 000004E1 0FB303                  	btr 	[ebx], eax	 ; reset relevant bit (0 to 31)
   688                                  	;
   689 000004E4 46                      	inc	esi		 ; next page table
   690 000004E5 E2EB                    	loop	mi_10		 ; allocate next kernel page table 
   691                                  				 ; (ecx = page table count + 1)		
   692                                  	;
   693 000004E7 59                      	pop	ecx		 ; (**) PDE count (= pg. tbl. count)
   694                                  	;
   695                                  	; Initialize Kernel Page Directory and Kernel Page Tables
   696                                  	;
   697                                  	; Initialize Kernel's Page Directory
   698 000004E8 8B3D[88770100]          	mov	edi, [k_page_dir]
   699 000004EE 89F8                    	mov	eax, edi
   700 000004F0 0C03                    	or	al, PDE_A_PRESENT + PDE_A_WRITE
   701                                  				; supervisor + read&write + present
   702 000004F2 89CA                    	mov	edx, ecx 	; (**) PDE count (= pg. tbl. count)	
   703                                  mi_11:
   704 000004F4 0500100000              	add	eax, 4096	; Add page size (PGSZ)
   705                                  			        ; EAX points to next page table
   706 000004F9 AB                      	stosd
   707 000004FA E2F8                    	loop	mi_11
   708 000004FC 29C0                    	sub	eax, eax	; Empty PDE
   709 000004FE 66B90004                	mov	cx, 1024	; Entry count (PGSZ/4)
   710 00000502 29D1                    	sub	ecx, edx
   711 00000504 7402                    	jz	short mi_12
   712 00000506 F3AB                    	rep	stosd 		; clear remain (empty) PDEs
   713                                  	;
   714                                  	; Initialization of Kernel's Page Directory is OK, here.
   715                                  mi_12:
   716                                  	; Initialize Kernel's Page Tables
   717                                  	;
   718                                  	; (EDI points to address of page table 0)
   719                                  	; eax = 0
   720 00000508 8B0D[8C770100]          	mov	ecx, [memory_size] ; memory size in pages
   721 0000050E 89CA                    	mov	edx, ecx	; (***)
   722 00000510 B003                    	mov	al, PTE_A_PRESENT + PTE_A_WRITE
   723                                  			     ; supervisor + read&write + present 	
   724                                  mi_13:
   725 00000512 AB                      	stosd
   726 00000513 0500100000              	add	eax, 4096	
   727 00000518 E2F8                    	loop	mi_13	
   728                                  	;and	dx, 1023	; (***)
   729                                  	; 30/08/2023
   730 0000051A 81E2FF030000            	and	edx, 1023
   731 00000520 7408                    	jz	short mi_14
   732                                  	;mov	cx, 1024	
   733                                  	; 30/08/2023
   734 00000522 B504                    	mov	ch, 4 ; 4*256 = 1024
   735                                  	;sub	cx, dx		; from dx (<= 1023) to 1024
   736                                  	; 24/07/2022
   737 00000524 29D1                    	sub	ecx, edx
   738 00000526 31C0                    	xor	eax, eax
   739 00000528 F3AB                    	rep	stosd		; clear remain (empty) PTEs 
   740                                  				; of the last page table
   741                                  mi_14:
   742                                  	;  Initialization of Kernel's Page Tables is OK, here.
   743                                  	;
   744 0000052A 89F8                    	mov	eax, edi	; end of the last page table page
   745                                  			        ; (beginging of user space pages)
   746 0000052C C1E80F                  	shr	eax, 15		; convert to M.A.T. byte offset
   747 0000052F 24FC                    	and	al, 0FCh	; clear bit 0 and bit 1 for
   748                                  				; aligning on dword boundary	
   749                                  	 
   750 00000531 A3[9C770100]            	mov	[first_page], eax
   751 00000536 A3[94770100]            	mov	[next_page], eax ; The first free page pointer
   752                                  				 ; for user programs
   753                                  				 ; (Offset in Mem. Alloc. Tbl.)	
   754                                  	;
   755                                  	; Linear/FLAT (1 to 1) memory paging for the kernel is OK, here.
   756                                  	;
   757                                  	
   758                                  	; Enable paging
   759                                  	;
   760 0000053B A1[88770100]                    mov     eax, [k_page_dir]
   761 00000540 0F22D8                  	mov	cr3, eax
   762 00000543 0F20C0                  	mov	eax, cr0
   763 00000546 0D00000080              	or	eax, 80000000h	; set paging bit (bit 31)
   764 0000054B 0F22C0                  	mov	cr0, eax
   765                                          ;jmp    KCODE:StartPMP
   766                                  
   767 0000054E EA                      	db 0EAh 		; Opcode for far jump
   768 0000054F [55050000]                      dd StartPMP		; 32 bit offset
   769 00000553 0800                    	dw KCODE		; kernel code segment descriptor
   770                                  
   771                                  StartPMP:
   772                                  	; 06/11//2014
   773                                  	; Clear video page 0
   774                                  	;
   775                                  	; Temporary Code
   776                                  	;
   777 00000555 B9E8030000              	mov	ecx, 80*25/2
   778 0000055A BF00800B00              	mov	edi, 0B8000h
   779                                  	; 30/01/2016
   780                                  	;xor	eax, eax	; black background, black fore color
   781 0000055F B800070007              	mov	eax, 07000700h  ; black background, light gray fore color
   782 00000564 F3AB                    	rep	stosd
   783                                  	
   784                                  	; 19/08/2014
   785                                  	; Kernel Base Address = 0
   786                                  	; It is mapped to (physically) 0 in the page table.
   787                                  	; So, here is exactly 'StartPMP' address.
   788                                  
   789                                   	; 29/01/2016 (TRDOS 386 = TRDOS v2.0)
   790 00000566 BE[5E3B0100]            	mov	esi, starting_msg
   791                                  	;; 14/08/2015 (kernel version message will appear
   792                                  	;;	       when protected mode and paging is enabled)
   793 0000056B BF00800B00              	mov	edi, 0B8000h ; 27/08/2014
   794                                  	
   795                                  	; 30/11/2020
   796                                  	; 14/11/2020 (TRDOS 386 v2.0.3)
   797                                  	;cmp	byte [vbe3], 3 ; 03h
   798                                  	;jne	short pkv_1
   799                                  	;;mov	ah, 0Bh ; Black background, light cyan forecolor
   800                                  	;; Light red TRDOS 386 version text shows VBE3 is ready !
   801                                  	;mov	ah, 0Ch ; Black background, light red forecolor
   802                                  	;jmp	short pkv_2
   803                                  ;pkv_1:
   804 00000570 B40A                    	mov	ah, 0Ah ; Black background, light green forecolor
   805                                  ;pkv_2:
   806                                  	; 20/08/2014
   807 00000572 E8F8030000              	call	printk
   808                                  
   809                                  	; 'UNIX v7/x86' source code by Robert Nordier (1999)
   810                                  	; // Set IRQ offsets
   811                                  	;
   812                                  	;  Linux (v0.12) source code by Linus Torvalds (1991)
   813                                  	;
   814                                  					;; ICW1
   815 00000577 B011                    	mov	al, 11h			; Initialization sequence
   816 00000579 E620                    	out	20h, al			; 	8259A-1
   817                                  	; jmp 	$+2
   818 0000057B E6A0                    	out	0A0h, al		; 	8259A-2
   819                                  					;; ICW2
   820 0000057D B020                    	mov	al, 20h			; Start of hardware ints (20h)
   821 0000057F E621                    	out	21h, al			;	for 8259A-1
   822                                  	; jmp 	$+2
   823 00000581 B028                    	mov	al, 28h			; Start of hardware ints (28h)
   824 00000583 E6A1                    	out	0A1h, al		; 	for 8259A-2
   825                                  					;
   826 00000585 B004                    	mov	al, 04h			;; ICW3
   827 00000587 E621                    	out	21h, al			; 	IRQ2 of 8259A-1 (master)
   828                                  	; jmp 	$+2
   829 00000589 B002                    	mov	al, 02h			; 	is 8259A-2 (slave)
   830 0000058B E6A1                    	out	0A1h, al		;
   831                                  					;; ICW4
   832 0000058D B001                    	mov	al, 01h	 		;
   833 0000058F E621                    	out	21h, al			; 	8086 mode, normal EOI	
   834                                  	; jmp 	$+2
   835 00000591 E6A1                    	out	0A1h, al		;	for both chips.
   836                                  
   837                                  	;mov	al, 0FFh	; mask off all interrupts for now
   838                                  	;out	21h, al
   839                                  	;; jmp 	$+2
   840                                  	;out	0A1h, al
   841                                  
   842                                  	; 02/04/2015
   843                                  	; 26/03/2015 System call (INT 30h) modification
   844                                  	;  DPL = 3 (Interrupt service routine can be called from user mode)			
   845                                  	;
   846                                  	;; Linux (v0.12) source code by Linus Torvalds (1991)
   847                                  	;  setup_idt:
   848                                  	;
   849                                          ;; 16/02/2015
   850                                  	;;mov     dword [DISKETTE_INT], fdc_int ; IRQ 6 handler
   851                                  	; 21/08/2014 (timer_int)
   852 00000593 BE[FC370100]            	mov	esi, ilist
   853 00000598 8D3D[A0740100]          	lea	edi, [idt]
   854                                  	; 26/03/2015
   855 0000059E B930000000              	mov	ecx, 48		; 48 hardware interrupts (INT 0 to INT 2Fh)
   856                                  	; 02/04/2015
   857 000005A3 BB00000800              	mov	ebx,  80000h
   858                                  rp_sidt1:
   859 000005A8 AD                      	lodsd
   860 000005A9 89C2                    	mov	edx, eax
   861 000005AB 66BA008E                	mov	dx, 8E00h
   862 000005AF 6689C3                  	mov	bx, ax
   863 000005B2 89D8                    	mov	eax, ebx	; /* selector = 0x0008 = cs */
   864                                         			        ; /* interrupt gate - dpl=0, present */
   865 000005B4 AB                      	stosd	; selector & offset bits 0-15 	
   866 000005B5 89D0                    	mov	eax, edx
   867 000005B7 AB                      	stosd	; attributes & offset bits 16-23
   868 000005B8 E2EE                    	loop	rp_sidt1
   869                                  	; 15/04/2016
   870                                  	; TRDOS 386 (TRDOS v2.0) /// 32 sofware interrupts ///
   871                                  	;mov	cl, 16        ; 16 software interrupts (INT 30h to INT 3Fh)
   872 000005BA B120                    	mov	cl, 32	      ; 32 software interrupts (INT 30h to INT 4Fh)	
   873                                  rp_sidt2:
   874 000005BC AD                      	lodsd
   875 000005BD 21C0                    	and	eax, eax
   876 000005BF 7413                    	jz	short rp_sidt3
   877 000005C1 89C2                    	mov	edx, eax
   878 000005C3 66BA00EE                	mov	dx, 0EE00h	; P=1b/DPL=11b/01110b
   879 000005C7 6689C3                  	mov	bx, ax
   880 000005CA 89D8                    	mov	eax, ebx	; selector & offset bits 0-15 	
   881 000005CC AB                      	stosd
   882 000005CD 89D0                    	mov	eax, edx
   883 000005CF AB                      	stosd
   884 000005D0 E2EA                    	loop	rp_sidt2
   885 000005D2 EB16                    	jmp	short sidt_OK
   886                                  rp_sidt3:
   887 000005D4 B8[9A0D0000]            	mov	eax, ignore_int
   888 000005D9 89C2                    	mov	edx, eax
   889 000005DB 66BA00EE                	mov	dx, 0EE00h	; P=1b/DPL=11b/01110b
   890 000005DF 6689C3                  	mov	bx, ax
   891 000005E2 89D8                    	mov	eax, ebx	; selector & offset bits 0-15 	
   892                                  rp_sidt4:
   893 000005E4 AB                      	stosd
   894 000005E5 92                      	xchg	eax, edx
   895 000005E6 AB                      	stosd
   896 000005E7 92                      	xchg	edx, eax
   897 000005E8 E2FA                    	loop	rp_sidt4
   898                                  sidt_OK: 
   899 000005EA 0F011D[9E640000]        	lidt 	[idtd]
   900                                  	;
   901                                  	; TSS descriptor setup ; 24/03/2015
   902 000005F1 B8[20770100]            	mov	eax, task_state_segment
   903 000005F6 66A3[4A640000]          	mov	[gdt_tss0], ax
   904 000005FC C1C010                  	rol	eax, 16
   905 000005FF A2[4C640000]            	mov	[gdt_tss1], al
   906 00000604 8825[4F640000]          	mov	[gdt_tss2], ah
   907 0000060A 66C705[86770100]68-     	mov	word [tss.IOPB], tss_end - task_state_segment
   907 00000612 00                 
   908                                  		; 
   909                                  		; IO Map Base address (When this address points
   910                                  		; to end of the TSS, CPU does not use IO port 
   911                                  		; permission bit map for RING 3 IO permissions, 
   912                                  		; access to any IO ports in ring 3 will be forbidden.)
   913                                   		;
   914                                  	;mov	[tss.esp0], esp ; TSS offset 4
   915                                  	;mov	word [tss.ss0], KDATA ; TSS offset 8 (SS)
   916 00000613 66B82800                   	mov	ax, TSS  ; It is needed when an interrupt 
   917                                  			 ; occurs (or a system call -software INT- is requested)
   918                                  			 ; while cpu running in ring 3 (in user mode).				
   919                                  			 ; (Kernel stack pointer and segment will be loaded
   920                                  			 ; from offset 4 and 8 of the TSS, by the CPU.)	 
   921 00000617 0F00D8                  	ltr	ax  ; Load task register
   922                                  	;
   923                                  esp0_set0:
   924                                  	; 30/07/2015
   925 0000061A 8B0D[8C770100]          	mov 	ecx, [memory_size] ; memory size in pages
   926 00000620 C1E10C                  	shl 	ecx, 12 ; convert page count to byte count
   927 00000623 81F900004000            	cmp	ecx, CORE ; beginning of user's memory space (400000h)
   928                                  			  ; (kernel mode virtual address)
   929 00000629 7605                    	jna	short esp0_set1
   930                                  	;
   931                                  	; If available memory > CORE (end of the 1st 4 MB)
   932                                  	; set stack pointer to CORE
   933                                  	;(Because, PDE 0 is reserved for kernel space in user's page directory)
   934                                  	;(PDE 0 points to page table of the 1st 4 MB virtual address space)
   935 0000062B B900004000              	mov	ecx, CORE
   936                                  esp0_set1:
   937 00000630 89CC                    	mov	esp, ecx ; top of kernel stack (**tss.esp0**)
   938                                  esp0_set_ok:
   939                                  	; 30/07/2015 (**tss.esp0**) 
   940 00000632 8925[24770100]          	mov	[tss.esp0], esp
   941 00000638 66C705[28770100]10-             mov     word [tss.ss0], KDATA
   941 00000640 00                 
   942                                  	; 14/08/2015
   943                                  	; 10/11/2014 (Retro UNIX 386 v1 - Erdogan Tan)
   944                                  	;
   945                                  	;cli	; Disable interrupts (for CPU)
   946                                  	;    (CPU will not handle hardware interrupts, except NMI!)
   947                                  	;
   948 00000641 30C0                    	xor	al, al		; Enable all hardware interrupts!
   949 00000643 E621                    	out	21h, al		; (IBM PC-AT compatibility)
   950 00000645 EB00                    	jmp 	$+2		; (All conventional PC-AT hardware
   951 00000647 E6A1                    	out	0A1h, al	;  interrupts will be in use.)	
   952                                  				; (Even if related hardware component
   953                                  				;  does not exist!)
   954                                  	; Enable NMI 
   955 00000649 B07F                    	mov	al, 7Fh		; Clear bit 7 to enable NMI (again)
   956 0000064B E670                    	out  	70h, al
   957                                  	; 23/02/2015
   958 0000064D 90                      	nop
   959 0000064E E471                    	in	al, 71h		; read in 71h just after writing out to 70h
   960                                  				; for preventing unknown state (!?)
   961                                  	;
   962                                  	; Only a NMI can occur here... (Before a 'STI' instruction)
   963                                  	;
   964                                  	; 02/09/2014
   965                                  	;xor	bx, bx
   966                                  	; 24/07/2022
   967 00000650 31DB                    	xor	ebx, ebx
   968 00000652 66BA0002                	mov	dx, 0200h	; Row 2, column 0  ; 07/03/2015
   969 00000656 E8951C0000              	call	_set_cpos	; 24/01/2016
   970                                  
   971                                  	; 14/11/2020 (TRDOS 386 v2.0.3)
   972                                  	; Check VBE3 protected mode interface/feature(s)
   973                                  
   974                                  	;cmp	byte [vbe3], 3 ; 03h
   975                                  	;jne	short display_mem_info
   976                                  
   977                                  	; 20/11/2020
   978 0000065B 803D[79090000]02        	cmp	byte [vbe3], 2 ; 02h
   979 00000662 7707                    	ja	short vbe3_pmid_chk
   980                                  	;;jb	short display_mem_info
   981                                  	;jb	display_mem_info ; 02/12/2020
   982 00000664 7220                    	jb	short jmp_display_mem_info ; 24/07/2022
   983 00000666 E90C020000              	jmp	check_boch_plex86_vbe
   984                                  
   985                                  vbe3_pmid_chk:	
   986 0000066B B9EA7F0000              	mov	ecx, 32768 - (20+2) ; 32766 - PMInfoBlockSize
   987 00000670 BE02000C00              	mov	esi, 0C0002h ; 1st word of the video bios rom is 0AA55h
   988                                  	
   989                                  chk_pmi_sign:
   990                                  	;mov	eax, [esi] 
   991                                  	;cmp	eax, 'PMID'
   992                                  	; 30/11/2020
   993                                  	;cmp	al, 'P'
   994                                  	;jne	short chk_pmi_sign_next
   995 00000675 813E504D4944            	cmp	dword [esi], 'PMID'
   996                                  	;je	short display_vbios_product_name
   997 0000067B 740E                    	je	short verify_pmib_chksum ; 15/11/2020
   998                                  ;chk_pmi_sign_next:
   999 0000067D 46                      	inc	esi  ; inc si
  1000 0000067E E2F5                    	loop	chk_pmi_sign
  1001                                  
  1002                                  not_valid_pmib:
  1003 00000680 FE0D[79090000]          	dec	byte [vbe3] ; 2 = VBE2 compatible 
  1004                                  			    ; (vbe3 feature is defective in this vbios)
  1005                                  	;jmp	short display_mem_info
  1006                                  jmp_display_mem_info:	; 24/07/2022
  1007                                  	; 02/12/2020
  1008 00000686 E9B3010000              	jmp	display_mem_info
  1009                                  
  1010                                  verify_pmib_chksum:
  1011                                  	; 18/10/2023
  1012                                  	; (ATI RV370 video bios contains ZERO at Checksum offset.)
  1013 0000068B 31C0                    	xor	eax, eax
  1014 0000068D 384613                  	cmp	byte [esi+19], al ; 0 ; Checksum byte
  1015 00000690 7611                    	jna	short skip_verify_pmib_chksum ; may be ATI video bios
  1016                                  	;cmp	dword [esi+16], 0C000h
  1017                                  	;	; CodeSegSel = 0C000h, InProtectMode = 0, Checksum = 0
  1018                                  	;je	short skip_verify_pmib_chksum ; may be ATI video bios
  1019                                  	; 18/10/2023
  1020                                  	; 15/11/2020
  1021                                  	;xor	eax, eax
  1022                                  	;;mov	ecx, eax 
  1023                                  	;mov	cl, 20
  1024 00000692 66B91400                	mov	cx, 20 ; 30/11/2020
  1025 00000696 56                      	push	esi
  1026                                  pmib_sum_bytes:
  1027 00000697 AC                      	lodsb
  1028 00000698 00C4                    	add	ah, al
  1029 0000069A E2FB                    	loop	pmib_sum_bytes
  1030 0000069C 5E                      	pop	esi
  1031 0000069D 08E4                    	or	ah, ah
  1032 0000069F 75DF                    	jnz	short not_valid_pmib ; AH must be 0
  1033                                  
  1034                                  	; 18/10/2023
  1035 000006A1 30C0                    	xor	al, al  ; eax = 0
  1036                                  
  1037                                  	; 28/02/2021
  1038                                  	; Set default (initial) truecolor bpp value to 32
  1039                                  	; (for VBE3 video bios.. because vbe3 video bioses
  1040                                  	;  use 32bpp -for truecolor modes- instead of 24bpp)
  1041                                  	; (This setting may be changed via 'sysvideo' bx=0908h)
  1042                                  
  1043                                  skip_verify_pmib_chksum: ; 18/10/2023
  1044                                  		
  1045 000006A3 C605[4F740100]20        	mov	byte [truecolor], 32 ; (RGB: 00RRGGBBh)
  1046                                  
  1047                                  display_vbios_product_name: ; 14/11/2020
  1048                                  
  1049                                  	; ESI points to 'PMID' (0C0000h + 'PMID' offset)
  1050                                  
  1051                                  	; 15/11/2020
  1052                                  	;mov	[pmid_addr], si	; PMInfoBlock offset
  1053                                  	;		; (in VGA bios, 0C0000h + offset)
  1054                                  	; 02/12/2020
  1055                                  	;push	esi ; * pmid_addr
  1056 000006AA 89F7                    	mov	edi, esi
  1057                                  
  1058                                  	;mov	esi, [VBE3INFOBLOCK+22] ; 097E00h + 16h
  1059                                  	;		; OemVendorNamePtr (seg16:off16)
  1060 000006AC 8B35067E0900            	mov	esi, [VBE3INFOBLOCK+6] ; 097E00h + 06h
  1061                                  			; OemStringPtr (seg16:off16)
  1062                                  	; 18/10/2023
  1063                                  	;xor	al, al  ; eax = 0
  1064 000006B2 6696                    	xchg	ax, si	; ax = offset, si = 0
  1065 000006B4 C1EE0C                  	shr	esi, 12 ; (to convert segment to base addr)
  1066 000006B7 6601C6                  	add	si, ax  ; esi has an address < 1 MB limit
  1067                                  			; (OemVendorName is in VBE3INFOBLOCK)
  1068                                  			; Example: 
  1069                                  			; TRDOS 386 v2.0.3 VESA VBE3 protected mode
  1070                                  			; interface development reference is ...
  1071                                  			; NVIDIA GeForce FX5500 VGA BIOS -C000h:029Ch-
  1072                                  			; Version 4.34.20.54.00 -C000h:02EDh- 	  
  1073                                  			; ((OemString is 'NVIDIA'))
  1074                                  			; ((OemVendorName is 'NVIDIA Corporation'))
  1075                                  			; ((OemProductName is 'NV34 Board - p162-1nz))
  1076                                  
  1077                                  	;mov	ah, 0Eh ; Black background, yellow forecolor
  1078                                  	; 30/11/2020
  1079 000006BA B40C                    	mov	ah, 0Ch ; Black background, light red forecolor
  1080                                  
  1081 000006BC E83D3A0000              	call	print_kmsg
  1082                                  
  1083                                  	;mov	ah, 07h
  1084                                  
  1085 000006C1 BE[31740100]            	mov	esi, vesa_vbe3_bios_msg
  1086                                  	;call	print_kmsg
  1087 000006C6 E8393A0000              	call	pkmsg_loop ; 30/11/2020
  1088                                  
  1089                                  	; 02/12/2020
  1090                                  	;pop	edi ; * pmid_addr
  1091                                  
  1092                                  	; 24/07/2022
  1093                                  	; 29/11/2020
  1094                                  vbe3pminit:
  1095                                  	; 30/11/2020
  1096                                  	;cmp	byte [vbe3], 3 ; is VESA VBE3 PMI ready ?
  1097                                  	;jne	short di4
  1098                                  
  1099                                  	; Allocate 64KB contiguous (kernel) memory block
  1100 000006CB 31C0                    	xor	eax, eax
  1101 000006CD B900000100              	mov	ecx, 65536
  1102 000006D2 E815550000              	call	allocate_memory_block
  1103                                  	;jc	short di4
  1104                                  	;jc	di0 ; 30/11/2020
  1105                                  	; 24/07/2022
  1106 000006D7 7305                    	jnc	short vbe3pminit0
  1107 000006D9 E959010000              	jmp	di0
  1108                                  
  1109                                  vbe3pminit0:
  1110                                  	; of course this block must be in the 1st 16MB
  1111                                  	; because vbe3 pmi segments will be 16 bit segments
  1112                                  	; (80286 type segment descriptors in GDT)
  1113                                  
  1114 000006DE A3[D40F0300]            	mov	[vbe3bios_addr], eax
  1115                                  
  1116                                  	; set [pmid_addr] to the new location
  1117 000006E3 BE00000C00              	mov	esi, 0C0000h
  1118                                  
  1119                                  	; 30/11/2020
  1120 000006E8 29F7                    	sub	edi, esi ; izolate offset
  1121 000006EA 01C7                    	add	edi, eax ; new address
  1122 000006EC 893D[D80F0300]          	mov	[pmid_addr], edi ; new 'PMID' location	
  1123                                  
  1124                                  	; Move VIDEO BIOS from 0C0000h to EAX
  1125 000006F2 B900400000              	mov	ecx, 65536/4
  1126 000006F7 89C7                    	mov	edi, eax ; 30/11/2020
  1127 000006F9 F3A5                    	rep	movsd
  1128                                  
  1129                                  	; 02/12/2020
  1130                                  	; 30/11/2020
  1131                                  	; set vbe3 segment selectors
  1132                                  
  1133                                  	; VBE3CS (VESA VBE3 video bios code segment)
  1134 000006FB BF[52640000]            	mov	edi, _vbe3_CS+2 ; base address bits 0..15
  1135 00000700 66AB                    	stosw	; edi = _vbe3_CS+4
  1136 00000702 C1C810                  	ror	eax, 16
  1137 00000705 8807                    	mov	[edi], al ; base address, bits 16..23
  1138                                  
  1139                                  	; VBE3DS ('CodeSegSel' in PMInfoBlock)
  1140 00000707 BF[7C640000]            	mov	edi, _vbe3_DS+4 ; base addr bits 16..23
  1141 0000070C 8807                    	mov	[edi], al 
  1142 0000070E C1C010                  	rol	eax, 16
  1143 00000711 668947FE                	mov	[edi-2], ax ; base address, bits 0..15
  1144                                  
  1145                                  	; VBE3BDS (BIOSDataSel in PMInfoBlock)
  1146 00000715 BF[5A640000]            	mov	edi, _vbe3_BDS+2 ; base addr bits 0..15
  1147 0000071A B800700900              	mov	eax, VBE3BIOSDATABLOCK ; 1536 bytes
  1148 0000071F 66AB                    	stosw	; edi = _vbe3_BDS+4
  1149 00000721 C1E810                  	shr	eax, 16
  1150 00000724 8807                    	mov	[edi], al ; base address, bits 16..23
  1151                                  
  1152                                  	; VBE3SS (1024 bytes)
  1153 00000726 BF[82640000]            	mov	edi, _vbe3_SS+2 ; base addr bits 0..15
  1154 0000072B B800600900              	mov	eax, VBE3STACKADDR ; size = 1024 bytes
  1155 00000730 66AB                    	stosw	; edi = _vbe3_SS+4
  1156 00000732 C1E810                  	shr	eax, 16
  1157 00000735 8807                    	mov	[edi], al ; base address, bits 16..23
  1158                                  
  1159                                  	; stack pointer (esp) will be set to 1020
  1160                                  	; (before VBE3 PMI call)
  1161                                  
  1162                                  	; VBE3ES (max: 2048 bytes)
  1163 00000737 BF[8A640000]            	mov	edi, _vbe3_ES+2 ; base addr bits 0..15
  1164 0000073C B800760900              	mov	eax, VBE3SAVERESTOREBLOCK
  1165 00000741 66AB                    	stosw	; edi = _vbe3_ES+4
  1166 00000743 C1E810                  	shr	eax, 16
  1167 00000746 8807                    	mov	[edi], al ; base address, bits 16..23 	
  1168                                  
  1169                                  	;Note: low word of _VBE3_ES base address will be
  1170                                  	;      set -again- by VBE3 PMI caller routine 
  1171                                  
  1172                                  	; 09/12/2020
  1173                                  	;; set pmi32 (as VBE3 PMI is ready)
  1174                                  	;inc	byte [pmi32] ; = 1 
  1175                                  
  1176                                  	; KCODE16 (set PMI far return segment)
  1177 00000748 BF[92640000]            	mov	edi, _16bit_CS+2 ; base addr bits 0..15
  1178 0000074D B8[D4070000]            	mov	eax, pminit_return_addr16
  1179 00000752 66AB                    	stosw	; edi = _16bit_CS+4
  1180 00000754 C1E810                  	shr	eax, 16
  1181 00000757 8807                    	mov	[edi], al ; base address, bits 16..23 
  1182                                  
  1183                                  	; 30/11/2020
  1184                                  	; clear mem from VBE3 BIOS data area emu block
  1185                                  	; to end of vbe3 buffers
  1186                                  
  1187                                  	; 18/10/2023 - TRDOS v2.0.7
  1188                                  	; (VBE3BIOSDATABLOCK contains a copy of the 1st
  1189                                  	; 1536 bytes of the memory, IVT, ROMBIOS DATA etc.)
  1190                                  	; ((it must not be cleared here))
  1191                                  %if 0	
  1192                                  	; 01/12/2020
  1193                                  	mov	edi, VBE3BIOSDATABLOCK ; 97000h
  1194                                  	;mov	cx, (VBE3INFOBLOCK-VBE3BIOSDATABLOCK)/4
  1195                                  	;	; ecx = 3584/4 double words
  1196                                  	; 21/12/2020
  1197                                  	mov	cx, (VBE3MODEINFOBLOCK-VBE3BIOSDATABLOCK)/4
  1198                                  		; ecx = 3072/4 double words
  1199                                  	;xor	eax, eax
  1200                                  	xor	al, al
  1201                                  	rep	stosd
  1202                                  %endif
  1203                                  	; 18/10/2023 - TRDOS v2.0.7
  1204                                  	; (VBE3BIOSDATABLOCK contains a copy of the 1st
  1205                                  	; 1536 bytes of the memory, IVT, ROMBIOS DATA etc.)
  1206                                  	; ((it must not be cleared here))
  1207 00000759 BF00760900              	mov	edi, VBE3SAVERESTOREBLOCK ; 97600h
  1208 0000075E 66B98001                	mov	cx, (VBE3MODEINFOBLOCK-VBE3SAVERESTOREBLOCK)/4
  1209                                  		 ; ecx = 1536/4 = 384 double words
  1210                                  	;xor	eax, eax
  1211 00000762 30C0                    	xor	al, al
  1212 00000764 F3AB                    	rep	stosd	
  1213                                  
  1214                                  	; Filling PMInfoBlock selector fields
  1215 00000766 8B3D[D80F0300]          	mov	edi, [pmid_addr]
  1216 0000076C 66C747083800            	mov	word [edi+PMInfo.BIOSDataSel], VBE3BDS
  1217 00000772 66C7470A4000            	mov	word [edi+PMInfo.A0000Sel], VBE3A000
  1218 00000778 66C7470C4800            	mov	word [edi+PMInfo.B0000Sel], VBE3B000
  1219 0000077E 66C7470E5000            	mov	word [edi+PMInfo.B8000Sel], VBE3B800	
  1220 00000784 66C747105800            	mov	word [edi+PMInfo.CodeSegSel], VBE3DS
  1221 0000078A C6471201                	mov	byte [edi+PMInfo.InProtectMode], 1
  1222                                  
  1223                                  	; Calculate and write checksum byte
  1224 0000078E 89FE                    	mov	esi, edi
  1225 00000790 B113                    	mov	cl, PMInfo.size - 1
  1226                                  	;xor	ah, ah
  1227                                  pmid_chksum:
  1228 00000792 AC                      	lodsb	
  1229 00000793 00C4                    	add	ah, al
  1230 00000795 E2FB                    	loop	pmid_chksum
  1231 00000797 F6DC                    	neg	ah ; 1 -> 255, 255 -> 1
  1232 00000799 8826                    	mov	[esi], ah  ; checksum
  1233                                  
  1234                                  	; far call PM initialization
  1235                                  	; (VBE3 video bios will return via 'retf')
  1236                                  
  1237 0000079B 668B4706                	mov	ax, [edi+PMInfo.PMInitialize]
  1238                                  	; 30/11/2020
  1239 0000079F C1E010                  	shl	eax, 16 ; save entry address in hw
  1240                                  	; ax = 0 
  1241                                  
  1242                                  	; 02/12/2020
  1243 000007A2 68[F8070000]            	push	pminit_ok ; normal, near return address
  1244                                  
  1245                                  	; 30/11/2020
  1246                                  _VBE3PMI_fcall:
  1247                                  	; ax = function, hw of eax = entry address
  1248 000007A7 9C                      	pushf	; save 32 bit flags
  1249 000007A8 56                      	push	esi ; *
  1250 000007A9 55                      	push	ebp ; **
  1251                                  
  1252 000007AA 89E5                    	mov	ebp, esp ; save 32 bit stack pointer
  1253                                  	
  1254 000007AC 89C6                    	mov	esi, eax
  1255                                  
  1256 000007AE FA                      	cli
  1257                                  
  1258                                  	; Disable interrupts (clear interrupt flag)
  1259                                  	; Reset Interrupt MASK Registers (Master&Slave)
  1260 000007AF B0FF                    	mov	al, 0FFh	; mask off all interrupts
  1261 000007B1 E621                    	out	21h, al		; on master PIC (8259)
  1262 000007B3 EB00                    	jmp 	$+2  ; (delay)
  1263 000007B5 E6A1                    	out	0A1h, al	; on slave PIC (8259)
  1264                                  
  1265                                  	; 02/12/2020
  1266 000007B7 66B86000                	mov	ax, VBE3SS
  1267 000007BB 8ED0                    	mov	ss, ax
  1268                                  	
  1269 000007BD BCFC030000              	mov	esp, 1020 ; 30/11/2020
  1270                                  
  1271                                  	; 01/12/2020
  1272                                  	;lss	esp, [stack16]
  1273                                  
  1274 000007C2 C1E810                  	shr	eax, 16	; now, entry address is in lw
  1275                                  
  1276                                  	; 30/11/2020 - 16 bit pm selector test (OK)
  1277                                  	; (32 bit stack push/pop & retf with 32 bit code segment)
  1278                                  	; (16 bit stack push/pop with 16 bit code segment)
  1279                                  	
  1280                                  	; return
  1281                                  	;push	KCODE16
  1282                                  	;push	0 ; 30/11/2020 (pminit_return_addr16)
  1283                                  
  1284                                  	; 30/11/2020 (16 bit stack during retf from video bios)
  1285 000007C5 C7042400007000          	mov	dword [esp], KCODE16 << 16
  1286                                  				; ip = 0, cs = KCODE16 
  1287                                  	; 01/12/2020
  1288                                  	;mov	dword [VBE3STACKADDR+1020], KCODE16*65536
  1289                                  
  1290                                  	;mov	[jumpfar16], eax
  1291                                  
  1292                                  	; 02/12/2020
  1293                                  	; 30/11/2020 (32 bit stack during retf from kernel)
  1294                                  	; far jump/call via retf
  1295 000007CC 6A30                    	push	VBE3CS ; VBE3 video bios's code segment
  1296 000007CE 50                      	push	eax ; PMInitialize or EntryPoint
  1297                                  
  1298                                  	;mov	ax, si ; restore function
  1299                                  	; 24/07/2022
  1300 000007CF 89F0                    	mov	eax, esi
  1301                                  
  1302                                  	; 02/12/2020
  1303 000007D1 31F6                    	xor	esi, esi ; (not necessary, it is not used)
  1304                                  	
  1305 000007D3 CB                      	retf 	; far return (to 16 bit code segment)
  1306                                  
  1307                                  	; 01/12/2020
  1308                                  	;db	0EAh  ; far jump to 16 bit code segment
  1309                                  ;jumpfar16:
  1310                                  	;dd	0		
  1311                                  	;dw	VBE3CS
  1312                                  
  1313                                  ;stack16:
  1314                                  	;dd	1020
  1315                                  	;dw	VBE3SS
  1316                                  
  1317                                  	align 2	
  1318                                  
  1319                                  pminit_return_addr16:
  1320                                  	; 02/12/2020
  1321                                  	; 30/11/2020
  1322                                  	;;db	66h 		     ; Prefix for 32-bit
  1323                                  	;db	0EAh 		     ; Opcode for far jump
  1324                                  	;dd	pminit_return_addr32 ; 32 bit Offset
  1325                                  	;dw	KCODE		     ; 32 bit code segment
  1326                                  	; 01/12/2020
  1327 000007D4 EA[DB070000]0800        	jmp	KCODE:pminit_return_addr32
  1328                                  
  1329                                  pminit_return_addr32:
  1330                                  	; restore 32 bit kernel selectors and 32 bit stack addr
  1331 000007DB BE10000000              	mov	esi, KDATA
  1332 000007E0 8EDE                    	mov	ds, si
  1333 000007E2 8EC6                    	mov	es, si
  1334 000007E4 8ED6                    	mov	ss, si
  1335 000007E6 89EC                    	mov	esp, ebp  ; top of stack = iretd return addr
  1336                                  
  1337 000007E8 5D                      	pop	ebp ; **
  1338 000007E9 5E                      	pop	esi ; *
  1339 000007EA 9D                      	popf	; restore 32 bit flags
  1340                                  
  1341                                  	; enable interrupts
  1342                                  
  1343 000007EB FA                      	cli
  1344                                  
  1345                                  	; 21/12/2020
  1346 000007EC 50                      	push	eax
  1347                                  
  1348 000007ED 30C0                    	xor	al, al	   ; Enable all hardware interrupts!
  1349 000007EF E621                    	out	21h, al	   ; (IBM PC-AT compatibility)
  1350 000007F1 EB00                    	jmp 	$+2	   ; (All conventional PC-AT hardware
  1351 000007F3 E6A1                    	out	0A1h, al   ;  interrupts will be in use.)	
  1352                                  			   ; (Even if related hardware component
  1353                                  			   ;  does not exist!)
  1354 000007F5 58                      	pop	eax
  1355                                  	
  1356 000007F6 FB                      	sti
  1357                                  
  1358                                  	; top of stack = return address 
  1359                                  	; ('pminit_ok' for PMinit)
  1360                                  
  1361 000007F7 C3                      	retn
  1362                                  
  1363                                  pminit_ok:
  1364                                  	; 03/12/2020
  1365                                  	; (set [pmid_addr] to PMI entry point for next calls)
  1366 000007F8 8305[D80F0300]04        	add	dword [pmid_addr], PMInfo.EntryPoint ; + 4
  1367                                  
  1368                                  	; 17/01/2021
  1369                                  	; copy EDID data from temporary location to final address
  1370 000007FF 803D[91410000]4F        	cmp	byte [edid], 4Fh
  1371 00000806 7510                    	jne	short vbe3h_chcl
  1372                                  	;mov	ecx, 32 ; 128 bytes, 32 dwords
  1373                                  	; 24/07/2022
  1374 00000808 31C9                    	xor	ecx, ecx
  1375 0000080A B120                    	mov	cl, 32
  1376 0000080C BE007D0900              	mov	esi, VBE3EDIDINFOBLOCK ; 97D00h
  1377 00000811 BF[500F0300]            	mov	edi, edid_info
  1378 00000816 F3A5                    	rep	movsd
  1379                                  	; 17/01/2021
  1380                                  vbe3h_chcl:
  1381                                  	; 16/01/2021
  1382                                  	;; 06/12/2020
  1383                                  	;; Save video mode 03h regs/dac/bios state
  1384                                  	;
  1385                                  	;mov	ax, 4F04h ; VESA VBE Function 04h
  1386                                  	;		  ; Save/Restore State
  1387                                  	;sub	dl, dl	; 0 = return buffer size
  1388                                  	;mov	cx, 0Fh  ; ctrl/bios/dac/regs
  1389                                  	;
  1390                                  	;call	int10h_32bit_pmi
  1391                                   	;; bx = number of 64-byte blocks to hold the state buff
  1392                                  	;	
  1393                                  	;;mov	[vbe3stbufsize], bx
  1394                                  	;; 16/01/2021
  1395                                  	;or	word [vbe3stbsflags], 32768  ; set bit 15
  1396                                  	;mov	ax, bx
  1397                                  	;shl	ax, 6  ; * 64
  1398                                  	;mov	[vbestatebufsize+30], ax
  1399                                  	;
  1400                                  	;; 06/12/2020	
  1401                                  	;; check 'vbe3stbufsize' (it must be <= 32)
  1402                                  	;
  1403                                  	;cmp	bx, 32
  1404                                  	;ja	short display_mem_info ; light red forecolor
  1405                                  	;
  1406                                  	;; 16/01/2021
  1407                                  	;or	byte [vbe3stbsflags], 1 ; set bit 0
  1408                                  
  1409                                  	; 30/11/2020
  1410                                  	; Change VESA VBE3 BIOS text color in order to give
  1411                                  	; "VBE3 PMI initialization has been successed" meaning 	
  1412                                  
  1413 00000818 BE40810B00              	mov	esi, 0B8000h + 160*2 ; row 2
  1414 0000081D 89F7                    	mov	edi, esi
  1415                                  vbe3h_chcl_next:
  1416 0000081F 66AD                    	lodsw
  1417 00000821 80FC0C                  	cmp	ah, 0Ch	; light red forecolor
  1418 00000824 7518                    	jne	short display_mem_info
  1419 00000826 B40E                    	mov	ah, 0Eh ; yellow forecolor
  1420 00000828 66AB                    	stosw
  1421 0000082A EBF3                    	jmp	short vbe3h_chcl_next
  1422                                  
  1423                                  di5:
  1424                                  	; 18/10/2023 - TRDOS 386 v2.0.7
  1425                                  	; ATI RV370 Video BIOS (VESA VBE2)
  1426                                  	; has PMI. (as described in VESA VBE3 specification)
  1427                                  	;
  1428 0000082C FE05[79090000]          	inc	byte [vbe3]  ; [vbe3] = 2 -> 3
  1429                                  			; will be decreased to 2 again if 'PMID'
  1430                                  			; signature will not be found. 	
  1431 00000832 E934FEFFFF              	jmp	vbe3_pmid_chk ; check for ATI Video BIOS
  1432                                  
  1433                                  di0:
  1434                                  	; 30/11/2020
  1435                                  	; Memory allocation error !
  1436 00000837 C605[79090000]00        	mov	byte [vbe3], 0 ; disable VBE3
  1437                                  
  1438                                  display_mem_info:
  1439                                  	; 19/12/2020
  1440                                  	; temporary
  1441 0000083E E8D7380000              	call	default_lfb_info
  1442                                  	;
  1443                                  	; 06/11/2014
  1444 00000843 E85D380000              	call	memory_info
  1445                                  	; 14/08/2015
  1446                                  	;call getch ; 28/02/2015
  1447                                  drv_init:
  1448 00000848 FB                      	sti	; Enable Interrupts 
  1449                                  	; 06/02/2015
  1450 00000849 8B15[2E650000]          	mov	edx, [hd0_type] ; hd0, hd1, hd2, hd3
  1451 0000084F 668B1D[2C650000]        	mov	bx, [fd0_type] ; fd0, fd1
  1452                                  	; 22/02/2015
  1453 00000856 6621DB                  	and	bx, bx
  1454 00000859 756C                    	jnz	short di1
  1455                                  	;
  1456 0000085B 09D2                    	or 	edx, edx
  1457 0000085D 757A                    	jnz	short di2
  1458                                  	;
  1459                                  setup_error:
  1460 0000085F BE[023B0100]            	mov 	esi, setup_error_msg
  1461                                  psem:	
  1462 00000864 AC                      	lodsb
  1463 00000865 08C0                    	or	al, al
  1464                                  	;jz	short haltx ; 22/02/2015
  1465 00000867 747C                    	jz	short di3
  1466 00000869 56                      	push	esi
  1467                                  	; 13/05/2016
  1468 0000086A BB07000000              	mov	ebx, 7	; Black background, 
  1469                                  			; light gray forecolor
  1470                                  			; Video page 0 (BH=0)
  1471 0000086F E8E4190000              	call	_write_tty
  1472 00000874 5E                      	pop	esi
  1473 00000875 EBED                    	jmp	short psem
  1474                                  
  1475                                  check_boch_plex86_vbe:
  1476                                  	; 20/10/2023
  1477                                  	; 18/10/2023
  1478                                  	; 20/11/2020
  1479                                  	; check Bochs/Plex86 VGABios VBE extension
  1480                                  	; (check if TRDOS 386 v2 is running on emulators)
  1481                                  	; BOCHS/QEMU/VIRTUALBOX
  1482                                  	;
  1483                                  	; ref: vbe_display_api.txt
  1484                                  
  1485                                  	; bochs/plex86 VGAbios VBE source code
  1486                                  	;  by Jeroen Janssen (2002)
  1487                                  	;  and Volker Ruppert (2003-2020)
  1488                                  
  1489                                  	; 20/10/2023
  1490                                  	; (ATI RV370 video bios has PMI support but
  1491                                  	; it is a VESA VBE2 bios. So, even if [vbe3] is set
  1492                                  	; to 3 for PMI functionality, it is better to display
  1493                                  	; VESA VBE number as it is declared by the video bios.)
  1494                                  
  1495 00000877 C605[3A740100]32        	mov	byte [vbe_vnumber], "2" ; 20/10/2023
  1496                                  
  1497 0000087E 29C0                    	sub	eax, eax ; 0
  1498 00000880 66BACE01                	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
  1499 00000884 66EF                    	out	dx, ax ; VBE_DISPI_INDEX_ID register
  1500                                  	;mov	ax, 0B0C0h ; VBE_DISPI_ID0
  1501                                  	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
  1502 00000886 6642                    	inc	dx
  1503                                  	;out	dx, ax
  1504                                  	;nop
  1505 00000888 66ED                    	in	ax, dx
  1506 0000088A 80FCB0                  	cmp	ah, 0B0h
  1507                                  	;jne	short not_boch_qemu_vbe
  1508                                  	; 18/10/2023
  1509                                  	;jne	short display_mem_info
  1510 0000088D 759D                    	jne	short di5  ; ATI VESA VBE2 bios or another
  1511                                  
  1512 0000088F 3CC5                    	cmp	al, 0C5h ; it must be 0B0C4h or 0B0C5h ..
  1513                                  	;ja	short not_boch_qemu_vbe
  1514 00000891 77AB                    	ja	short display_mem_info
  1515 00000893 3CC0                    	cmp	al, 0C0h ; 0B0C0h to 0B0C5h .. ; Qemu
  1516                                  	;cmp	al, 0C4h ; 0BC04h or 0B0C5h is OK ; Bochs
  1517                                  	;jb	short not_boch_qemu_vbe
  1518 00000895 72A7                    	jb	short display_mem_info
  1519                                  
  1520                                  	; save VESA VBE2 bios (bochs/qemu) signature
  1521                                  	; for enabling VBE2 functions in TRDOS 386 v2 kernel
  1522 00000897 A2[7A090000]            	mov	[vbe2bios], al ; 0C4h or 0C5h (for BOCHS) 
  1523                                  			       ; (0C0h-0C5h for QEMU)
  1524                                  	; 20/10/2023
  1525                                  	;mov	byte [vbe_vnumber], "2"
  1526                                  
  1527                                  	; 26/11/2020
  1528                                  	; "BOCHS/QEMU/VIRTUALBOX VBE2 Video BIOS ..".
  1529 0000089C BE[1C740100]            	mov	esi, vbe2_bochs_vbios ; BOCH/QEMU vbios msg
  1530 000008A1 B40E                    	mov	ah, 0Eh  ; Yellow font
  1531 000008A3 E856380000              	call	print_kmsg
  1532                                  	
  1533                                  	; this is not necessary ! (20/11/2020)
  1534 000008A8 803D[7A090000]C4        	cmp	byte [vbe2bios], 0C4h 
  1535 000008AF 728D                    	jb	display_mem_info	; (QEMU) 
  1536                                  
  1537                                  	; Display kernel version message if 0E9h hack port
  1538                                  	; is enabled (bochs emulator feature)
  1539 000008B1 66BAE900                	mov	dx, 0E9h ; hack port for BOCHS
  1540 000008B5 BE[75740100]            	mov	esi, kernel_version_msg
  1541                                  kvmsg_next_char:
  1542 000008BA AC                      	lodsb	
  1543 000008BB 08C0                    	or	al, al
  1544 000008BD 7505                    	jnz	short put_kvmsg_in_hack_port
  1545                                  not_boch_qemu_vbe:
  1546 000008BF E97AFFFFFF               	jmp	display_mem_info
  1547                                  put_kvmsg_in_hack_port:	
  1548 000008C4 EE                      	out	dx, al
  1549 000008C5 EBF3                    	jmp	short kvmsg_next_char
  1550                                  
  1551                                  di1:
  1552                                  	; supress 'jmp short T6'
  1553                                  	;  (activate fdc motor control code)
  1554 000008C7 66C705[DB090000]90-     	mov	word [T5], 9090h ; nop
  1554 000008CF 90                 
  1555                                  	;
  1556                                  	;mov	ax, int_0Eh	; IRQ 6 handler
  1557                                  	;mov	di, 0Eh*4	; IRQ 6 vector
  1558                                  	;stosw
  1559                                  	;mov 	ax, cs
  1560                                  	;stosw
  1561                                  	;; 16/02/2015
  1562                                          ;;mov     dword [DISKETTE_INT], fdc_int ; IRQ 6 handler
  1563                                  	;
  1564 000008D0 E84D450000              	CALL	DSKETTE_SETUP	; Initialize Floppy Disks
  1565                                  	;
  1566 000008D5 09D2                    	or	edx, edx
  1567 000008D7 740C                            jz      short di3
  1568                                  di2:
  1569 000008D9 E87A450000              	call   	DISK_SETUP	; Initialize Fixed Disks
  1570                                          ;jc	setup_error
  1571                                  	; 24/07/2022
  1572 000008DE 7305                    	jnc	short di3
  1573 000008E0 E97AFFFFFF              	jmp	setup_error
  1574                                  di3:
  1575 000008E5 E88F370000              	call	setup_rtc_int	; 22/05/2015 (dsectrpm.s)
  1576                                  	;
  1577 000008EA E8A9300100              	call	display_disks ; 07/03/2015  (Temporary)
  1578                                  ;haltx:
  1579                                  	; 14/08/2015
  1580                                  	;call	getch ; 22/02/2015
  1581                                  	;sti	; Enable interrupts (for CPU)
  1582                                  ;	; 29/01/2016
  1583                                  ;	sub	ah, ah ;  read time count
  1584                                  ;	call	int1Ah
  1585                                  ;	mov	edx, ecx ; 18.2 * seconds
  1586                                  ;md_info_msg_wait1:
  1587                                  ;	; 29/01/2016
  1588                                  ;	mov	ah, 1
  1589                                  ;	call	int16h
  1590                                  ;	jz	short md_info_msg_wait2
  1591                                  ;	xor	ah, ah ; 0
  1592                                  ;       call    int16h
  1593                                  ;	jmp 	short md_info_msg_ok
  1594                                  ;md_info_msg_wait2:
  1595                                  ;	sub	ah, ah  ; read time count
  1596                                  ;	call	int1Ah
  1597                                  ;	cmp	edx, ecx ; ; 18.2 * seconds
  1598                                  ;	jna	short md_info_msg_wait3
  1599                                  ;	xchg 	edx, ecx	
  1600                                  ;md_info_msg_wait3:
  1601                                  ;	sub	ecx, edx
  1602                                  ;	cmp	ecx, 127 ; 7 seconds (18.2 * 7)
  1603                                  ;	jb	short md_info_msg_wait1		
  1604                                  ;md_info_msg_ok:
  1605                                  
  1606                                  	; 15/12/2020
  1607                                  	; set initial values of LFB parameters
  1608                                  
  1609 000008EF 803D[79090000]02        	cmp	byte [vbe3], 2
  1610 000008F6 7229                    	jb	short di4
  1611                                  
  1612                                  	;mov	ax, [def_LFB_addr]
  1613                                  	;shl	eax, 16
  1614                                  	;mov	[LFB_ADDR], eax
  1615                                  	;mov	eax, 1024*768*3
  1616                                  	;mov	[LFB_SIZE], eax
  1617                                  
  1618 000008F8 BEFE7B0900              	mov	esi, VBE3MODEINFOBLOCK - 2
  1619 000008FD 66C7061801              	mov	word [esi], 0118h ; default vbe mode
  1620                                  				  ; 1024*768, 24bpp
  1621 00000902 E81D300000              	call	set_lfbinfo_table
  1622                                  
  1623                                  	;;;
  1624                                  	; 20/10/2023 - TRDOS 386 v2.0.7
  1625 00000907 8B35[E00F0300]          	mov	esi, [LFB_ADDR]
  1626 0000090D 89F0                    	mov	eax, esi
  1627                                  	;add	eax, 4095 ; LFB start addr is always in page boundary
  1628 0000090F C1E80C                  	shr	eax, 12	; convert byte address to page address 
  1629 00000912 8B0D[8C770100]          	mov	ecx, [memory_size]
  1630 00000918 39C8                    	cmp	eax, ecx
  1631 0000091A 7305                    	jnb	short di4 ; LFB addr >= main memory size	
  1632                                  	
  1633                                  	; (set the overlapped pages as allocated for kernel)
  1634                                  	;;;
  1635 0000091C E813580000              	call	allocate_lfb_pages_for_kernel
  1636                                  di4:
  1637                                  	; 08/09/2016
  1638 00000921 0F20C0                  	mov	eax, cr0
  1639 00000924 A810                    	test	al, 10h  ; Bit 4, ET (Extension Type)
  1640 00000926 7408                    	jz	short sysinit
  1641                                  	; 27/02/2017
  1642 00000928 FE05[40840100]          	inc	byte [fpready]
  1643                                  	; 80387 (FPU) is ready
  1644 0000092E DBE3                    	fninit ; Initialize Floating-Point Unit
  1645                                  sysinit:
  1646                                  	; 30/06/2015
  1647 00000930 E805620000              	call	sys_init
  1648                                  	;
  1649                                  	;jmp 	cpu_reset ; 22/02/2015
  1650                                  hang:  
  1651                                  	; 23/02/2015
  1652                                  	;sti			; Enable interrupts
  1653 00000935 F4                      	hlt
  1654                                  	;
  1655                                  	;nop
  1656                                  	;; 03/12/2014
  1657                                  	;; 28/08/2014
  1658                                  	;mov	ah, 11h
  1659                                  	;call	getc
  1660                                  	;jz      _c8
  1661                                  	;
  1662                                  	; 23/02/2015
  1663                                  	; 06/02/2015
  1664                                  	; 07/09/2014
  1665 00000936 31DB                    	xor	ebx, ebx
  1666 00000938 8A1D[B6770100]          	mov	bl, [ptty]	; active_page
  1667 0000093E 89DE                    	mov	esi, ebx
  1668                                  	;shl 	si, 1
  1669                                  	; 24/07/2022
  1670 00000940 D1E6                    	shl	esi, 1
  1671 00000942 81C6[B8770100]          	add	esi, ttychr
  1672 00000948 668B06                  	mov	ax, [esi]
  1673 0000094B 6621C0                  	and	ax, ax
  1674                                  	;jz	short _c8
  1675 0000094E 74E5                    	jz	short hang
  1676 00000950 66C7060000              	mov	word [esi], 0
  1677 00000955 80FB03                  	cmp	bl, 3		; Video page 3
  1678                                  	;jb	short _c8
  1679 00000958 72DB                    	jb	short hang
  1680                                  	;	
  1681                                  	; 13/05/2016
  1682                                  	; 07/09/2014
  1683                                  nxtl:
  1684                                  	;push	bx
  1685                                  	; 18/04/2021
  1686 0000095A 53                      	push	ebx
  1687 0000095B 66BB0E00                	mov	bx, 0Eh 	; Yellow character 
  1688                                  				; on black background
  1689                                  				; bh = 0 (video page 0)
  1690                                  				; Retro UNIX 386 v1 - Video Mode 0
  1691                                  				; (PC/AT Video Mode 3 - 80x25 Alpha.)
  1692                                  	;push	ax
  1693                                  	; 18/04/2021
  1694 0000095F 50                      	push	eax
  1695 00000960 E8F3180000              	call 	_write_tty
  1696                                  	;pop	ax
  1697                                  	; 18/04/2021
  1698 00000965 58                      	pop	eax
  1699                                  	;pop	bx
  1700 00000966 5B                      	pop	ebx
  1701 00000967 3C0D                    	cmp	al, 0Dh		; carriage return (enter)
  1702                                  	;jne	short _c8
  1703 00000969 75CA                    	jne	short hang
  1704 0000096B B00A                    	mov	al, 0Ah		; next line
  1705 0000096D EBEB                    	jmp	short nxtl
  1706                                  	
  1707                                  ;_c8:
  1708                                  ;	; 25/08/2014
  1709                                  ;	cli				; Disable interrupts
  1710                                  ;	mov	al, [scounter + 1]
  1711                                  ;	and	al, al
  1712                                  ;	jnz	hang
  1713                                  ;	call	rtc_p
  1714                                  ;	jmp     hang
  1715                                  
  1716                                  	; 27/08/2014
  1717                                  	; 20/08/2014
  1718                                  printk:
  1719                                          ;mov    edi, [scr_row]
  1720                                  pkl:
  1721 0000096F AC                      	lodsb
  1722 00000970 08C0                    	or 	al, al
  1723 00000972 7404                    	jz	short pkr
  1724 00000974 66AB                    	stosw
  1725 00000976 EBF7                    	jmp	short pkl
  1726                                  pkr:
  1727 00000978 C3                      	retn
  1728                                  
  1729                                  ; 14/11/2020 (TRDOS 386 v2.0.3)
  1730 00000979 00                      vbe3:	db 0  ; VESA VBE version (must be 03h)
  1731                                  	      ; for using video bios calls in protected mode
  1732                                  vbe2bios:
  1733 0000097A B0                      	db 0B0h ; 
  1734                                  ;pmid_addr: 		
  1735                                  	;dw 0  ; > 0 if 'PMID' sign is found 
  1736                                  	;     ;	('pmid' offset addr in VGA bios seg, 0C000h)
  1737                                  	;; 02/12/2020
  1738                                  	;dw 0	; 32 bit address in pmid_addr
  1739                                  		
  1740                                  ; 28/02/2017
  1741                                  ; 22/01/2017
  1742                                  ; 15/01/2017
  1743                                  ; 14/01/2017
  1744                                  ; 02/01/2017
  1745                                  ; 25/12/2016
  1746                                  ; 19/12/2016
  1747                                  ; 10/12/2016 (callback)
  1748                                  ; 06/06/2016
  1749                                  ; 23/05/2016
  1750                                  ; 22/05/2016 - TRDOS 386 (TRDOS v2.0) Timer Event Modifications
  1751                                  ; 25/07/2015
  1752                                  ; 14/05/2015 (multi tasking -time sharing- 'clock', x_timer)
  1753                                  ; 17/02/2015
  1754                                  ; 06/02/2015 (unix386.s)
  1755                                  ; 11/12/2014 - 22/12/2014 (dsectrm2.s) 
  1756                                  ;
  1757                                  ; IBM PC-XT Model 286 Source Code - BIOS2.ASM (06/10/85)
  1758                                  ;
  1759                                  ;-- HARDWARE INT  08 H - ( IRQ LEVEL 0 ) ---------------------------------------
  1760                                  ;	THIS ROUTINE HANDLES THE TIMER INTERRUPT FROM FROM CHANNEL 0 OF        :
  1761                                  ;	THE 8254 TIMER.  INPUT FREQUENCY IS 1.19318 MHZ AND THE DIVISOR        :
  1762                                  ;	IS 65536, RESULTING IN APPROXIMATELY 18.2 INTERRUPTS EVERY SECOND.     :
  1763                                  ;									       :
  1764                                  ;	THE INTERRUPT HANDLER MAINTAINS A COUNT (40:6C) OF INTERRUPTS SINCE    :
  1765                                  ;	POWER ON TIME, WHICH MAY BE USED TO ESTABLISH TIME OF DAY.	       :
  1766                                  ;	THE INTERRUPT HANDLER ALSO DECREMENTS THE MOTOR CONTROL COUNT (40:40)  :
  1767                                  ;	OF THE DISKETTE, AND WHEN IT EXPIRES, WILL TURN OFF THE 	       :
  1768                                  ;	DISKETTE MOTOR(s), AND RESET THE MOTOR RUNNING FLAGS.		       :
  1769                                  ;	THE INTERRUPT HANDLER WILL ALSO INVOKE A USER ROUTINE THROUGH	       :
  1770                                  ;	INTERRUPT 1CH AT EVERY TIME TICK.  THE USER MUST CODE A 	       :
  1771                                  ;	ROUTINE AND PLACE THE CORRECT ADDRESS IN THE VECTOR TABLE.	       :
  1772                                  ;-------------------------------------------------------------------------------
  1773                                  ;
  1774                                  
  1775                                  timer_int:	; IRQ 0
  1776                                  ;int_08h:	; Timer
  1777                                  	; 14/10/2015
  1778                                  	; Here, we are simulating system call entry (for task switch)
  1779                                  	; (If multitasking is enabled, 
  1780                                  	; 'clock' procedure may jump to 'sysrelease')
  1781                                  
  1782 0000097B 1E                      	push	ds
  1783 0000097C 06                      	push	es
  1784 0000097D 0FA0                    	push	fs
  1785 0000097F 0FA8                    	push	gs
  1786                                  
  1787 00000981 60                      	pushad	; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
  1788 00000982 66B91000                	mov     cx, KDATA
  1789 00000986 8ED9                            mov     ds, cx
  1790 00000988 8EC1                            mov     es, cx
  1791 0000098A 8EE1                            mov     fs, cx
  1792 0000098C 8EE9                            mov     gs, cx
  1793                                  
  1794 0000098E 0F20D9                  	mov	ecx, cr3
  1795 00000991 890D[28020300]          	mov	[cr3reg], ecx ; save current cr3 register value/content
  1796                                  
  1797                                  	; 14/01/2017
  1798 00000997 3B0D[88770100]          	cmp 	ecx, [k_page_dir]
  1799 0000099D 7409                    	je	short T3
  1800                                  
  1801 0000099F 8B0D[88770100]          	mov	ecx, [k_page_dir]
  1802 000009A5 0F22D9                  	mov	cr3, ecx
  1803                                  T3:
  1804                                  	;sti				; INTERRUPTS BACK ON
  1805 000009A8 66FF05[08780100]        	INC	word [TIMER_LOW]	; INCREMENT TIME
  1806 000009AF 7507                    	JNZ	short T4		; GO TO TEST_DAY
  1807 000009B1 66FF05[0A780100]        	INC	word [TIMER_HIGH]	; INCREMENT HIGH WORD OF TIME
  1808                                  T4:					; TEST_DAY
  1809 000009B8 66833D[0A780100]18      	CMP	word [TIMER_HIGH],018H	; TEST FOR COUNT EQUALING 24 HOURS
  1810 000009C0 7519                    	JNZ	short T5		; GO TO DISKETTE_CTL
  1811 000009C2 66813D[08780100]B0-     	CMP	word [TIMER_LOW],0B0H
  1811 000009CA 00                 
  1812 000009CB 750E                    	JNZ	short T5		; GO TO DISKETTE_CTL
  1813                                  
  1814                                  ;-----	TIMER HAS GONE 24 HOURS
  1815                                  	;;SUB	AX,AX
  1816                                  	;MOV	[TIMER_HIGH],AX
  1817                                  	;MOV	[TIMER_LOW],AX
  1818 000009CD 29C0                    	sub	eax, eax
  1819 000009CF A3[08780100]            	mov	[TIMER_LH], eax
  1820                                  	;	
  1821 000009D4 C605[0C780100]01        	MOV	byte [TIMER_OFL],1
  1822                                  
  1823                                  ;-----	TEST FOR DISKETTE TIME OUT
  1824                                  
  1825                                  T5:
  1826                                  	; 23/12/2014
  1827 000009DB EB1D                    	jmp	short T6		; will be replaced with nop, nop
  1828                                  					; (9090h) if a floppy disk
  1829                                  					; is detected.
  1830                                  	;mov	al,[CS:MOTOR_COUNT]
  1831 000009DD A0[0F780100]            	mov	al, [MOTOR_COUNT]
  1832 000009E2 FEC8                    	dec	al
  1833                                  	;mov	[CS:MOTOR_COUNT], al	; DECREMENT DISKETTE MOTOR CONTROL
  1834 000009E4 A2[0F780100]            	mov	[MOTOR_COUNT], al
  1835                                  	;mov	[ORG_MOTOR_COUNT], al
  1836 000009E9 750F                    	JNZ	short T6		; RETURN IF COUNT NOT OUT
  1837 000009EB B0F0                    	mov 	al,0F0h
  1838                                  	;AND	[CS:MOTOR_STATUS],al 	; TURN OFF MOTOR RUNNING BITS
  1839 000009ED 2005[0E780100]          	and	[MOTOR_STATUS], al
  1840                                  	;and	[ORG_MOTOR_STATUS], al
  1841 000009F3 B00C                    	MOV	AL,0CH			; bit 3 = enable IRQ & DMA, 
  1842                                  					; bit 2 = enable controller
  1843                                  					;	1 = normal operation
  1844                                  					;	0 = reset	
  1845                                  					; bit 0, 1 = drive select
  1846                                  					; bit 4-7 = motor running bits 
  1847 000009F5 66BAF203                	MOV	DX,03F2H		; FDC CTL PORT
  1848 000009F9 EE                      	OUT	DX,AL			; TURN OFF THE MOTOR
  1849                                  T6:	
  1850                                  	;inc	word [CS:wait_count]	; 22/12/2014 (byte -> word)
  1851                                  					; TIMER TICK INTERRUPT
  1852                                  	;;inc	word [wait_count] ;;27/02/2015
  1853                                  	;INT	1CH			; TRANSFER CONTROL TO A USER ROUTINE
  1854                                  	;cli
  1855 000009FA E857040000              	call 	u_timer			; TRANSFER CONTROL TO A USER ROUTINE
  1856                                  	; 23/05/2016
  1857 000009FF E8A4140100              	call	clock			; Multi Tasking control procedure
  1858                                  T7:
  1859                                  	; 14/10/2015
  1860 00000A04 B020                    	MOV	AL,EOI			; GET END OF INTERRUPT MASK
  1861 00000A06 FA                      	CLI				; DISABLE INTERRUPTS TILL STACK CLEARED
  1862 00000A07 E620                    	OUT	INTA00,AL		; END OF INTERRUPT TO 8259 - 1	
  1863                                  	;
  1864                                  rtc_int_2:
  1865                                  	; 26/12/2016
  1866                                  	;mov	ecx, [cr3reg]
  1867                                  	; 13/01/2017
  1868 00000A09 803D[90010300]00        	cmp	byte [u.t_lock], 0  	; T_LOCK
  1869 00000A10 7730                    	ja	short timer_int_return  ; Timer Lock : 'sysrele' is needed !
  1870                                  	; 28/02/2017
  1871                                  	; We need to exit if the user's IRQ callback service is in progress!
  1872                                  	; (To prevent a conflict!)
  1873 00000A12 803D[94010300]00        	cmp	byte [u.r_lock], 0	; R_LOCK, IRQ callback service lock !
  1874 00000A19 7727                    	ja	short timer_int_return  ; Timer Lock : 'sysrele' is needed !	
  1875                                  	; 15/01/2017
  1876 00000A1B 803D[14840100]02        	cmp	byte [priority], 2
  1877 00000A22 733A                    	jnb	short T8  ; current process has a timer event (15/01/2017)
  1878                                  	; 22/05/2016
  1879 00000A24 803D[15840100]00        	cmp	byte [p_change], 0 ; in 'set_run_sequence', in 'rtc_p'
  1880 00000A2B 7615                    	jna	short timer_int_return ; 23/05/2016
  1881                                  
  1882                                  	; 15/01/2017
  1883                                  	
  1884                                  	; present process must be changed with high priority process	
  1885                                  	;xor	al, al
  1886 00000A2D 31C0                    	xor	eax, eax ; 26/12/2016
  1887 00000A2F A2[15840100]            	mov	[p_change], al ; 0
  1888                                  	;mov	byte [priority], 2 ; 15/01/2017 (there is a timer event)
  1889                                  
  1890 00000A34 803D[10010300]FF        	cmp     byte [sysflg], 0FFh ; user or system space ?
  1891 00000A3B 7416                    	je	short rtc_int_3     ; user space ([sysflg]= 0FFh)
  1892                                  
  1893                                  	; system space, wait for 'sysret'
  1894                                  	; to change running process 	
  1895                                  	; with high priority (event) process
  1896                                  
  1897 00000A3D A2[64010300]            	mov	[u.quant], al ; 0
  1898                                  
  1899                                  timer_int_return: ; 23/05/2016 - jump from 'rtc_int' ('rtc_int_2')
  1900 00000A42 8B0D[28020300]          	mov 	ecx, [cr3reg] 	; previous value/content of cr3 register
  1901 00000A48 0F22D9                   	mov	cr3, ecx	; restore cr3 register content
  1902                                  	;
  1903 00000A4B 61                      	popad ; edi, esi, ebp, temp (icrement esp by 4), ebx, edx, ecx, eax
  1904                                  	;
  1905 00000A4C 0FA9                    	pop	gs
  1906 00000A4E 0FA1                    	pop	fs
  1907 00000A50 07                      	pop	es
  1908 00000A51 1F                      	pop	ds
  1909                                  	;
  1910 00000A52 CF                      	iretd	; return from interrupt
  1911                                  
  1912                                  rtc_int_3:
  1913 00000A53 FE05[10010300]          	inc	byte [sysflg] 	; now, we are in system space
  1914                                  	;
  1915 00000A59 E9E2C20000                      jmp     sysrelease ; change running process immediatelly 
  1916                                  
  1917                                  T8:
  1918                                  	; 13/01/2017 (eax -> ebx)
  1919                                  	; callback checking... (19/12/2016)
  1920 00000A5E 31DB                    	xor	ebx, ebx
  1921 00000A60 871D[8C010300]          	xchg	ebx, [u.tcb] ; callback address (0 = normal return)
  1922 00000A66 09DB                    	or	ebx, ebx
  1923 00000A68 74D8                    	jz	short timer_int_return
  1924                                  
  1925                                  	; Set user's callback routine as return address from this interrupt
  1926                                  	; and set normal return address as return address from callback
  1927                                  	; routine!!! (19/12/2016)
  1928                                  	
  1929                                  	; 14/01/2017
  1930                                  	; 13/01/2017 - Timer Lock (T_LOCK)
  1931 00000A6A FE05[90010300]          	inc	byte [u.t_lock]
  1932 00000A70 8A0D[10010300]          	mov	cl, [sysflg]
  1933 00000A76 880D[91010300]          	mov	[u.t_mode], cl 
  1934                                  
  1935 00000A7C 8B2D[24770100]          	mov	ebp, [tss.esp0] ; kernel stack address (for ring 0)
  1936 00000A82 83ED14                  	sub	ebp, 20		; eip, cs, eflags, esp, ss
  1937 00000A85 892D[14010300]           	mov	[u.sp], ebp
  1938 00000A8B 8925[18010300]          	mov	[u.usp], esp
  1939                                  
  1940                                  	;or	word [ebp+8], 200h ; 22/01/2017, force enabling interrupts
  1941                                  
  1942 00000A91 8B44241C                	mov	eax, [esp+28] ; pushed eax
  1943 00000A95 A3[1C010300]            	mov	[u.r0], eax
  1944                                  
  1945 00000A9A E876010100              	call	wswap ; save user's registers & status
  1946                                  
  1947                                  	; software int is in ring 0 but timer int must return to ring 3
  1948                                  	; so, ring 3 return address and stack registers
  1949                                  	; (eip, cs, eflags, esp, ss) 
  1950                                  	; must be copied to timer int return
  1951                                  	; eip will be replaced by callback service routine address
  1952                                  
  1953 00000A9F C605[10010300]FF        	mov	byte [sysflg], 0FFh ; user mode
  1954                                  
  1955                                  	; system mode (system call)
  1956                                  	;mov	ebp, [u.sp] ; EIP (u), CS (UCODE), EFLAGS (u),
  1957                                  			    ; ESP (u), SS (UDATA)
  1958                                  
  1959 00000AA6 8B4510                  	mov	eax, [ebp+16]	; SS (UDATA
  1960 00000AA9 89E6                    	mov	esi, esp
  1961 00000AAB 50                      	push	eax
  1962 00000AAC 50                      	push	eax
  1963 00000AAD 89E7                    	mov	edi, esp
  1964 00000AAF 893D[18010300]          	mov	[u.usp], edi
  1965 00000AB5 B908000000              	mov	ecx, ((ESPACE/4) - 4) ; except DS, ES, FS, GS
  1966 00000ABA F3A5                    	rep	movsd
  1967 00000ABC B104                    	mov	cl, 4	
  1968 00000ABE F3AB                    	rep	stosd
  1969 00000AC0 893D[14010300]          	mov	[u.sp], edi
  1970 00000AC6 89EE                    	mov	esi, ebp
  1971 00000AC8 B105                    	mov	cl, 5 ; EIP (u), CS (UCODE), EFLAGS (u), ESP (u), SS (UDATA)
  1972 00000ACA F3A5                    	rep	movsd
  1973                                  
  1974 00000ACC 8B0D[74010300]          	mov	ecx, [u.pgdir]
  1975 00000AD2 890D[28020300]          	mov	[cr3reg], ecx
  1976                                  
  1977                                  	; 13/01/207 (eax -> ebx)
  1978                                  	; EBX = callback routine address (virtual, not physical address!)
  1979                                  
  1980                                  	; 09/01/2017
  1981                                  	; !!! CALLBACK ROUTINE MUST BE ENDED/RETURNED WITH 'sysrele'
  1982                                  	;     system call !!!	
  1983                                  	; 25/12/2016
  1984                                  	; Callback Note: (19/12/2016)
  1985                                  	; !!! CALLBACK ROUTINE MUST BE ENDED/RETURNED WITH 'RETN' !!!
  1986                                  	;	pushf ; save flags	
  1987                                  	; 	<callback service code>
  1988                                  	; 	popf  ; restore flags
  1989                                  	; 	retn ; return to normal running address
  1990                                  	;
  1991                                  
  1992                                  	; 15/01/2017
  1993                                  	; 14/01/2017
  1994                                  	; 13/01/2017 (eax -> ebx)
  1995                                  	; 10/01/2017
  1996                                  set_callback_addr:
  1997                                  	; 09/01/2017 (**)
  1998                                  	; 02/01/2017 (*)
  1999                                  	; 25/12/2016 (*)
  2000                                  	; 19/12/2016 (TRDOS 386 feature only!)
  2001                                  	;
  2002                                  	; This routine sets return address
  2003                                  	; to start of user's interrupt
  2004                                  	; service (callback) address
  2005                                  	;; and sets callback 'retn' address to normal
  2006                                  	;; return address of user's running code! 
  2007                                  	;
  2008                                  	; INPUT:
  2009                                  	;	EBX = callback routine/service address
  2010                                  	;	      (virtual, not physical address!)	
  2011                                  	;	[u.sp] = kernel stack, points to
  2012                                  	;		 user's EIP,CS,EFLAGS,ESP,SS
  2013                                  	;		 registers.
  2014                                  	; OUTPUT:
  2015                                  	;	EIP (user) = callback (service) address
  2016                                  	;	CS (user) = UCODE
  2017                                  	;	EFLAGS (user) = flags before callback 	 
  2018                                  	;       ESP (user) = ESP-4 (user, before callback) 
  2019                                  	;	[ESP](user) = EIP (user) before callback
  2020                                  	;
  2021                                  	; Note: If CPU was in user mode while entering 
  2022                                  	;	the timer interrupt service routine,
  2023                                  	;	'IRET' will get return to callback routine
  2024                                  	;	immediately. If CPU was in system/kernel mode  
  2025                                  	;	'iret' will get return to system call and
  2026                                  	;	then, callback routine will be return address
  2027                                  	;	from system call. (User's callback/service code
  2028                                  	;	will be able to return to normal return address
  2029                                  	;	via an 'retn' at the end.) 
  2030                                  	;
  2031                                  	; Note(**): User's callback service code must be ended
  2032                                  	;	with a 'sysrele' sytstem call ! (09/01/2017)
  2033                                  	;
  2034                                  	;	For example:
  2035                                  	;
  2036                                  	;	timer_callback:
  2037                                  	;	    ...	 
  2038                                    	;	    inc	dword [time_counter]
  2039                                  	;	    ...
  2040                                  	;	    mov eax, 39 ; 'sysrele'
  2041                                  	;	    int 40h ; TRDOS 386 system call (interrupt)		
  2042                                  	;
  2043                                  	;
  2044                                  	;; Note(*): User's callback service code must preserve cpu 
  2045                                  	;;	flags if it has any instructions which changes
  2046                                  	;;	flags in the service code. (25/12/2016)
  2047                                  	;;
  2048                                  	;;	For example:
  2049                                  	;;
  2050                                  	;;	timer_callback:
  2051                                  	;;	    pushf ; save flags
  2052                                  	;;	    ; this instruction changes zero flag
  2053                                    	;;	    inc	dword [time_counter]
  2054                                  	;;	    popf ; restore flags
  2055                                  	;;	    retn ; return to normal user code
  2056                                  	;;		  (which is interrupted by the 
  2057                                  	;;		   timer interput) 	
  2058                                  	;;
  2059                                  
  2060                                  	; 15/01/2017
  2061 00000AD8 8B2D[14010300]          	mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
  2062 00000ADE 895D00                  	mov	[ebp], ebx
  2063 00000AE1 E95CFFFFFF              	jmp	timer_int_return
  2064                                  
  2065                                  	; 15/01/2017
  2066                                  	; 13/01/2017
  2067                                  	; 19/12/2016
  2068                                  	; 06/06/2016
  2069                                  	; 23/05/2016
  2070                                  	; 22/05/2016
  2071                                  	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  2072                                  	; 26/02/2015
  2073                                  	; 07/09/2014
  2074                                  	; 25/08/2014
  2075                                  rtc_int:       ; Real Time Clock Interrupt (IRQ 8)
  2076                                  	; 22/05/2016
  2077 00000AE6 1E                      	push	ds ; ** ; 23/05/2016
  2078 00000AE7 50                      	push	eax ; *
  2079 00000AE8 66B81000                	mov	ax, KDATA
  2080 00000AEC 8ED8                    	mov	ds, ax
  2081                                  	;
  2082 00000AEE 8A25[06780100]          	mov	ah, [RTC_2Hz] ;  2 Hz interrupt to 1 Hz function
  2083 00000AF4 80F401                  	xor	ah, 1
  2084 00000AF7 8825[06780100]          	mov	[RTC_2Hz], ah ; 1 = 0.5 second, 0 = 1 second
  2085 00000AFD 753B                    	jnz	short rtc_int_return ; half second
  2086                                  	; 1 second
  2087                                  rtc_int_0:
  2088                                  	; 22/05/2016
  2089 00000AFF 58                      	pop	eax ; *
  2090                                  	;
  2091                                  	; 14/10/2015 ('timer_int')
  2092                                  	; Here, we are simulating system call entry (for task switch)
  2093                                  	; (If multitasking is enabled, 
  2094                                  	; 'clock' procedure may jump to 'sysrelease')
  2095                                  	;push	ds ; ** ; 23/05/2016
  2096 00000B00 06                      	push	es
  2097 00000B01 0FA0                    	push	fs
  2098 00000B03 0FA8                    	push	gs
  2099 00000B05 60                      	pushad  ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
  2100 00000B06 66B91000                	mov     cx, KDATA
  2101                                          ;mov    ds, cx ; 06/06/2016
  2102 00000B0A 8EC1                            mov     es, cx
  2103 00000B0C 8EE1                            mov     fs, cx
  2104 00000B0E 8EE9                            mov     gs, cx
  2105                                  	;
  2106 00000B10 0F20D9                  	mov	ecx, cr3
  2107 00000B13 890D[28020300]          	mov	[cr3reg], ecx ; save current cr3 register value/content
  2108                                  	;
  2109 00000B19 803D[90010300]00        	cmp	byte [u.t_lock], 0 ; timer lock (callback) status ?
  2110 00000B20 7711                    	ja	short rtc_int_1	   ; yes
  2111                                  
  2112                                  	; 15/01/2017
  2113 00000B22 3B0D[88770100]          	cmp 	ecx, [k_page_dir]
  2114 00000B28 7409                    	je	short rtc_int_1
  2115                                  
  2116 00000B2A 8B0D[88770100]          	mov	ecx, [k_page_dir]
  2117 00000B30 0F22D9                  	mov	cr3, ecx
  2118                                  rtc_int_1:
  2119                                  	; Timer event (kernel) functions must be performed with
  2120                                  	; 1 second intervals - TRDOS 386 (TRDOS v2.0) feature ! -
  2121                                   	;	
  2122                                  	; 25/08/2014
  2123 00000B33 E81A030000              	call	rtc_p  ; 19/05/2016 - major modification 
  2124                                  	
  2125                                  	; 23/05/2016
  2126 00000B38 28E4                    	sub	ah, ah ; 0
  2127                                  	; 22/05/2016 - TRDOS 386 timer event modifications
  2128                                  rtc_int_return: ; 19/05/2016
  2129                                  	; 22/02/2015 - dsectpm.s
  2130                                  	; [ source: http://wiki.osdev.org/RTC ]
  2131                                  	; read status register C to complete procedure
  2132                                  	;(it is needed to get a next IRQ 8) 
  2133 00000B3A B00C                    	mov	al, 0Ch ; 
  2134 00000B3C E670                    	out	70h, al ; select register C
  2135 00000B3E 90                      	nop
  2136 00000B3F E471                    	in	al, 71h ; just throw away contents
  2137                                  	; 22/02/2015
  2138 00000B41 B020                    	MOV	AL,EOI		; END OF INTERRUPT
  2139                                  	;CLI			; DISABLE INTERRUPTS TILL STACK CLEARED
  2140 00000B43 E6A0                    	OUT	INTB00,AL	; FOR CONTROLLER #2
  2141                                  
  2142                                  	; 23/05/2016
  2143 00000B45 B020                    	MOV	AL,EOI		; GET END OF INTERRUPT MASK
  2144 00000B47 FA                      	CLI			; DISABLE INTERRUPTS TILL STACK CLEARED
  2145 00000B48 E620                    	OUT	INTA00,AL	; END OF INTERRUPT TO 8259 - 1	
  2146                                  	;
  2147                                  	; 23/05/2016
  2148 00000B4A 20E4                    	and	ah, ah
  2149                                  	;jz	rtc_int_2
  2150                                  	; 24/07/2022
  2151 00000B4C 7505                    	jnz	short rtc_int_4
  2152 00000B4E E9B6FEFFFF              	jmp	rtc_int_2
  2153                                  rtc_int_4:
  2154                                  	; ah = 1 (half second)
  2155 00000B53 58                      	pop	eax ; *
  2156 00000B54 1F                      	pop	ds  ; **
  2157 00000B55 CF                      	iretd
  2158                                  
  2159                                  ; ////////////////
  2160                                  
  2161                                  	; 28/08/2014
  2162                                  irq0:
  2163 00000B56 6A00                            push 	dword 0
  2164 00000B58 EB48                    	jmp	short which_irq
  2165                                  irq1:
  2166 00000B5A 6A01                            push 	dword 1
  2167 00000B5C EB44                    	jmp	short which_irq
  2168                                  irq2:
  2169 00000B5E 6A02                            push 	dword 2
  2170 00000B60 EB40                    	jmp	short which_irq
  2171                                  irq3:
  2172                                  	; 20/11/2015
  2173                                  	; 24/10/2015
  2174 00000B62 2EFF15[63210100]        	call	dword [cs:com2_irq3]
  2175 00000B69 6A03                    	push 	dword 3
  2176 00000B6B EB35                    	jmp	short which_irq
  2177                                  irq4:
  2178                                  	; 20/11/2015
  2179                                  	; 24/10/2015
  2180 00000B6D 2EFF15[5F210100]        	call	dword [cs:com1_irq4]
  2181 00000B74 6A04                            push 	dword 4
  2182 00000B76 EB2A                    	jmp	short which_irq
  2183                                  irq5:
  2184 00000B78 6A05                            push 	dword 5
  2185 00000B7A EB26                    	jmp	short which_irq
  2186                                  irq6:
  2187 00000B7C 6A06                            push 	dword 6
  2188 00000B7E EB22                    	jmp	short which_irq
  2189                                  irq7:
  2190 00000B80 6A07                            push 	dword 7
  2191 00000B82 EB1E                    	jmp	short which_irq
  2192                                  irq8:
  2193 00000B84 6A08                            push 	dword 8
  2194 00000B86 EB1A                    	jmp	short which_irq
  2195                                  irq9:
  2196 00000B88 6A09                            push 	dword 9
  2197 00000B8A EB16                    	jmp	short which_irq
  2198                                  irq10:
  2199 00000B8C 6A0A                            push 	dword 10
  2200 00000B8E EB12                    	jmp	short which_irq
  2201                                  irq11:
  2202 00000B90 6A0B                            push 	dword 11
  2203 00000B92 EB0E                    	jmp	short which_irq
  2204                                  irq12:
  2205 00000B94 6A0C                            push 	dword 12
  2206 00000B96 EB0A                    	jmp	short which_irq
  2207                                  irq13:
  2208 00000B98 6A0D                            push 	dword 13
  2209 00000B9A EB06                    	jmp	short which_irq
  2210                                  irq14:
  2211 00000B9C 6A0E                            push 	dword 14
  2212 00000B9E EB02                    	jmp	short which_irq
  2213                                  irq15:
  2214 00000BA0 6A0F                            push 	dword 15
  2215                                  	;jmp	short which_irq
  2216                                  
  2217                                  	; 22/01/2017
  2218                                  	; 19/10/2015
  2219                                  	; 29/08/2014
  2220                                  	; 21/08/2014
  2221                                  which_irq:
  2222 00000BA2 870424                  	xchg	eax, [esp]  ; 28/08/2014
  2223 00000BA5 53                      	push	ebx
  2224 00000BA6 56                      	push	esi
  2225 00000BA7 57                      	push	edi
  2226 00000BA8 1E                      	push 	ds
  2227 00000BA9 06                      	push 	es
  2228                                  	;
  2229 00000BAA 88C3                    	mov	bl, al
  2230                                  	;
  2231 00000BAC B810000000              	mov	eax, KDATA
  2232 00000BB1 8ED8                    	mov	ds, ax
  2233 00000BB3 8EC0                    	mov	es, ax
  2234                                  	; 19/10/2015
  2235 00000BB5 FC                      	cld
  2236                                          ; 27/08/2014
  2237 00000BB6 8105[F4370100]A000-             add     dword [scr_row], 0A0h
  2237 00000BBE 0000               
  2238                                  	;
  2239 00000BC0 B417                    	mov	ah, 17h	; blue (1) background, 
  2240                                  			; light gray (7) forecolor
  2241 00000BC2 8B3D[F4370100]                  mov     edi, [scr_row]
  2242 00000BC8 B049                    	mov	al, 'I'
  2243 00000BCA 66AB                    	stosw
  2244 00000BCC B052                    	mov	al, 'R'
  2245 00000BCE 66AB                    	stosw
  2246 00000BD0 B051                    	mov	al, 'Q'
  2247 00000BD2 66AB                    	stosw
  2248 00000BD4 B020                    	mov	al, ' '
  2249 00000BD6 66AB                    	stosw
  2250 00000BD8 88D8                    	mov	al, bl
  2251 00000BDA 3C0A                    	cmp	al, 10
  2252 00000BDC 7208                    	jb	short ii1
  2253 00000BDE B031                    	mov	al, '1'
  2254 00000BE0 66AB                    	stosw
  2255 00000BE2 88D8                    	mov	al, bl
  2256 00000BE4 2C0A                    	sub	al, 10
  2257                                  ii1:
  2258 00000BE6 0430                    	add	al, '0'
  2259 00000BE8 66AB                    	stosw
  2260 00000BEA B020                    	mov	al, ' '
  2261 00000BEC 66AB                    	stosw
  2262 00000BEE B021                    	mov	al, '!'
  2263 00000BF0 66AB                    	stosw
  2264 00000BF2 B020                    	mov	al, ' '
  2265 00000BF4 66AB                    	stosw
  2266                                  	; 23/02/2015
  2267 00000BF6 80FB07                  	cmp	bl, 7 ; check for IRQ 8 to IRQ 15 
  2268 00000BF9 7604                    	jna	ii2
  2269                                  	; 22/01/2017
  2270 00000BFB B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  2271 00000BFD E6A0                    	out	0A0h, al ; the 2nd 8259
  2272                                  ii2:
  2273 00000BFF B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  2274 00000C01 E620                    	out	20h, al ; the 2nd 8259
  2275 00000C03 E9CC010000              	jmp     iiret
  2276                                  	;
  2277                                  	; 22/08/2014
  2278                                  	;mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  2279                                  	;out	20h, al	; 8259 PORT
  2280                                  	;
  2281                                  	;pop	es
  2282                                  	;pop	ds
  2283                                  	;pop	edi
  2284                                  	;pop	esi
  2285                                  	;pop	ebx
  2286                                  	;pop 	eax
  2287                                  	;iret
  2288                                  
  2289                                  	; 02/04/2015
  2290                                  	; 25/08/2014
  2291                                  exc0:
  2292 00000C08 6A00                            push 	dword 0
  2293 00000C0A E990000000                      jmp     cpu_except
  2294                                  exc1:
  2295 00000C0F 6A01                            push 	dword 1
  2296 00000C11 E989000000                      jmp     cpu_except
  2297                                  exc2:
  2298 00000C16 6A02                            push 	dword 2
  2299 00000C18 E982000000                      jmp     cpu_except
  2300                                  exc3:
  2301 00000C1D 6A03                            push 	dword 3
  2302 00000C1F EB7E                            jmp     cpu_except
  2303                                  exc4:
  2304 00000C21 6A04                            push 	dword 4
  2305 00000C23 EB7A                            jmp     cpu_except
  2306                                  exc5:
  2307 00000C25 6A05                            push 	dword 5
  2308 00000C27 EB76                            jmp     cpu_except
  2309                                  exc6:
  2310 00000C29 6A06                            push 	dword 6
  2311 00000C2B EB72                            jmp     cpu_except
  2312                                  exc7:
  2313 00000C2D 6A07                            push 	dword 7
  2314 00000C2F EB6E                            jmp     cpu_except
  2315                                  exc8:
  2316                                  	; [esp] = Error code
  2317 00000C31 6A08                            push 	dword 8
  2318 00000C33 EB5C                            jmp     cpu_except_en
  2319                                  exc9:
  2320 00000C35 6A09                            push 	dword 9
  2321 00000C37 EB66                            jmp     cpu_except
  2322                                  exc10:
  2323                                  	; [esp] = Error code
  2324 00000C39 6A0A                            push 	dword 10
  2325 00000C3B EB54                            jmp     cpu_except_en
  2326                                  exc11:
  2327                                  	; [esp] = Error code
  2328 00000C3D 6A0B                            push 	dword 11
  2329 00000C3F EB50                            jmp     cpu_except_en
  2330                                  exc12:
  2331                                  	; [esp] = Error code
  2332 00000C41 6A0C                            push 	dword 12
  2333 00000C43 EB4C                            jmp     cpu_except_en
  2334                                  exc13:
  2335                                  	; [esp] = Error code
  2336 00000C45 6A0D                            push 	dword 13
  2337 00000C47 EB48                            jmp     cpu_except_en
  2338                                  exc14:
  2339                                  	; [esp] = Error code
  2340 00000C49 6A0E                            push 	dword 14
  2341 00000C4B EB44                    	jmp	short cpu_except_en
  2342                                  exc15:
  2343 00000C4D 6A0F                            push 	dword 15
  2344 00000C4F EB4E                            jmp     cpu_except
  2345                                  exc16:
  2346 00000C51 6A10                            push 	dword 16
  2347 00000C53 EB4A                            jmp     cpu_except
  2348                                  exc17:
  2349                                  	; [esp] = Error code
  2350 00000C55 6A11                            push 	dword 17
  2351 00000C57 EB38                    	jmp	short cpu_except_en
  2352                                  exc18:
  2353 00000C59 6A12                            push 	dword 18
  2354 00000C5B EB42                    	jmp	short cpu_except
  2355                                  exc19:
  2356 00000C5D 6A13                            push 	dword 19
  2357 00000C5F EB3E                    	jmp	short cpu_except
  2358                                  exc20:
  2359 00000C61 6A14                            push 	dword 20
  2360 00000C63 EB3A                    	jmp	short cpu_except
  2361                                  exc21:
  2362 00000C65 6A15                            push 	dword 21
  2363 00000C67 EB36                    	jmp	short cpu_except
  2364                                  exc22:
  2365 00000C69 6A16                            push 	dword 22
  2366 00000C6B EB32                    	jmp	short cpu_except
  2367                                  exc23:
  2368 00000C6D 6A17                            push 	dword 23
  2369 00000C6F EB2E                    	jmp	short cpu_except
  2370                                  exc24:
  2371 00000C71 6A18                            push 	dword 24
  2372 00000C73 EB2A                    	jmp	short cpu_except
  2373                                  exc25:
  2374 00000C75 6A19                            push 	dword 25
  2375 00000C77 EB26                    	jmp	short cpu_except
  2376                                  exc26:
  2377 00000C79 6A1A                            push 	dword 26
  2378 00000C7B EB22                    	jmp	short cpu_except
  2379                                  exc27:
  2380 00000C7D 6A1B                            push 	dword 27
  2381 00000C7F EB1E                    	jmp	short cpu_except
  2382                                  exc28:
  2383 00000C81 6A1C                            push 	dword 28
  2384 00000C83 EB1A                    	jmp	short cpu_except
  2385                                  exc29:
  2386 00000C85 6A1D                            push 	dword 29
  2387 00000C87 EB16                    	jmp	short cpu_except
  2388                                  exc30:
  2389 00000C89 6A1E                            push 	dword 30
  2390 00000C8B EB04                    	jmp	short cpu_except_en
  2391                                  exc31:
  2392 00000C8D 6A1F                            push 	dword 31
  2393 00000C8F EB0E                            jmp     short cpu_except
  2394                                  
  2395                                  	; 19/10/2015
  2396                                  	; 19/09/2015
  2397                                  	; 01/09/2015
  2398                                  	; 28/08/2015
  2399                                  	; 28/08/2014
  2400                                  cpu_except_en:
  2401 00000C91 87442404                	xchg	eax, [esp+4] ; Error code
  2402 00000C95 36A3[2C030300]          	mov	[ss:error_code], eax
  2403 00000C9B 58                      	pop	eax  ; Exception number
  2404 00000C9C 870424                  	xchg	eax, [esp]
  2405                                  		; eax = eax before exception
  2406                                  		; [esp] -> exception number
  2407                                  		; [esp+4] -> EIP to return
  2408                                  	; 22/01/2017
  2409                                  	; 19/10/2015
  2410                                  	; 19/09/2015
  2411                                  	; 01/09/2015
  2412                                  	; 28/08/2015
  2413                                  	; 29/08/2014
  2414                                  	; 28/08/2014
  2415                                  	; 25/08/2014
  2416                                  	; 21/08/2014
  2417                                  cpu_except:	; CPU Exceptions
  2418 00000C9F FC                      	cld
  2419 00000CA0 870424                  	xchg	eax, [esp] 
  2420                                  		; eax = Exception number
  2421                                  		; [esp] = eax (before exception)	
  2422 00000CA3 53                      	push	ebx
  2423 00000CA4 56                      	push	esi
  2424 00000CA5 57                      	push	edi
  2425 00000CA6 1E                      	push 	ds
  2426 00000CA7 06                      	push 	es
  2427                                  	; 28/08/2015
  2428 00000CA8 66BB1000                	mov	bx, KDATA
  2429 00000CAC 8EDB                    	mov	ds, bx
  2430 00000CAE 8EC3                    	mov	es, bx
  2431 00000CB0 0F20DB                  	mov	ebx, cr3
  2432 00000CB3 53                      	push	ebx ; (*) page directory
  2433                                  	; 19/10/2015
  2434 00000CB4 FC                      	cld
  2435                                  	; 25/03/2015
  2436 00000CB5 8B1D[88770100]          	mov	ebx, [k_page_dir]
  2437 00000CBB 0F22DB                  	mov	cr3, ebx
  2438                                  	; 28/08/2015
  2439 00000CBE 83F80E                  	cmp	eax, 0Eh ; 14, PAGE FAULT	
  2440 00000CC1 7510                    	jne	short cpu_except_nfp
  2441 00000CC3 E8B44C0000              	call	page_fault_handler
  2442 00000CC8 21C0                    	and 	eax, eax
  2443                                  	;jz	iiretp ; 01/09/2015
  2444                                  	; 24/07/2022
  2445 00000CCA 7505                    	jnz	short cpu_except_pf
  2446 00000CCC E9FF000000              	jmp	iiretp
  2447                                  cpu_except_pf:	; 24/07/2022
  2448 00000CD1 B00E                    	mov	al, 0Eh ; 14
  2449                                  cpu_except_nfp:
  2450                                  	; 23/08/2016
  2451 00000CD3 803D[CE660000]03        	cmp	byte [CRT_MODE], 3
  2452 00000CDA 7409                    	je	short cpu_except_mode_3
  2453 00000CDC 50                      	push	eax
  2454 00000CDD B003                    	mov	al, 3
  2455 00000CDF E8220E0000              	call	_set_mode
  2456 00000CE4 58                      	pop	eax
  2457                                  cpu_except_mode_3:
  2458                                  	; 02/04/2015
  2459 00000CE5 BB[35090000]            	mov	ebx, hang
  2460 00000CEA 875C241C                	xchg	ebx, [esp+28]
  2461                                  		; EIP (points to instruction which faults)
  2462                                  	  	; New EIP (hang)
  2463 00000CEE 891D[30030300]          	mov	[FaultOffset], ebx
  2464 00000CF4 C744242008000000        	mov	dword [esp+32], KCODE ; kernel's code segment
  2465 00000CFC 814C242400020000        	or	dword [esp+36], 200h ; enable interrupts (set IF)
  2466                                  	;
  2467 00000D04 88C4                    	mov	ah, al
  2468 00000D06 240F                    	and	al, 0Fh
  2469 00000D08 3C09                    	cmp	al, 9
  2470 00000D0A 7602                    	jna	short h1ok
  2471 00000D0C 0407                    	add	al, 'A'-':'
  2472                                  h1ok:
  2473 00000D0E C0EC04                  	shr	ah, 4
  2474 00000D11 80FC09                  	cmp	ah, 9
  2475 00000D14 7603                    	jna	short h2ok
  2476 00000D16 80C407                  	add	ah, 'A'-':'
  2477                                  h2ok:	
  2478 00000D19 86E0                    	xchg 	ah, al	
  2479 00000D1B 66053030                	add	ax, '00'
  2480 00000D1F 66A3[4C3A0100]          	mov	[excnstr], ax
  2481                                  	;
  2482                                  	; 29/08/2014
  2483 00000D25 A1[30030300]            	mov	eax, [FaultOffset]
  2484 00000D2A 51                      	push	ecx
  2485 00000D2B 52                      	push	edx
  2486 00000D2C 89E3                    	mov	ebx, esp
  2487                                  	; 28/08/2015
  2488 00000D2E B910000000              	mov	ecx, 16	  ; divisor value to convert binary number
  2489                                  			  ; to hexadecimal string
  2490                                  	;mov	ecx, 10	    ; divisor to convert	
  2491                                  			    ; binary number to decimal string
  2492                                  b2d1:
  2493 00000D33 31D2                    	xor	edx, edx
  2494 00000D35 F7F1                    	div	ecx
  2495                                  	;push	dx
  2496                                  	; 18/04/2021
  2497 00000D37 52                      	push	edx
  2498 00000D38 39C8                    	cmp	eax, ecx
  2499 00000D3A 73F7                    	jnb	short b2d1
  2500 00000D3C BF[573A0100]            	mov	edi, EIPstr ; EIP value
  2501                                  			    ; points to instruction which faults	
  2502                                  	; 28/08/2015
  2503 00000D41 89C2                    	mov	edx, eax
  2504                                  b2d2:
  2505                                  	;add	al, '0'
  2506 00000D43 8A82[81410000]          	mov	al, [edx+hexchrs]
  2507 00000D49 AA                      	stosb		    ; write hexadecimal digit to its place	
  2508 00000D4A 39E3                    	cmp	ebx, esp
  2509 00000D4C 7605                    	jna	short b2d3
  2510                                  	;pop	ax
  2511                                  	; 18/04/2021
  2512 00000D4E 58                      	pop	eax
  2513 00000D4F 88C2                    	mov	dl, al
  2514 00000D51 EBF0                    	jmp	short b2d2
  2515                                  b2d3:
  2516 00000D53 B068                    	mov 	al, 'h' ; 28/08/2015
  2517 00000D55 AA                      	stosb
  2518 00000D56 B020                    	mov	al, 20h	    ; space
  2519 00000D58 AA                      	stosb
  2520 00000D59 30C0                    	xor	al, al	    ; to do it an ASCIIZ string	
  2521 00000D5B AA                      	stosb
  2522                                  	;
  2523 00000D5C 5A                      	pop	edx
  2524 00000D5D 59                      	pop	ecx
  2525                                  	;
  2526 00000D5E B44F                    	mov	ah, 4Fh	; red (4) background, 
  2527                                  			; white (F) forecolor
  2528 00000D60 BE[3C3A0100]            	mov	esi, exc_msg ; message offset
  2529                                  	;
  2530                                  	; 20/01/2017 (!cpu exception!)
  2531                                  	;
  2532 00000D65 8105[F4370100]A000-             add    dword [scr_row], 0A0h
  2532 00000D6D 0000               
  2533 00000D6F 8B3D[F4370100]                  mov    edi, [scr_row]
  2534                                  	;	
  2535 00000D75 C605[10010300]00        	mov	byte [sysflg], 0  ; system mode
  2536 00000D7C FB                              sti
  2537                                  	;
  2538 00000D7D E8EDFBFFFF              	call 	printk
  2539                                  	;
  2540 00000D82 B410                    	mov	ah, 10h
  2541 00000D84 E87F010000              	call	int16h ; getc
  2542                                  	;
  2543 00000D89 B003                    	mov	al, 3
  2544 00000D8B E8760D0000              	call	_set_mode
  2545                                  	;
  2546 00000D90 B801000000              	mov	eax, 1
  2547 00000D95 E9C2C00000              	jmp	sysexit ; terminate process !!!
  2548                                  	
  2549                                  	; 22/01/2017
  2550                                  	; 18/04/2016
  2551                                  	; 28/08/2015
  2552                                  	; 23/02/2015
  2553                                  	; 20/08/2014
  2554                                  ignore_int:
  2555 00000D9A 50                      	push	eax
  2556 00000D9B 53                      	push	ebx ; 23/02/2015
  2557 00000D9C 56                      	push	esi
  2558 00000D9D 57                      	push	edi
  2559 00000D9E 1E                      	push 	ds
  2560 00000D9F 06                      	push 	es
  2561                                  	; 18/04/2016
  2562 00000DA0 66B81000                	mov	ax, KDATA
  2563 00000DA4 8ED8                    	mov	ds, ax
  2564 00000DA6 8EC0                    	mov	es, ax
  2565                                  	; 28/08/2015
  2566 00000DA8 0F20D8                  	mov	eax, cr3
  2567 00000DAB 50                      	push	eax ; (*) page directory
  2568                                  	;
  2569 00000DAC B467                    	mov	ah, 67h	; brown (6) background, 
  2570                                  			; light gray (7) forecolor
  2571 00000DAE BE[04390100]            	mov	esi, int_msg ; message offset
  2572                                  piemsg:
  2573                                          ; 27/08/2014
  2574 00000DB3 8105[F4370100]A000-             add     dword [scr_row], 0A0h
  2574 00000DBB 0000               
  2575 00000DBD 8B3D[F4370100]                  mov     edi, [scr_row]
  2576                                          ;
  2577 00000DC3 E8A7FBFFFF              	call 	printk
  2578                                  	;
  2579                                  	; 23/02/2015
  2580 00000DC8 B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  2581 00000DCA E6A0                    	out	0A0h, al ; the 2nd 8259
  2582                                  	; 22/08/2014
  2583 00000DCC B020                    	mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  2584 00000DCE E620                    	out	20h, al	; 8259 PORT
  2585                                  iiretp: 
  2586                                  	; 22/01/2017
  2587                                  	; 01/09/2015
  2588                                  	; 28/08/2015
  2589 00000DD0 58                      	pop	eax ; (*) page directory
  2590 00000DD1 0F22D8                  	mov	cr3, eax
  2591                                  iiret:
  2592 00000DD4 07                      	pop	es
  2593 00000DD5 1F                      	pop	ds
  2594 00000DD6 5F                      	pop	edi
  2595 00000DD7 5E                      	pop	esi
  2596 00000DD8 5B                      	pop	ebx ; 29/08/2014
  2597 00000DD9 58                      	pop 	eax
  2598 00000DDA CF                      	iretd
  2599                                  
  2600                                  	; 23/05/2016
  2601                                  	; 22/08/2014
  2602                                  	; IBM PC/AT BIOS source code ----- 10/06/85 (bios.asm)
  2603                                  	; (INT 1Ah)
  2604                                  	;; Linux (v0.12) source code (main.c) by Linus Torvalds (1991)
  2605                                  time_of_day:
  2606 00000DDB E8EC550000              	call	UPD_IPR			; WAIT TILL UPDATE NOT IN PROGRESS
  2607 00000DE0 726F                            jc      short time_of_day_retn ; 23/05/2016
  2608 00000DE2 B000                    	mov	al, CMOS_SECONDS
  2609 00000DE4 E819560000              	call	CMOS_READ
  2610 00000DE9 A2[F8770100]            	mov	[time_seconds], al 
  2611 00000DEE B002                    	mov	al, CMOS_MINUTES
  2612 00000DF0 E80D560000              	call	CMOS_READ
  2613 00000DF5 A2[F9770100]            	mov	[time_minutes], al 
  2614 00000DFA B004                    	mov	al, CMOS_HOURS
  2615 00000DFC E801560000              	call	CMOS_READ
  2616 00000E01 A2[FA770100]                    mov     [time_hours], al
  2617 00000E06 B006                    	mov	al, CMOS_DAY_WEEK 
  2618 00000E08 E8F5550000              	call	CMOS_READ
  2619 00000E0D A2[FB770100]            	mov	[date_wday], al
  2620 00000E12 B007                     	mov	al, CMOS_DAY_MONTH
  2621 00000E14 E8E9550000              	call	CMOS_READ
  2622 00000E19 A2[FC770100]            	mov	[date_day], al
  2623 00000E1E B008                    	mov	al, CMOS_MONTH
  2624 00000E20 E8DD550000              	call	CMOS_READ
  2625 00000E25 A2[FD770100]            	mov	[date_month], al
  2626 00000E2A B009                    	mov	al, CMOS_YEAR
  2627 00000E2C E8D1550000              	call	CMOS_READ
  2628 00000E31 A2[FE770100]            	mov	[date_year], al
  2629 00000E36 B032                    	mov	al, CMOS_CENTURY
  2630 00000E38 E8C5550000              	call	CMOS_READ
  2631 00000E3D A2[FF770100]            	mov	[date_century], al
  2632                                  	;
  2633 00000E42 B000                    	mov	al, CMOS_SECONDS
  2634 00000E44 E8B9550000              	call 	CMOS_READ
  2635 00000E49 3A05[F8770100]          	cmp	al, [time_seconds]
  2636 00000E4F 758A                    	jne	short time_of_day
  2637                                  
  2638                                  time_of_day_retn:
  2639 00000E51 C3                      	retn
  2640                                  
  2641                                  	; 15/01/2017
  2642                                  	; 10/06/2016
  2643                                  	; 07/06/2016
  2644                                  	; 06/06/2016
  2645                                  	; 23/05/2016
  2646                                  rtc_p:
  2647 00000E52 B101                    	mov	cl, 1 ; 15/01/2017
  2648 00000E54 EB02                    	jmp	short rtc_p0
  2649                                  u_timer: 
  2650                                  	; Timer Events with 18.2 Hz Timer Ticks
  2651                                  	; (and also timer events with RTC seconds)
  2652 00000E56 28C9                    	sub	cl, cl ; mov cl, 0 ; 15/01/2017
  2653                                  rtc_p0:
  2654                                  	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  2655                                  	; Major Modification:
  2656                                  	; Check and Perform Timer Events (for RTC)
  2657                                  	; 25/08/2014 - 07/09/2014
  2658                                  	; Retro UNIX 386 v1:
  2659                                   	; Print Real Time Clock content
  2660                                  	
  2661                                  	; 15/01/2017
  2662 00000E58 880D[14840100]          	mov	byte [priority], cl ; 0 or 1 (not 2)
  2663 00000E5E 8A2D[17840100]          	mov	ch, [timer_events]
  2664 00000E64 20ED                    	and	ch, ch
  2665 00000E66 7420                    	jz	short rtc_p3
  2666                                  
  2667 00000E68 BE[2C020300]            	mov	esi, timer_set  ; beginning address of
  2668                                  				; timer events space
  2669                                  rtc_p1:
  2670 00000E6D 8B06                    	mov	eax, [esi]	
  2671 00000E6F 20C0                    	and	al, al ; 0 = free, >0 = process no.
  2672 00000E71 7416                    	jz	short rtc_p4
  2673                                  	;
  2674 00000E73 C1C810                  	ror	eax, 16
  2675                                  	; ah = response value, al = interrupt type
  2676                                  	; 15/01/2017
  2677                                  	; cl = interrupt source
  2678                                  	;       1 = RTC, 0 = PIT  	 	
  2679 00000E76 38C8                    	cmp	al, cl 
  2680 00000E78 750A                    	jne	short rtc_p2 ; not as requested or undefined !
  2681 00000E7A 3C01                    	cmp	al, 1 ; 1 ; RTC interrupt ?
  2682 00000E7C 7410                    	je	short rtc_p5 ; yes, check for response
  2683                                  	; 06/06/2016 - 18.2 Hz Timer Ticks
  2684 00000E7E 836E080A                	sub	dword [esi+8], 10 ; 1 tick = 10
  2685 00000E82 7613                    	jna	short rtc_p6  ; continue for responding
  2686                                  rtc_p2:
  2687                                  	; 15/01/2017 (cl -> ch)
  2688                                  	; 07/06/2016
  2689 00000E84 FECD                    	dec	ch    ; remain count of timer events	
  2690 00000E86 7501                    	jnz	short rtc_p4
  2691                                  rtc_p3:	 
  2692 00000E88 C3                      	retn
  2693                                  rtc_p4:	
  2694                                  	;cmp	esi, timer_set + 240 ; 15*16 (last event)
  2695                                  	;jnb	short rtc_p3 ; end of timer event space
  2696 00000E89 83C610                  	add	esi, 16 ; next timer event
  2697 00000E8C EBDF                    	jmp	short rtc_p1
  2698                                  rtc_p5:	 
  2699                                  	; current timer count ; 06/06/2016 (182)
  2700 00000E8E 816E08B6000000          	sub	dword [esi+8], 182 ; 1 second (10*18.2)
  2701 00000E95 77ED                    	ja	short rtc_p2  ; check for the next 
  2702                                  rtc_p6:	
  2703                                  	; it is the time of response! 
  2704 00000E97 8B5E04                  	mov	ebx, [esi+4] ; set (count limit) value
  2705 00000E9A 895E08                  	mov	[esi+8], ebx ; reset count down value
  2706                                  			     ; to count limit
  2707                                  	; 19/12/2016
  2708                                  	; 10/12/2016 - timer callback modification
  2709 00000E9D 8B7E0C                  	mov	edi, [esi+12] ; response (or callback) address	
  2710 00000EA0 807E0100                	cmp	byte [esi+1], 0 ; >0 = callback
  2711 00000EA4 762A                    	jna	short rtc_p8
  2712                                  
  2713                                  	; timer callback !
  2714 00000EA6 0FB61E                  	movzx	ebx, byte [esi] ; process number (>0)
  2715 00000EA9 89D8                    	mov	eax, ebx
  2716 00000EAB C0E302                  	shl	bl, 2 ; *4
  2717 00000EAE 89BB[BC000300]          	mov	[ebx+p.tcb-4], edi ; user's callback service addr
  2718 00000EB4 3A05[6D010300]          	cmp	al, [u.uno]
  2719 00000EBA 7521                    	jne	short rtc_p9
  2720 00000EBC 893D[8C010300]          	mov	[u.tcb], edi
  2721                                  rtc_p7:
  2722                                  	; 15/01/2017
  2723 00000EC2 B002                    	mov	al, 2
  2724 00000EC4 A2[14840100]            	mov	[priority], al ; 2
  2725                                  	; 10/01/2017
  2726                                  	;mov	byte [u.pri], 2
  2727 00000EC9 A2[66010300]            	mov	[u.pri], al ; 2
  2728 00000ECE EBB4                    	jmp	short rtc_p2
  2729                                  rtc_p8:
  2730                                  	; response address is physical address of
  2731                                  	; the program's response (signal return) byte
  2732                                  	; 06/06/2016
  2733                                  	;mov	edi, [esi+12] ; response address
  2734 00000ED0 8827                    	mov	[edi], ah     ; response value 
  2735                                  	;
  2736 00000ED2 C1C010                  	rol	eax, 16
  2737                                  	; 15/01/2017
  2738 00000ED5 3A05[6D010300]          	cmp	al, [u.uno] ; running process ?
  2739 00000EDB 74E5                    	je	short rtc_p7
  2740                                  rtc_p9:
  2741                                  	; al = process number  ; 10/06/2016
  2742 00000EDD B202                    	mov	dl, 2 ; priority, 2 = event (high)	
  2743 00000EDF E8790F0100              	call	set_run_sequence ; 19/05/2016
  2744 00000EE4 EB9E                    	jmp	short rtc_p2 ; 10/06/2016
  2745                                  
  2746                                  ; Default IRQ 7 handler against spurious IRQs (from master PIC)
  2747                                  ; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  2748                                  default_irq7:
  2749                                  	;push	ax
  2750                                  	; 18/04/2021
  2751 00000EE6 50                      	push	eax
  2752 00000EE7 B00B                    	mov	al, 0Bh  ; In-Service register
  2753 00000EE9 E620                    	out	20h, al
  2754 00000EEB EB00                            jmp short $+2
  2755 00000EED EB00                    	jmp short $+2
  2756 00000EEF E420                    	in	al, 20h
  2757 00000EF1 2480                    	and 	al, 80h ; bit 7 (is it real IRQ 7 or fake?)
  2758 00000EF3 7404                            jz      short irq7_iret ; Fake (spurious) IRQ, do not send EOI 
  2759 00000EF5 B020                            mov     al, 20h ; EOI
  2760 00000EF7 E620                    	out	20h, al 
  2761                                  irq7_iret:
  2762                                  	;pop	ax
  2763                                  	; 18/04/2021
  2764 00000EF9 58                      	pop	eax
  2765 00000EFA CF                      	iretd
  2766                                  	
  2767                                  bcd_to_ascii:
  2768                                  	; 25/08/2014
  2769                                  	; INPUT ->
  2770                                  	;	al = Packed BCD number
  2771                                  	; OUTPUT ->
  2772                                  	;	ax  = ASCII word/number
  2773                                  	;
  2774                                  	; Erdogan Tan - 1998 (proc_hex) - TRDOS.ASM (2004-2011)
  2775                                  	;
  2776 00000EFB D410                    	db	0D4h, 10h	; Undocumented inst. AAM
  2777                                  				; AH = AL / 10h
  2778                                  				; AL = AL MOD 10h
  2779 00000EFD 660D3030                	or	ax, '00'	; Make it ASCII based
  2780                                  
  2781 00000F01 86E0                            xchg	ah, al 
  2782                                  	
  2783 00000F03 C3                      	retn
  2784                                  
  2785                                  ; 15/12/2020
  2786                                  real_mem_16m_64k: 
  2787 00000F04 0000                    	dw	0	; Real size of system memory (if > 16MB)
  2788                                  			; as number of 64K blocks - 256
  2789                                  			; (This is for saving real system memory
  2790                                  			; because if system memory is larger than
  2791                                  			; 3 GB and if a VESA VBE video bios
  2792                                  			; is detected, 'mem_16m_64K' may be
  2793                                  			; decreased to reserve LFB space 
  2794                                  			; at the end of system memory.)
  2795                                  			; Upper memory space from LFB base address
  2796                                  			; to 4GB will not be included by M.A.T.
  2797                                  def_LFB_addr:	
  2798 00000F06 0000                    	dw	0 	; HW of default LFB addr (for mode 118h)	
  2799                                  	
  2800                                  
  2801                                  %include 'keyboard.s' ; 07/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - keyboard.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 07/08/2022 (Previous: 12/04/2021)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 17/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; keyboard.inc (17/10/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Ref: Retro UNIX 386 v1.2 - keyboard.s - 11/06/2022
    20                              <1> 
    21                              <1> ; Retro UNIX 386 v1 Kernel - KEYBOARD.INC
    22                              <1> ; Last Modification: 17/10/2015
    23                              <1> ;		    (Keyboard Data is in 'KYBDATA.INC')	
    24                              <1> ;
    25                              <1> ; ///////// KEYBOARD FUNCTIONS (PROCEDURES) ///////////////
    26                              <1> 
    27                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
    28                              <1> 
    29                              <1> ; 03/12/2014
    30                              <1> ; 26/08/2014
    31                              <1> ; KEYBOARD I/O
    32                              <1> ; (INT_16h - Retro UNIX 8086 v1 - U9.ASM, 30/06/2014)
    33                              <1> 
    34                              <1> ;NOTE: 'k0' to 'k7' are name of OPMASK registers.
    35                              <1> ;	(The reason of using '_k' labels!!!) (27/08/2014)    
    36                              <1> ;NOTE: 'NOT' keyword is '~' unary operator in NASM.
    37                              <1> ;	('NOT LC_HC' --> '~LC_HC') (bit reversing operator)
    38                              <1> 
    39                              <1> int16h:	; 30/06/2015
    40                              <1> ;getc:
    41 00000F08 9C                  <1> 	pushfd	; 28/08/2014
    42 00000F09 0E                  <1> 	push 	cs
    43 00000F0A E826000000          <1> 	call 	KEYBOARD_IO_1 ; getc_int
    44 00000F0F C3                  <1> 	retn	
    45                              <1> 
    46                              <1> ; 24/07/2022 - TRDOS 386 v2.0.5
    47                              <1> 
    48                              <1> 	;-----	SHIFT STATUS
    49                              <1> _K3E:                                   ; GET THE EXTENDED SHIFT STATUS FLAGS
    50 00000F10 8A25[9A660000]      <1> 	mov	ah, [KB_FLAG_1]		; GET SYSTEM SHIFT KEY STATUS
    51 00000F16 80E404              <1> 	and	ah, SYS_SHIFT		; MASK ALL BUT SYS KEY BIT
    52                              <1> 	;mov	cl, 5			; SHIFT THEW SYSTEMKEY BIT OVER TO
    53                              <1> 	;shl	ah, cl			; BIT 7 POSITION
    54 00000F19 C0E405              <1>         shl	ah, 5
    55 00000F1C A0[9A660000]        <1> 	mov	al, [KB_FLAG_1]		; GET SYSTEM SHIFT STATES BACK
    56 00000F21 2473                <1> 	and	al, 01110011b		; ELIMINATE SYS SHIFT, HOLD_STATE AND INS_SHIFT
    57 00000F23 08C4                <1> 	or	ah, al                  ; MERGE REMAINING BITS INTO AH
    58 00000F25 A0[9C660000]        <1> 	mov	al, [KB_FLAG_3]		; GET RIGHT CTL AND ALT
    59 00000F2A 240C                <1> 	and	al, 00001100b		; ELIMINATE LC_E0 AND LC_E1
    60 00000F2C 08C4                <1> 	or	ah, al			; OR THE SHIFT FLAGS TOGETHER
    61                              <1> _K3:
    62 00000F2E A0[99660000]        <1> 	mov	al, [KB_FLAG]		; GET THE SHIFT STATUS FLAGS
    63                              <1> 	; 24/07/2022
    64 00000F33 EB38                <1> 	jmp	short _KIO_EXIT		; RETURN TO CALLER
    65                              <1> 
    66                              <1> getc_int:
    67                              <1> 	; 28/02/2015
    68                              <1> 	; 03/12/2014 (derivation from pc-xt-286 bios source code -1986-, 
    69                              <1> 	;	      instead of pc-at bios - 1985-)
    70                              <1> 	; 28/08/2014 (_k1d)
    71                              <1> 	; 30/06/2014
    72                              <1> 	; 03/03/2014
    73                              <1> 	; 28/02/2014
    74                              <1> 	; Derived from "KEYBOARD_IO_1" procedure of IBM "pc-xt-286" 
    75                              <1> 	; rombios source code (21/04/1986)
    76                              <1> 	;	 'keybd.asm', INT 16H, KEYBOARD_IO
    77                              <1> 	;
    78                              <1> 	; KYBD --- 03/06/86  KEYBOARD BIOS
    79                              <1> 	;
    80                              <1> 	;--- INT 16 H -----------------------------------------------------------------
    81                              <1> 	; KEYBOARD I/O								      :
    82                              <1> 	;	THESE ROUTINES PROVIDE READ KEYBOARD SUPPORT			      :
    83                              <1> 	; INPUT									      :
    84                              <1> 	;	(AH)= 00H  READ THE NEXT ASCII CHARACTER ENTERED FROM THE KEYBOARD,   :
    85                              <1> 	;		   RETURN THE RESULT IN (AL), SCAN CODE IN (AH).              :
    86                              <1> 	;		   THIS IS THE COMPATIBLE READ INTERFACE, EQUIVALENT TO THE   :
    87                              <1> 	;                  STANDARD PC OR PCAT KEYBOARD				      :	
    88                              <1> 	;-----------------------------------------------------------------------------:
    89                              <1> 	;	(AH)= 01H  SET THE ZERO FLAG TO INDICATE IF AN ASCII CHARACTER IS     :
    90                              <1> 	;		   AVAILABLE TO BE READ FROM THE KEYBOARD BUFFER.	      :
    91                              <1> 	;		   (ZF)= 1 -- NO CODE AVAILABLE			              :
    92                              <1> 	;		   (ZF)= 0 -- CODE IS AVAILABLE  (AX)= CHARACTER              :
    93                              <1> 	;		   IF (ZF)= 0, THE NEXT CHARACTER IN THE BUFFER TO BE READ IS :
    94                              <1> 	;		   IN (AX), AND THE ENTRY REMAINS IN THE BUFFER.              :
    95                              <1> 	;		   THIS WILL RETURN ONLY PC/PCAT KEYBOARD COMPATIBLE CODES    :
    96                              <1> 	;-----------------------------------------------------------------------------:	
    97                              <1> 	;	(AH)= 02H  RETURN THE CURRENT SHIFT STATUS IN AL REGISTER             :
    98                              <1> 	;		   THE BIT SETTINGS FOR THIS CODE ARE INDICATED IN THE        :
    99                              <1> 	;		   EQUATES FOR @KB_FLAG		                              :
   100                              <1> 	;-----------------------------------------------------------------------------:	
   101                              <1> 	;	(AH)= 03H  SET TYPAMATIC RATE AND DELAY                               :
   102                              <1> 	;	      (AL) = 05H                                                      :
   103                              <1> 	;	      (BL) = TYPAMATIC RATE (BITS 5 - 7 MUST BE RESET TO 0)           :
   104                              <1> 	;		       							      :
   105                              <1> 	;                     REGISTER     RATE      REGISTER     RATE                :
   106                              <1> 	;                      VALUE     SELECTED     VALUE     SELECTED              :
   107                              <1> 	;                     --------------------------------------------            :
   108                              <1> 	;			00H        30.0        10H        7.5                 :
   109                              <1> 	;			01H        26.7        11H        6.7                 :
   110                              <1> 	;			02H        24.0        12H        6.0                 :
   111                              <1> 	;			03H        21.8        13H        5.5                 :
   112                              <1> 	;			04H        20.0        14H        5.0                 :
   113                              <1> 	;			05H        18.5        15H        4.6                 :
   114                              <1> 	;			06H        17.1        16H        4.3                 :
   115                              <1> 	;			07H        16.0        17H        4.0                 :
   116                              <1> 	;			08H        15.0        18H        3.7                 :
   117                              <1> 	;			09H        13.3        19H        3.3                 :
   118                              <1> 	;			0AH        12.0        1AH        3.0                 :
   119                              <1> 	;			0BH        10.9        1BH        2.7                 :
   120                              <1>         ;			0CH        10.0        1CH        2.5                 :
   121                              <1> 	;			0DH         9.2        1DH        2.3                 :
   122                              <1> 	;			0EH         8.6        1EH        2.1                 :
   123                              <1> 	;			0FH         8.0        1FH        2.0                 :
   124                              <1> 	;									      :
   125                              <1> 	;	      (BH) = TYPAMATIC DELAY  (BITS 2 - 7 MUST BE RESET TO 0)         :
   126                              <1> 	;		       							      :
   127                              <1> 	;                     REGISTER     DELAY                                      :
   128                              <1> 	;                      VALUE       VALUE                                      :
   129                              <1> 	;                     ------------------                                      :
   130                              <1> 	;			00H        250 ms                                     :
   131                              <1> 	;			01H        500 ms                                     :
   132                              <1> 	;			02H        750 ms                                     :
   133                              <1> 	;			03H       1000 ms                                     :
   134                              <1> 	;-----------------------------------------------------------------------------:
   135                              <1> 	;	(AH)= 05H  PLACE ASCII CHARACTER/SCAN CODE COMBINATION IN KEYBOARD    :
   136                              <1> 	;		   BUFFER AS IF STRUCK FROM KEYBOARD                          :
   137                              <1> 	;		   ENTRY:  (CL) = ASCII CHARACTER		              :
   138                              <1> 	;		           (CH) = SCAN CODE                                   :
   139                              <1> 	;		   EXIT:   (AH) = 00H = SUCCESSFUL OPERATION                  :
   140                              <1> 	;		           (AL) = 01H = UNSUCCESSFUL - BUFFER FULL            :
   141                              <1> 	;		   FLAGS:  CARRY IF ERROR                                     :
   142                              <1> 	;-----------------------------------------------------------------------------:		
   143                              <1> 	;	(AH)= 10H  EXTENDED READ INTERFACE FOR THE ENHANCED KEYBOARD,         :
   144                              <1> 	;		   OTHERWISE SAME AS FUNCTION AH=0                            :
   145                              <1> 	;-----------------------------------------------------------------------------:
   146                              <1> 	;	(AH)= 11H  EXTENDED ASCII STATUS FOR THE ENHANCED KEYBOARD,           :
   147                              <1> 	;		   OTHERWISE SAME AS FUNCTION AH=1                            :
   148                              <1> 	;-----------------------------------------------------------------------------:	
   149                              <1> 	;	(AH)= 12H  RETURN THE EXTENDED SHIFT STATUS IN AX REGISTER            :
   150                              <1> 	;		   AL = BITS FROM KB_FLAG, AH = BITS FOR LEFT AND RIGHT       :
   151                              <1> 	;		   CTL AND ALT KEYS FROM KB_FLAG_1 AND KB_FLAG_3              :
   152                              <1> 	; OUTPUT					                              :
   153                              <1> 	;	AS NOTED ABOVE, ONLY (AX) AND FLAGS CHANGED	                      :
   154                              <1> 	;	ALL REGISTERS RETAINED		                                      :
   155                              <1> 	;------------------------------------------------------------------------------
   156                              <1> 
   157                              <1> ; 07/08/2022
   158                              <1> ; 24/07/2022 - TRDOS 386 v2.0.5
   159                              <1> ; 12/04/2021 - TRDOS 386 v2.0.3 (32 bit push/pop)
   160                              <1> ; 15/01/2017
   161                              <1> ; 14/01/2017
   162                              <1> ; 02/01/2017
   163                              <1> ; 29/05/2016
   164                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   165                              <1> int32h:  ; Keyboard BIOS
   166                              <1> 
   167                              <1> KEYBOARD_IO_1:	
   168                              <1> 	;sti				; INTERRUPTS BACK ON
   169                              <1> 	; 29/05/2016
   170 00000F35 80642408BE          <1>         and     byte [esp+8], 10111110b ; clear zero flag and cary flag
   171                              <1> 	;
   172 00000F3A 1E                  <1> 	push	ds			; SAVE CURRENT DS
   173 00000F3B 53                  <1> 	push	ebx			; SAVE BX TEMPORARILY
   174                              <1> 	;push	ecx			; SAVE CX TEMPORARILY
   175 00000F3C 66BB1000            <1>         mov     bx, KDATA
   176 00000F40 8EDB                <1> 	mov	ds, bx			; PUT SEGMENT VALUE OF DATA AREA INTO DS
   177                              <1> 	; 14/01/2017
   178 00000F42 8B1C24              <1> 	mov	ebx, [esp]
   179                              <1> 	;; 15/01/2017
   180                              <1> 	; 02/01/2017
   181                              <1> 	;;mov	byte [intflg], 32h	; keyboard interrupt 
   182 00000F45 FB                  <1> 	sti
   183                              <1> 	;
   184 00000F46 08E4                <1> 	or	ah, ah			; CHECK FOR (AH)= 00H
   185 00000F48 7433                <1> 	jz	short _K1		; ASCII_READ
   186 00000F4A FECC                <1> 	dec	ah                      ; CHECK FOR (AH)= 01H
   187 00000F4C 744C                <1>         jz      short _K2               ; ASCII_STATUS
   188 00000F4E FECC                <1> 	dec	ah			; CHECK FOR (AH)= 02H
   189 00000F50 74DC                <1>         jz	short _K3		; SHIFT STATUS
   190 00000F52 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 03H	
   191 00000F54 746F                <1>         jz      short _K300		; SET TYPAMATIC RATE/DELAY
   192 00000F56 80EC02              <1> 	sub	ah, 2			; CHECK FOR (AH)= 05H	
   193                              <1>         ;jz	short _K500		; KEYBOARD WRITE
   194                              <1> 	; 07/08/2022
   195 00000F59 7505                <1> 	jnz	short _KIO1
   196 00000F5B E988000000          <1> 	jmp	_K500         
   197                              <1> _KIO1:	
   198 00000F60 80EC0B              <1> 	sub	ah, 11			; AH =  10H
   199 00000F63 740C                <1> 	jz	short _K1E		; EXTENDED ASCII READ
   200 00000F65 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 11H
   201 00000F67 7422                <1> 	jz	short _K2E		; EXTENDED_ASCII_STATUS
   202 00000F69 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 12H
   203 00000F6B 74A3                <1> 	jz	short _K3E		; EXTENDED_SHIFT_STATUS
   204                              <1> _KIO_EXIT:
   205                              <1> 	; 02/01/2017
   206 00000F6D FA                  <1> 	cli
   207                              <1> 	;;mov	byte [intflg], 0 ;; 15/01/2017
   208                              <1> 	;
   209                              <1> 	;pop	ecx			; RECOVER REGISTER
   210 00000F6E 5B                  <1> 	pop	ebx			; RECOVER REGISTER
   211 00000F6F 1F                  <1> 	pop	ds			; RECOVER SEGMENT
   212 00000F70 CF                  <1> 	iretd				; INVALID COMMAND, EXIT
   213                              <1> 
   214                              <1> ; 24/07/2022
   215                              <1> ;
   216                              <1> ;	;-----	SHIFT STATUS
   217                              <1> ;_K3E:					; GET THE EXTENDED SHIFT STATUS FLAGS
   218                              <1> ;	mov	ah, [KB_FLAG_1]		; GET SYSTEM SHIFT KEY STATUS
   219                              <1> ;	and	ah, SYS_SHIFT		; MASK ALL BUT SYS KEY BIT
   220                              <1> ;	;mov	cl, 5			; SHIFT THEW SYSTEMKEY BIT OVER TO
   221                              <1> ;	;shl	ah, cl			; BIT 7 POSITION
   222                              <1> ;       shl	ah, 5
   223                              <1> ;	mov	al, [KB_FLAG_1]		; GET SYSTEM SHIFT STATES BACK
   224                              <1> ;	and	al, 01110011b		; ELIMINATE SYS SHIFT, HOLD_STATE AND INS_SHIFT
   225                              <1> ;	or	ah, al                  ; MERGE REMAINING BITS INTO AH
   226                              <1> ;	mov	al, [KB_FLAG_3]		; GET RIGHT CTL AND ALT
   227                              <1> ;	and	al, 00001100b		; ELIMINATE LC_E0 AND LC_E1
   228                              <1> ;	or	ah, al			; OR THE SHIFT FLAGS TOGETHER
   229                              <1> ;_K3:
   230                              <1> ;	mov	al, [KB_FLAG]		; GET THE SHIFT STATUS FLAGS
   231                              <1> ;	; 24/07/2022
   232                              <1> ;	jmp	short _KIO_EXIT		; RETURN TO CALLER
   233                              <1> 
   234                              <1> 	;-----	ASCII CHARACTER
   235                              <1> _K1E:	
   236 00000F71 E89F000000          <1> 	call	_K1S			; GET A CHARACTER FROM THE BUFFER (EXTENDED)
   237 00000F76 E812010000          <1> 	call	_KIO_E_XLAT		; ROUTINE TO XLATE FOR EXTENDED CALLS
   238 00000F7B EBF0                <1> 	jmp	short _KIO_EXIT         ; GIVE IT TO THE CALLER
   239                              <1> _K1:	
   240 00000F7D E893000000          <1> 	call	_K1S			; GET A CHARACTER FROM THE BUFFER
   241 00000F82 E811010000          <1> 	call	_KIO_S_XLAT		; ROUTINE TO XLATE FOR STANDARD CALLS
   242 00000F87 72F4                <1> 	jc	short _K1		; CARRY SET MEANS TROW CODE AWAY
   243                              <1> _K1A:
   244 00000F89 EBE2                <1> 	jmp	short _KIO_EXIT         ; RETURN TO CALLER
   245                              <1> 
   246                              <1> 	;-----	ASCII STATUS
   247                              <1> _K2E:	
   248 00000F8B E8D0000000          <1> 	call	_K2S			; TEST FOR CHARACTER IN BUFFER (EXTENDED)
   249 00000F90 7420                <1> 	jz	short _K2B		; RETURN IF BUFFER EMPTY
   250 00000F92 9C                  <1> 	pushf				; SAVE ZF FROM TEST
   251 00000F93 E8F5000000          <1> 	call	_KIO_E_XLAT		; ROUTINE TO XLATE FOR EXTENDED CALLS
   252 00000F98 EB17                <1> 	jmp	short _K2A	        ; GIVE IT TO THE CALLER
   253                              <1> _K2:	
   254 00000F9A E8C1000000          <1> 	call	_K2S			; TEST FOR CHARACTER IN BUFFER
   255 00000F9F 7411                <1> 	jz	short _K2B		; RETURN IF BUFFER EMPTY
   256 00000FA1 9C                  <1> 	pushf				; SAVE ZF FROM TEST
   257 00000FA2 E8F1000000          <1> 	call	_KIO_S_XLAT		; ROUTINE TO XLATE FOR STANDARD CALLS
   258 00000FA7 7308                <1> 	jnc	short _K2A	        ; CARRY CLEAR MEANS PASS VALID CODE
   259 00000FA9 9D                  <1> 	popf				; INVALID CODE FOR THIS TYPE OF CALL
   260 00000FAA E866000000          <1> 	call	_K1S			; THROW THE CHARACTER AWAY
   261 00000FAF EBE9                <1> 	jmp	short _K2		; GO LOOK FOR NEXT CHAR, IF ANY
   262                              <1> _K2A:
   263 00000FB1 9D                  <1> 	popf				; RESTORE ZF FROM TEST
   264                              <1> _K2B:
   265                              <1> 	; 02/01/2017
   266 00000FB2 FA                  <1> 	cli
   267                              <1> 	;; mov	byte [intflg], 0 ;; 15/01/2017
   268                              <1> 	;
   269                              <1> 	;pop	ecx			; RECOVER REGISTER
   270 00000FB3 5B                  <1> 	pop	ebx			; RECOVER REGISTER
   271 00000FB4 1F                  <1> 	pop	ds			; RECOVER SEGMENT
   272                              <1> 	; (*) 29/05/2016
   273                              <1> 	; (*) retf 4			; THROW AWAY (e)FLAGS
   274 00000FB5 7208                <1> 	jc	short _k2d
   275 00000FB7 7505                <1> 	jnz	short _k2c
   276 00000FB9 804C240840          <1> 	or	byte [esp+8], 01000000b	; set zero flag bit of eflags register
   277                              <1> _k2c:
   278 00000FBE CF                  <1> 	iretd
   279                              <1> _k2d:
   280                              <1> 	; 29/05/2016 -set carry flag on stack-
   281                              <1> 	; [esp] = EIP
   282                              <1> 	; [esp+4] = CS
   283                              <1> 	; [esp+8] = E-FLAGS
   284 00000FBF 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
   285                              <1> 	; [esp+12] = ESP (user)
   286                              <1> 	; [esp+16] = SS (User)
   287 00000FC4 CF                  <1> 	iretd
   288                              <1> 	
   289                              <1> 	; (*) 29/05/2016 - 'retf 4' intruction causes to stack fault
   290                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
   291                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
   292                              <1> 	; // RETF instruction:
   293                              <1> 	;
   294                              <1> 	; IF OperandMode=32 THEN
   295                              <1>  	;    Load CS:EIP from stack;
   296                              <1>  	;    Set CS RPL to CPL;
   297                              <1>  	;    Increment ESP by 8 plus the immediate offset if it exists;
   298                              <1>  	;    Load SS:ESP from stack;
   299                              <1>  	; ELSE (* OperandMode=16 *)
   300                              <1>  	;    Load CS:IP from stack;
   301                              <1>  	;    Set CS RPL to CPL;
   302                              <1>  	;    Increment SP by 4 plus the immediate offset if it exists;
   303                              <1> 	;    Load SS:SP from stack;
   304                              <1>  	; FI;
   305                              <1> 	;
   306                              <1> 	; //
   307                              <1> 
   308                              <1> 	; 24/07/2022
   309                              <1> 	;-----	SET TYPAMATIC RATE AND DELAY
   310                              <1> _K300:
   311 00000FC5 3C05                <1> 	cmp	al, 5			; CORRECT FUNCTION CALL?
   312 00000FC7 75A4                <1> 	jne	short _KIO_EXIT		; NO, RETURN
   313 00000FC9 F6C3E0              <1> 	test	bl, 0E0h		; TEST FOR OUT-OF-RANGE RATE
   314 00000FCC 759F                <1> 	jnz	short _KIO_EXIT		; RETURN IF SO
   315 00000FCE F6C7FC              <1> 	test	bh, 0FCh		; TEST FOR OUT-OF-RANGE DELAY
   316 00000FD1 759A                <1> 	jnz	short _KIO_EXIT		; RETURN IF SO
   317 00000FD3 B0F3                <1> 	mov	al, KB_TYPA_RD		; COMMAND FOR TYPAMATIC RATE/DELAY		
   318 00000FD5 E875060000          <1> 	call	SND_DATA		; SEND TO KEYBOARD	
   319                              <1> 	;mov	cx, 5			; SHIFT COUNT
   320                              <1> 	;shl	bh, cl			; SHIFT DELAY OVER
   321 00000FDA C0E705              <1> 	shl	bh, 5
   322 00000FDD 88D8                <1> 	mov	al, bl			; PUT IN RATE
   323 00000FDF 08F8                <1> 	or	al, bh			; AND DELAY
   324 00000FE1 E869060000          <1> 	call	SND_DATA		; SEND TO KEYBOARD	
   325 00000FE6 EB85                <1>         jmp     _KIO_EXIT               ; RETURN TO CALLER
   326                              <1> 
   327                              <1> 	;-----	WRITE TO KEYBOARD BUFFER
   328                              <1> _K500:
   329 00000FE8 56                  <1> 	push	esi			; SAVE SI (esi)
   330 00000FE9 FA                  <1> 	cli				; 
   331 00000FEA 8B1D[AA660000]      <1>      	mov	ebx, [BUFFER_TAIL]	; GET THE 'IN TO' POINTER TO THE BUFFER
   332 00000FF0 89DE                <1> 	mov	esi, ebx		; SAVE A COPY IN CASE BUFFER NOT FULL
   333 00000FF2 E8D1000000          <1> 	call	_K4			; BUMP THE POINTER TO SEE IF BUFFER IS FULL
   334 00000FF7 3B1D[A6660000]      <1> 	cmp	ebx, [BUFFER_HEAD]	; WILL THE BUFFER OVERRUN IF WE STORE THIS?
   335 00000FFD 740D                <1> 	je	short _K502		; YES - INFORM CALLER OF ERROR		
   336 00000FFF 66890E              <1> 	mov	[esi], cx		; NO - PUT ASCII/SCAN CODE INTO BUFFER	
   337 00001002 891D[AA660000]      <1> 	mov	[BUFFER_TAIL], ebx	; ADJUST 'IN TO' POINTER TO REFLECT CHANGE
   338 00001008 28C0                <1> 	sub	al, al			; TELL CALLER THAT OPERATION WAS SUCCESSFUL
   339 0000100A EB02                <1> 	jmp	short _K504		; SUB INSTRUCTION ALSO RESETS CARRY FLAG
   340                              <1> _K502:
   341 0000100C B001                <1> 	mov	al, 01h			; BUFFER FULL INDICATION
   342                              <1> _K504:
   343 0000100E FB                  <1> 	sti				
   344 0000100F 5E                  <1> 	pop	esi			; RECOVER SI (esi)
   345 00001010 E958FFFFFF          <1>         jmp     _KIO_EXIT               ; RETURN TO CALLER WITH STATUS IN AL
   346                              <1> 
   347                              <1> 	;-----	READ THE KEY TO FIGURE OUT WHAT TO DO -----
   348                              <1> _K1S:
   349 00001015 FA                  <1> 	cli	; 03/12/2014
   350 00001016 8B1D[A6660000]      <1>         mov     ebx, [BUFFER_HEAD] 	; GET POINTER TO HEAD OF BUFFER
   351 0000101C 3B1D[AA660000]      <1>         cmp     ebx, [BUFFER_TAIL] 	; TEST END OF BUFFER
   352                              <1> 	;jne	short _K1U		; IF ANYTHING IN BUFFER SKIP INTERRUPT
   353 00001022 750F                <1> 	jne	short _k1x ; 03/12/2014
   354                              <1> 	;
   355                              <1> 	; 03/12/2014
   356                              <1> 	; 28/08/2014
   357                              <1> 	; PERFORM OTHER FUNCTION ?? here !
   358                              <1> 	;; MOV	AX, 9002h		; MOVE IN WAIT CODE & TYPE
   359                              <1> 	;; INT 	15H			; PERFORM OTHER FUNCTION
   360                              <1> _K1T:                                   ; ASCII READ
   361 00001024 FB                  <1> 	sti				; INTERRUPTS BACK ON DURING LOOP
   362 00001025 90                  <1> 	nop				; ALLOW AN INTERRUPT TO OCCUR
   363                              <1> _K1U:	
   364 00001026 FA                  <1> 	cli				; INTERRUPTS BACK OFF
   365 00001027 8B1D[A6660000]      <1>         mov    	ebx, [BUFFER_HEAD] 	; GET POINTER TO HEAD OF BUFFER
   366 0000102D 3B1D[AA660000]      <1>         cmp     ebx, [BUFFER_TAIL] 	; TEST END OF BUFFER
   367                              <1> _k1x:
   368 00001033 53                  <1> 	push	ebx			; SAVE ADDRESS		
   369 00001034 9C                  <1> 	pushf				; SAVE FLAGS
   370 00001035 E8C9060000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
   371 0000103A 8A1D[9B660000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
   372 00001040 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
   373 00001042 80E307              <1> 	and	bl, 07h	; KB_LEDS	; ISOLATE INDICATOR BITS
   374 00001045 7406                <1> 	jz	short _K1V		; IF NO CHANGE BYPASS UPDATE
   375 00001047 E863060000          <1> 	call	SND_LED1
   376 0000104C FA                  <1> 	cli				; DISABLE INTERRUPTS
   377                              <1> _K1V:
   378 0000104D 9D                  <1> 	popf				; RESTORE FLAGS
   379 0000104E 5B                  <1> 	pop	ebx			; RESTORE ADDRESS
   380 0000104F 74D3                <1>         je      short _K1T              ; LOOP UNTIL SOMETHING IN BUFFER
   381                              <1> 	;
   382 00001051 668B03              <1> 	mov	ax, [ebx] 		; GET SCAN CODE AND ASCII CODE
   383 00001054 E86F000000          <1>         call    _K4                     ; MOVE POINTER TO NEXT POSITION
   384 00001059 891D[A6660000]      <1>         mov     [BUFFER_HEAD], ebx      ; STORE VALUE IN VARIABLE
   385 0000105F C3                  <1> 	retn				; RETURN
   386                              <1> 
   387                              <1> 	;-----	READ THE KEY TO SEE IF ONE IS PRESENT -----
   388                              <1> _K2S:
   389 00001060 FA                  <1> 	cli				; INTERRUPTS OFF
   390 00001061 8B1D[A6660000]      <1>         mov     ebx, [BUFFER_HEAD]      ; GET HEAD POINTER
   391 00001067 3B1D[AA660000]      <1>         cmp     ebx, [BUFFER_TAIL]      ; IF EQUAL (Z=1) THEN NOTHING THERE
   392 0000106D 668B03              <1> 	mov	ax, [ebx]
   393 00001070 9C                  <1> 	pushf				; SAVE FLAGS
   394                              <1> 	;push	ax			; SAVE CODE
   395                              <1> 	; 12/04/2021
   396 00001071 50                  <1> 	push	eax
   397 00001072 E88C060000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
   398 00001077 8A1D[9B660000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
   399 0000107D 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
   400 0000107F 80E307              <1> 	and	bl, 07h ; KB_LEDS	; ISOLATE INDICATOR BITS
   401 00001082 7405                <1> 	jz	short _K2T		; IF NO CHANGE BYPASS UPDATE
   402 00001084 E80F060000          <1> 	call	SND_LED			; GO TURN ON MODE INDICATORS
   403                              <1> _K2T:
   404                              <1> 	;pop	ax			; RESTORE CODE
   405                              <1> 	; 12/04/2021
   406 00001089 58                  <1> 	pop	eax
   407 0000108A 9D                  <1> 	popf				; RESTORE FLAGS
   408 0000108B FB                  <1> 	sti				; INTERRUPTS BACK ON
   409 0000108C C3                  <1> 	retn				; RETURN
   410                              <1> 
   411                              <1> 	;-----	ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR EXTENDED CALLS -----
   412                              <1> _KIO_E_XLAT:
   413 0000108D 3CF0                <1> 	cmp	al, 0F0h		; IS IT ONE OF THE FILL-INs?
   414 0000108F 7506                <1> 	jne	short _KIO_E_RET	; NO, PASS IT ON
   415 00001091 08E4                <1>         or 	ah, ah			; AH = 0 IS SPECIAL CASE
   416 00001093 7402                <1>         jz	short _KIO_E_RET        ; PASS THIS ON UNCHANGED
   417 00001095 30C0                <1> 	xor	al, al			; OTHERWISE SET AL = 0
   418                              <1> _KIO_E_RET:				
   419 00001097 C3                  <1> 	retn				; GO BACK
   420                              <1> 
   421                              <1> 	;-----	ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR STANDARD CALLS -----
   422                              <1> _KIO_S_XLAT:
   423 00001098 80FCE0              <1> 	cmp	ah, 0E0h		; IS IT KEYPAD ENTER OR / ?
   424 0000109B 750F                <1> 	jne	short _KIO_S2		; NO, CONTINUE
   425 0000109D 3C0D                <1> 	cmp	al, 0Dh			; KEYPAD ENTER CODE?
   426 0000109F 7408                <1>         je	short _KIO_S1		; YES, MASSAGE A BIT
   427 000010A1 3C0A                <1> 	cmp	al, 0Ah			; CTRL KEYPAD ENTER CODE?
   428 000010A3 7404                <1>         je	short _KIO_S1		; YES, MASSAGE THE SAME
   429 000010A5 B435                <1> 	mov	ah, 35h			; NO, MUST BE KEYPAD /
   430                              <1> _kio_ret: ; 03/12/2014
   431 000010A7 F8                  <1> 	clc
   432 000010A8 C3                  <1> 	retn
   433                              <1> 	;jmp	short _KIO_USE		; GIVE TO CALLER
   434                              <1> _KIO_S1:				
   435 000010A9 B41C                <1> 	mov	ah, 1Ch			; CONVERT TO COMPATIBLE OUTPUT
   436                              <1> 	;jmp	short _KIO_USE		; GIVE TO CALLER
   437 000010AB C3                  <1> 	retn
   438                              <1> _KIO_S2:		
   439 000010AC 80FC84              <1> 	cmp	ah, 84h			; IS IT ONE OF EXTENDED ONES?
   440 000010AF 7715                <1> 	ja	short _KIO_DIS		; YES, THROW AWAY AND GET ANOTHER CHAR
   441 000010B1 3CF0                <1> 	cmp	al, 0F0h		; IS IT ONE OF THE FILL-INs?
   442 000010B3 7506                <1>         jne	short _KIO_S3		; NO, TRY LAST TEST
   443 000010B5 08E4                <1> 	or	ah, ah			; AH = 0 IS SPECIAL CASE
   444 000010B7 740C                <1>         jz	short _KIO_USE		; PASS THIS ON UNCHANGED
   445 000010B9 EB0B                <1> 	jmp	short _KIO_DIS		; THROW AWAY THE REST
   446                              <1> _KIO_S3:
   447 000010BB 3CE0                <1> 	cmp	al, 0E0h		; IS IT AN EXTENSION OF A PREVIOUS ONE?
   448                              <1> 	;jne	short _KIO_USE		; NO, MUST BE A STANDARD CODE
   449 000010BD 75E8                <1> 	jne	short _kio_ret
   450 000010BF 08E4                <1> 	or	ah, ah			; AH = 0 IS SPECIAL CASE
   451 000010C1 7402                <1>         jz	short _KIO_USE		; JUMP IF AH = 0
   452 000010C3 30C0                <1> 	xor	al, al			; CONVERT TO COMPATIBLE OUTPUT
   453                              <1> 	;jmp	short _KIO_USE		; PASS IT ON TO CALLER
   454                              <1> _KIO_USE:
   455                              <1> 	;clc				; CLEAR CARRY TO INDICATE GOOD CODE
   456 000010C5 C3                  <1> 	retn				; RETURN	
   457                              <1> _KIO_DIS:
   458 000010C6 F9                  <1> 	stc				; SET CARRY TO INDICATE DISCARD CODE
   459 000010C7 C3                  <1> 	retn				; RETURN
   460                              <1> 
   461                              <1> 	;-----	INCREMENT BUFFER POINTER ROUTINE -----
   462                              <1> _K4:    
   463 000010C8 43                  <1> 	inc     ebx
   464 000010C9 43                  <1> 	inc	ebx			; MOVE TO NEXT WORD IN LIST
   465 000010CA 3B1D[A2660000]      <1>         cmp     ebx, [BUFFER_END] 	; AT END OF BUFFER?
   466                              <1>         ;jne    short _K5               ; NO, CONTINUE
   467 000010D0 7206                <1> 	jb	short _K5
   468 000010D2 8B1D[9E660000]      <1>         mov     ebx, [BUFFER_START]     ; YES, RESET TO BUFFER BEGINNING
   469                              <1> _K5:
   470 000010D8 C3                  <1> 	retn
   471                              <1> 
   472                              <1> ; 20/02/2015
   473                              <1> ; 05/12/2014
   474                              <1> ; 26/08/2014
   475                              <1> ; KEYBOARD (HARDWARE) INTERRUPT -  IRQ LEVEL 1
   476                              <1> ; (INT_09h - Retro UNIX 8086 v1 - U9.ASM, 07/03/2014)
   477                              <1> ;
   478                              <1> ; Derived from "KB_INT_1" procedure of IBM "pc-at" 
   479                              <1> ; rombios source code (06/10/1985)
   480                              <1> ; 'keybd.asm', HARDWARE INT 09h - (IRQ Level 1)
   481                              <1> 
   482                              <1> ; EQUATES (IBM PC-XT-286 BIOS, 1986, 'POSQEQU.INC')
   483                              <1> 
   484                              <1> ;--------- 8042 COMMANDS -------------------------------------------------------
   485                              <1> ENA_KBD		equ	0AEh		; ENABLE KEYBOARD COMMAND
   486                              <1> DIS_KBD		equ	0ADh		; DISABLE KEYBOARD COMMAND
   487                              <1> SHUT_CMD	equ	0FEh		; CAUSE A SHUTDOWN COMMAND
   488                              <1> ;--------- 8042 KEYBOARD INTERFACE AND DIAGNOSTIC CONTROL REGISTERS ------------
   489                              <1> STATUS_PORT	equ	064h		; 8042 STATUS PORT
   490                              <1> INPT_BUF_FULL	equ	00000010b 	; 1 = +INPUT BUFFER FULL
   491                              <1> PORT_A		equ	060h		; 8042 KEYBOARD SCAN CODE/CONTROL PORT
   492                              <1> ;---------- 8042 KEYBOARD RESPONSE ---------------------------------------------
   493                              <1> KB_ACK		equ	0FAh		; ACKNOWLEDGE PROM TRANSMISSION
   494                              <1> KB_RESEND	equ	0FEh		; RESEND REQUEST
   495                              <1> KB_OVER_RUN	equ	0FFh		; OVER RUN SCAN CODE
   496                              <1> ;---------- KEYBOARD/LED COMMANDS ----------------------------------------------
   497                              <1> KB_ENABLE	equ	0F4h		; KEYBOARD ENABLE
   498                              <1> LED_CMD		equ	0EDh		; LED WRITE COMMAND
   499                              <1> KB_TYPA_RD	equ	0F3h		; TYPAMATIC RATE/DELAY COMMAND
   500                              <1> ;---------- KEYBOARD SCAN CODES ------------------------------------------------
   501                              <1> NUM_KEY		equ	69		; SCAN CODE FOR	 NUMBER LOCK KEY
   502                              <1> SCROLL_KEY	equ	70		; SCAN CODE FOR	 SCROLL LOCK KEY
   503                              <1> ALT_KEY		equ	56		; SCAN CODE FOR	 ALTERNATE SHIFT KEY
   504                              <1> CTL_KEY		equ	29		; SCAN CODE FOR	 CONTROL KEY
   505                              <1> CAPS_KEY	equ	58		; SCAN CODE FOR	 SHIFT LOCK KEY
   506                              <1> DEL_KEY		equ	83		; SCAN CODE FOR	 DELETE KEY
   507                              <1> INS_KEY		equ	82		; SCAN CODE FOR	 INSERT KEY
   508                              <1> LEFT_KEY	equ	42		; SCAN CODE FOR	 LEFT SHIFT
   509                              <1> RIGHT_KEY	equ	54		; SCAN CODE FOR	 RIGHT SHIFT
   510                              <1> SYS_KEY		equ	84		; SCAN CODE FOR	 SYSTEM KEY
   511                              <1> ;---------- ENHANCED KEYBOARD SCAN CODES ---------------------------------------
   512                              <1> ID_1		equ	0ABh		; 1ST ID CHARACTER FOR KBX
   513                              <1> ID_2		equ	041h		; 2ND ID CHARACTER FOR KBX
   514                              <1> ID_2A		equ	054h		; ALTERNATE 2ND ID CHARACTER FOR KBX
   515                              <1> F11_M		equ	87		; F11 KEY MAKE
   516                              <1> F12_M		equ	88		; F12 KEY MAKE
   517                              <1> MC_E0		equ	224		; GENERAL MARKER CODE
   518                              <1> MC_E1		equ	225		; PAUSE KEY MARKER CODE
   519                              <1> ;---------- FLAG EQUATES WITHIN @KB_FLAG----------------------------------------
   520                              <1> RIGHT_SHIFT	equ	00000001b	; RIGHT SHIFT KEY DEPRESSED
   521                              <1> LEFT_SHIFT	equ	00000010b	; LEFT SHIFT KEY DEPRESSED
   522                              <1> CTL_SHIFT	equ	00000100b	; CONTROL SHIFT KEY DEPRESSED
   523                              <1> ALT_SHIFT	equ	00001000b	; ALTERNATE SHIFT KEY DEPRESSED
   524                              <1> SCROLL_STATE	equ	00010000b	; SCROLL LOCK STATE IS ACTIVE
   525                              <1> NUM_STATE	equ	00100000b	; NUM LOCK STATE IS ACTIVE
   526                              <1> CAPS_STATE	equ	01000000b	; CAPS LOCK STATE IS ACTIVE
   527                              <1> INS_STATE	equ	10000000b	; INSERT STATE IS ACTIVE
   528                              <1> ;---------- FLAG EQUATES WITHIN	@KB_FLAG_1 -------------------------------------
   529                              <1> L_CTL_SHIFT	equ	00000001b	; LEFT CTL KEY DOWN
   530                              <1> L_ALT_SHIFT	equ	00000010b	; LEFT ALT KEY DOWN
   531                              <1> SYS_SHIFT	equ	00000100b	; SYSTEM KEY DEPRESSED AND HELD
   532                              <1> HOLD_STATE	equ	00001000b	; SUSPEND KEY HAS BEEN TOGGLED
   533                              <1> SCROLL_SHIFT	equ	00010000b	; SCROLL LOCK KEY IS DEPRESSED
   534                              <1> NUM_SHIFT	equ	00100000b	; NUM LOCK KEY IS DEPRESSED
   535                              <1> CAPS_SHIFT	equ	01000000b	; CAPS LOCK KEY IS DEPRE55ED
   536                              <1> INS_SHIFT	equ	10000000b	; INSERT KEY IS DEPRESSED
   537                              <1> ;---------- FLAGS EQUATES WITHIN @KB_FLAG_2 -----------------------------------
   538                              <1> KB_LEDS		equ	00000111b	; KEYBOARD LED STATE BITS
   539                              <1> ;		equ	00000001b	; SCROLL LOCK INDICATOR
   540                              <1> ;		equ	00000010b	; NUM LOCK INDICATOR
   541                              <1> ;		equ	00000100b	; CAPS LOCK INDICATOR
   542                              <1> ;		equ	00001000b	; RESERVED (MUST BE ZERO)
   543                              <1> KB_FA		equ	00010000b	; ACKNOWLEDGMENT RECEIVED
   544                              <1> KB_FE		equ	00100000b	; RESEND RECEIVED FLAG
   545                              <1> KB_PR_LED	equ	01000000b	; MODE INDICATOR UPDATE
   546                              <1> KB_ERR		equ	10000000b	; KEYBOARD TRANSMIT ERROR FLAG
   547                              <1> ;----------- FLAGS EQUATES WITHIN @KB_FLAG_3 -----------------------------------
   548                              <1> LC_E1		equ	00000001b	; LAST CODE WAS THE E1 HIDDEN CODE
   549                              <1> LC_E0		equ	00000010b	; LAST CODE WAS THE E0 HIDDEN CODE
   550                              <1> R_CTL_SHIFT	equ	00000100b	; RIGHT CTL KEY DOWN
   551                              <1> R_ALT_SHIFT	equ	00001000b	; RIGHT ALT KEY DOWN
   552                              <1> GRAPH_ON	equ	00001000b	; ALT GRAPHICS KEY DOWN (WT ONLY)	
   553                              <1> KBX		equ	00010000b	; ENHANCED KEYBOARD INSTALLED
   554                              <1> SET_NUM_LK	equ	00100000b	; FORCE NUM LOCK IF READ ID AND KBX
   555                              <1> LC_AB		equ	01000000b	; LAST CHARACTER WAS FIRST ID CHARACTER
   556                              <1> RD_ID		equ	10000000b	; DOING A READ ID (MUST BE BIT0)
   557                              <1> ;
   558                              <1> ;----------- INTERRUPT EQUATES -------------------------------------------------
   559                              <1> EOI		equ	020h		; END OF INTERRUPT COMMAND TO 8259
   560                              <1> INTA00		equ	020h		; 8259 PORT
   561                              <1> 
   562                              <1> 
   563                              <1> kb_int:
   564                              <1> 
   565                              <1> ; 24/07/2022 - TRDOS 386 v2.0.5
   566                              <1> ; 12/04/2021 - TRDOS 386 v2.0.3 (32 bit push/pop)
   567                              <1> ; 17/10/2015 ('ctrlbrk') 
   568                              <1> ; 05/12/2014
   569                              <1> ; 04/12/2014 (derived from pc-xt-286 bios source code -1986-)
   570                              <1> ; 26/08/2014
   571                              <1> ;
   572                              <1> ; 03/06/86  KEYBOARD BIOS
   573                              <1> ;
   574                              <1> ;--- HARDWARE INT 09H -- (IRQ LEVEL 1) ------------------------------------------
   575                              <1> ;										;
   576                              <1> ;	KEYBOARD INTERRUPT ROUTINE						;
   577                              <1> ;										;
   578                              <1> ;--------------------------------------------------------------------------------
   579                              <1> 
   580                              <1> KB_INT_1:
   581 000010D9 FB                  <1> 	sti				; ENABLE INTERRUPTS
   582                              <1> 	;push	ebp
   583 000010DA 50                  <1> 	push	eax
   584 000010DB 53                  <1> 	push	ebx
   585 000010DC 51                  <1> 	push	ecx
   586 000010DD 52                  <1> 	push	edx
   587 000010DE 56                  <1> 	push	esi
   588 000010DF 57                  <1> 	push	edi
   589 000010E0 1E                  <1> 	push	ds
   590 000010E1 06                  <1> 	push	es
   591 000010E2 FC                  <1> 	cld				; FORWARD DIRECTION
   592 000010E3 66B81000            <1> 	mov	ax, KDATA
   593 000010E7 8ED8                <1> 	mov	ds, ax
   594 000010E9 8EC0                <1> 	mov	es, ax
   595                              <1> 	;
   596                              <1> 	;-----	WAIT FOR KEYBOARD DISABLE COMMAND TO BE ACCEPTED
   597 000010EB B0AD                <1> 	mov	al, DIS_KBD		; DISABLE THE KEYBOARD COMMAND
   598 000010ED E84B050000          <1> 	call	SHIP_IT			; EXECUTE DISABLE
   599 000010F2 FA                  <1> 	cli				; DISABLE INTERRUPTS
   600 000010F3 B900000100          <1> 	mov	ecx, 10000h		; SET MAXIMUM TIMEOUT
   601                              <1> KB_INT_01:
   602 000010F8 E464                <1> 	in	al, STATUS_PORT		; READ ADAPTER STATUS
   603 000010FA A802                <1> 	test	al, INPT_BUF_FULL	; CHECK INPUT BUFFER FULL STATUS BIT
   604 000010FC E0FA                <1> 	loopnz	KB_INT_01		; WAIT FOR COMMAND TO BE ACCEPTED
   605                              <1> 	;
   606                              <1> 	;-----	READ CHARACTER FROM KEYBOARD INTERFACE
   607 000010FE E460                <1> 	in	al, PORT_A		; READ IN THE CHARACTER
   608                              <1> 	;
   609                              <1> 	;-----	SYSTEM HOOK INT 15H - FUNCTION 4FH (ON HARDWARE INT LEVEL 9H) 	
   610                              <1> 	;mov	ah, 04Fh		; SYSTEM INTERCEPT - KEY CODE FUNCTION
   611                              <1> 	;stc				; SET CY=1 (IN CASE OF IRET)
   612                              <1> 	;int	15h			; CASETTE CALL (AL)=KEY SCAN CODE
   613                              <1> 	;				; RETURNS CY=1 FOR INVALID FUNCTION
   614                              <1> 	;jc	KB_INT_02		; CONTINUE IF CARRY FLAG SET ((AL)=CODE)
   615                              <1> 	;jmp	K26			; EXIT IF SYSTEM HANDLES SCAN CODE
   616                              <1> 	;				; EXT HANDLES HARDWARE EOI AND ENABLE		
   617                              <1> 	;
   618                              <1> 	;-----	CHECK FOR A RESEND COMMAND TO KEYBOARD
   619                              <1> KB_INT_02:				; 	  (AL)= SCAN CODE
   620 00001100 FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
   621 00001101 3CFE                <1> 	cmp	al, KB_RESEND		; IS THE INPUT A RESEND
   622 00001103 740E                <1>         je      short KB_INT_4          ; GO IF RESEND
   623                              <1> 	;
   624                              <1> 	;-----	CHECK FOR RESPONSE TO A COMMAND TO KEYBOARD
   625 00001105 3CFA                <1> 	cmp	al, KB_ACK		; IS THE INPUT AN ACKNOWLEDGE
   626 00001107 7514                <1>         jne     short KB_INT_2          ; GO IF NOT
   627                              <1> 	;
   628                              <1> 	;-----	A COMMAND TO THE KEYBOARD WAS ISSUED
   629 00001109 FA                  <1> 	cli				; DISABLE INTERRUPTS
   630 0000110A 800D[9B660000]10    <1> 	or	byte [KB_FLAG_2], KB_FA ; INDICATE ACK RECEIVED
   631                              <1>         ;jmp	K26                     ; RETURN IF NOT ACK RETURNED FOR DATA)
   632                              <1> 	; 12/04/2021
   633 00001111 EB76                <1> 	jmp	short ID_EX  ; K26
   634                              <1> 	;
   635                              <1> 	;-----	RESEND THE LAST BYTE
   636                              <1> KB_INT_4:
   637 00001113 FA                  <1> 	cli				; DISABLE INTERRUPTS
   638 00001114 800D[9B660000]20    <1> 	or	byte [KB_FLAG_2], KB_FE ; INDICATE RESEND RECEIVED
   639                              <1>         ;jmp	K26                     ; RETURN IF NOT ACK RETURNED FOR DATA)
   640                              <1> 	; 12/04/2021
   641 0000111B EB6C                <1> 	jmp	short ID_EX  ; K26
   642                              <1> 	;
   643                              <1> ;-----	UPDATE MODE INDICATORS IF CHANGE IN STATE
   644                              <1> KB_INT_2:
   645                              <1> 	;push 	ax			; SAVE DATA IN
   646                              <1> 	; 12/04/2021
   647 0000111D 50                  <1> 	push	eax
   648 0000111E E8E0050000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
   649 00001123 8A1D[9B660000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
   650 00001129 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
   651 0000112B 80E307              <1> 	and	bl, KB_LEDS		; ISOLATE INDICATOR BITS
   652 0000112E 7405                <1> 	jz	short UP0		; IF NO CHANGE BYPASS UPDATE
   653 00001130 E863050000          <1> 	call	SND_LED			; GO TURN ON MODE INDICATORS
   654                              <1> UP0:
   655                              <1> 	;pop	ax			; RESTORE DATA IN
   656                              <1> 	; 12/04/2021
   657 00001135 58                  <1> 	pop	eax
   658                              <1> ;------------------------------------------------------------------------
   659                              <1> ;	START OF KEY PROCESSING						;
   660                              <1> ;------------------------------------------------------------------------
   661 00001136 88C4                <1> 	mov	ah, al			; SAVE SCAN CODE IN AH ALSO
   662                              <1> 	;
   663                              <1> 	;-----	TEST FOR OVERRUN SCAN CODE FROM KEYBOARD
   664 00001138 3CFF                <1> 	cmp	al, KB_OVER_RUN		; IS THIS AN OVERRUN CHAR
   665                              <1>         ;je	K62			; BUFFER_FULL_BEEP
   666                              <1> 	; 12/04/2021
   667 0000113A 7505                <1> 	jne	short K16
   668 0000113C E9E8040000          <1> 	jmp	K62
   669                              <1> K16:	
   670 00001141 8A3D[9C660000]      <1> 	mov	bh, [KB_FLAG_3]		; LOAD FLAGS FOR TESTING
   671                              <1> 	;
   672                              <1> 	;-----	TEST TO SEE IF A READ_ID IS IN PROGRESS
   673 00001147 F6C7C0              <1> 	test 	bh, RD_ID+LC_AB 	; ARE WE DOING A READ ID?
   674 0000114A 7442                <1> 	jz	short NOT_ID		; CONTINUE IF NOT
   675 0000114C 7914                <1> 	jns	short TST_ID_2		; IS THE RD_ID FLAG ON?
   676 0000114E 3CAB                <1> 	cmp	al, ID_1		; IS THIS THE 1ST ID CHARACTER?
   677 00001150 7507                <1> 	jne	short RST_RD_ID
   678 00001152 800D[9C660000]40    <1> 	or	byte [KB_FLAG_3], LC_AB ; INDICATE 1ST ID WAS OK
   679                              <1> RST_RD_ID:
   680 00001159 8025[9C660000]7F    <1> 	and	byte [KB_FLAG_3], ~RD_ID ; RESET THE READ ID FLAG
   681 00001160 EB27                <1>         jmp	short ID_EX		; AND EXIT
   682                              <1> 	; 12/04/2021
   683                              <1> 	;jmp	K26
   684                              <1> 	;
   685                              <1> TST_ID_2:
   686 00001162 8025[9C660000]BF    <1> 	and	byte [KB_FLAG_3], ~LC_AB ; RESET FLAG
   687 00001169 3C54                <1> 	cmp	al, ID_2A		; IS THIS THE 2ND ID CHARACTER?
   688 0000116B 7415                <1>         je	short KX_BIT		; JUMP IF SO
   689 0000116D 3C41                <1> 	cmp	al, ID_2		; IS THIS THE 2ND ID CHARACTER?
   690 0000116F 7518                <1>         jne	short ID_EX		; LEAVE IF NOT
   691                              <1> 	; 12/04/2021
   692                              <1> 	;jne	K26
   693                              <1> 	;
   694                              <1> 	;-----	A READ ID SAID THAT IT WAS ENHANCED KEYBOARD
   695 00001171 F6C720              <1> 	test	bh, SET_NUM_LK 		; SHOULD WE SET NUM LOCK?
   696 00001174 740C                <1>         jz      short KX_BIT		; EXIT IF NOT
   697 00001176 800D[99660000]20    <1> 	or	byte [KB_FLAG], NUM_STATE ; FORCE NUM LOCK ON
   698 0000117D E816050000          <1> 	call	SND_LED			; GO SET THE NUM LOCK INDICATOR
   699                              <1> KX_BIT:
   700 00001182 800D[9C660000]10    <1> 	or	byte [KB_FLAG_3], KBX	; INDICATE ENHANCED KEYBOARD WAS FOUND
   701 00001189 E9CB010000          <1> ID_EX:	jmp     K26			; EXIT
   702                              <1> 	;
   703                              <1> NOT_ID:
   704 0000118E 3CE0                <1> 	cmp	al, MC_E0		; IS THIS THE GENERAL MARKER CODE?
   705 00001190 7509                <1> 	jne	short TEST_E1
   706 00001192 800D[9C660000]12    <1> 	or	byte [KB_FLAG_3], LC_E0+KBX ; SET FLAG BIT, SET KBX, AND
   707 00001199 EB0B                <1> 	jmp	short EXIT		; THROW AWAY THIS CODE
   708                              <1> 	; 12/04/2021
   709                              <1> 	;jmp	K26A	
   710                              <1> TEST_E1:	
   711 0000119B 3CE1                <1> 	cmp	al, MC_E1		; IS THIS THE PAUSE KEY?
   712 0000119D 750C                <1> 	jne	short NOT_HC
   713 0000119F 800D[9C660000]11    <1> 	or	byte [KB_FLAG_3], LC_E1+KBX ; SET FLAG BIT, SET KBX, AND
   714 000011A6 E9B5010000          <1> EXIT:	jmp	K26A			; THROW AWAY THIS CODE
   715                              <1> 	;
   716                              <1> NOT_HC:
   717 000011AB 247F                <1> 	and	al, 07Fh		; TURN OFF THE BREAK BIT
   718 000011AD F6C702              <1> 	test	bh, LC_E0		; LAST CODE THE E0 MARKER CODE
   719 000011B0 7410                <1> 	jz	short NOT_LC_E0		; JUMP IF NOT
   720                              <1> 	;
   721 000011B2 BF[86650000]        <1> 	mov	edi, _K6+6		; IS THIS A SHIFT KEY?
   722 000011B7 AE                  <1> 	scasb
   723                              <1> 	;je	K26 ; K16B              ; YES, THROW AWAY & RESET FLAG
   724                              <1> 	; 12/04/2021
   725 000011B8 745B                <1> 	je	short K16B ; K26
   726 000011BA AE                  <1> 	scasb
   727 000011BB 756D                <1> 	jne	short K16A		; NO, CONTINUE KEY PROCESSING
   728                              <1> 	;jmp	short K16B		; YES, THROW AWAY & RESET FLAG
   729 000011BD E997010000          <1> 	jmp	K26
   730                              <1> 	;
   731                              <1> NOT_LC_E0:
   732 000011C2 F6C701              <1> 	test	bh, LC_E1		; LAST CODE THE E1 MARKER CODE?
   733 000011C5 7425                <1> 	jz	short T_SYS_KEY		; JUMP IF NOT
   734 000011C7 B904000000          <1> 	mov	ecx, 4			; LENGHT OF SEARCH
   735 000011CC BF[84650000]        <1> 	mov	edi, _K6+4		; IS THIS AN ALT, CTL, OR SHIFT?
   736 000011D1 F2AE                <1> 	repne	scasb			; CHECK IT
   737 000011D3 74D1                <1> 	je	short EXIT		; THROW AWAY IF SO
   738                              <1> 	; 12/04/2021
   739                              <1> 	;je	K26A			
   740                              <1> 	;
   741 000011D5 3C45                <1> 	cmp	al, NUM_KEY		; IS IT THE PAUSE KEY?
   742 000011D7 753C                <1> 	jne	short K16B		; NO, THROW AWAY & RESET FLAG
   743                              <1> 	; 12/04/2021
   744                              <1> 	;jne	K26
   745 000011D9 F6C480              <1> 	test	ah, 80h			; YES, IS IT THE BREAK OF THE KEY?
   746 000011DC 7537                <1> 	jnz	short K16B		; YES, THROW THIS AWAY, TOO	
   747                              <1> 	; 24/07/2022
   748                              <1> 	;jnz	K26
   749                              <1>         ; 20/02/2015 
   750 000011DE F605[9A660000]08    <1> 	test	byte [KB_FLAG_1],HOLD_STATE ; NO, ARE WE PAUSED ALREADY?
   751 000011E5 752E                <1> 	jnz	short K16B		; YES, THROW AWAY
   752                              <1> 	; 12/04/2021
   753                              <1> 	;jnz	K26
   754 000011E7 E9B1020000          <1> 	jmp     K39P                    ; NO, THIS IS THE REAL PAUSE STATE
   755                              <1> 	;
   756                              <1> 	;-----	TEST FOR SYSTEM KEY
   757                              <1> T_SYS_KEY:
   758 000011EC 3C54                <1> 	cmp	al, SYS_KEY		; IS IT THE SYSTEM KEY?
   759 000011EE 753A                <1> 	jnz	short K16A		; CONTINUE IF NOT
   760                              <1> 	;
   761 000011F0 F6C480              <1> 	test	ah, 80h			; CHECK IF THIS A BREAK CODE
   762 000011F3 7525                <1> 	jnz	short K16C		; DO NOT TOUCH SYSTEM INDICATOR IF TRUE
   763                              <1> 	;
   764 000011F5 F605[9A660000]04    <1> 	test	byte [KB_FLAG_1], SYS_SHIFT ; SEE IF IN SYSTEM KEY HELD DOWN 
   765 000011FC 7517                <1> 	jnz	short K16B		; IF YES, DO NOT PROCESS SYSTEM INDICATOR	
   766                              <1> 	; 12/04/2021
   767                              <1> 	;jnz	K26		
   768                              <1> 	;
   769 000011FE 800D[9A660000]04    <1> 	or	byte [KB_FLAG_1], SYS_SHIFT ; INDICATE SYSTEM KEY DEPRESSED
   770 00001205 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
   771 00001207 E620                <1> 	out	20h, al ;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
   772                              <1> 					; INTERRUPT-RETURN-NO-EOI
   773 00001209 B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
   774 0000120B E82D040000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
   775                              <1> 	; !!! SYSREQ !!! function/system call (INTERRUPT) must be here !!!
   776                              <1> 	;MOV	AL, 8500H		; FUNCTION VALUE FOR MAKE OF SYSTEM KEY
   777                              <1> 	;STI				; MAKE SURE INTERRUPTS ENABLED
   778                              <1> 	;INT	15H			; USER INTERRUPT	
   779 00001210 E957010000          <1>         jmp     K27A                    ; END PROCESSING
   780                              <1> 	;
   781 00001215 E93F010000          <1> K16B:	jmp	K26			; IGNORE SYSTEM KEY
   782                              <1> 	;
   783                              <1> K16C:
   784 0000121A 8025[9A660000]FB    <1> 	and	byte [KB_FLAG_1], ~SYS_SHIFT ; TURN OFF SHIFT KEY HELD DOWN
   785 00001221 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
   786 00001223 E620                <1> 	out	20h, al ;out INTA00, al ; SEND COMMAND TO INTERRUPT CONTROL PORT
   787                              <1> 					; INTERRUPT-RETURN-NO-EOI
   788                              <1> 	;MOV	AL, ENA_KBD		; INSURE KEYBOARD IS ENABLED
   789                              <1> 	;CALL	SHIP_IT			; EXECUTE ENABLE
   790                              <1> 	;
   791                              <1> 	;MOV	AX, 8501H		; FUNCTION VALUE FOR BREAK OF SYSTEM KEY
   792                              <1> 	;STI				; MAKE SURE INTERRUPTS ENABLED
   793                              <1> 	;INT	15H			; USER INTERRUPT
   794                              <1> 	;JMP	K27A			; INGONRE SYSTEM KEY				
   795                              <1> 	;
   796 00001225 E93B010000          <1> 	jmp     K27			; IGNORE SYSTEM KEY
   797                              <1> 	;
   798                              <1> 	;-----	TEST FOR SHIFT KEYS
   799                              <1> K16A:
   800 0000122A 8A1D[99660000]      <1> 	mov	bl, [KB_FLAG]		; PUT STATE FLAGS IN BL
   801 00001230 BF[80650000]        <1> 	mov	edi, _K6		; SHIFT KEY TABLE offset
   802 00001235 B908000000          <1> 	mov	ecx, _K6L		; LENGTH
   803 0000123A F2AE                <1> 	repne	scasb			; LOOK THROUGH THE TABLE FOR A MATCH
   804 0000123C 88E0                <1> 	mov	al, ah			; RECOVER SCAN CODE
   805                              <1>         ;jne	K25                     ; IF NO MATCH, THEN SHIFT NOT FOUND
   806                              <1> 	; 12/04/2021
   807 0000123E 7405                <1> 	je	short K17
   808 00001240 E9FC000000          <1> 	jmp	K25
   809                              <1> 	;
   810                              <1> 	;------	SHIFT KEY FOUND
   811                              <1> K17:
   812 00001245 81EF[81650000]      <1>         sub     edi, _K6+1              ; ADJUST PTR TO SCAN CODE MATCH
   813 0000124B 8AA7[88650000]      <1>        	mov     ah, [edi+_K7]       	; GET MASK INTO AH
   814 00001251 B102                <1> 	mov	cl, 2			; SETUP COUNT FOR FLAG SHIFTS
   815 00001253 A880                <1> 	test	al, 80h			; TEST FOR BREAK KEY
   816                              <1> 	;jnz	short K23		; JUMP OF BREAK
   817                              <1> 	; 12/04/2021
   818 00001255 7405                <1> 	jz	short K17C
   819 00001257 E981000000          <1> 	jmp	K23
   820                              <1> 	;
   821                              <1> 	;-----	SHIFT MAKE FOUND, DETERMINE SET OR TOGGLE
   822                              <1> K17C:
   823 0000125C 80FC10              <1> 	cmp	ah, SCROLL_SHIFT
   824 0000125F 7324                <1> 	jae	short K18		; IF SCROLL SHIFT OR ABOVE, TOGGLE KEY
   825                              <1> 	;
   826                              <1> 	;-----	PLAIN SHIFT KEY, SET SHIFT ON
   827 00001261 0825[99660000]      <1> 	or	[KB_FLAG], ah		; TURN ON SHIFT BIT
   828 00001267 A80C                <1>         test	al, CTL_SHIFT+ALT_SHIFT ; IS IT ALT OR CTRL?
   829                              <1> 	;;jnz	short K17D		; YES, MORE FLAGS TO SET
   830                              <1> 	;jz	K26			; NO, INTERRUPT RETURN
   831                              <1> 	; 12/04/2021
   832 00001269 7415                <1> 	jz	short k17f
   833                              <1> K17D:
   834 0000126B F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OF NEW KEYS?
   835 0000126E 7408                <1> 	jz 	short K17E		; NO, JUMP
   836 00001270 0825[9C660000]      <1> 	or	[KB_FLAG_3], ah		; SET BITS FOR RIGHT CTRL, ALT
   837                              <1> 	;jmp	K26			; INTERRUPT RETURN
   838                              <1> 	; 12/04/2021
   839 00001276 EB08                <1> 	jmp	short k17f
   840                              <1> K17E:
   841 00001278 D2EC                <1> 	shr	ah, cl			; MOVE FLAG BITS TWO POSITIONS
   842 0000127A 0825[9A660000]      <1> 	or	[KB_FLAG_1], ah		; SET BITS FOR LEFT CTRL, ALT
   843                              <1> k17f:	; 12/04/2021
   844 00001280 E9D4000000          <1> 	jmp	K26
   845                              <1> 	;
   846                              <1> 	;-----	TOGGLED SHIFT KEY, TEST FOR 1ST MAKE OR NOT
   847                              <1> K18:					; SHIFT-TOGGLE
   848 00001285 F6C304              <1> 	test	bl, CTL_SHIFT 		; CHECK CTL SHIFT STATE
   849 00001288 7402                <1> 	jz	short K18A              ; JUMP IF NOT CTL STATE
   850                              <1>         ;jnz	K25                     ; JUMP IF CTL STATE
   851                              <1> 	; 12/04/2021
   852 0000128A EB1C                <1> 	jmp	short k20a ; K25
   853                              <1> K18A:
   854 0000128C 3C52                <1> 	cmp	al, INS_KEY		; CHECK FOR INSERT KEY
   855 0000128E 7522                <1> 	jne	short K22		; JUMP IF NOT INSERT KEY
   856 00001290 F6C308              <1> 	test	bl, ALT_SHIFT 		; CHECK FOR ALTERNATE SHIFT
   857 00001293 7402                <1>       	jz	short K18B		; JUMP IF NOT ALTERNATE SHIFT	
   858                              <1>         ;jnz	K25			; JUMP IF ALTERNATE SHIFT
   859                              <1> 	; 12/04/2021
   860 00001295 EB11                <1> 	jmp	short k20a ; K25
   861                              <1> K18B:
   862 00001297 F6C702              <1> 	test	bh, LC_E0 ;20/02/2015	; IS THIS NEW INSERT KEY?
   863 0000129A 7516                <1> 	jnz	short K22		; YES, THIS ONE'S NEVER A '0'
   864                              <1> K19:	
   865 0000129C F6C320              <1> 	test	bl, NUM_STATE 		; CHECK FOR BASE STATE
   866 0000129F 750C                <1> 	jnz	short K21		; JUMP IF NUM LOCK IS ON
   867 000012A1 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST FOR SHIFT STATE
   868 000012A4 740C                <1> 	jz	short K22		; JUMP IF BASE STATE
   869                              <1> K20:					; NUMERIC ZERO, NOT INSERT KEY
   870 000012A6 88C4                <1> 	mov	ah, al			; PUT SCAN CODE BACK IN AH
   871                              <1> k20a:	; 12/04/2021
   872 000012A8 E994000000          <1>         jmp     K25                     ; NUMERAL '0', STNDRD. PROCESSING
   873                              <1> K21:					; MIGHT BE NUMERIC
   874 000012AD F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT
   875 000012B0 74F4                <1> 	jz	short K20		; IS NUMERIC, STD. PROC.
   876                              <1> 	;
   877                              <1> K22:					; SHIFT TOGGLE KEY HIT; PROCESS IT
   878 000012B2 8425[9A660000]      <1> 	test	ah, [KB_FLAG_1] 	; IS KEY ALREADY DEPRESSED
   879                              <1>         ;jnz	short K26		; JUMP IF KEY ALREADY DEPRESSED
   880                              <1> 	; 12/04/2021
   881 000012B8 75C6                <1> 	jnz	short k17f ; K26
   882                              <1> K22A:
   883 000012BA 0825[9A660000]      <1>         or      [KB_FLAG_1], ah 	; INDICATE THAT THE KEY IS DEPRESSED
   884 000012C0 3025[99660000]      <1> 	xor	[KB_FLAG], ah		; TOGGLE THE SHIFT STATE
   885                              <1> 	;
   886                              <1> 	;-----	TOGGLE LED IF CAPS, NUM  OR SCROLL KEY DEPRESSED
   887 000012C6 F6C470              <1> 	test	ah, CAPS_SHIFT+NUM_SHIFT+SCROLL_SHIFT ; SHIFT TOGGLE?
   888 000012C9 7407                <1> 	jz	short K22B		; GO IF NOT
   889                              <1> 	;
   890                              <1> 	; 12/04/2021 (32 bit push/pop)
   891 000012CB 50                  <1> 	push	eax ; push ax		; SAVE SCAN CODE AND SHIFT MASK
   892 000012CC E8C7030000          <1> 	call	SND_LED			; GO TURN MODE INDICATORS ON
   893 000012D1 58                  <1> 	pop	eax ; pop ax		; RESTORE SCAN CODE
   894                              <1> K22B:
   895 000012D2 3C52                <1> 	cmp	al, INS_KEY		; TEST FOR 1ST MAKE OF INSERT KEY
   896                              <1>         ;jne	short K26		; JUMP IF NOT INSERT KEY
   897                              <1> 	; 12/04/2021
   898 000012D4 75AA                <1> 	jne	short k17f ; K26
   899 000012D6 88C4                <1> 	mov	ah, al		        ; SCAN CODE IN BOTH HALVES OF AX
   900 000012D8 E999000000          <1>         jmp	K28                     ; FLAGS UPDATED, PROC. FOR BUFFER
   901                              <1> 	;
   902                              <1> 	;-----	BREAK SHIFT FOUND
   903                              <1> K23:					; BREAK-SHIFT-FOUND
   904 000012DD 80FC10              <1> 	cmp	ah, SCROLL_SHIFT	; IS THIS A TOGGLE KEY
   905 000012E0 F6D4                <1> 	not	ah			; INVERT MASK
   906 000012E2 7355                <1> 	jae	short K24		; YES, HANDLE BREAK TOGGLE
   907 000012E4 2025[99660000]      <1> 	and	[KB_FLAG], ah		; TURN OFF SHIFT BIT
   908 000012EA 80FCFB              <1> 	cmp	ah, ~CTL_SHIFT		; IS THIS ALT OR CTL?
   909 000012ED 7730                <1> 	ja	short K23D		; NO, ALL DONE
   910                              <1> 	;
   911 000012EF F6C702              <1> 	test	bh, LC_E0		; 2ND ALT OR CTL?
   912 000012F2 7408                <1> 	jz	short K23A		; NO, HANSLE NORMALLY
   913 000012F4 2025[9C660000]      <1> 	and 	[KB_FLAG_3], ah		; RESET BIT FOR RIGHT ALT OR CTL
   914 000012FA EB08                <1> 	jmp	short K23B		; CONTINUE
   915                              <1> K23A:
   916 000012FC D2FC                <1> 	sar	ah, cl			; MOVE THE MASK BIT TWO POSITIONS
   917 000012FE 2025[9A660000]      <1> 	and	[KB_FLAG_1], ah		; RESET BIT FOR LEFT ALT AND CTL
   918                              <1> K23B:
   919 00001304 88C4                <1> 	mov	ah, al			; SAVE SCAN CODE
   920 00001306 A0[9C660000]        <1> 	mov	al, [KB_FLAG_3]		; GET RIGHT ALT & CTRL FLAGS
   921 0000130B D2E8                <1> 	shr	al, cl			; MOVE TO BITS 1 & 0
   922 0000130D 0A05[9A660000]      <1> 	or	al, [KB_FLAG_1]		; PUT IN LEFT ALT & CTL FLAGS
   923 00001313 D2E0                <1> 	shl	al, cl			; MOVE BACK TO BITS 3 & 2
   924 00001315 240C                <1> 	and	al, ALT_SHIFT+CTL_SHIFT ; FILTER OUT OTHER GARBAGE
   925 00001317 0805[99660000]      <1> 	or	[KB_FLAG], al		; PUT RESULT IN THE REAL FLAGS	
   926 0000131D 88E0                <1> 	mov	al, ah
   927                              <1> K23D:
   928 0000131F 3CB8                <1> 	cmp	al, ALT_KEY+80h		; IS THIS ALTERNATE SHIFT RELEASE
   929 00001321 7536                <1> 	jne	short K26		; INTERRUPT RETURN
   930                              <1> 	;	
   931                              <1> 	;-----	ALTERNATE SHIFT KEY RELEASED, GET THE VALUE INTO BUFFER
   932 00001323 A0[9D660000]        <1> 	mov	al, [ALT_INPUT]
   933 00001328 B400                <1> 	mov	ah, 0			; SCAN CODE OF 0
   934 0000132A 8825[9D660000]      <1> 	mov	[ALT_INPUT], ah 	; ZERO OUT THE FIELD
   935 00001330 3C00                <1> 	cmp	al, 0			; WAS THE INPUT = 0?
   936 00001332 7425                <1> 	je	short K26		; INTERRUPT_RETURN
   937                              <1>         ; 29/01/2016
   938                              <1> 	;jmp	K61			; IT WASN'T, SO PUT IN BUFFER
   939 00001334 E9AB020000          <1> 	jmp	_K60
   940                              <1> 	;
   941                              <1> K24:					; BREAK-TOGGLE
   942 00001339 2025[9A660000]      <1> 	and	[KB_FLAG_1], ah 	; INDICATE NO LONGER DEPRESSED
   943 0000133F EB18                <1> 	jmp	short K26		; INTERRUPT_RETURN
   944                              <1> 	;
   945                              <1> 	;-----	TEST FOR HOLD STATE
   946                              <1> 					; AL, AH = SCAN CODE
   947                              <1> K25:					; NO-SHIFT-FOUND
   948 00001341 3C80                <1> 	cmp	al, 80h			; TEST FOR BREAK KEY
   949 00001343 7314                <1> 	jae	short K26		; NOTHING FOR BREAK CHARS FROM HERE ON
   950 00001345 F605[9A660000]08    <1> 	test	byte [KB_FLAG_1], HOLD_STATE ; ARE WE IN HOLD STATE
   951 0000134C 7428                <1> 	jz	short K28		; BRANCH AROUND TEST IF NOT
   952 0000134E 3C45                <1> 	cmp	al, NUM_KEY
   953 00001350 7407                <1> 	je	short K26		; CAN'T END HOLD ON NUM_LOCK
   954 00001352 8025[9A660000]F7    <1> 	and	byte [KB_FLAG_1], ~HOLD_STATE ; TURN OFF THE HOLD STATE BIT
   955                              <1> K26:
   956 00001359 8025[9C660000]FC    <1> 	and	byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG
   957                              <1> K26A:					; INTERRUPT-RETURN
   958 00001360 FA                  <1> 	cli				; TURN OFF INTERRUPTS
   959 00001361 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
   960 00001363 E620                <1> 	out	20h, al	;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
   961                              <1> K27:					; INTERRUPT-RETURN-NO-EOI
   962 00001365 B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
   963 00001367 E8D1020000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
   964                              <1> K27A:
   965 0000136C FA                  <1> 	cli				; DISABLE INTERRUPTS
   966                              <1> 	;;mov	byte [intflg], 0 ; 07/01/2017 ;; 15/01/2017
   967 0000136D 07                  <1> 	pop	es			; RESTORE REGISTERS
   968 0000136E 1F                  <1> 	pop	ds
   969 0000136F 5F                  <1> 	pop	edi
   970 00001370 5E                  <1> 	pop	esi
   971 00001371 5A                  <1> 	pop	edx
   972 00001372 59                  <1> 	pop	ecx
   973 00001373 5B                  <1> 	pop	ebx
   974 00001374 58                  <1> 	pop	eax
   975                              <1> 	;pop	ebp
   976 00001375 CF                  <1> 	iretd				; RETURN
   977                              <1> 
   978                              <1> 	;-----	NOT IN	HOLD STATE
   979                              <1> K28:					; NO-HOLD-STATE
   980 00001376 3C58                <1> 	cmp	al, 88			; TEST FOR OUT-OF-RANGE SCAN CODES
   981 00001378 77DF                <1> 	ja	short K26		; IGNORE IF OUT-OF-RANGE	
   982                              <1> 	;
   983 0000137A F6C308              <1> 	test	bl, ALT_SHIFT 		; ARE WE IN ALTERNATE SHIFT
   984 0000137D 740E                <1>         jz	short K28A		; IF NOT ALTERNATE
   985                              <1>         ; 12/04/2021
   986                              <1> 	;jz	K38
   987                              <1> 	;
   988 0000137F F6C710              <1> 	test	bh, KBX			; IS THIS THE ENCHANCED KEYBOARD?
   989 00001382 740E                <1> 	jz	short K29		; NO, ALT STATE IS REAL
   990                              <1> 	 ;28/02/2015
   991 00001384 F605[9A660000]04    <1> 	test	byte [KB_FLAG_1], SYS_SHIFT ; YES, IS SYSREQ KEY DOWN?
   992 0000138B 7405                <1> 	jz	short K29		;  NO, ALT STATE IS REAL
   993                              <1> 	; 12/04/2021
   994                              <1> 	;jnz	K38			; YES, THIS IS PHONY ALT STATE 
   995                              <1>         ;				; DUE TO PRESSING SYSREQ	
   996 0000138D E9C4000000          <1> K28A:	jmp	K38
   997                              <1> 	;
   998                              <1> 	;-----	TEST FOR RESET KEY SEQUENCE (CTL ALT DEL)
   999                              <1> K29:					; TEST-RESET
  1000 00001392 F6C304              <1> 	test	bl, CTL_SHIFT 		; ARE WE IN CONTROL SHIFT ALSO?
  1001 00001395 740B                <1> 	jz	short K31		; NO_RESET
  1002 00001397 3C53                <1> 	cmp	al, DEL_KEY		; CTL-ALT STATE, TEST FOR DELETE KEY
  1003 00001399 7507                <1> 	jne	short K31		; NO_RESET, IGNORE
  1004                              <1> 	;
  1005                              <1> 	;-----	CTL-ALT-DEL HAS BEEN FOUND
  1006                              <1>  	; 26/08/2014
  1007                              <1> cpu_reset:
  1008                              <1> 	; IBM PC/AT ROM BIOS source code - 10/06/85 (TEST4.ASM - PROC_SHUTDOWN)
  1009                              <1> 	; Send FEh (system reset command) to the keyboard controller.
  1010 0000139B B0FE                <1> 	mov	al, SHUT_CMD		; SHUTDOWN COMMAND
  1011 0000139D E664                <1> 	out	STATUS_PORT, al		; SEND TO KEYBOARD CONTROL PORT
  1012                              <1> khere:
  1013 0000139F F4                  <1> 	hlt				; WAIT FOR 80286 RESET
  1014 000013A0 EBFD                <1> 	jmp 	short khere		; INSURE HALT
  1015                              <1> 	;
  1016                              <1> 	;-----	IN ALTERNATE SHIFT, RESET NOT FOUND
  1017                              <1> K31:					; NO-RESET
  1018 000013A2 3C39                <1> 	cmp	al, 57			; TEST FOR SPACE KEY
  1019 000013A4 7507                <1> 	jne	short K311		; NOT THERE
  1020 000013A6 B020                <1> 	mov	al, ' '			; SET SPACE CHAR
  1021                              <1> k31a:	; 12/04/2021
  1022 000013A8 E929020000          <1>         jmp     K57                     ; BUFFER_FILL
  1023                              <1> K311:
  1024 000013AD 3C0F                <1> 	cmp	al, 15			; TEST FOR TAB KEY
  1025 000013AF 7506                <1> 	jne	short K312		; NOT THERE
  1026 000013B1 66B800A5            <1> 	mov	ax, 0A500h		; SET SPECIAL CODE FOR ALT-TAB
  1027                              <1>         ;jmp	K57			; BUFFER_FILL
  1028                              <1> 	; 12/04/2021
  1029 000013B5 EBF1                <1> 	jmp	short k31a
  1030                              <1> K312:
  1031 000013B7 3C4A                <1> 	cmp	al, 74			; TEST FOR KEY PAD -
  1032                              <1>         ;je	short K37B		; GO PROCESS
  1033                              <1> 	; 12/04/2021
  1034 000013B9 7404                <1> 	je	short k312a
  1035 000013BB 3C4E                <1> 	cmp	al, 78			; TEST FOR KEY PAD +
  1036                              <1>         ;je	short K37B		; GO PROCESS
  1037                              <1> 	; 12/04/2021
  1038 000013BD 7505                <1> 	jne	short K32
  1039                              <1> k312a:
  1040 000013BF E988000000          <1> 	jmp	K37B	
  1041                              <1> 	;
  1042                              <1> 	;-----	LOOK FOR KEY PAD ENTRY
  1043                              <1> K32:					; ALT-KEY-PAD
  1044 000013C4 BF[5C650000]        <1> 	mov	edi, K30		; ALT-INPUT-TABLE offset
  1045 000013C9 B90A000000          <1> 	mov	ecx, 10			; LOOK FOR ENTRY USING KEYPAD
  1046 000013CE F2AE                <1> 	repne	scasb			; LOOK FOR MATCH
  1047 000013D0 7521                <1> 	jne	short K33		; NO_ALT_KEYPAD
  1048 000013D2 F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OF THE NEW KEYS?
  1049 000013D5 7579                <1>         jnz	short K37C		; YES, JUMP, NOT NUMPAD KEY
  1050 000013D7 81EF[5D650000]      <1> 	sub	edi, K30+1		; DI NOW HAS ENTRY VALUE
  1051 000013DD A0[9D660000]        <1> 	mov	al, [ALT_INPUT] 	; GET THE CURRENT BYTE
  1052 000013E2 B40A                <1> 	mov	ah, 10			; MULTIPLY BY 10
  1053 000013E4 F6E4                <1> 	mul	ah
  1054 000013E6 6601F8              <1> 	add	ax, di			; ADD IN THE LATEST ENTRY
  1055 000013E9 A2[9D660000]        <1> 	mov	[ALT_INPUT], al 	; STORE IT AWAY
  1056                              <1> K32A:
  1057 000013EE E966FFFFFF          <1>         jmp     K26                     ; THROW AWAY THAT KEYSTROKE
  1058                              <1> 	;
  1059                              <1> 	;-----	LOOK FOR SUPERSHIFT ENTRY
  1060                              <1> K33:					; NO-ALT-KEYPAD
  1061 000013F3 C605[9D660000]00    <1>         mov     byte [ALT_INPUT], 0     ; ZERO ANY PREVIOUS ENTRY INTO INPUT
  1062 000013FA B91A000000          <1> 	mov	ecx, 26			; (DI),(ES) ALREADY POINTING
  1063 000013FF F2AE                <1> 	repne	scasb			; LOOK FOR MATCH IN ALPHABET
  1064 00001401 7445                <1> 	je	short K37A		; MATCH FOUND, GO FILLL THE BUFFER
  1065                              <1> 	;
  1066                              <1> 	;-----	LOOK FOR TOP ROW OF ALTERNATE SHIFT
  1067                              <1> K34:					; ALT-TOP-ROW
  1068 00001403 3C02                <1> 	cmp	al, 2			; KEY WITH '1' ON IT
  1069 00001405 7245                <1> 	jb	short K37B		; MUST BE ESCAPE
  1070 00001407 3C0D                <1> 	cmp	al, 13			; IS IT IN THE REGION
  1071 00001409 7705                <1> 	ja	short K35		; NO, ALT SOMETHING ELSE
  1072 0000140B 80C476              <1> 	add	ah, 118			; CONVERT PSEUDO SCAN CODE TO RANGE
  1073 0000140E EB38                <1> 	jmp	short K37A		; GO FILL THE BUFFER
  1074                              <1> 	;
  1075                              <1> 	;-----	TRANSLATE ALTERNATE SHIFT PSEUDO SCAN CODES
  1076                              <1> K35:					; ALT-FUNCTION
  1077 00001410 3C57                <1> 	cmp	al, F11_M		; IS IT F11?	
  1078 00001412 7209                <1> 	jb	short K35A ; 20/02/2015	; NO, BRANCH
  1079 00001414 3C58                <1> 	cmp	al, F12_M		; IS IT F12?
  1080 00001416 7705                <1> 	ja	short K35A ; 20/02/2015	; NO, BRANCH
  1081 00001418 80C434              <1> 	add	ah, 52			; CONVERT TO PSEUDO SCAN CODE
  1082 0000141B EB2B                <1> 	jmp	short K37A		; GO FILL THE BUFFER
  1083                              <1> K35A:
  1084 0000141D F6C702              <1> 	test	bh, LC_E0		; DO WE HAVE ONE OF THE NEW KEYS?
  1085 00001420 741B                <1> 	jz	short K37		; NO, JUMP
  1086 00001422 3C1C                <1> 	cmp	al, 28			; TEST FOR KEYPAD ENTER
  1087 00001424 7506                <1>         jne     short K35B              ; NOT THERE
  1088 00001426 66B800A6            <1> 	mov	ax, 0A600h		; SPECIAL CODE
  1089                              <1> 	;jmp	K57			; BUFFER FILL
  1090                              <1> 	; 12/04/2021
  1091 0000142A EB0C                <1> 	jmp	short k35c
  1092                              <1> K35B:
  1093 0000142C 3C53                <1> 	cmp	al, 83			; TEST FOR DELETE KEY
  1094 0000142E 7420                <1> 	je	short K37C		; HANDLE WITH OTHER EDIT KEYS
  1095 00001430 3C35                <1> 	cmp	al, 53			; TEST FOR KEYPAD /
  1096 00001432 75BA                <1> 	jne	short K32A		; NOT THERE, NO OTHER E0 SPECIALS
  1097                              <1>         ; 12/04/2021
  1098                              <1> 	;jne	K26
  1099 00001434 66B800A4            <1> 	mov	ax, 0A400h		; SPECIAL CODE1
  1100                              <1> k35c:	; 12/04/2021
  1101 00001438 E999010000          <1> 	jmp	K57			; BUFFER FILL
  1102                              <1> K37:
  1103 0000143D 3C3B                <1> 	cmp	al, 59			; TEST FOR FUNCTION KEYS (F1)
  1104 0000143F 720B                <1>         jb      short K37B		; NO FN, HANDLE W/OTHER EXTENDED
  1105 00001441 3C44                <1> 	cmp	al, 68			; IN KEYPAD REGION?
  1106 00001443 77A9                <1> 	ja	short K32A		; IF SO, IGNORE
  1107                              <1> 	; 12/04/2021
  1108                              <1> 	;ja	K26
  1109 00001445 80C42D              <1> 	add	ah, 45			; CONVERT TO PSEUDO SCAN CODE
  1110                              <1> K37A:
  1111 00001448 B000                <1> 	mov	al, 0			; ASCII CODE OF ZERO
  1112                              <1> 	;jmp	K57			; PUT IT IN THE BUFFER
  1113                              <1> 	; 12/04/2021
  1114 0000144A EBEC                <1> 	jmp	short k35c
  1115                              <1> K37B:
  1116 0000144C B0F0                <1> 	mov	al, 0F0h		; USE SPECIAL ASCII CODE
  1117                              <1> 	;jmp	K57			; PUT IT IN THE BUFFER
  1118                              <1> 	; 12/04/2021
  1119 0000144E EBE8                <1> 	jmp	short k35c
  1120                              <1> K37C:
  1121 00001450 0450                <1> 	add	al, 80			; CONVERT SCAN CODE (EDIT KEYS)
  1122 00001452 88C4                <1> 	mov	ah, al			; (SCAN CODE NOT IN AH FOR INSERT)
  1123 00001454 EBF2                <1> 	jmp     short K37A              ; PUT IT IN THE BUFFER
  1124                              <1> 	;
  1125                              <1> 	;-----	NOT IN ALTERNATE SHIFT
  1126                              <1> K38:					; NOT-ALT-SHIFT
  1127                              <1> 					; BL STILL HAS SHIFT FLAGS
  1128 00001456 F6C304              <1> 	test	bl, CTL_SHIFT 		; ARE WE IN CONTROL SHIFT?
  1129                              <1> 	;;jnz	short K38A		; YES, START PROCESSING	
  1130                              <1>         ;jz	K44			; NOT-CTL-SHIFT
  1131                              <1> 	; 12/04/2021
  1132 00001459 7505                <1> 	jnz	short K38A		; YES, START PROCESSING	
  1133 0000145B E9AB000000          <1> 	jmp	K44			; NOT-CTL-SHIFT
  1134                              <1> 	;
  1135                              <1> 	;-----	CONTROL SHIFT, TEST SPECIAL CHARACTERS
  1136                              <1> 	;-----	TEST FOR BREAK
  1137                              <1> K38A:
  1138 00001460 3C46                <1> 	cmp	al, SCROLL_KEY		; TEST FOR BREAK
  1139 00001462 7530                <1> 	jne	short K39		; JUMP, NO-BREAK
  1140 00001464 F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  1141 00001467 7405                <1> 	jz	short K38B		; NO, BREAK IS VALID	
  1142 00001469 F6C702              <1> 	test	bh, LC_E0		; YES, WAS LAST CODE AN E0?
  1143 0000146C 7426                <1> 	jz	short K39		; NO-BREAK, TEST FOR PAUSE	
  1144                              <1> K38B:
  1145 0000146E 8B1D[A6660000]      <1> 	mov	ebx, [BUFFER_HEAD] 	; RESET BUFFER TO EMPTY
  1146 00001474 891D[AA660000]      <1> 	mov	[BUFFER_TAIL], ebx
  1147 0000147A C605[98660000]80    <1> 	mov	byte [BIOS_BREAK], 80h  ; TURN ON BIOS_BREAK BIT
  1148                              <1> 	;
  1149                              <1> 	;-----	ENABLE KEYBOARD
  1150 00001481 B0AE                <1> 	mov	al, ENA_KBD		; ENABLE KEYBOARD
  1151 00001483 E8B5010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  1152                              <1> 	;
  1153                              <1> 	; CTRL+BREAK code here !!!
  1154                              <1> 	;INT	1BH			; BREAK INTERRUPT VECTOR
  1155                              <1> 	; 17/10/2015	
  1156 00001488 E851580000          <1> 	call	ctrlbrk ; control+break subroutine
  1157                              <1> 	;
  1158                              <1> 	;sub	ax, ax			; PUT OUT DUMMY CHARACTER
  1159                              <1>         ; 12/04/2021
  1160 0000148D 29C0                <1> 	sub	eax, eax
  1161 0000148F E942010000          <1>         jmp     K57                     ; BUFFER_FILL
  1162                              <1> 	;
  1163                              <1> 	;-----	TEST FOR PAUSE
  1164                              <1> K39:					; NO_BREAK
  1165 00001494 F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  1166 00001497 7537                <1> 	jnz	short K41		; YES, THEN THIS CAN'T BE PAUSE	
  1167 00001499 3C45                <1> 	cmp	al, NUM_KEY		; LOOK FOR PAUSE KEY
  1168 0000149B 7533                <1> 	jne	short K41		; NO-PAUSE
  1169                              <1> K39P:
  1170 0000149D 800D[9A660000]08    <1> 	or	byte [KB_FLAG_1], HOLD_STATE ; TURN ON THE HOLD FLAG
  1171                              <1> 	;
  1172                              <1> 	;-----	ENABLE KEYBOARD
  1173 000014A4 B0AE                <1> 	mov	al, ENA_KBD		; ENABLE KEYBOARD
  1174 000014A6 E892010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  1175                              <1> K39A:
  1176 000014AB B020                <1> 	mov	al, EOI			; END OF INTERRUPT TO CONTROL PORT
  1177 000014AD E620                <1> 	out	20h, al ;out INTA00, al	; ALLOW FURTHER KEYSTROKE INTERRUPTS
  1178                              <1> 	;
  1179                              <1> 	;-----	DURING PAUSE INTERVAL, TURN COLOR CRT BACK ON
  1180 000014AF 803D[CE660000]07    <1>         cmp     byte [CRT_MODE], 7      ; IS THIS BLACK AND WHITE CARD
  1181 000014B6 740A                <1>         je      short K40              	; YES, NOTHING TO DO
  1182 000014B8 66BAD803            <1> 	mov	dx, 03D8h		; PORT FOR COLOR CARD
  1183 000014BC A0[CF660000]        <1>         mov     al, [CRT_MODE_SET] 	; GET THE VALUE OF THE CURRENT MODE
  1184 000014C1 EE                  <1> 	out	dx, al			; SET THE CRT MODE, SO THAT CRT IS ON
  1185                              <1> 	;
  1186                              <1> K40:					; PAUSE-LOOP
  1187 000014C2 F605[9A660000]08    <1>         test    byte [KB_FLAG_1], HOLD_STATE ; CHECK HOLD STATE FLAG
  1188 000014C9 75F7                <1> 	jnz	short K40		; LOOP UNTIL FLAG TURNED OFF
  1189                              <1> 	;
  1190 000014CB E995FEFFFF          <1>         jmp     K27                     ; INTERRUPT_RETURN_NO_EOI
  1191                              <1>         ;
  1192                              <1> 	;-----	TEST SPECIAL CASE KEY 55
  1193                              <1> K41:					; NO-PAUSE
  1194 000014D0 3C37                <1> 	cmp	al, 55			; TEST FOR */PRTSC KEY
  1195 000014D2 7513                <1> 	jne	short K42		; NOT-KEY-55
  1196 000014D4 F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  1197 000014D7 7405                <1> 	jz	short K41A		; NO, CTL-PRTSC IS VALID	
  1198 000014D9 F6C702              <1> 	test	bh, LC_E0		; YES, WAS LAST CODE AN E0?
  1199 000014DC 7421                <1> 	jz	short K42B		; NO, TRANSLATE TO A FUNCTION
  1200                              <1> K41A:	
  1201 000014DE 66B80072            <1> 	mov	ax, 114*256		; START/STOP PRINTING SWITCH
  1202 000014E2 E9EF000000          <1>         jmp     K57                     ; BUFFER_FILL
  1203                              <1> 	;
  1204                              <1> 	;-----	SET UP TO TRANSLATE CONTROL SHIFT
  1205                              <1> K42:					; NOT-KEY-55
  1206 000014E7 3C0F                <1> 	cmp	al, 15			; IS IT THE TAB KEY?
  1207 000014E9 7414                <1> 	je	short K42B		; YES, XLATE TO FUNCTION CODE
  1208 000014EB 3C35                <1> 	cmp	al, 53			; IS IT THE / KEY?
  1209 000014ED 750E                <1> 	jne	short K42A		; NO, NO MORE SPECIAL CASES	
  1210 000014EF F6C702              <1> 	test	bh, LC_E0		; YES, IS IT FROM THE KEY PAD?
  1211 000014F2 7409                <1> 	jz	short K42A		; NO, JUST TRANSLATE
  1212 000014F4 66B80095            <1> 	mov	ax, 9500h		; YES, SPECIAL CODE FOR THIS ONE
  1213 000014F8 E9D9000000          <1> 	jmp	K57			; BUFFER FILL	
  1214                              <1> K42A: 
  1215                              <1> 	;;mov	ebx, _K8		; SET UP TO TRANSLATE CTL
  1216 000014FD 3C3B                <1> 	cmp	al, 59			; IS IT IN CHARACTER TABLE?
  1217                              <1>         ;jb	short K45F              ; YES, GO TRANSLATE CHAR
  1218                              <1> 	;;jb	K56 ; 20/02/2015
  1219                              <1> 	;;jmp	K64 ; 20/02/2015
  1220                              <1> K42B:
  1221 000014FF BB[90650000]        <1> 	mov	ebx, _K8		; SET UP TO TRANSLATE CTL
  1222                              <1> 	;jb	K56 ;; 20/02/2015
  1223                              <1> 	; 12/04/2021
  1224 00001504 7267                <1> 	jb	short K45F	
  1225 00001506 E9B9000000          <1> 	jmp	K64	
  1226                              <1>         ;
  1227                              <1> 	;-----	NOT IN CONTROL SHIFT
  1228                              <1> K44:					; NOT-CTL-SHIFT
  1229 0000150B 3C37                <1> 	cmp	al, 55			; PRINT SCREEN KEY?
  1230 0000150D 7528                <1> 	jne	short K45		; NOT PRINT SCREEN
  1231 0000150F F6C710              <1> 	test	bh, KBX			; IS THIS ENHANCED KEYBOARD?
  1232 00001512 7407                <1> 	jz	short K44A		; NO, TEST FOR SHIFT STATE	
  1233 00001514 F6C702              <1> 	test	bh, LC_E0		; YES, LAST CODE A MARKER?
  1234 00001517 7507                <1> 	jnz	short K44B		; YES, IS PRINT SCREEN
  1235 00001519 EB41                <1> 	jmp	short K45C		; NO, TRANSLATE TO '*' CHARACTER
  1236                              <1> K44A:
  1237 0000151B F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; NOT 101 KBD, SHIFT KEY DOWN?
  1238 0000151E 743C                <1> 	jz	short K45C		; NO, TRANSLATE TO '*' CHARACTER
  1239                              <1> 	;
  1240                              <1> 	;-----	ISSUE INTERRUPT TO INDICATE PRINT SCREEN FUNCTION
  1241                              <1> K44B:
  1242 00001520 B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  1243 00001522 E816010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  1244 00001527 B020                <1> 	mov	al, EOI			; END OF CURRENT INTERRUPT
  1245 00001529 E620                <1> 	out	20h, al ;out INTA00, al	; SO FURTHER THINGS CAN HAPPEN
  1246                              <1> 	; Print Screen !!!		; ISSUE PRINT SCREEN INTERRUPT (INT 05h)
  1247                              <1> 	;PUSH 	BP			; SAVE POINTER
  1248                              <1> 	;INT 	5H			; ISSUE PRINT SCREEN INTERRUPT
  1249                              <1> 	;POP	BP			; RESTORE POINTER
  1250 0000152B 8025[9C660000]FC    <1>         and     byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; ZERO OUT THESE FLAGS
  1251 00001532 E92EFEFFFF          <1>         jmp     K27                     ; GO BACK WITHOUT EOI OCCURRING
  1252                              <1> 	;
  1253                              <1> 	;-----	HANDLE IN-CORE KEYS
  1254                              <1> K45:					; NOT-PRINT-SCREEN
  1255 00001537 3C3A                <1> 	cmp	al, 58			; TEST FOR IN-CORE AREA
  1256 00001539 7734                <1> 	ja	short K46		; JUMP IF NOT
  1257 0000153B 3C35                <1> 	cmp	al, 53			; IS THIS THE '/' KEY?
  1258 0000153D 7505                <1> 	jne	short K45A		; NO, JUMP
  1259 0000153F F6C702              <1> 	test	bh, LC_E0		; WAS THE LAST CODE THE MARKER?
  1260 00001542 7518                <1> 	jnz	short K45C		; YES, TRANSLATE TO CHARACTER
  1261                              <1> K45A:
  1262 00001544 B91A000000          <1> 	mov	ecx, 26			; LENGHT OF SEARCH
  1263 00001549 BF[66650000]        <1> 	mov	edi, K30+10		; POINT TO TABLE OF A-Z CHARS
  1264 0000154E F2AE                <1> 	repne	scasb			; IS THIS A LETTER KEY?
  1265                              <1> 		; 20/02/2015
  1266 00001550 7505                <1> 	jne	short K45B              ; NO, SYMBOL KEY
  1267                              <1> 	;
  1268 00001552 F6C340              <1> 	test	bl, CAPS_STATE		; ARE WE IN CAPS_LOCK?
  1269 00001555 750C                <1> 	jnz	short K45D		; TEST FOR SURE
  1270                              <1> K45B:
  1271 00001557 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE?
  1272 0000155A 750C                <1> 	jnz	short K45E		; YES, UPPERCASE
  1273                              <1> 					; NO, LOWERCASE
  1274                              <1> K45C:
  1275 0000155C BB[E8650000]        <1> 	mov	ebx, K10		; TRANSLATE TO LOWERCASE LETTERS
  1276 00001561 EB51                <1> 	jmp	short K56	
  1277                              <1> K45D:					; ALMOST-CAPS-STATE
  1278 00001563 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; CL ON. IS SHIFT ON, TOO?
  1279 00001566 75F4                <1> 	jnz	short K45C		; SHIFTED TEMP OUT OF CAPS STATE
  1280                              <1> K45E:
  1281 00001568 BB[40660000]        <1> 	mov	ebx, K11		; TRANSLATE TO UPPER CASE LETTERS
  1282 0000156D EB45                <1> K45F:	jmp	short K56
  1283                              <1> 	;
  1284                              <1> 	;-----	TEST FOR KEYS F1 - F10
  1285                              <1> K46:					; NOT IN-CORE AREA
  1286 0000156F 3C44                <1> 	cmp	al, 68			; TEST FOR F1 - F10
  1287                              <1> 	;ja	short K47		; JUMP IF NOT
  1288                              <1> 	;jmp	short K53		; YES, GO DO FN KEY PROCESS			
  1289 00001571 7635                <1> 	jna	short K53		
  1290                              <1> 	;
  1291                              <1> 	;-----	HANDLE THE NUMERIC PAD KEYS
  1292                              <1> K47:					; NOT F1 - F10
  1293 00001573 3C53                <1> 	cmp	al, 83			; TEST NUMPAD KEYS
  1294 00001575 772D                <1> 	ja	short K52		; JUMP IF NOT
  1295                              <1> 	;
  1296                              <1> 	;-----	KEYPAD KEYS, MUST TEST NUM LOCK FOR DETERMINATION
  1297                              <1> K48:
  1298 00001577 3C4A                <1> 	cmp	al, 74			; SPECIAL CASE FOR MINUS
  1299 00001579 74ED                <1> 	je	short K45E		; GO TRANSLATE
  1300 0000157B 3C4E                <1> 	cmp	al, 78			; SPECIAL CASE FOR PLUS
  1301 0000157D 74E9                <1> 	je	short K45E		; GO TRANSLATE
  1302 0000157F F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OFTHE NEW KEYS?
  1303 00001582 750A                <1> 	jnz	short K49		; YES, TRANSLATE TO BASE STATE
  1304                              <1> 	;		
  1305 00001584 F6C320              <1> 	test 	bl, NUM_STATE		; ARE WE IN NUM LOCK
  1306 00001587 7514                <1> 	jnz	short K50		; TEST FOR SURE
  1307 00001589 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE?
  1308                              <1> 	;jnz	short K51		; IF SHIFTED, REALLY NUM STATE
  1309 0000158C 75DA                <1> 	jnz	short K45E
  1310                              <1> 	;
  1311                              <1> 	;-----	BASE CASE FOR KEYPAD
  1312                              <1> K49:					
  1313 0000158E 3C4C                <1> 	cmp	al, 76			; SPECIAL CASE FOR BASE STATE 5
  1314 00001590 7504                <1> 	jne	short K49A		; CONTINUE IF NOT KEYPAD 5
  1315 00001592 B0F0                <1> 	mov	al, 0F0h		; SPECIAL ASCII CODE	
  1316 00001594 EB40                <1> 	jmp	short K57		; BUFFER FILL
  1317                              <1> K49A:
  1318 00001596 BB[E8650000]        <1> 	mov	ebx, K10		; BASE CASE TABLE	
  1319 0000159B EB27                <1> 	jmp	short K64		; CONVERT TO PSEUDO SCAN
  1320                              <1> 	;
  1321                              <1> 	;-----	MIGHT BE NUM LOCK, TEST SHIFT STATUS
  1322                              <1> K50:					; ALMOST-NUM-STATE
  1323 0000159D F6C303              <1>         test    bl, LEFT_SHIFT+RIGHT_SHIFT
  1324 000015A0 75EC                <1> 	jnz 	short K49		; SHIFTED TEMP OUT OF NUM STATE
  1325 000015A2 EBC4                <1> K51:	jmp	short K45E		; REALLY NUM STATE
  1326                              <1> 	;
  1327                              <1> 	;-----	TEST FOR THE NEW KEYS ON WT KEYBOARDS 
  1328                              <1> K52:					; NOT A NUMPAD KEY
  1329 000015A4 3C56                <1> 	cmp	al, 86			; IS IT THE NEW WT KEY?
  1330                              <1> 	;jne	short K53		; JUMP IF NOT
  1331                              <1> 	;jmp	short K45B		; HANDLE WITH REST OF LETTER KEYS
  1332 000015A6 74AF                <1> 	je	short K45B		
  1333                              <1> 	;
  1334                              <1> 	;-----	MUST BE F11 OR F12 
  1335                              <1> K53:					; F1 - F10 COME HERE, TOO
  1336 000015A8 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST SHIFT STATE
  1337 000015AB 74E1                <1> 	jz	short K49		; JUMP, LOWER CASE PSEUDO SC'S
  1338                              <1> 		; 20/02/2015 
  1339 000015AD BB[40660000]        <1> 	mov	ebx, K11		; UPPER CASE PSEUDO SCAN CODES
  1340 000015B2 EB10                <1> 	jmp	short K64		; TRANSLATE SCAN
  1341                              <1> 	;
  1342                              <1> 	;-----	TRANSLATE THE CHARACTER
  1343                              <1> K56:					; TRANSLATE-CHAR
  1344 000015B4 FEC8                <1> 	dec	al			; CONVERT ORIGIN
  1345 000015B6 D7                  <1> 	xlat    			; CONVERT THE SCAN CODE TO ASCII
  1346 000015B7 F605[9C660000]02    <1> 	test	byte [KB_FLAG_3], LC_E0	; IS THIS A NEW KEY?
  1347 000015BE 7416                <1> 	jz	short K57		; NO, GO FILL BUFFER
  1348 000015C0 B4E0                <1> 	mov	ah, MC_E0		; YES, PUT SPECIAL MARKER IN AH
  1349 000015C2 EB12                <1> 	jmp	short K57		; PUT IT INTO THE BUFFER	
  1350                              <1> 	;
  1351                              <1> 	;-----	TRANSLATE SCAN FOR PSEUDO SCAN CODES
  1352                              <1> K64:					; TRANSLATE-SCAN-ORGD
  1353 000015C4 FEC8                <1> 	dec	al			; CONVERT ORIGIN
  1354 000015C6 D7                  <1>        	xlat    	                ; CTL TABLE SCAN
  1355 000015C7 88C4                <1> 	mov	ah, al			; PUT VALUE INTO AH
  1356 000015C9 B000                <1> 	mov	al, 0			; ZERO ASCII CODE
  1357 000015CB F605[9C660000]02    <1> 	test	byte [KB_FLAG_3], LC_E0	; IS THIS A NEW KEY?
  1358 000015D2 7402                <1> 	jz	short K57		; NO, GO FILL BUFFER
  1359 000015D4 B0E0                <1> 	mov	al, MC_E0		; YES, PUT SPECIAL MARKER IN AL
  1360                              <1> 	;
  1361                              <1> 	;-----	PUT CHARACTER INTO BUFFER
  1362                              <1> K57:					; BUFFER_FILL
  1363 000015D6 3CFF                <1> 	cmp	al, -1			; IS THIS AN IGNORE CHAR
  1364 000015D8 7405                <1> 	je	short K59		; YES, DO NOTHING WITH IT
  1365                              <1> 	;je	K26			; YES, DO NOTHING WITH IT
  1366 000015DA 80FCFF              <1> 	cmp	ah, -1			; LOOK FOR -1 PSEUDO SCAN
  1367                              <1>         ;;jne	short K61		; NEAR_INTERRUPT_RETURN
  1368                              <1> 	;je	K26			; INTERRUPT_RETURN
  1369                              <1> 	; 12/04/2021
  1370 000015DD 7505                <1>         jne	short _K60		; NEAR_INTERRUPT_RETURN
  1371                              <1> K59:					; NEAR_INTERRUPT_RETURN
  1372 000015DF E975FDFFFF          <1> 	jmp	K26			; INTERRUPT_RETURN
  1373                              <1> 
  1374                              <1> _K60: ; 29/01/2016
  1375 000015E4 80FC68              <1> 	cmp	ah, 68h	; ALT + F1 key
  1376 000015E7 721D                <1> 	jb	short K61
  1377 000015E9 80FC6F              <1> 	cmp	ah, 6Fh ; ALT + F8 key	
  1378 000015EC 7718                <1> 	ja	short K61
  1379                              <1> 	;
  1380 000015EE 8A1D[B6770100]      <1> 	mov	bl, [ACTIVE_PAGE]
  1381 000015F4 80C368              <1> 	add	bl, 68h
  1382 000015F7 38E3                <1> 	cmp	bl, ah
  1383 000015F9 740B                <1> 	je	short K61
  1384                              <1> 	; 24/07/2022
  1385                              <1> 	;push	ax
  1386 000015FB 50                  <1> 	push	eax
  1387 000015FC 88E0                <1> 	mov	al, ah
  1388 000015FE 2C68                <1> 	sub	al, 68h
  1389 00001600 E827090000          <1> 	call	set_active_page
  1390 00001605 58                  <1> 	pop	eax
  1391                              <1> 	;pop	ax
  1392                              <1> K61:					; NOT-CAPS-STATE
  1393 00001606 8B1D[AA660000]      <1> 	mov	ebx, [BUFFER_TAIL] 	; GET THE END POINTER TO THE BUFFER
  1394 0000160C 89DE                <1> 	mov	esi, ebx		; SAVE THE VALUE
  1395 0000160E E8B5FAFFFF          <1> 	call	_K4			; ADVANCE THE TAIL
  1396 00001613 3B1D[A6660000]      <1> 	cmp	ebx, [BUFFER_HEAD] 	; HAS THE BUFFER WRAPPED AROUND
  1397 00001619 740E                <1> 	je	short K62		; BUFFER_FULL_BEEP
  1398 0000161B 668906              <1> 	mov	[esi], ax		; STORE THE VALUE
  1399 0000161E 891D[AA660000]      <1> 	mov	[BUFFER_TAIL], ebx 	; MOVE THE POINTER UP
  1400 00001624 E930FDFFFF          <1> 	jmp	K26
  1401                              <1> 	;;cli				; TURN OFF INTERRUPTS
  1402                              <1> 	;;mov	al, EOI			; END OF INTERRUPT COMMAND
  1403                              <1> 	;;out	INTA00, al		; SEND COMMAND TO INTERRUPT CONTROL PORT
  1404                              <1> 	;mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  1405                              <1> 	;call	SHIP_IT			; EXECUTE ENABLE
  1406                              <1> 	;mov	ax, 9102h		; MOVE IN POST CODE & TYPE
  1407                              <1> 	;int	15h			; PERFORM OTHER FUNCTION
  1408                              <1> 	;;and	byte [KB_FLAG_3],~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG
  1409                              <1> 	;jmp	K27A			; INTERRUPT_RETURN
  1410                              <1> 	;;jmp   K27                    
  1411                              <1> 	;
  1412                              <1> 	;-----	BUFFER IS FULL SOUND THE BEEPER
  1413                              <1> K62:
  1414 00001629 B020                <1> 	mov	al, EOI			; ENABLE INTERRUPT CONTROLLER CHIP
  1415 0000162B E620                <1> 	out	INTA00, al
  1416 0000162D 66B9A602            <1> 	mov	cx, 678			; DIVISOR FOR 1760 HZ
  1417 00001631 B304                <1> 	mov	bl, 4			; SHORT BEEP COUNT (1/16 + 1/64 DELAY)
  1418 00001633 E8190D0000          <1> 	call	beep			; GO TO COMMON BEEP HANDLER
  1419 00001638 E928FDFFFF          <1> 	jmp     K27			; EXIT   
  1420                              <1> 
  1421                              <1> SHIP_IT:
  1422                              <1> 	;---------------------------------------------------------------------------------
  1423                              <1> 	; SHIP_IT
  1424                              <1> 	;	THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES
  1425                              <1> 	;	TO THE KEYBOARD CONTROLLER.
  1426                              <1> 	;---------------------------------------------------------------------------------
  1427                              <1> 	;
  1428                              <1> 	
  1429                              <1> 	;push	ax			; SAVE DATA TO SEND
  1430                              <1> 	; 12/04/2021
  1431 0000163D 50                  <1> 	push	eax
  1432                              <1> 
  1433                              <1> 	;-----	WAIT FOR COMMAND TO ACCEPTED
  1434 0000163E FA                  <1> 	cli				; DISABLE INTERRUPTS TILL DATA SENT
  1435                              <1> 	; xor	ecx, ecx		; CLEAR TIMEOUT COUNTER
  1436 0000163F B900000100          <1> 	mov	ecx, 10000h			
  1437                              <1> S10:
  1438 00001644 E464                <1> 	in	al, STATUS_PORT		; READ KEYBOARD CONTROLLER STATUS
  1439 00001646 A802                <1> 	test	al, INPT_BUF_FULL	; CHECK FOR ITS INPUT BUFFER BUSY
  1440 00001648 E0FA                <1> 	loopnz	S10			; WAIT FOR COMMAND TO BE ACCEPTED
  1441                              <1> 
  1442                              <1> 	;pop	ax			; GET DATA TO SEND
  1443                              <1> 	; 12/04/2021
  1444 0000164A 58                  <1> 	pop	eax
  1445                              <1> 
  1446 0000164B E664                <1> 	out	STATUS_PORT, al		; SEND TO KEYBOARD CONTROLLER
  1447 0000164D FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
  1448 0000164E C3                  <1> 	retn				; RETURN TO CALLER
  1449                              <1> 
  1450                              <1> 	; 12/04/2021 (32 bit push/pop)
  1451                              <1> SND_DATA:
  1452                              <1> 	; ---------------------------------------------------------------------------------
  1453                              <1> 	; SND_DATA
  1454                              <1> 	;	THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES
  1455                              <1> 	;	TO THE KEYBOARD AND RECEIPT OF ACKNOWLEDGEMENTS. IT ALSO
  1456                              <1> 	;	HANDLES ANY RETRIES IF REQUIRED
  1457                              <1> 	; ---------------------------------------------------------------------------------
  1458                              <1> 	;
  1459 0000164F 50                  <1> 	push	eax ; push ax		; SAVE REGISTERS
  1460 00001650 53                  <1> 	push	ebx ; push bx
  1461 00001651 51                  <1> 	push	ecx
  1462 00001652 88C7                <1> 	mov	bh, al			; SAVE TRANSMITTED BYTE FOR RETRIES
  1463 00001654 B303                <1> 	mov	bl, 3			; LOAD RETRY COUNT
  1464                              <1> SD0:
  1465 00001656 FA                  <1> 	cli				; DISABLE INTERRUPTS
  1466 00001657 8025[9B660000]CF    <1> 	and	byte [KB_FLAG_2], ~(KB_FE+KB_FA) ; CLEAR ACK AND RESEND FLAGS
  1467                              <1> 	;
  1468                              <1> 	;-----	WAIT FOR COMMAND TO BE ACCEPTED
  1469 0000165E B900000100          <1> 	mov	ecx, 10000h		; MAXIMUM WAIT COUNT
  1470                              <1> SD5:
  1471 00001663 E464                <1> 	in	al, STATUS_PORT		; READ KEYBOARD PROCESSOR STATUS PORT
  1472 00001665 A802                <1> 	test	al, INPT_BUF_FULL	; CHECK FOR ANY PENDING COMMAND
  1473 00001667 E0FA                <1> 	loopnz	SD5			; WAIT FOR COMMAND TO BE ACCEPTED
  1474                              <1> 	;
  1475 00001669 88F8                <1> 	mov	al, bh			; REESTABLISH BYTE TO TRANSMIT
  1476 0000166B E660                <1> 	out	PORT_A, al		; SEND BYTE
  1477 0000166D FB                  <1> 	sti				; ENABLE INTERRUPTS
  1478                              <1> 	;mov	cx, 01A00h		; LOAD COUNT FOR 10 ms+
  1479 0000166E B9FFFF0000          <1> 	mov	ecx, 0FFFFh
  1480                              <1> SD1:
  1481 00001673 F605[9B660000]30    <1> 	test	byte [KB_FLAG_2], KB_FE+KB_FA ; SEE IF EITHER BIT SET
  1482 0000167A 750F                <1> 	jnz	short SD3		; IF SET, SOMETHING RECEIVED GO PROCESS
  1483 0000167C E2F5                <1> 	loop	SD1			; OTHERWISE WAIT
  1484                              <1> SD2:
  1485 0000167E FECB                <1> 	dec	bl			; DECREMENT RETRY COUNT
  1486 00001680 75D4                <1> 	jnz	short SD0		; RETRY TRANSMISSION
  1487 00001682 800D[9B660000]80    <1> 	or	byte [KB_FLAG_2], KB_ERR ; TURN ON TRANSMIT ERROR FLAG
  1488 00001689 EB09                <1> 	jmp	short SD4		; RETRIES EXHAUSTED FORGET TRANSMISSION
  1489                              <1> SD3:
  1490 0000168B F605[9B660000]10    <1> 	test	byte [KB_FLAG_2], KB_FA ; SEE IF THIS IS AN ACKNOWLEDGE
  1491 00001692 74EA                <1> 	jz	short SD2		; IF NOT, GO RESEND
  1492                              <1> SD4:	
  1493 00001694 59                  <1> 	pop	ecx			; RESTORE REGISTERS
  1494 00001695 5B                  <1> 	pop	ebx ; pop bx
  1495 00001696 58                  <1> 	pop	eax ; pop ax
  1496 00001697 C3                  <1> 	retn				; RETURN, GOOD TRANSMISSION
  1497                              <1> 
  1498                              <1> SND_LED:
  1499                              <1> 	; ---------------------------------------------------------------------------------
  1500                              <1> 	; SND_LED
  1501                              <1> 	;	THIS ROUTINES TURNS ON THE MODE INDICATORS.
  1502                              <1> 	;
  1503                              <1> 	;----------------------------------------------------------------------------------
  1504                              <1> 	;
  1505 00001698 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1506 00001699 F605[9B660000]40    <1> 	test	byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE
  1507 000016A0 755F                <1> 	jnz 	short SL1		; DON'T UPDATE AGAIN IF UPDATE UNDERWAY
  1508                              <1> 	;
  1509 000016A2 800D[9B660000]40    <1> 	or	byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS
  1510 000016A9 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
  1511 000016AB E620                <1> 	out	20h, al ;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
  1512 000016AD EB11                <1> 	jmp	short SL0		; GO SEND MODE INDICATOR COMMAND
  1513                              <1> SND_LED1:
  1514 000016AF FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1515 000016B0 F605[9B660000]40    <1> 	test	byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE
  1516 000016B7 7548                <1> 	jnz	short SL1		; DON'T UPDATE AGAIN IF UPDATE UNDERWAY
  1517                              <1> 	;
  1518 000016B9 800D[9B660000]40    <1> 	or	byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS
  1519                              <1> SL0:
  1520 000016C0 B0ED                <1> 	mov	al, LED_CMD		; LED CMD BYTE
  1521 000016C2 E888FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  1522 000016C7 FA                  <1> 	cli
  1523 000016C8 E836000000          <1> 	call	MAKE_LED		; GO FORM INDICATOR DATA BYTE
  1524 000016CD 8025[9B660000]F8    <1> 	and	byte [KB_FLAG_2], 0F8h	; ~KB_LEDS ; CLEAR MODE INDICATOR BITS
  1525 000016D4 0805[9B660000]      <1> 	or	[KB_FLAG_2], al 	; SAVE PRESENT INDICATORS FOR NEXT TIME
  1526 000016DA F605[9B660000]80    <1> 	test	byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED
  1527 000016E1 750F                <1> 	jnz	short SL2		; IF SO, BYPASS SECOND BYTE TRANSMISSION
  1528                              <1> 	;
  1529 000016E3 E867FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  1530 000016E8 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1531 000016E9 F605[9B660000]80    <1> 	test	byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED
  1532 000016F0 7408                <1> 	jz	short SL3		; IF NOT, DON'T SEND AN ENABLE COMMAND
  1533                              <1> SL2:
  1534 000016F2 B0F4                <1> 	mov	al, KB_ENABLE		; GET KEYBOARD CSA ENABLE COMMAND
  1535 000016F4 E856FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  1536 000016F9 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1537                              <1> SL3:
  1538 000016FA 8025[9B660000]3F    <1> 	and	byte [KB_FLAG_2], ~(KB_PR_LED+KB_ERR) ; TURN OFF MODE INDICATOR
  1539                              <1> SL1:					; UPDATE AND TRANSMIT ERROR FLAG
  1540 00001701 FB                  <1> 	sti				; ENABLE INTERRUPTS
  1541 00001702 C3                  <1> 	retn				; RETURN TO CALLER
  1542                              <1> 
  1543                              <1> MAKE_LED:
  1544                              <1> 	;---------------------------------------------------------------------------------
  1545                              <1> 	; MAKE_LED
  1546                              <1> 	;	THIS ROUTINES FORMS THE DATA BYTE NECESSARY TO TURN ON/OFF
  1547                              <1> 	;	THE MODE INDICATORS.
  1548                              <1> 	;---------------------------------------------------------------------------------
  1549                              <1> 	;
  1550                              <1> 	;push 	cx			; SAVE CX
  1551 00001703 A0[99660000]        <1> 	mov	al, [KB_FLAG]		; GET CAPS & NUM LOCK INDICATORS
  1552 00001708 2470                <1> 	and	al, CAPS_STATE+NUM_STATE+SCROLL_STATE ; ISOLATE INDICATORS
  1553                              <1> 	;mov	cl, 4			; SHIFT COUNT
  1554                              <1> 	;rol	al, cl			; SHIFT BITS OVER TO TURN ON INDICATORS
  1555 0000170A C0C004              <1> 	rol	al, 4 ; 20/02/2015
  1556 0000170D 2407                <1> 	and	al, 07h			; MAKE SURE ONLY MODE BITS ON
  1557                              <1> 	;pop	cx
  1558 0000170F C3                  <1> 	retn				; RETURN TO CALLER
  1559                              <1> 
  1560                              <1> ; % include 'kybdata.s'   ; KEYBOARD DATA
  1561                              <1> 
  1562                              <1> 
  1563                              <1> ; /// End Of KEYBOARD FUNCTIONS ///
  2802                                  
  2803                                  %include 'video.s' ; 07/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - video.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 07/08/2022 (Previous: 17/04/2021 - Kernel v2.0.4)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 16/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; video.inc (13/08/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - VIDEO.INC
    20                              <1> ; Last Modification: 13/08/2015
    21                              <1> ;		  (Video Data is in 'VIDATA.INC')
    22                              <1> ;
    23                              <1> ; ///////// VIDEO (CGA) FUNCTIONS ///////////////
    24                              <1> 
    25                              <1> ; 16/01/2016 (32 bit modifications, TRDOS386 - TRDOS v2.0, video.s)
    26                              <1> ; INT 31H (TRDOS 386) = INT 10H (IBM PC/AT REAL MODE)
    27                              <1> 
    28                              <1> ; IBM PC-AT BIOS Source Code
    29                              <1> ; TITLE VIDEO1 --- 06/10/85 VIDEO DISPLAY BIOS
    30                              <1> 
    31                              <1> _int10h:
    32                              <1> 	; 23/03/2016
    33                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
    34 00001710 9C                  <1> 	pushfd
    35 00001711 0E                  <1> 	push	cs
    36 00001712 E851000000          <1> 	call	VIDEO_IO_1
    37 00001717 C3                  <1> 	retn
    38                              <1> 
    39                              <1> ;--- INT 10 H -------------------------------------------------------------------
    40                              <1> ; VIDEO_IO									:
    41                              <1> ;	THESE ROUTINES PROVIDE THE CRT DISPLAY INTERFACE			:
    42                              <1> ;	THE FOLLOWING FUNCTIONS ARE PROVIDED:					:
    43                              <1> ;										:
    44                              <1> ;    (AH)= 00H	SET MODE (AL) CONTAINS MODE VALUE				:
    45                              <1> ;		(AL) = 00H  40X25 BW MODE (POWER ON DEFAULT)			:
    46                              <1> ;		(AL) = 01H  40X25 COLOR						:
    47                              <1> ;		(AL) = 02H  80X25 BW						:
    48                              <1> ;		(AL) = 03H  80X25 COLOR						:
    49                              <1> ;		              GRAPHICS MODES					:
    50                              <1> ;		(AL) = 04H  320X200 COLOR					:
    51                              <1> ;		(AL) = 05H  320X200 BW MODE					:
    52                              <1> ;		(AL) = 06H  640X200 BW MODE					:
    53                              <1> ;		(AL) = 07H   80X25 MONOCHROME (USED INTERNAL TO VIDEO ONLY)	:
    54                              <1> ;		*** NOTES -BW MODES OPERATE SAME AS COLOR MODES, BUT COLOR	:
    55                              <1> ;		           BURST IS NOT ENABLED					:
    56                              <1> ;		          -CURSOR IS NOT DISPLAYED IN GRAPHICS MODE		:
    57                              <1> ;    (AH)= 01H	SET CURSOR TYPE							:
    58                              <1> ;		(CH) = BITS 4-0 = START LINE FOR CURSOR				:
    59                              <1> ;		       ** HARDWARE WILL ALWAYS CAUSE BLINK			:
    60                              <1> ;		       ** SETTING BIT 5 OR 6 WILL CAUSE ERRATIC BLINKING	:
    61                              <1> ;		          OR NO CURSOR AT ALL					:
    62                              <1> ;		(CL) = BITS 4-0 = END LINE FOR CURSOR				:
    63                              <1> ;    (AH)= 02H	SET CURSOR POSITION						:
    64                              <1> ;		(DH,DL) = ROW,COLUMN  (00H,00H) IS UPPER LEFT			:
    65                              <1> ;		(BH) = A PAGE NUMBER (MUST BE 00H FOR GRAPHICS MODES)		:
    66                              <1> ;    (AH)= 03H	READ CURSOR POSITION						:
    67                              <1> ;		(BH) = PAGE NUMBER (MUST BE 00H FOR GRAPHICS MODES)		:
    68                              <1> ;		ON EXIT (DH,DL) = ROW,COLUMN OF CURRENT CURSOR			:
    69                              <1> ;		        (CH,CL) = CURSOR MODE CURRENTLY SET			:
    70                              <1> ;    (AH)= 04H	READ LIGHT PEN POSITION						:
    71                              <1> ;		ON EXIT:							:
    72                              <1> ;		(AH) = 00H -- LIGHT PEN SWITCH NOT DOWN/NOT TRIGGERED		:
    73                              <1> ;		(AH) = 01H -- VALID LIGHT PEN VALUE IN REGISTERS		:
    74                              <1> ;		        (DH,DL) = ROW,COLUMN OF CHARACTER LP POSITION		:
    75                              <1> ;		        (CH) = RASTER LINE (0-199)				:
    76                              <1> ;		        (BX) = PIXEL COLUMN (0-319,639)				:
    77                              <1> ;    (AH)= 05H	SELECT ACTIVE DISPLAY PAGE (VALID ONLY FOR ALPHA MODES)		:
    78                              <1> ;		(AL) = NEW PAGE VALUE (0-7 FOR MODES 0&1, 0-3 FOR MODES 2&3)	:
    79                              <1> ;    (AH)= 06H	SCROLL ACTIVE PAGE UP						:
    80                              <1> ;		(AL) = NUMBER OF LINES. ( LINES BLANKED AT BOTTOM OF WINDOW )	:
    81                              <1> ;		        (AL) = 00H MEANS BLANK ENTIRE WINDOW			:
    82                              <1> ;		(CH,CL) = ROW,COLUMN OF UPPER LEFT CORNER OF SCROLL		:
    83                              <1> ;		(DH,DL) = ROW,COLUMN OF LOWER RIGHT CORNER OF SCROLL		:
    84                              <1> ;		(BH) = ATTRIBUTE TO BE USED ON BLANK LINE			:
    85                              <1> ;    (AH)= 07H	SCROLL ACTIVE PAGE DOWN						:
    86                              <1> ;		(AL) = NUMBER OF LINES, INPUT LINES BLANKED AT TOP OF WINDOW	:
    87                              <1> ;		        (AL) = 00H MEANS BLANK ENTIRE WINDOW			:
    88                              <1> ;		(CH,CL) = ROW,COLUMN OF UPPER LEFT CORNER OF SCROLL		:
    89                              <1> ;		(DH,DL) = ROW,COLUMN OF LOWER RIGHT CORNER OF SCROLL		:
    90                              <1> ;		(BH) = ATTRIBUTE TO BE USED ON BLANK LINE			:
    91                              <1> ;										:
    92                              <1> ;   CHARACTER HANDLING ROUTINES							:
    93                              <1> ;										:
    94                              <1> ;    (AH)= 08H	READ ATTRIBUTE/CHARACTER AT CURRENT CURSOR POSITION		:
    95                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
    96                              <1> ;		ON EXIT:							:
    97                              <1> ;		(AL) = CHAR READ						:
    98                              <1> ;		(AH) = ATTRIBUTE OF CHARACTER READ (ALPHA MODES ONLY)		:
    99                              <1> ;    (AH)= 09H	WRITE ATTRIBUTE/CHARACTER AT CURRENT CURSOR POSITION		:
   100                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
   101                              <1> ;		(CX) = COUNT OF CHARACTERS TO WRITE				:
   102                              <1> ;		(AL) = CHAR TO WRITE						:
   103                              <1> ;		(BL) = ATTRIBUTE OF CHARACTER (ALPHA)/COLOR OF CHAR (GRAPHICS)	:
   104                              <1> ;		         SEE NOTE ON WRITE DOT FOR BIT 7 OF BL = 1.		:
   105                              <1> ;    (AH) = 0AH	WRITE CHARACTER ONLY AT CURRENT CURSOR POSITION			:
   106                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
   107                              <1> ;		(CX) = COUNT OF CHARACTERS TO WRITE				:
   108                              <1> ;		(AL) = CHAR TO WRITE						:
   109                              <1> ;		       NOTE: USE FUNCTION (AH)= 09H IN GRAPHICS MODES		:
   110                              <1> ;	FOR READ/WRITE CHARACTER INTERFACE WHILE IN GRAPHICS MODE, THE		:
   111                              <1> ;		CHARACTERS ARE FORMED FROM A CHARACTER GENERATOR IMAGE		:
   112                              <1> ;		MAINTAINED IN THE SYSTEM ROM. ONLY THE 1ST 128 CHARS		:
   113                              <1> ;		ARE CONTAINED THERE. TO READ/WRITE THE SECOND 128 CHARS,	:
   114                              <1> ;		THE USER MUST INITIALIZE THE POINTER AT INTERRUPT 1FH		:
   115                              <1> ;		(LOCATION 0007CH) TO POINT TO THE 1K BYTE TABLE CONTAINING	:
   116                              <1> ;		THE CODE POINTS FOR THE SECOND 128 CHARS (128-255).		:
   117                              <1> ;	FOR WRITE CHARACTER INTERFACE IN GRAPHICS MODE, THE REPLICATION FACTOR	:
   118                              <1> ;		CONTAINED IN (CX) ON ENTRY WILL PRODUCE VALID RESULTS ONLY	:
   119                              <1> ;		FOR CHARACTERS CONTAINED ON THE SAME ROW. CONTINUATION TO	:
   120                              <1> ;		SUCCEEDING LINES WILL NOT PRODUCE CORRECTLY.			:
   121                              <1> ;										:
   122                              <1> ;    GRAPHICS INTERFACE								:
   123                              <1> ;    (AH)= 0BH	SET COLOR PALETTE						:
   124                              <1> ;		(BH) = PALETTE COLOR ID BEING SET (0-127)			:
   125                              <1> ;		(BL) = COLOR VALUE TO BE USED WITH THAT COLOR ID		:
   126                              <1> ;		       NOTE: FOR THE CURRENT COLOR CARD, THIS ENTRY POINT HAS	:
   127                              <1> ;		               MEANING ONLY FOR 320X200 GRAPHICS.		:
   128                              <1> ;		       COLOR ID = 0 SELECTS THE BACKGROUND COLOR (0-15)		:
   129                              <1> ;		       COLOR ID = 1 SELECTS THE PALETTE TO BE USED:		:
   130                              <1> ;		               0 = GREEN(1)/RED(2)/YELLOW(3)			:
   131                              <1> ;		               1 = CYAN(1)/MAGENTA(2)/WHITE(3)			:
   132                              <1> ;		       IN 40X25 OR 80X25 ALPHA MODES, THE VALUE SET FOR 	:
   133                              <1> ;		               PALETTE COLOR 0 INDICATES THE BORDER COLOR	:
   134                              <1> ;		               TO BE USED (VALUES 0-31, WHERE 16-31 SELECT	:
   135                              <1> ;		               THE HIGH INTENSITY BACKGROUND SET.		:
   136                              <1> ;    (AH)= 0CH	WRITE DOT							:
   137                              <1> ;		(DX) = ROW NUMBER						:
   138                              <1> ;		(CX) = COLUMN NUMBER						:
   139                              <1> ;		(AL) = COLOR VALUE						:
   140                              <1> ;		        IF BIT 7 OF AL = 1, THEN THE COLOR VALUE IS EXCLUSIVE	:
   141                              <1> ;		        ORed WITH THE CURRENT CONTENTS OF THE DOT		:
   142                              <1> ;    (AH)= ODH	READ DOT							:
   143                              <1> ;		(DX) = ROW NUMBER						:
   144                              <1> ;		(CX) = COLUMN NUMBER						:
   145                              <1> ;		(AL) = RETURNS THE DOT READ					:
   146                              <1> ;										:
   147                              <1> ;    ASCII TELETYPE ROUTINE FOR OUTPUT						:
   148                              <1> ;										:
   149                              <1> ;    (AH)= 0EH	WRITE TELETYPE TO ACTIVE PAGE					:
   150                              <1> ;		(AL) = CHAR TO WRITE						:
   151                              <1> ;		(BL) = FOREGROUND COLOR IN GRAPHICS MODE			:
   152                              <1> ;		NOTE -- SCREEN WIDTH IS CONTROLLED BY PREVIOUS MODE SET		:
   153                              <1> ;    (AH)= 0FH	CURRENT VIDEO STATE						:
   154                              <1> ;		RETURNS THE CURRENT VIDEO STATE					:
   155                              <1> ;		(AL) = MODE CURRENTLY SET ( SEE (AH)=00H FOR EXPLANATION)	:
   156                              <1> ;		(AH) = NUMBER OR CHARACTER COLUMNS ON SCREEN			:
   157                              <1> ;		(BH) = CURRENT ACTIVE DISPLAY PAGE				:
   158                              <1> ;    (AH)= 10H	RESERVED							:
   159                              <1> ;    (AH)= 11H	RESERVED							:
   160                              <1> ;    (AH)= 12H	RESERVED							:
   161                              <1> ;    (AH)= 13H	WRITE STRING							:
   162                              <1> ;			ES:BP  -  POINTER T0 STRING TO BE WRITTEN		:
   163                              <1> ;			CX     -  LENGTH OF CHARACTER STRING TO WRITTEN		:
   164                              <1> ;			DX     -  CURSOR POSITION FOR STRING TO BE WRITTEN	:
   165                              <1> ;			BH     -  PAGE NUMBER					:
   166                              <1> ;		(AL)= 00H	WRITE CHARACTER STRING				:
   167                              <1> ;			BL     -  ATTRIBUTE					:
   168                              <1> ;			STRING IS  <CHAR,CHAR, ... ,CHAR>			:
   169                              <1> ;			CURSOR NOT MOVED					:
   170                              <1> ;		(AL)= 01H	WRITE CHARACTER STRING AND MOVE CURSOR		:
   171                              <1> ;			BL     -  ATTRIBUTE					:
   172                              <1> ;			STRING IS  <CHAR,CHAR, ... ,CHAR>			:
   173                              <1> ;			CURSOR MOVED						:
   174                              <1> ;		(AL)= 02H	WRITE CHARACTER AND ATTRIBUTE STRING		:
   175                              <1> ;			       (VALID FOR ALPHA MODES ONLY)			:
   176                              <1> ;			STRING IS <CHAR,ATTR,CHAR,ATTR ..  ,CHAR,ATTR>		:
   177                              <1> ;			CURSOR IS NOT MOVED					:
   178                              <1> ;		(AL)= 03H WRITE CHARACTER AND ATTRIBUTE STRING AND MOVE CURSOR	:
   179                              <1> ;			       (VALID FOR ALPHA MODES ONLY)			:
   180                              <1> ;			STRING IS <CHAR,ATTR,CHAR,ATTR ..  ,CHAR,ATTR>		:
   181                              <1> ;			CURSOR IS MOVED						:
   182                              <1> ;		 NOTE:  CARRIAGE RETURN, LINE FEED, BACKSPACE, AND BELL ARE	:
   183                              <1> ;		        TREATED AS COMMANDS RATHER THAN PRINTABLE CHARACTERS.	:
   184                              <1> ;										:
   185                              <1> ;	BX,CX,DX,SI,DI,BP,SP,DS,ES,SS PRESERVED DURING CALLS EXCEPT FOR		:
   186                              <1> ;	BX,CX,DX RETURN VALUES ON FUNCTIONS 03H,04H,0DH AND 0FH. ON ALL CALLS	:
   187                              <1> ;	AX IS MODIFIED.								:
   188                              <1> ;--------------------------------------------------------------------------------
   189                              <1> 
   190 00001718 [C01A0000]          <1> M1:	dd	SET_MODE	; TABLE OF ROUTINES WITHIN VIDEO I/O
   191 0000171C [761E0000]          <1> 	dd	SET_CTYPE
   192 00001720 [A41E0000]          <1> 	dd	SET_CPOS
   193 00001724 [C81E0000]          <1> 	dd	READ_CURSOR
   194                              <1> 	;dd	VIDEO_RETURN	; READ_LPEN
   195 00001728 [BE1A0000]          <1> 	dd	set_mode_ncm	; Set mode without clearing video memory
   196 0000172C [0E1F0000]          <1> 	dd	ACT_DISP_PAGE
   197 00001730 [981F0000]          <1> 	dd	SCROLL_UP
   198 00001734 [AF200000]          <1> 	dd	SCROLL_DOWN
   199 00001738 [2E210000]          <1> 	dd	READ_AC_CURRENT
   200 0000173C [8B210000]          <1> 	dd	WRITE_AC_CURRENT
   201 00001740 [B1210000]          <1> 	dd	WRITE_C_CURRENT
   202 00001744 [B92A0000]          <1> 	dd	SET_COLOR
   203 00001748 [212B0000]          <1> 	dd	WRITE_DOT
   204 0000174C [F02A0000]          <1> 	dd	READ_DOT
   205 00001750 [3B220000]          <1> 	dd	WRITE_TTY
   206 00001754 [A61A0000]          <1> 	dd	VIDEO_STATE
   207 00001758 [EE350000]          <1> 	dd	vga_pal_funcs	; 10/08/2016 (TRDOS 386)
   208 0000175C [06300000]          <1> 	dd	font_setup	; 10/07/2016 (TRDOS 386)
   209 00001760 [F51A0000]          <1> 	dd	VIDEO_RETURN	; RESERVED
   210 00001764 [B1230000]          <1> 	dd	WRITE_STRING	; 23/06/2016 (TRDOS 386)
   211                              <1> M1L	EQU	$ - M1
   212                              <1> 
   213                              <1> ; 02/08/2022 - TRDOS 386 v2.0.5
   214                              <1> ; 06/12/2020
   215                              <1> ; 05/12/2020
   216                              <1> ; 03/12/2020
   217                              <1> ; 27/11/2020 - TRDOS 386 v2.0.3
   218                              <1> ; 14/01/2017
   219                              <1> ; 02/01/2017
   220                              <1> ; 04/07/2016
   221                              <1> ; 12/05/2016
   222                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   223                              <1> int31h:  ; Video BIOS
   224                              <1> 
   225                              <1> ; BH = Video page number
   226                              <1> ; BL = Color/Attribute
   227                              <1> ; AH = Function number
   228                              <1> ; AL = Character
   229                              <1> 
   230                              <1> VIDEO_IO_1:
   231                              <1> 	;sti				; INTERRUPTS BACK ON
   232 00001768 FC                  <1> 	cld				; SET DIRECTION FORWARD
   233                              <1> 	
   234                              <1> 	;cmp	ah, M1L/4		; TEST FOR WITHIN TABLE RANGE
   235                              <1> 	;jnb	short M4		; BRANCH TO EXIT IF NOT A VALID COMMAND
   236                              <1> 
   237                              <1> 	; 26/11/2020
   238 00001769 80FC14              <1> 	cmp	ah, M1L/4
   239 0000176C 7205                <1> 	jb	short VGA_func
   240                              <1> 
   241 0000176E 80FC4F              <1> 	cmp	ah, 4Fh
   242 00001771 7532                <1> 	jne	short M4 ; invalid !
   243                              <1> 
   244                              <1> VGA_func: ; 26/11/2020
   245 00001773 06                  <1> 	push	es ; *
   246 00001774 1E                  <1> 	push	ds ; **			; SAVE WORK AND PARAMETER REGISTERS
   247                              <1> 
   248                              <1> 	; 26/11/2020
   249 00001775 50                  <1> 	push	eax ; -
   250                              <1> 	
   251 00001776 66B81000            <1> 	mov	ax, KDATA 		; POINT DS: TO DATA SEGMENT
   252 0000177A 8ED8                <1> 	mov	ds, ax
   253 0000177C 8EC0                <1> 	mov	es, ax
   254                              <1> 
   255                              <1> 	; 26/11/2020
   256 0000177E 58                  <1> 	pop	eax ; +
   257                              <1> 	;
   258 0000177F FB                  <1> 	sti
   259 00001780 80FC4F              <1> 	cmp	ah, 4Fh
   260 00001783 747A                <1> 	je	short VBE_func
   261                              <1> 
   262                              <1> 	; 04/12/2020
   263 00001785 A3[0C840100]        <1> 	mov	[video_eax], eax
   264                              <1> 
   265                              <1> 	; 21/12/2020
   266 0000178A 803D[CE660000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh	; Current mode is a VESA VBE mode ?
   267 00001791 7213                <1> 	jb	short VGA_func_std
   268                              <1> 
   269 00001793 08E4                <1> 	or	ah, ah			; set mode ?
   270 00001795 750F                <1> 	jnz	short VGA_func_std	; no
   271                              <1> 
   272 00001797 803D[79090000]03    <1> 	cmp	byte [vbe3], 3		; (real) VESA VBE 3 video bios ?
   273 0000179E 7506                <1> 	jne	short VGA_func_std	; no
   274                              <1> 
   275 000017A0 E984010000          <1> 	jmp	vesa_vbe3_pmi
   276                              <1> 
   277                              <1> 	; 21/12/2020
   278                              <1> M4:					; COMMAND NOT VALID
   279 000017A5 CF                  <1> 	iretd				; DO NOTHING IF NOT IN VALID RANGE
   280                              <1> 
   281                              <1> VGA_func_std:
   282                              <1> 	; 06/12/2020
   283                              <1> 	; 03/12/2020
   284 000017A6 80FC0F              <1> 	cmp	ah, 0Fh
   285 000017A9 773D                <1> 	ja	short VGA_funcs_0	; only CGA funcs will be handled by	
   286                              <1> 	; 06/12/2020			; vga bios firmware
   287                              <1> 	; 03/12/2020			
   288                              <1> 	;test	ah, 7Fh ; set mode ?
   289                              <1> 	;;or	ah, ah			; only 'set mode' will be handled by
   290                              <1> 	;jnz	short VGA_funcs_0	; vga bios firmware	
   291                              <1> 	;jz	short vbe_pmi32_0
   292                              <1> 
   293                              <1> 	; 28/11/2020
   294 000017AB 803D[D00F0300]00    <1> 	cmp	byte [pmi32], 0		; 32 bit protected mode interface for
   295 000017B2 7634                <1> 	jna	short VGA_funcs_0	; video hardware's vga bios firmware
   296                              <1> 					; ([pmi32] > 0 if it is activated)
   297                              <1> 					; note:
   298                              <1> 					; [vbe3] = 3 is required to activate
   299                              <1> 	; 07/12/2020
   300 000017B4 20E4                <1> 	and	ah, ah ; is this set mode ?
   301 000017B6 7413                <1> 	jz	short vbe_pmi32_2 ; yes
   302                              <1> 
   303 000017B8 80FC04              <1> 	cmp	ah, 04h	 ; set mode ('no clear memory' option)
   304 000017BB 742B                <1> 	je	short VGA_funcs_0
   305                              <1> 
   306                              <1> 	; 07/12/2020
   307 000017BD 803D[CE660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; current mode > 7 ?
   308 000017C4 7622                <1> 	jna	short VGA_funcs_0  ; no	
   309                              <1> 
   310                              <1> 	; when mode 3 is active, 
   311                              <1> 	; video bios functions are not redirected
   312                              <1> 	; to VESA VBE3 PMI except 'set mode' function
   313                              <1> 
   314                              <1> vbe_pmi32_0:
   315                              <1> 	; 06/12/2020
   316                              <1> 	;or	ah, ah
   317                              <1> 	;jnz	short vbe_pmi32_2
   318                              <1> 	; ah = 0 ; 'set mode'
   319                              <1> 	;cmp	al, 3 ; 80x25 text mode, 16 colors, default mode for MainProg
   320                              <1> 	;jne	short vbe_pmi32_1
   321                              <1> 	;cmp	byte [CRT_MODE], 3 ; If current video mode <> 3 and requested
   322                              <1> 	;			; video mode is 3, use internal 'set mode';
   323                              <1> 	;			; otherwise, use vesa vbe 3 bios's 'set mode'.
   324                              <1> 	;jne	short VGA_funcs_0
   325                              <1> vbe_pmi32_1:
   326 000017C6 E95E010000          <1> 	jmp	vesa_vbe3_pmi
   327                              <1> ;vbe_pmi32_2:
   328                              <1> 	;cmp	ah, 04h ; set mode (no clear mem option)
   329                              <1> 	;jne	short vbe_pmi32_1
   330                              <1> 
   331                              <1> vbe_pmi32_2:
   332                              <1> 	; 07/12/2020
   333 000017CB 803D[CE660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; current mode > 7 ?
   334 000017D2 77F2                <1> 	ja	short vbe_pmi32_1  ; yes
   335                              <1> 
   336 000017D4 3C07                <1> 	cmp	al, 7	; requested mode > 7 ?
   337 000017D6 7610                <1> 	jna	short VGA_funcs_0  ; no (CGA)
   338                              <1> 
   339 000017D8 3C13                <1> 	cmp	al, 13h
   340 000017DA 76EA                <1> 	jna	short vbe_pmi32_1
   341                              <1> 
   342 000017DC A880                <1> 	test	al, 80h
   343 000017DE 7408                <1> 	jz	short VGA_funcs_0  ; unknown or special
   344                              <1> 
   345 000017E0 3C87                <1> 	cmp	al, 87h	; requested mode > 7 ? 
   346                              <1> 			; (with no clear mem ops)
   347 000017E2 7604                <1> 	jna	short VGA_funcs_0  ; no (CGA)
   348                              <1> 
   349 000017E4 3C93                <1> 	cmp	al, 93h
   350 000017E6 76DE                <1> 	jna	short vbe_pmi32_1
   351                              <1> 
   352                              <1> 	; > 13h video modes are unknown or special
   353                              <1>  	; they must be handled by kernel	
   354                              <1> 
   355                              <1> 	; CGA video modes will be handled by kernel
   356                              <1> 
   357                              <1> VGA_funcs_0:
   358 000017E8 52                  <1> 	push	edx ; ***
   359 000017E9 51                  <1> 	push	ecx ; ****
   360 000017EA 53                  <1> 	push	ebx ; *****
   361 000017EB 56                  <1> 	push	esi ; ******
   362 000017EC 57                  <1> 	push	edi ; *******
   363 000017ED 55                  <1> 	push	ebp ; ********
   364                              <1> 
   365                              <1> 	;mov	[video_eax], eax ; 12/05/2016 
   366 000017EE BF00800B00          <1> 	mov	edi, 0B8000h		; GET offset FOR COLOR CARD
   367                              <1> 
   368                              <1> 	; 23/03/2016
   369 000017F3 C0E402              <1> 	shl	ah, 2  ; dword		; TIMES 2 FOR WORD TABLE LOOKUP
   370 000017F6 0FB6F4              <1> 	movzx	esi, ah			; MOVE OFFSET INTO LOOK UP REGISTER (SI)
   371                              <1> 	;mov	ah, [CRT_MODE]		; MOVE CURRENT MODE INTO (AH) REGISTER
   372                              <1> 
   373                              <1> 	;;15/01/2017
   374                              <1> 	; 14/01/2017
   375                              <1> 	; 02/01/2017
   376                              <1> 	;;mov	byte [intflg], 31h  ; video interrupt
   377                              <1> 	;sti ; 26/11/2020
   378                              <1> 	;
   379                              <1> 
   380 000017F9 FFA6[18170000]      <1> 	jmp	dword [esi+M1]		; GO TO SELECTED FUNCTION
   381                              <1> 
   382                              <1> VBE_func:
   383                              <1> 	; 26/11/2020
   384                              <1> 	;sti
   385 000017FF 55                  <1> 	push	ebp ; *** ; 27/11/2020	
   386 00001800 56                  <1> 	push	esi ; **** 
   387                              <1> 	
   388                              <1> 	; Note:
   389                              <1> 	; ebx, ecx, edx, edi, ebp registers
   390                              <1> 	; must be saved by VBE functions and
   391                              <1> 	; eax register must be set
   392                              <1> 	; (according to VBE 3 standard)
   393                              <1> 	; before return from this interrupt
   394                              <1> 	; (every function must restore and set
   395                              <1> 	; registers except esp, esi, es, ds)
   396                              <1> 
   397 00001801 803D[79090000]02    <1> 	cmp	byte [vbe3], 2
   398 00001808 7740                <1> 	ja	short VESA_VBE3_PMI_CALL ; VBE3 video bios ('PMID')
   399                              <1> 	;je	short VBE_func_0  ; Bochs/Qemu/VirtualBox emulator
   400 0000180A 7268                <1> 	jb	short VBE_unknown ; invalid ([vbe3] = 0)
   401                              <1> 
   402                              <1> 	;jmp	VESA_VBE3_PMI_CALL
   403                              <1> 
   404                              <1> VBE_func_0:	
   405                              <1> 	; Bochs/Plex86 VGAbios VBE extension
   406                              <1> 	; (TRDOS 386 v2.0.3 can use VBE graphics modes on emulators)
   407                              <1> 	; BOCHS/QEMU/VIRTUALBOX
   408                              <1>  
   409 0000180C 8A25[7A090000]      <1> 	mov	ah, [vbe2bios]
   410 00001812 80FCC0              <1> 	cmp	ah, 0C0h		
   411 00001815 725D                <1> 	jb	short VBE_unknown 	
   412 00001817 80FCC5              <1> 	cmp	ah, 0C5h
   413 0000181A 7758                <1> 	ja	short VBE_unknown
   414                              <1> 
   415                              <1> 	; TRDOS 386 is running on BOCHS or QEMU
   416 0000181C B44F                <1> 	mov	ah, 4Fh
   417                              <1> VBE_func_1:
   418 0000181E 0FB6F0              <1> 	movzx	esi, al ; VESA VBE function number
   419                              <1> 	;shl	si, 2 ; dword
   420                              <1> 	; 02/08/2022
   421 00001821 C1E602              <1> 	shl	esi, 2
   422 00001824 6683FE14            <1> 	cmp	si, N1L
   423 00001828 734A                <1> 	jnb	short VBE_unknown
   424                              <1> 	;sti
   425                              <1> 	
   426 0000182A FF96[36180000]      <1> 	call	dword [esi+N1] ; call VBE function
   427                              <1> 		
   428                              <1> 	;jmp	short VBE_bios_return
   429                              <1> 
   430                              <1> VBE_bios_return:
   431 00001830 FA                  <1> 	cli
   432 00001831 5E                  <1> 	pop	esi ; ****
   433 00001832 5D                  <1> 	pop	ebp ; *** ; 27/11/2020
   434 00001833 07                  <1> 	pop	es  ; **
   435 00001834 1F                  <1> 	pop	ds  ; *
   436 00001835 CF                  <1> 	iretd
   437                              <1> 
   438                              <1> 	; 26/11/2020
   439                              <1> N1:
   440 00001836 [97180000]          <1> 	dd	vbe_biosfn_return_ctrl_info
   441 0000183A [A6380000]          <1> 	dd	vbe_biosfn_return_mode_info
   442 0000183E [60390000]          <1> 	dd	vbe_biosfn_set_mode
   443 00001842 [303A0000]          <1> 	dd	vbe_biosfn_return_current_mode
   444 00001846 [4F3A0000]          <1> 	dd	vbe_biosfn_save_restore_state
   445                              <1> 	;dd	vbe_biosfn_display_window_ctrl
   446                              <1> 	;dd	vbe_biosfn_set_get_log_scanline
   447                              <1> 	;dd	vbe_biosfn_set_get_disp_start
   448                              <1> 	;dd	vbe_biosfn_set_get_dac_pal_frm
   449                              <1> 	;dd	vbe_biosfn_set_get_palette_data
   450                              <1> 	
   451                              <1> N1L	EQU	$ - N1
   452                              <1> 
   453                              <1> 
   454                              <1> VESA_VBE3_PMI_CALL: ; VESA VBE video bios (firmware) functions
   455                              <1> 		    ; by using VESA VBE3 Protected Mode Interface
   456                              <1> 	
   457                              <1> 	; 02/08/2022 - TRDOS 386 v2.0.5
   458                              <1> 	; 29/11/2020
   459                              <1> 	; 26/11/2020 - TRDOS 386 v2.0.3 video.s
   460                              <1> 
   461                              <1> 	; We are here because..
   462                              <1> 	; 'PMID' has been verified by TRDOS 386 v2.0.3 kernel.
   463                              <1> 	; (Otherwise bochs/plex86 compatible VBE functions and
   464                              <1> 	;  modes would be used on BOCHS/QEMU/VIRTUALBOX emulators
   465                              <1> 	;  or only standard/old VGA graphics modes would be used.)
   466                              <1> 
   467                              <1> 	; (TRDOS 386 v2.0.3 can use VESA VBE graphics modes if
   468                              <1> 	;  the video bios is full compatible with VBE3 standard) 
   469                              <1> 
   470                              <1> 	; 29/11/2020
   471                              <1> 
   472 0000184A 0FB6F0              <1> 	movzx	esi, al ; VESA VBE 3 function number
   473                              <1> 	;shl	si, 2 ; dword
   474                              <1> 	; 02/08/2022
   475 0000184D C1E602              <1> 	shl	esi, 2
   476 00001850 6683FE14            <1> 	cmp	si, P1L
   477 00001854 731E                <1> 	jnb	short VBE_unknown
   478                              <1> 	;sti
   479                              <1> 
   480 00001856 57                  <1> 	push	edi ; *****
   481                              <1> 		
   482 00001857 FF96[60180000]      <1> 	call	dword [esi+P1] ; call VBE 3 function
   483                              <1> 
   484 0000185D 5F                  <1> 	pop	edi ; *****
   485                              <1> 		
   486 0000185E EBD0                <1> 	jmp	short VBE_bios_return
   487                              <1> 
   488                              <1> P1:
   489 00001860 [7A180000]          <1> 	dd	vbe3_pmfn_return_ctrl_info
   490 00001864 [9D180000]          <1> 	dd	vbe3_pmfn_return_mode_info
   491 00001868 [D9180000]          <1> 	dd	vbe3_pmfn_set_mode
   492 0000186C [D4180000]          <1> 	dd	vbe3_pmfn_return_current_mode
   493 00001870 [CA190000]          <1> 	dd	vbe3_pmfn_save_restore_state
   494                              <1> 	;dd	vbe3_pmfn_display_window_ctrl
   495                              <1> 	;dd	vbe3_pmfn_set_get_log_scanline
   496                              <1> 	;dd	vbe3_pmfn_set_get_disp_start
   497                              <1> 	;dd	vbe3_pmfn_set_get_dac_pal_frm
   498                              <1> 	;dd	vbe3_pmfn_set_get_palette_data
   499                              <1> 	;dd	vbe3_pmfn_return_pmi ; invalid for TRDOS 386 v2
   500                              <1> 	;dd	vbe3_pmfn_set_get_pixel_clock
   501                              <1> 	
   502                              <1> P1L	EQU	$ - P1
   503                              <1> 
   504                              <1> ;	; 29/11/2020
   505                              <1> ;	mov	edi, VBE3MODEINFOBLOCK >> 4 ; / 16
   506                              <1> ;	
   507                              <1> ;	cmp	al, 04h
   508                              <1> ;	jb	short vbe3_pm_f ; function: 4F00h to 4F03h
   509                              <1> ;	ja	short vbe3_pmi_f5B ; function: 4F05h to 4F0Bh
   510                              <1> ;
   511                              <1> ;	; check buffer length (must be <= 2048 bytes)
   512                              <1> ;
   513                              <1> ;	and	dl, dl ; 0
   514                              <1> ;	jz	short vbe3_pm_f 
   515                              <1> ;		       ; Return Save/Restore State buffer size
   516                              <1> ;
   517                              <1> ;	push	ebx  ; buffer address
   518                              <1> ;	push	edx  ; function: save (01h) or restore (02h)
   519                              <1> ;	call	
   520                              <1> ;
   521                              <1> ;vbe3_pm_f03:
   522                              <1> ;	cmp	al, 2
   523                              <1> ;	ja	short vbe3_pm_f ; function 4F03h
   524                              <1> ;	jb	short vbe3_pm_f1
   525                              <1> ;
   526                              <1> ;
   527                              <1> ;vbe3_pm_f1:
   528                              <1> ;	
   529                              <1> ;
   530                              <1> ;vbe3_pmi_f5B:
   531                              <1> ;	cmp	al, 09h
   532                              <1> ;	jna	short vbe3_pm_f ; funcs 05h to 09h are usable 
   533                              <1> ;	
   534                              <1> ;	cmp	al, 0Bh ; Get/Set pixel clock, last function
   535                              <1> ;	jne	short VBE_unknown 
   536                              <1> ;			; (do not use 'uncertain' functions
   537                              <1> ;			; because of system-user buff transfers)
   538                              <1> ;vbe3_pm_f:
   539                              <1> ;	mov	byte [vbe3_pm_fn], al	; set
   540                              <1> ;	; prepare 16 bit pm segments & registers for pmi call 
   541                              <1> ;	call	VESA_VBE3_PM_FUNCTION
   542                              <1> ;
   543                              <1> ;
   544                              <1> 
   545                              <1> 	; 26/11/2020
   546                              <1> VBE_unknown:
   547 00001874 66B80001            <1> 	mov	ax, 0100h  ; ah = 1 : Function call failed	
   548                              <1> 			   ; al = 0 : Function is not supported	
   549                              <1> 	
   550 00001878 EBB6                <1> 	jmp	short VBE_bios_return
   551                              <1> 
   552                              <1> vbe3_pmfn_return_ctrl_info:
   553                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
   554                              <1> 	; 12/12/2020
   555                              <1> 	;
   556                              <1> 	; VBE function 4F00h - Return VBE Controller Information
   557                              <1> 	;
   558                              <1> 	; Input:
   559                              <1> 	;      EDI = Pointer to buffer in which to place
   560                              <1> 	;	     VbeInfoBlock structure
   561                              <1> 	;
   562                              <1> 	;	AX = 4F00h
   563                              <1> 	; Output:
   564                              <1> 	;	AX = VBE return status
   565                              <1> 	;	     AX = 004Fh -> succeeded
   566                              <1> 	;	     AX <> 004Fh -> failed
   567                              <1> 	; 
   568                              <1> 	; Modified registers: eax (+ edi for kernel's own call)
   569                              <1> 
   570                              <1> 	; NOTE: TRDOS 386 v2 (v2.0.3) kernel calls this function
   571                              <1> 	; during startup while cpu is in real mode
   572                              <1> 	; (by using int 10h, 4F02h) and saves VbeInfoBlock at
   573                              <1> 	; VBE3INFOBLOCK address (97E00h for TRDOS 386 v2.0.3).
   574                              <1> 	;	
   575                              <1> 	; So...
   576                              <1> 	; This VBE function is adjusted to return/move same info
   577                              <1> 	; from VBE3INFOBLOCK to user's buffer in EDI.
   578                              <1> 
   579                              <1> 	; int 31h (int 10h) entrance
   580                              <1> 
   581 0000187A 21FF                <1> 	and	edi, edi
   582 0000187C 7423                <1> 	jz	short vbe3_func_fail ; invalid buffer address !
   583                              <1> 
   584                              <1> ;_vbe3_pmfn_return_ctrl_info:		
   585                              <1> 	;or	edi, edi
   586                              <1> 	;jnz	short _vbe_biosfn_return_ctrl_info
   587                              <1> 	;
   588                              <1> 	;; this option may not be necessary - 12/12/2020
   589                              <1> 	;
   590                              <1> 	;; edi = 0, kernel forces to get ctrl info again
   591                              <1> 	;;	   by using VESA VBE3 video bios's pmi
   592                              <1> 	;
   593                              <1> 	;;push	edi
   594                              <1> 	;; far call to VESA VBE3 PMI 
   595                              <1> 	;;mov	ax, 4F00h ; Return VBE Controller Info
   596                              <1> 	;mov	edi, VBE3INFOBLOCK-VBE3SAVERESTOREBLOCK
   597                              <1> 	;; ES selector base address = VBE3SAVERESTOREBLOCK 
   598                              <1> 	;call	int10h_32bit_pmi
   599                              <1> 	;;pop	edi
   600                              <1> 	;mov	edi, VBE3INFOBLOCK ; retn to the kernel sub
   601                              <1> 	;cmp	ax, 004Fh
   602                              <1> 	;je	short vbe_ctrl_info_retn
   603                              <1> 	;stc	
   604                              <1> 	;retn
   605                              <1> 
   606                              <1> _vbe_biosfn_return_ctrl_info:
   607 0000187E 57                  <1> 	push	edi
   608 0000187F 51                  <1> 	push	ecx
   609 00001880 BE007E0900          <1> 	mov	esi, VBE3INFOBLOCK
   610                              <1> 	;mov	ecx, 512
   611                              <1> 	; 02/08/2022
   612 00001885 29C9                <1> 	sub	ecx, ecx
   613 00001887 B502                <1> 	mov	ch, 2
   614                              <1> 	; ecx = 512
   615 00001889 E8CBF40000          <1> 	call	transfer_to_user_buffer
   616 0000188E 59                  <1> 	pop	ecx
   617 0000188F 5F                  <1> 	pop	edi
   618 00001890 720F                <1> 	jc	short vbe3_func_fail
   619                              <1> 
   620 00001892 31C0                <1> 	xor	eax, eax
   621 00001894 B04F                <1> 	mov	al, 4Fh ; successful
   622                              <1> ;vbe_ctrl_info_retn:
   623 00001896 C3                  <1> 	retn
   624                              <1> 
   625                              <1> vbe_biosfn_return_ctrl_info:
   626                              <1> 	; 12/12/2020
   627                              <1> 	;
   628                              <1> 	; VBE function 4F00h - Return VBE Controller Information
   629                              <1> 	;
   630                              <1> 	; Input:
   631                              <1> 	;      EDI = Pointer to buffer in which to place
   632                              <1> 	;	     VbeInfoBlock structure
   633                              <1> 	;
   634                              <1> 	;	AX = 4F00h
   635                              <1> 	; Output:
   636                              <1> 	;	AX = VBE return status
   637                              <1> 	;	     AX = 004Fh -> succeeded
   638                              <1> 	;	     AX <> 004Fh -> failed   
   639                              <1> 	; 
   640                              <1> 	; Modified registers: eax
   641                              <1> 
   642 00001897 21FF                <1> 	and	edi, edi
   643 00001899 7406                <1> 	jz	short vbe3_func_fail ; invalid buffer addr !
   644 0000189B EBE1                <1> 	jmp	short _vbe_biosfn_return_ctrl_info 
   645                              <1> 
   646                              <1> vbe3_pmfn_return_mode_info:
   647                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)	
   648                              <1> 	; 21/12/2020
   649                              <1> 	; 12/12/2020
   650                              <1> 	;
   651                              <1> 	; VBE function 4F01h - Return VBE Mode Information
   652                              <1> 	;
   653                              <1> 	; Input:
   654                              <1> 	;	CX = Mode number (VESA VBE mode number)
   655                              <1> 	;      EDI = Pointer to ModeInfoBlock structure
   656                              <1> 	;	     (256 bytes) -User's buffer address-
   657                              <1> 	;      EDI = 0 -> kernel call
   658                              <1> 	;		  (do not transfer ModeInfoBlock
   659                              <1> 	;		  to user's buffer address)
   660                              <1> 	;	AX = 4F01h	
   661                              <1> 	; Output:
   662                              <1> 	;	AX = VBE return status
   663                              <1> 	;	     AX = 004Fh -> succeeded
   664                              <1> 	;	     AX <> 004Fh -> failed   
   665                              <1> 	; 
   666                              <1> 	; Modified registers: eax, esi, edi
   667                              <1> 
   668                              <1> 	; int 31h (int 10h) entrance
   669                              <1> 	
   670 0000189D 09FF                <1> 	or	edi, edi
   671 0000189F 7506                <1> 	jnz	short _vbe3_pmfn_return_mode_info
   672                              <1> 
   673                              <1> vbe3_func_fail:
   674 000018A1 B84F010000          <1> 	mov	eax, 014Fh ; ah = 1 : Function call failed
   675                              <1> 			   ; al = 4Fh : Function is supported
   676 000018A6 C3                  <1> 	retn
   677                              <1> 	
   678                              <1> 	; jump from '_vbe_biosfn_return_mode_info' 
   679                              <1> _vbe3_pmfn_return_mode_info:
   680 000018A7 57                  <1> 	push	edi
   681                              <1> 
   682                              <1> 	;; clear vbe3 'mode info block' buffer
   683                              <1> 	;push	ecx
   684                              <1> 	;xor	eax, eax
   685                              <1> 	;mov	ecx, 256/4
   686                              <1> 	;mov	edi, VBE3MODEINFOBLOCK
   687                              <1> 	;rep	stosd
   688                              <1> 	;pop	ecx
   689                              <1> 
   690                              <1> 	; far call to VESA VBE3 PMI 
   691                              <1> 	;mov	ax, 4F01h ; Return VBE Mode Information
   692 000018A8 BF00060000          <1> 	mov	edi, VBE3MODEINFOBLOCK-VBE3SAVERESTOREBLOCK
   693                              <1> 	; ES selector base address = VBE3SAVERESTOREBLOCK 
   694 000018AD E8FA000000          <1> 	call	int10h_32bit_pmi
   695                              <1> 
   696 000018B2 5F                  <1> 	pop	edi
   697                              <1> 
   698                              <1> 	;cmp	ax, 004Fh
   699                              <1> 	;jne	short vbe3_func_retn  ; failed !
   700                              <1> 
   701 000018B3 21FF                <1> 	and	edi, edi
   702                              <1> 	;jz	short vbe3_func_success
   703                              <1> 	; 21/12/2020
   704 000018B5 741C                <1> 	jz	short vbe3_func_retn
   705                              <1> 
   706 000018B7 6683F84F            <1> 	cmp	ax, 004Fh
   707 000018BB 7516                <1> 	jne	short vbe3_func_retn  ; failed !
   708                              <1> 
   709 000018BD 51                  <1> 	push	ecx
   710 000018BE BE007C0900          <1> 	mov	esi, VBE3MODEINFOBLOCK		
   711                              <1> 	;mov	ecx, 256
   712                              <1> 	; 02/08/2022
   713 000018C3 29C9                <1> 	sub	ecx, ecx
   714 000018C5 FEC5                <1> 	inc	ch
   715                              <1> 	; ecx = 256
   716 000018C7 E88DF40000          <1> 	call	transfer_to_user_buffer
   717 000018CC 59                  <1> 	pop	ecx
   718 000018CD 72D2                <1> 	jc	short vbe3_func_fail
   719                              <1> 
   720 000018CF 31C0                <1> 	xor	eax, eax
   721 000018D1 B04F                <1> 	mov	al, 4Fh ; successful
   722                              <1> vbe3_func_success:
   723                              <1> vbe3_func_retn:	
   724 000018D3 C3                  <1> 	retn
   725                              <1> 
   726                              <1> vbe3_pmfn_return_current_mode:
   727                              <1> 	; 12/12/2020
   728                              <1> 	;
   729                              <1> 	; VBE function 4F03h - Return Current VBE Mode
   730                              <1> 	;
   731                              <1> 	; Input:
   732                              <1> 	;	none (AX = 4F03h)
   733                              <1> 	; Output:
   734                              <1> 	;	AX = VBE return status
   735                              <1> 	;	     AX = 004Fh -> succeeded
   736                              <1> 	;	     AX <> 004Fh -> failed
   737                              <1> 	;	BX = Current VBE mode
   738                              <1> 	;	  bit 0-13 = Mode number
   739                              <1> 	;	  bit 14 = 0 Windowed frame buffer model
   740                              <1> 	;	         = 1 Linear frame buffer model
   741                              <1> 	;	  bit 15 
   742                              <1> 	;	      = 0 Memory cleared at last mode set
   743                              <1> 	;	      = 1 Memory not cleared at last mode set
   744                              <1> 	; 
   745                              <1> 	; Modified registers: eax, ebx
   746                              <1> 
   747                              <1> 	; int 31h (int 10h) entrance
   748                              <1> 	
   749                              <1> 	; far call to VESA VBE3 PMI 
   750                              <1> 
   751                              <1> 	;mov	eax, 4F03h ; Return Current VBE Mode
   752                              <1> vbe3_pmfn_far_call:
   753                              <1> 	; ES selector base address = VBE3SAVERESTOREBLOCK 
   754                              <1> 	;call	int10h_32bit_pmi
   755                              <1> 	;retn
   756 000018D4 E9D3000000          <1> 	jmp	int10h_32bit_pmi
   757                              <1> 
   758                              <1> vbe3_pmfn_set_mode:
   759                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
   760                              <1> 	; 22/12/2020
   761                              <1> 	; 21/12/2020
   762                              <1> 	; 12/12/2020
   763                              <1> 	;
   764                              <1> 	; VBE function 4F02h - Set VBE Mode
   765                              <1> 	;
   766                              <1> 	; Input:
   767                              <1> 	;	BX = Desired Mode to set
   768                              <1> 	;	  bit 0-13 = Mode number
   769                              <1> 	;	  bit 14 = 0 Windowed frame buffer model
   770                              <1> 	;	         = 1 Linear frame buffer model
   771                              <1> 	;	  bit 15 
   772                              <1> 	;	      = 0 Memory cleared at last mode set
   773                              <1> 	;	      = 1 Memory not cleared at last mode set
   774                              <1> 	; Output:
   775                              <1> 	;	AX = VBE return status
   776                              <1> 	;	     AX = 004Fh -> succeeded
   777                              <1> 	;	     AX <> 004Fh -> failed
   778                              <1> 	; 
   779                              <1> 	; Modified registers: eax, ebx, esi (21/12/2020)
   780                              <1> 
   781                              <1> 	; int 31h (int 10h) entrance
   782                              <1> 
   783                              <1> 	; 22/12/2020 (VESA VBE3 feature)
   784                              <1> 	; BX bit 11 is flag for
   785                              <1> 	;	user specified CRTC values for refresh rate
   786                              <1> 	; 'test bh, 8'
   787                              <1> 	; if bit 11 is set, EDI points to 'CRTCInfoBlock'
   788                              <1> 
   789                              <1> 	; 22/12/2020
   790                              <1> 	;; test bx for VBE video mode
   791                              <1> 	;test	bh, 1
   792                              <1> 	;jnz	short vbe3_sm_0
   793                              <1> 
   794                              <1> 	;; use internal VBE mode set procedure
   795                              <1> 	;; for non-vbe (std VGA/CGA) modes
   796                              <1> 	;
   797                              <1> 	;; (it is useful -as 4F02h function- 
   798                              <1> 	;;  to jump 'vbe_biosfn_set_mode'
   799                              <1> 	;;  instead of direct jump to '_set_mode')
   800                              <1> 	;; ((eliminates additional push-pops and settings))
   801                              <1>  
   802                              <1> 	;jmp	vbe_biosfn_set_mode	
   803                              <1> 
   804                              <1> vbe3_sm_0: 
   805                              <1> 	;;push	ds  ; *
   806                              <1> 	;;push	es  ; **
   807                              <1> 	;;push	ebp ; ***
   808                              <1> 	;;push	esi ; **** 
   809                              <1> 	
   810                              <1> 	; Fit bx to VESA VBE2 type mode setting
   811                              <1> 	; (bx bit 11 is used for custom CRTC values in VBE3)
   812                              <1> 	; clear bit 9 to 11 (clear bh bit 1 to bit 3)
   813                              <1> 
   814                              <1> 	; 22/12/2020
   815 000018D9 57                  <1> 	push	edi ; *****
   816 000018DA F6C708              <1> 	test	bh, 8	; Use user specified CRTC values
   817 000018DD 7530                <1> 	jnz	short vbe3_sm_3  ; for refresh rate
   818                              <1> vbe3_sm_4:
   819 000018DF 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
   820                              <1> 	;mov	[vbe_mode_x], bh
   821                              <1> 
   822 000018E2 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 3 ; is current mode 03h ?
   823 000018E9 7509                <1> 	jne	short vbe3_sm_1    ; no
   824                              <1> 
   825                              <1> 	; save mode 03h video pages and cursor positions
   826 000018EB 57                  <1> 	push	edi ; **!***	
   827 000018EC 51                  <1> 	push	ecx ; ******
   828                              <1> 	;push	esi
   829                              <1> 	
   830 000018ED E8B6040000          <1> 	call	save_mode3_multiscreen
   831                              <1> 	
   832                              <1> 	;pop	esi
   833 000018F2 59                  <1> 	pop	ecx ; ******
   834 000018F3 5F                  <1> 	pop	edi ; **!***
   835                              <1> vbe3_sm_1:
   836                              <1> 	; ax = 4F02h
   837                              <1> 	; bx = video mode number (vbe2 type)
   838 000018F4 E8B3000000          <1> 	call	int10h_32bit_pmi 
   839                              <1> 			; call to far call to VBE3 PMI
   840                              <1> 
   841 000018F9 6683F84F            <1> 	cmp	ax, 004Fh ; succeeded ?
   842 000018FD 750E                <1> 	jne	short vbe3_sm_2
   843                              <1> 	; set current mode byte/sign to extended (SVGA) mode
   844 000018FF C605[CE660000]FF    <1> 	mov	byte [CRT_MODE], 0FFh ; VESA VBE mode
   845                              <1> 	; set current VBE mode word to bx input
   846 00001906 66891D[D20F0300]    <1> 	mov	[video_mode], bx
   847                              <1> vbe3_sm_2:
   848                              <1> 	; 22/12/2020
   849 0000190D 5F                  <1> 	pop	edi ; ***** 
   850 0000190E C3                  <1> 	retn
   851                              <1> 
   852                              <1> vbe3_sm_3:
   853                              <1> 	; 22/12/2020
   854                              <1> 	; copy user's CRTCInfoBlock to the buffer
   855 0000190F 51                  <1> 	push	ecx
   856 00001910 89FE                <1> 	mov	esi, edi
   857 00001912 BF807D0900          <1> 	mov	edi, VBE3CRTCINFOBLOCK
   858                              <1> 	;mov	ecx, 64
   859                              <1> 	; 02/08/2022
   860 00001917 29C9                <1> 	sub	ecx, ecx
   861 00001919 B140                <1> 	mov	cl, 64
   862 0000191B E883F40000          <1> 	call	transfer_from_user_buffer
   863 00001920 59                  <1> 	pop	ecx
   864                              <1> 	; set offset (es base addr is VBE3SAVERESTOREBLOCK) 
   865 00001921 81EF00760900        <1> 	sub	edi, VBE3SAVERESTOREBLOCK
   866 00001927 EBB6                <1> 	jmp	short vbe3_sm_4
   867                              <1> 	
   868                              <1> vesa_vbe3_pmi:
   869                              <1> 	; 12/12/2020
   870                              <1> 	; 08/12/2020
   871                              <1> 	; 07/12/2020
   872                              <1> 	; 05/12/2020, 06/12/2020
   873                              <1> 	; 03/12/2020, 04/12/2020
   874                              <1> 	; 28/11/2020 (TRDOS 386 v2.0.3)
   875                              <1> 	; VGA BIOS functions via
   876                              <1> 	; VESA VBE3 Protected Mode Inface
   877                              <1> 	; [vbe3] = 3 and [pmi32] > 0
   878                              <1> 
   879                              <1> 	; 04/12/2020
   880                              <1> 	; Only 'set mode' will be redirected to vbe3 video bios
   881                              <1> 	; (by setting mode 3 multiscreen paraters before and after) 
   882                              <1> 
   883                              <1> 	; 06/12/2020
   884 00001929 20E4                <1> 	and	ah, ah	; 0 = set mode function
   885 0000192B 7402                <1> 	jz	short vbe3_pmi_0
   886 0000192D EB76                <1> 	jmp	vbe3_pmi_9 
   887                              <1> 
   888                              <1> vbe3_pmi_0:
   889                              <1> 	; 07/12/2020
   890 0000192F 88C4                <1> 	mov	ah, al
   891 00001931 80E480              <1> 	and	ah, 80h ; 0 or 80h
   892 00001934 30E0                <1> 	xor	al, ah ; 8?h -> 0?h
   893                              <1> 
   894                              <1> 	;cmp	al, 13h ; mode number above 13h is returned
   895                              <1> 	;jna	short vbe3_pmi_1
   896                              <1> 	;		; back to default code due to uncertainty
   897                              <1> 	; 		; (>13h is not std for all svga bioses)
   898                              <1> 	;jmp	VGA_funcs_0
   899                              <1> vbe3_pmi_1:
   900                              <1> 	; 07/12/2020
   901                              <1> 	; Possible cases for VBE3 (PMI, ah=0) set mode:
   902                              <1> 	; current mode > 07h and requested mode: any 
   903                              <1> 	; current mode <= 07h and requested mode > 07h
   904                              <1> 
   905                              <1> 	; 06/12/2020
   906 00001936 8825[1B840100]      <1> 	mov	byte [noclearmem], ah ; 0 or 80h
   907                              <1> 	; check current video mode if it is 03h
   908 0000193C 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 3 ; current mode
   909 00001943 750B                <1> 	jne	short vbe3_pmi_3
   910                              <1> 	; 07/12/2020
   911                              <1> 	; check new video mode if it is 03h also
   912                              <1> 	;cmp	al, 3
   913                              <1> 	;jne	short vbe3_pmi_2
   914                              <1> 	;mov	byte [p_crt_mode], 80h 	; clear video memory
   915                              <1> 	;jmp	short vbe3_pmi_5
   916                              <1> vbe3_pmi_2:
   917                              <1> 	; case 1:
   918                              <1> 	; Current mode is 03h and new mode is not 03h
   919                              <1> 
   920                              <1> 	; save video pages and cursor positions
   921 00001945 56                  <1> 	push	esi
   922 00001946 57                  <1> 	push	edi
   923 00001947 51                  <1> 	push	ecx
   924                              <1> 
   925                              <1> 	; 12/12/2020
   926                              <1> 	;mov	esi, 0B8000h ; mode 3 video memory
   927                              <1> 	;mov	edi, 98000h  ; backup location
   928                              <1> 	;mov	ecx, (0B8000h-0B0000h)/4
   929                              <1> 	;rep	movsd
   930                              <1> 	;
   931                              <1> 	;mov	byte [p_crt_mode], 3 ; previous mode, backup sign
   932                              <1> 	;xchg	cl, [ACTIVE_PAGE]
   933                              <1> 	;mov	[p_crt_page], cl  ; save as previous active page
   934                              <1> 	;
   935                              <1> 	;; save cursor positions
   936                              <1> 	;mov	esi, CURSOR_POSN
   937                              <1> 	;mov	edi, cursor_pposn ; cursor positions backup
   938                              <1> 	;mov	cl, 4
   939                              <1> 	;rep	movsd
   940                              <1> 
   941                              <1> 	; 12/12/2020
   942 00001948 E85B040000          <1> 	call	save_mode3_multiscreen
   943                              <1> 
   944 0000194D 59                  <1> 	pop	ecx
   945 0000194E 5F                  <1> 	pop	edi
   946 0000194F 5E                  <1> 	pop	esi
   947                              <1> vbe3_pmi_3:
   948                              <1> 	; 08/12/2020
   949                              <1> 	; 07/12/2020
   950                              <1> 	; case 3 or case 4
   951 00001950 A2[CE660000]        <1> 	mov	[CRT_MODE], al
   952 00001955 3C03                <1> 	cmp	al, 3
   953 00001957 7407                <1> 	je	short vbe3_pmi_4
   954                              <1> 	; case 4:
   955                              <1> 	; Current mode is not 03h and also new mode is not 03h
   956 00001959 800D[19840100]80    <1> 	or	byte [p_crt_mode], 80h  ; 83h (case 1 -> case 4)
   957                              <1> 	;jmp	short vbe3_pmi_5
   958                              <1> vbe3_pmi_4:
   959                              <1> 	; case 3:
   960                              <1> 	;
   961                              <1> 	; Current mode is not 03h and new mode is 03h
   962                              <1> 
   963                              <1> ;vbe3_pmi_5:
   964                              <1> 	;mov	[CRT_MODE], al
   965                              <1> 
   966 00001960 E847000000          <1> 	call	int10h_32bit_pmi	
   967                              <1> 
   968 00001965 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 3  ; new video mode
   969                              <1> 	;jne	vbe3_pmi_8	; video mode <> 03h
   970 0000196C 7532                <1> 	jne	short vbe3_pmi_8	
   971                              <1> 
   972                              <1> 	;push	eax ; 04/12/2020
   973 0000196E 53                  <1> 	push	ebx
   974 0000196F 51                  <1> 	push	ecx
   975 00001970 52                  <1> 	push	edx
   976 00001971 57                  <1> 	push	edi ; 03/12/2020
   977                              <1> 
   978                              <1> 	; 12/12/2020
   979 00001972 56                  <1> 	push	esi
   980 00001973 E862040000          <1> 	call	restore_mode3_multiscreen
   981 00001978 5E                  <1> 	pop	esi
   982                              <1> 	; AL = active video page
   983                              <1> 
   984                              <1> 	; 12/12/2020
   985                              <1> 	;mov	al, [p_crt_page] ; previous mode 3 active page
   986                              <1> 	;
   987                              <1> 	;;test	byte [p_crt_mode], 7Fh ; 83h or 80h or 03h
   988                              <1> 	;;jz	short vbe3_pmi_6 ; do not restore video pages
   989                              <1> 	;			 ; clear current video page
   990                              <1> 	;; case 3
   991                              <1> 	;
   992                              <1> 	;; ([p_crt_mode] = 03h)
   993                              <1> 	;
   994                              <1> 	;; New video mode is 3 while current video mode is not 3
   995                              <1> 	;; (multi screen) video pages will be restored from 098000h
   996                              <1> 	;
   997                              <1> 	;; restore video pages and cursor positions
   998                              <1> 	;
   999                              <1> 	;mov	[ACTIVE_PAGE], al ; current mode 3 active page
  1000                              <1> 	;
  1001                              <1> 	;push	esi
  1002                              <1> 	;
  1003                              <1> 	;; restore video pages
  1004                              <1> 	;mov	esi, 98000h
  1005                              <1> 	;mov	edi, 0B8000h
  1006                              <1> 	;;mov	ecx, 2000h
  1007                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
  1008                              <1> 	;rep	movsd
  1009                              <1> 	;
  1010                              <1> 	;mov	[p_crt_mode], cl ; reset ('case 3' end condition)
  1011                              <1> 	;
  1012                              <1> 	;; restore cursor positions
  1013                              <1> 	;mov	esi, cursor_pposn
  1014                              <1> 	;mov	edi, CURSOR_POSN
  1015                              <1> 	;;mov	ecx, 4	; restore all cursor positions (16 bytes)
  1016                              <1> 	;mov	cl, 4
  1017                              <1> 	;rep 	movsd
  1018                              <1> 	;
  1019                              <1> 	;pop	esi
  1020                              <1> 	;
  1021                              <1> 	;; 07/12/2020
  1022                              <1> 	;; restore CRT_START according to ACTIVE_PAGE
  1023                              <1> 	;mov	[CRT_START], cx ; 0
  1024                              <1> 	;
  1025                              <1> 	;; check active page and set it again if it is not 0
  1026                              <1> 	;or	al, al
  1027                              <1> 	;jz	short vbe3_pmi_7
  1028                              <1> 	;
  1029                              <1> 	;mov	cl, al
  1030                              <1> ;vbe3_pmi_5:
  1031                              <1> 	;add	word [CRT_START], 4096
  1032                              <1> 	;dec	cl
  1033                              <1> 	;jnz	short vbe3_pmi_5
  1034                              <1> 
  1035 00001979 B405                <1> 	mov	ah, 05h ; set current video page
  1036                              <1> 	;al = video page
  1037 0000197B E82C000000          <1> 	call	int10h_32bit_pmi
  1038                              <1> 	
  1039                              <1> 	; check current cursor position & set it again if not 0,0
  1040                              <1> 	;movzx	ebx, byte [ACTIVE_PAGE]
  1041 00001980 0FB6D8              <1> 	movzx	ebx, al
  1042 00001983 D0E3                <1> 	shl	bl, 1
  1043 00001985 81C3[A6770100]      <1> 	add	ebx, CURSOR_POSN
  1044 0000198B 668B13              <1> 	mov	dx, [ebx]
  1045 0000198E 6621D2              <1> 	and	dx, dx		
  1046 00001991 7409                <1> 	jz	short vbe3_pmi_7
  1047                              <1> 	
  1048                              <1> 	;dx = cursor position (dl = column, dh = row)
  1049                              <1> 	;mov	bh, [ACTIVE_PAGE] ; 06/12/2020
  1050 00001993 88C7                <1> 	mov	bh, al
  1051 00001995 B402                <1> 	mov	ah, 02h ; set cursor position
  1052 00001997 E810000000          <1> 	call	int10h_32bit_pmi
  1053                              <1> 	
  1054                              <1> 	;jmp	short vbe3_pmi_7
  1055                              <1> 
  1056                              <1> ;vbe3_pmi_6:
  1057                              <1> ;	; 07/12/2020
  1058                              <1> ;	; case 1, previous mode is 03h, current mode is 03h
  1059                              <1> ;	; 03/12/2020
  1060                              <1> ;	cmp	byte [noclearmem], 0
  1061                              <1> ;	jna	short vbe3_pmi_7 ; do not clear memory
  1062                              <1> ;	; clear video page
  1063                              <1> ;	mov	ecx, 1024 ; 4096/4
  1064                              <1> ;	mov	eax, 07200720h
  1065                              <1> ;	mov	edi, 0B8000h ; [crt_base]
  1066                              <1> ;	add	di, [CRT_START]
  1067                              <1> ;	rep	stosd	; FILL THE REGEN BUFFER WITH BLANKS
  1068                              <1> 
  1069                              <1> vbe3_pmi_7:
  1070 0000199C 5F                  <1> 	pop	edi
  1071 0000199D 5A                  <1> 	pop	edx
  1072 0000199E 59                  <1> 	pop	ecx
  1073 0000199F 5B                  <1> 	pop	ebx
  1074                              <1> 	;pop	eax ; 04/12/2020
  1075                              <1> vbe3_pmi_8:
  1076                              <1> 	; 04/12/2020
  1077                              <1> 	;(TRDOS 386 v2.0.3, INT 31h, ah=0 return)
  1078 000019A0 31C0                <1> 	xor	eax, eax  ; eax = 0 -> succesful
  1079                              <1> vesa_vbe3_pmi_retn:
  1080 000019A2 07                  <1> 	pop	es  ; **
  1081 000019A3 1F                  <1> 	pop	ds  ; *
  1082 000019A4 CF                  <1> 	iretd
  1083                              <1> 
  1084                              <1> vbe3_pmi_9:
  1085                              <1> 	; 06/12/2020 
  1086                              <1> 	;cmp	ah, 10h ; Set/Get Palette Registers
  1087                              <1> 	;jnb	short vbe3_pmi_10
  1088                              <1> 	; 05/12/2020
  1089 000019A5 E802000000          <1> 	call	int10h_32bit_pmi
  1090 000019AA EBF6                <1> 	jmp	short vesa_vbe3_pmi_retn
  1091                              <1> 
  1092                              <1> ;vbe3_pmi_10:
  1093                              <1> 	; 06/12/2020
  1094                              <1> 	;jmp	VGA_funcs_0
  1095                              <1> 
  1096                              <1> int10h_32bit_pmi:
  1097                              <1> 	; 03/12/2020
  1098                              <1> 	; 28/11/2020
  1099                              <1> 	; calling standard VGA Bios (INT 10h) functions
  1100                              <1> 	; by using 32 bit protected mode interface of
  1101                              <1> 	; VESA VBE3 Video Bios (with 'PMID' signature)
  1102                              <1> 
  1103                              <1> 	; 03/12/2020
  1104                              <1> 	; eax, ebx, ecx, edx, edi will be used by vbios pmi
  1105                              <1> 	; (esi and ebp will not be used) 
  1106                              <1> 
  1107                              <1> 	; 03/12/2020
  1108 000019AC 56                  <1> 	push	esi
  1109 000019AD C1E010              <1> 	shl	eax, 16  ; move function number (ax) to hw
  1110 000019B0 8B35[D80F0300]      <1> 	mov	esi, [pmid_addr] ; linear address of
  1111                              <1> 				 ; PMInfo.Entrypoint pointer
  1112                              <1> 	;mov	ax, [esi+PMInfo.EntryPoint]	
  1113 000019B6 668B06              <1> 	mov	ax, [esi]	 
  1114 000019B9 C1C010              <1> 	rol	eax, 16 ; move PM entry address to hw
  1115                              <1> 			; and move function number to lw (ax)
  1116 000019BC 5E                  <1> 	pop	esi
  1117                              <1> 
  1118                              <1> 	; top of stack: ; (*)
  1119                              <1> 	; return (the caller) address of "int10h_32bit_pmi"
  1120                              <1> 
  1121 000019BD E9E5EDFFFF          <1> 	jmp	_VBE3PMI_fcall ; will return to the caller (*)
  1122                              <1> 
  1123                              <1> _vbe3_pmfn_srs_8:
  1124                              <1> 	; 17/01/2021
  1125 000019C2 31DB                <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  1126                              <1> _vbe3_pmfn_srs_9: ; 24/01/2021
  1127 000019C4 66B8044F            <1> 	mov	ax, 4F04h
  1128 000019C8 EBE2                <1> 	jmp	short int10h_32bit_pmi
  1129                              <1> 
  1130                              <1> vbe3_pmfn_save_restore_state:
  1131                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  1132                              <1> 	; 24/01/2021
  1133                              <1> 	; 23/01/2021
  1134                              <1> 	; 16/01/2021 - 17/01/2021
  1135                              <1> 	; 14/01/2021
  1136                              <1> 	;
  1137                              <1> 	; VBE function 4F04h - Save/Restore Video State
  1138                              <1> 	;
  1139                              <1> 	; Input:
  1140                              <1> 	;	DL = sub function
  1141                              <1> 	;	CL = requested state
  1142                              <1> 	;      EBX = pointer to buffer (if DL<>00h)
  1143                              <1> 	;	AX = 4F04h 
  1144                              <1> 	; Output:
  1145                              <1> 	;	AX = 004Fh (successful)
  1146                              <1> 	;	AH > 0 -> error
  1147                              <1> 	;	BX = Number of 64-byte blocks 
  1148                              <1> 	;	     to hold the state buffer (if DL=00h)
  1149                              <1> 
  1150                              <1> 	; Modified registers: eax, ebx, esi, edi
  1151                              <1> 	
  1152 000019CA 21DB                <1> 	and	ebx, ebx ; user's buffer address
  1153 000019CC 750A                <1> 	jnz	short _vbe3_pmfn_save_restore_state
  1154                              <1> 
  1155 000019CE 08D2                <1> 	or	dl, dl
  1156 000019D0 740C                <1> 	jz	short _vbe3_pmfn_srs_0
  1157                              <1> 
  1158                              <1> 	; function failed
  1159                              <1> 	;;mov	eax, 0100h
  1160                              <1> 	;sub	eax, eax
  1161                              <1> 	;inc	ah  ; eax = 0100h
  1162                              <1> 	;retn
  1163                              <1> 	; 16/01/2021
  1164                              <1> _vbe3_pmfn_srs_fail:
  1165 000019D2 B84F010000          <1> 	mov	eax, 014Fh ; ah = 1 : Function call failed
  1166                              <1> 			   ; al = 4Fh : Function is supported
  1167                              <1> _vbe3_srs_retn:
  1168 000019D7 C3                  <1> 	retn
  1169                              <1> 
  1170                              <1> _vbe3_pmfn_save_restore_state:
  1171 000019D8 20D2                <1> 	and	dl, dl
  1172 000019DA 7555                <1> 	jnz	short _vbe3_pmfn_srs_2
  1173                              <1> _vbe3_pmfn_srs:
  1174 000019DC 31DB                <1> 	xor	ebx, ebx
  1175                              <1> _vbe3_pmfn_srs_0:
  1176                              <1> 	; 24/01/2021
  1177 000019DE 83F90F              <1> 	cmp	ecx, 0Fh
  1178                              <1> 	;ja	short _vbe3_pmfn_srs_1
  1179 000019E1 77EF                <1> 	ja	short _vbe3_pmfn_srs_fail 
  1180                              <1> 
  1181                              <1> 	; !!! CLEAR CL BIT 2 !!! 
  1182                              <1> 	; (when bit 2 is set, function causes cpu exception)
  1183                              <1> 	; BIOS data will not be saved and restored
  1184                              <1> 	; (to prevent protected mode page fault error)
  1185 000019E3 80E1FD              <1> 	and	cl, ~2 ; and cl, not 2
  1186                              <1> 	
  1187                              <1> 	; 24/01/2021
  1188                              <1> 	;mov	bl, 1
  1189 000019E6 FEC3                <1> 	inc	bl ; = 1
  1190                              <1> 	;shl	bx, cl 
  1191                              <1> 	; 02/08/2022
  1192 000019E8 D3E3                <1> 	shl	ebx, cl
  1193 000019EA 66231D[DC0F0300]    <1> 	and	bx, [vbe3stbsflags]
  1194 000019F1 7415                <1> 	jz	short _vbe3_pmfn_srs_1
  1195                              <1> 	;mov	bx, cx
  1196 000019F3 89CB                <1> 	mov	ebx, ecx ; <= 15
  1197 000019F5 D0E3                <1> 	shl	bl, 1 ; 0, 2, 8 .. 30
  1198 000019F7 668B9B[003B0000]    <1> 	mov	bx, [vbestatebufsize+ebx]
  1199 000019FE 89DF                <1> 	mov	edi, ebx
  1200                              <1> 	; edi = state buffer size in bytes
  1201                              <1> 	;shr	bx, 6 ; / 64
  1202                              <1> 	; 02/08/2022
  1203 00001A00 C1EB06              <1> 	shr	ebx, 6
  1204                              <1> 	;mov	ax, 4Fh
  1205 00001A03 28E4                <1> 	sub	ah, ah
  1206 00001A05 B04F                <1> 	mov	al, 4Fh
  1207 00001A07 C3                  <1> 	retn
  1208                              <1> _vbe3_pmfn_srs_1:
  1209                              <1> 	; ax = 4F04h
  1210                              <1> 	;call	int10h_32bit_pmi
  1211                              <1> 	; 24/01/2021
  1212                              <1> 	;call	_vbe3_pmfn_srs_8
  1213                              <1> 	; ebx = 0
  1214 00001A08 E8B7FFFFFF          <1> 	call	_vbe3_pmfn_srs_9	
  1215 00001A0D 6683F84F            <1> 	cmp	ax, 004Fh
  1216 00001A11 75C4                <1> 	jne	short _vbe3_srs_retn
  1217                              <1> 	; 24/01/2021
  1218                              <1> 	;cmp	ecx, 0Fh
  1219                              <1> 	;ja	short _vbe3_srs_retn
  1220                              <1> 	; 24/01/2021
  1221                              <1> 	;mov	ax, 1
  1222 00001A13 B001                <1> 	mov	al, 1
  1223                              <1> 	;shl	ax, cl		
  1224                              <1> 	; 02/08/2022
  1225 00001A15 D3E0                <1> 	shl	eax, cl
  1226 00001A17 660905[DC0F0300]    <1> 	or	[vbe3stbsflags], ax ; set flag for state option
  1227                              <1> 	; 23/01/2021
  1228 00001A1E 89DF                <1> 	mov	edi, ebx
  1229 00001A20 89C8                <1> 	mov	eax, ecx
  1230 00001A22 D0E0                <1> 	shl	al, 1
  1231                              <1> 	;shl	di, 6 ; * 64
  1232                              <1> 	; 02/08/2022
  1233 00001A24 C1E706              <1> 	shl	edi, 6
  1234 00001A27 6689B8[003B0000]    <1> 	mov	[vbestatebufsize+eax], di
  1235                              <1> 				; save buf size for option 
  1236                              <1> 	;xchg	edi, ebx
  1237                              <1> 	; edi = state buffer size in bytes
  1238 00001A2E B04F                <1> 	mov	al, 4Fh
  1239 00001A30 C3                  <1> 	retn
  1240                              <1> 
  1241                              <1> _vbe3_pmfn_srs_2:
  1242                              <1> 	; 24/01/2021
  1243                              <1> 	; !!! CLEAR CL BIT 2 !!! 
  1244                              <1> 	; (when bit 2 is set, function causes cpu exception)
  1245                              <1> 	; BIOS data will not be saved and restored
  1246                              <1> 	; (to prevent protected mode page fault error)
  1247                              <1> 
  1248 00001A31 F6C1FD              <1> 	test	cl, ~2 ; test cl, not 2
  1249 00001A34 749C                <1> 	jz	short _vbe3_pmfn_srs_fail
  1250                              <1> 
  1251 00001A36 80FA02              <1> 	cmp	dl, 2
  1252 00001A39 7748                <1> 	ja	short _vbe3_pmfn_srs_5
  1253                              <1> 
  1254                              <1> 	;and	cl, ~2 ; and cl, not 2
  1255                              <1> 
  1256 00001A3B 53                  <1> 	push	ebx ; * ; buffer address
  1257                              <1> 	; save or restore state
  1258                              <1> 	; (get required buffer size at first)
  1259 00001A3C 52                  <1> 	push	edx ; **
  1260 00001A3D 28D2                <1> 	sub	dl, dl ; 0
  1261 00001A3F E898FFFFFF          <1> 	call	_vbe3_pmfn_srs
  1262 00001A44 5A                  <1> 	pop	edx ; **
  1263                              <1> 	; 24/01/2021
  1264 00001A45 5B                  <1> 	pop	ebx ; *
  1265 00001A46 08E4                <1> 	or	ah, ah
  1266 00001A48 7538                <1> 	jnz	short _vbe3_pmfn_srs_4 ; error
  1267                              <1> 
  1268                              <1> 	; edi = buffer size in bytes
  1269 00001A4A 81FF00080000        <1> 	cmp	edi, 2048
  1270 00001A50 772B                <1> 	ja	short _vbe3_pmfn_srs_3
  1271                              <1> 
  1272 00001A52 80FA01              <1> 	cmp	dl, 1
  1273 00001A55 7531                <1> 	jne	short _vbe3_pmfn_srs_6 ; restore state
  1274                              <1> 	
  1275                              <1> 	; save video state
  1276                              <1> 	;xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  1277                              <1> 	;mov	ax, 4F04h
  1278                              <1> 	;call	int10h_32bit_pmi
  1279                              <1> 
  1280                              <1> 	; 24/01/2021
  1281 00001A57 E842000000          <1> 	call	_vbe3_pmfn_srs_7
  1282                              <1> 	
  1283 00001A5C 6683F84F            <1> 	cmp	ax, 004Fh
  1284 00001A60 7520                <1> 	jne	short _vbe3_pmfn_srs_4
  1285                              <1> 
  1286 00001A62 09DB                <1> 	or	ebx, ebx  ; kernel ('sysvideo') ?
  1287 00001A64 741C                <1> 	jz	short _vbe3_pmfn_srs_4 ; yes
  1288                              <1> 
  1289                              <1> 	; the caller is user
  1290 00001A66 51                  <1> 	push	ecx ; *
  1291 00001A67 89F9                <1> 	mov	ecx, edi ; state buffer size
  1292 00001A69 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK ; source
  1293                              <1> 					; (vbe3 pmi buff)
  1294 00001A6E 89DF                <1> 	mov	edi, ebx	; destination (user buff)
  1295 00001A70 E8E4F20000          <1> 	call	transfer_to_user_buffer
  1296 00001A75 59                  <1> 	pop	ecx ; *
  1297 00001A76 7205                <1> 	jc	short _vbe3_pmfn_srs_3
  1298                              <1> 
  1299 00001A78 29C0                <1> 	sub	eax, eax
  1300 00001A7A B04F                <1> 	mov	al, 4Fh
  1301 00001A7C C3                  <1> 	retn
  1302                              <1> 
  1303                              <1> 	; 24/01/2021
  1304                              <1> _vbe3_pmfn_srs_3:
  1305 00001A7D B84F010000          <1> 	mov	eax, 014Fh
  1306                              <1> _vbe3_pmfn_srs_4:
  1307 00001A82 C3                  <1> 	retn
  1308                              <1> _vbe3_pmfn_srs_5:
  1309 00001A83 31C0                <1> 	xor	eax, eax
  1310 00001A85 FEC4                <1> 	inc	ah
  1311                              <1> 	; eax = 0100h, function is not supported
  1312 00001A87 C3                  <1> 	retn
  1313                              <1> 
  1314                              <1> _vbe3_pmfn_srs_6:
  1315                              <1> 	; restore video state
  1316                              <1> 	; 24/01/2021
  1317                              <1> 	;pop	ebx ; *
  1318                              <1> 	; 23/01/2021
  1319 00001A88 09DB                <1> 	or	ebx, ebx ; 0 ?	
  1320 00001A8A 7412                <1> 	jz	short _vbe3_pmfn_srs_7 ; 'sysvideo' call
  1321                              <1> 	; 24/01/2021
  1322                              <1> 	;jz	_vbe3_pmfn_srs_8
  1323 00001A8C 89DE                <1> 	mov	esi, ebx
  1324                              <1> 	; esi = user's video state buffer
  1325 00001A8E 51                  <1> 	push	ecx ; *
  1326 00001A8F 89F9                <1> 	mov	ecx, edi ; state buffer size
  1327 00001A91 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; destination
  1328                              <1> 					; (vbe3 pmi buff)
  1329                              <1> 	;mov	esi, ebx	; source (user buff)
  1330 00001A96 E808F30000          <1> 	call	transfer_from_user_buffer
  1331 00001A9B 59                  <1> 	pop	ecx ; *
  1332 00001A9C 72DF                <1> 	jc	short _vbe3_pmfn_srs_3
  1333                              <1> _vbe3_pmfn_srs_7:
  1334 00001A9E 53                  <1> 	push	ebx ; *
  1335                              <1> 	; restore video state
  1336                              <1> 	;xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  1337                              <1> 	;mov	ax, 4F04h
  1338                              <1> 	;call	int10h_32bit_pmi
  1339                              <1> 	; 17/01/2021
  1340 00001A9F E81EFFFFFF          <1> 	call	_vbe3_pmfn_srs_8
  1341 00001AA4 5B                  <1> 	pop	ebx ; *
  1342 00001AA5 C3                  <1> 	retn
  1343                              <1> 
  1344                              <1> VIDEO_STATE:
  1345                              <1> 	; 26/06/2016
  1346                              <1> 	; 12/05/2016
  1347                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1348                              <1> 
  1349                              <1> ;---------------------------------------------------
  1350                              <1> ; VIDEO STATE
  1351                              <1> ;  RETURNS THE CURRENT VIDEO STATE IN AX
  1352                              <1> ;  AH = NUMBER OF COLUMNS ON THE SCREEN
  1353                              <1> ;  AL = CURRENT VIDEO MODE
  1354                              <1> ;  BH = CURRENT ACTIVE PAGE
  1355                              <1> ;---------------------------------------------------
  1356                              <1> 
  1357 00001AA6 8A25[D0660000]      <1> 	mov	ah, [CRT_COLS]	; GET NUMBER OF COLUMNS
  1358 00001AAC A0[CE660000]        <1> 	mov	al, [CRT_MODE]	; CURRENT MODE
  1359                              <1> 	;movzx	esi, al
  1360                              <1> 	;mov	ah, [esi+M6] 
  1361                              <1> 	; BH = active page
  1362 00001AB1 8A3D[B6770100]      <1> 	mov	bh, [ACTIVE_PAGE] ; GET CURRENT ACTIVE PAGE
  1363 00001AB7 FA                  <1> 	cli	; 02/01/2017
  1364 00001AB8 5D                  <1> 	pop	ebp		; RECOVER REGISTERS
  1365 00001AB9 5F                  <1> 	pop	edi
  1366 00001ABA 5E                  <1> 	pop	esi
  1367 00001ABB 59                  <1> 	pop	ecx		; DISCARD SAVED BX
  1368 00001ABC EB41                <1> 	jmp	short M15	; RETURN TO CALLER
  1369                              <1> 
  1370                              <1> set_mode_ncm:
  1371                              <1> 	; 17/11/2020 (TRDOS 386 v2.0.3)
  1372                              <1> 	; 04/07/2016 - TRDOS 386 (TRDOS v2.0)
  1373                              <1> 	; set mode without clearing the video memory
  1374                              <1> 	; (ony for graphics modes)
  1375                              <1> 
  1376                              <1> 	;cmp	al, 7 ; IBM PC CGA modes
  1377                              <1> 	;jna	short SET_MODE ; normal function (clear)
  1378                              <1> 	;; do not clear memory
  1379                              <1> 	;;mov	[noclearmem], al ; > 0
  1380                              <1> 	;mov	byte [noclearmem], 80h ; 17/11/2020
  1381                              <1> 	;call	_set_mode
  1382                              <1> 	;mov	byte [noclearmem], 0
  1383                              <1>         ;jmp     short VIDEO_RETURN
  1384                              <1> 
  1385                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  1386 00001ABE 0C80                <1> 	or	al, 80h ; not clear memory option
  1387                              <1> 
  1388                              <1> 	; 05/12/2020
  1389                              <1> 	; 27/11/2020
  1390                              <1> 	; 17/11/2020
  1391                              <1> 	; 08/08/2016, 10/08/2016
  1392                              <1> 	; 29/07/2016, 30/07/2016
  1393                              <1> 	; 25/07/2016, 26/07/2016, 27/07/2016
  1394                              <1> 	; 02/07/2016, 18/07/2016, 23/07/2016
  1395                              <1> 	; 24/06/2016, 26/06/2016
  1396                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  1397                              <1> SET_MODE:
  1398                              <1> 	; For 32 bit TRDOS and Retro UNIX 386:
  1399                              <1> 	;	valid video mode: 03h only!
  1400                              <1> 	;	(VGA modes will be selected with another routine)
  1401                              <1> 	;
  1402                              <1> 	; set_txt_mode ; 80*25 (16 fore colors, 8 back colors)
  1403                              <1> 
  1404                              <1> 	; 27/11/2020
  1405                              <1> 	
  1406                              <1> 	; Check if current mode is 
  1407                              <1> 	; Bochs/Plex86 VBE graphics mode
  1408 00001AC0 803D[CE660000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; VESA VBE graphics mode
  1409 00001AC7 7220                <1> 	jb	short _set_mode_      ; signature  	
  1410                              <1> 				      ; VBE mode number is in	 
  1411                              <1> 				      ; [video_mode] bit 0to8
  1412 00001AC9 88C3                <1> 	mov	bl, al ; save video mode
  1413 00001ACB E87C230000          <1> 	call	dispi_get_enable
  1414 00001AD0 50                  <1> 	push	eax ; save current VBE dispi status 
  1415                              <1> 	; Disable Bochs/Plex86 VBE dispi
  1416                              <1> 	;mov	ax, 0 ; VBE_DISPI_DISABLED 
  1417 00001AD1 31C0                <1> 	xor	eax, eax ; 0 
  1418 00001AD3 E849230000          <1> 	call	dispi_set_enable
  1419 00001AD8 88D8                <1> 	mov	al, bl ; restore video mode
  1420 00001ADA E827000000          <1> 	call	_set_mode
  1421 00001ADF 58                  <1> 	pop	eax ; restore current VBE dispi status 
  1422 00001AE0 7313                <1> 	jnc	short VIDEO_RETURN
  1423                              <1> 	; ! unimplemented or invalid video mode number !
  1424                              <1> 	; VBE dispi must be enabled again
  1425                              <1> 	; (return to run on current VBE graphics mode)
  1426                              <1> 	;;mov	al, [video_mode+1] ; bit 8 to 15
  1427                              <1> 	;;and	al, 0C0h ; isolate bit 14 and bit 15 
  1428                              <1> 	;;or	al, 1 ; VBE_DISPI_ENABLED
  1429 00001AE2 E83A230000          <1> 	call	dispi_set_enable
  1430 00001AE7 EB07                <1> 	jmp	short _video_func_err
  1431                              <1> 
  1432                              <1> _set_mode_:
  1433                              <1> 	; VGA bios (non-VBE) 'setmode' procedure
  1434                              <1> 
  1435                              <1> 	; 26/11/2020 (TRDOS v2.0.3)
  1436                              <1> 	
  1437                              <1> ;------------------------------------------------------
  1438                              <1> ; SET MODE					      :
  1439                              <1> ;	THIS ROUTINE INITIALIZES THE ATTACHMENT TO    :
  1440                              <1> ;	THE SELECTED MODE, THE SCREEN IS BLANKED.     :
  1441                              <1> ; INPUT						      :
  1442                              <1> ;	(AL) - MODE SELECTED (RANGE 0-7)	      :
  1443                              <1> ; OUTPUT					      :
  1444                              <1> ;	NONE					      :
  1445                              <1> ;------------------------------------------------------
  1446                              <1> 
  1447 00001AE9 E818000000          <1> 	call	_set_mode ; 24/06/2016 (set_txt_mode)
  1448                              <1> 	; 26/11/2020
  1449 00001AEE 7305                <1> 	jnc	short VIDEO_RETURN
  1450                              <1> 
  1451                              <1> 	; 26/11/2020
  1452                              <1> _video_func_err:
  1453 00001AF0 31C0                <1> 	xor	eax, eax ; function call failed
  1454 00001AF2 48                  <1> 	dec	eax  ; 0FFFFFFFFh ; - 1	
  1455 00001AF3 EB05                <1> 	jmp	short _video_return	
  1456                              <1> 
  1457                              <1> ; 12/05/2016
  1458                              <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1459                              <1> 
  1460                              <1> ;-----	NORMAL RETURN FROM ALL VIDEO RETURNS
  1461                              <1> 
  1462                              <1> VIDEO_RETURN:
  1463 00001AF5 A1[0C840100]        <1> 	mov	eax, [video_eax] ; 12/05/2016
  1464                              <1> _video_return:
  1465 00001AFA FA                  <1> 	cli ; 02/01/2017
  1466 00001AFB 5D                  <1> 	pop	ebp ; ******** ; 26/11/2020
  1467 00001AFC 5F                  <1> 	pop	edi ; *******
  1468 00001AFD 5E                  <1> 	pop	esi ; ******
  1469 00001AFE 5B                  <1> 	pop	ebx ; *****
  1470                              <1> M15:	; VIDEO_RETURN_C
  1471                              <1> 	;;15/01/2017
  1472                              <1> 	; 02/01/2017
  1473                              <1> 	;;mov	byte [intflg], 0
  1474                              <1> 	;
  1475 00001AFF 59                  <1> 	pop	ecx ; **** ; 26/11/2020
  1476 00001B00 5A                  <1> 	pop	edx ; ***
  1477 00001B01 1F                  <1> 	pop	ds  ; **
  1478 00001B02 07                  <1> 	pop	es  ; *	; RECOVER SEGMENTS
  1479 00001B03 CF                  <1> 	iretd		; ALL DONE
  1480                              <1> 
  1481                              <1> set_txt_mode:
  1482                              <1> 	
  1483                              <1> 	; 29/07/2016
  1484                              <1> 	; 27/06/2016
  1485 00001B04 B003                <1> 	mov	al, 3 ; 26/11/2020 (bit 7 = 0)
  1486                              <1> 
  1487                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  1488                              <1> 	;mov	byte [noclearmem], 0
  1489                              <1> 
  1490                              <1> ; 04/08/2022
  1491                              <1> ; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  1492                              <1> ; 12/04/2021
  1493                              <1> ; 10/08/2016
  1494                              <1> ; 08/08/2016
  1495                              <1> ; 30/07/2016
  1496                              <1> ; 29/07/2016
  1497                              <1> ; 25/07/2016 - 26/07/2016 - 27/07/2016
  1498                              <1> ; 07/07/2016 - 18/07/2016 - 23/07/2016
  1499                              <1> ; 02/07/2016 - 03/07/2016 - 04/07/2016
  1500                              <1> ; 26/06/2016
  1501                              <1> ; 24/06/2016 (set_txt_mode -> _set_mode)
  1502                              <1> ; 17/06/2016
  1503                              <1> ; 29/05/2016
  1504                              <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1505                              <1> 
  1506                              <1> _set_mode:
  1507                              <1> 	; 12/12/2020
  1508                              <1> 	; 26/11/2020
  1509                              <1> 	; call from 'biosfn_set_video_mode'
  1510                              <1> 	;	(bochs/plex86 video bios code)
  1511                              <1> 	; call from 'SET_MODE'
  1512                              <1> 	;	(TRDOS 386 v2 default, IBM PC/AT rom bios code)
  1513                              <1> 	; continue from 'set_txt_mode'	
  1514                              <1> 
  1515                              <1> 	; INPUT:
  1516                              <1> 	;	al = VGA video mode
  1517                              <1> 	; RETURN:
  1518                              <1> 	;	cf = 1 -> video mode not implemented
  1519                              <1> 	;	cf = 0 -> OK
  1520                              <1> 	;
  1521                              <1> 	; Modified registers: eax, bx, ecx, esi, edi, (ebp)
  1522                              <1> 
  1523                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  1524                              <1> 	; no clear memory option 
  1525                              <1> 	; (from mode number byte bit 7)
  1526 00001B06 88C4                <1> 	mov	ah, al
  1527 00001B08 80E480              <1> 	and	ah, 80h
  1528                              <1> 	;mov	[noclearmem], al
  1529 00001B0B 8825[1B840100]      <1> 	mov	[noclearmem], ah
  1530                              <1> 	;and	al, 7Fh ; clear bit 7
  1531                              <1> 	;;xor	[noclearmem], al ; clear bit 0 to 6
  1532                              <1> 	; 26/11/2020
  1533 00001B11 30E0                <1> 	xor	al, ah ; and al, 7Fh
  1534                              <1> 
  1535                              <1> 	; 19/11/2020
  1536                              <1> 
  1537                              <1> 	; Video mode 03h action principle:
  1538                              <1> 	;
  1539                              <1> 	; for case 1:
  1540                              <1> 	; Current mode is 03h and next/requested mode is not 03h
  1541                              <1> 	;	- save mode (set mode 03h flag)
  1542                              <1> 	;	- save 8 video pages (which are will be restored)	
  1543                              <1> 	;	- save active page number (which will be reactivated)
  1544                              <1> 	;	- set active page to 0 always (no multi screen)
  1545                              <1> 	;	- save 8 cursor positions (which will be restored)
  1546                              <1> 	; 	- use 'noclearmem' option
  1547                              <1> 	;	[p_crt_mode] = 0 -> 03h 
  1548                              <1> 	;
  1549                              <1> 	; for case 2:
  1550                              <1> 	; Current mode is 03h and next/requested mode is also 03h
  1551                              <1> 	;	- clear active video page if 'noclearmem' is not set
  1552                              <1> 	;	[p_crt_mode] = 0 -> 80h -> 0
  1553                              <1> 	;
  1554                              <1> 	; for case 3:
  1555                              <1> 	; Current mode is not 03h and next/requested mode is 03h
  1556                              <1> 	;	- restore video pages (8 video pages were saved)	
  1557                              <1> 	;	- restore active page number (which were saved)
  1558                              <1> 	;	- restore 8 cursor positions (which were saved)
  1559                              <1> 	;	- reset/clear mode 03h flag
  1560                              <1> 	;	[p_crt_mode] = 03h -> 0
  1561                              <1> 	;
  1562                              <1> 	; for case 4:
  1563                              <1> 	; Current mode is not 03h and next/requested mode is not 03h
  1564                              <1> 	; 	- use 'noclearmem' option
  1565                              <1> 	;	- set active page to 0 always
  1566                              <1> 	;	[p_crt_mode] = 03h -> 83h -> 03h
  1567                              <1> 	;
  1568                              <1> 	; initial (boot time) values:
  1569                              <1> 	;	[p_crt_mode] = 0 ("there isn't a page backup, yet")
  1570                              <1> 	;	  [CRT_MODE] = 3 (kernel's starting mode)
  1571                              <1> 
  1572                              <1> 	; 26/11/2020
  1573 00001B13 3C03                <1> 	cmp	al, 03h	    ; mode 3, 80x25 text, 16 colors
  1574 00001B15 7515                <1> 	jne	short _sm_0 ; (default mode for TRDOS 386 mainprog)
  1575                              <1> 
  1576                              <1> 	; case 2 or case 3
  1577                              <1> 
  1578                              <1> 	; check current video mode if it is 03h
  1579 00001B17 08E4                <1> 	or	ah, ah ; 80h or 0 ('noclearmem' option)
  1580 00001B19 7521                <1> 	jnz	short _sm_1 ; do not clear display page
  1581                              <1>  	
  1582                              <1> 	; 26/11/2020
  1583                              <1> 	; Note:
  1584                              <1> 	; [CRT_MODE] = 0FFh for VESA VBE video modes
  1585                              <1> 	; [video_mode] = standard VGA and VESA VBE video modes
  1586                              <1> 	
  1587 00001B1B 3805[CE660000]      <1> 	cmp	[CRT_MODE], al	; 03h
  1588 00001B21 7520                <1> 	jne	short _sm_2	; case 3 ([p_crt_mode] = 03h)
  1589                              <1> 
  1590                              <1> 	; case 2
  1591                              <1> 
  1592                              <1> 	; [p_crt_mode] = 0
  1593                              <1> 
  1594                              <1> 	; 19/11/2020
  1595                              <1> 	; If '_set_mode' procedure is called for video mode 3
  1596                              <1> 	;     while video mode is 3, video page will be cleared
  1597                              <1> 	;     and cursor position of video page will be reset.	 
  1598                              <1> 
  1599                              <1> 	; clear display page
  1600 00001B23 C605[19840100]80    <1> 	mov	byte [p_crt_mode], 80h ; clear page sign
  1601 00001B2A EB1C                <1> 	jmp	short _sm_3	; bypass save video page routine
  1602                              <1> _sm_0:
  1603                              <1> 	; case 1 or case 4
  1604                              <1> 
  1605                              <1> 	; 05/12/2020
  1606 00001B2C 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 3 ; is current mode 03h?
  1607 00001B33 7507                <1> 	jne	short _sm_1	; case 4 ; [p_crt_mode] = 03h
  1608                              <1> 	
  1609                              <1> 	; case 1
  1610                              <1> 	; [p_crt_mode] = 0
  1611                              <1> 
  1612                              <1> 	; 19/11/2020
  1613                              <1> 	; If '_set_mode' procedure is called for a video mode
  1614                              <1> 	;     except video mode 3 while current video mode
  1615                              <1> 	;     is 3, all video pages of mode 3 will be copied 
  1616                              <1> 	;     to 98000h address as backup, before mode change.
  1617                              <1> 	
  1618                              <1> _sm_save_pm:
  1619                              <1> 	; 12/12/2020
  1620                              <1> 	;; 03/07/2016
  1621                              <1> 	;; save video pages
  1622                              <1> 	;mov	esi, 0B8000h
  1623                              <1> 	;mov	edi, 98000h ; 30/07/2016
  1624                              <1> 	;mov	ecx, (0B8000h-0B0000h)/4
  1625                              <1> 	;rep	movsd
  1626                              <1> 
  1627                              <1> 	;mov	byte [p_crt_mode], 3 ; previous mode, backup sign
  1628                              <1> 	;; 26/11/2020
  1629                              <1> 	;xchg	cl, [ACTIVE_PAGE]
  1630                              <1> 	;mov	[p_crt_page], cl  ; save as previous active page
  1631                              <1> 	;
  1632                              <1> 	;; save cursor positions
  1633                              <1> 	;mov	esi, CURSOR_POSN
  1634                              <1> 	;mov	edi, cursor_pposn ; cursor positions backup
  1635                              <1> 	;mov	cl, 4
  1636                              <1> 	;rep	movsd
  1637                              <1> 
  1638                              <1> 	; 12/12/2020
  1639 00001B35 E86E020000          <1> 	call	save_mode3_multiscreen
  1640                              <1> 
  1641                              <1> 	; 29/07/2016
  1642                              <1> 	;;mov	[ACTIVE_PAGE], cl ; 0
  1643                              <1> 	;xchg	cl, [ACTIVE_PAGE]
  1644                              <1> 	;mov	[p_crt_page], cl  ; previous page (for mode 3)
  1645                              <1> 	
  1646                              <1> 	; [ACTIVE_PAGE] = 0 
  1647                              <1> 	
  1648 00001B3A EB07                <1> 	jmp	short _sm_2	; case 1 - 19/11/2020
  1649                              <1> _sm_1:
  1650                              <1> 	; 26/11/2020
  1651                              <1> 	; 19/11/2020
  1652                              <1> 	
  1653                              <1> 	; case 4
  1654 00001B3C 800D[19840100]80    <1> 	or	byte [p_crt_mode], 80h 
  1655                              <1> 				; here [p_crt_mode] must be 83h
  1656                              <1> 				;	  (for case 4)
  1657                              <1> 				; (because video mode 03h
  1658                              <1> 				; was changed before as in case 1)
  1659                              <1> 
  1660                              <1> _sm_2:	; case 4 (jump to _sm_2) - 19/11/2020 
  1661                              <1> 
  1662                              <1> 	; 19/11/2020
  1663                              <1> 	; case 3
  1664                              <1> 	; If '_set_mode' procedure is called for video mode 3
  1665                              <1> 	;     while video mode is not 3 and if there is video
  1666                              <1> 	;     page backup for video mode 3, all (of 8) mode 3
  1667                              <1> 	;     video pages will be restored from 98000h.
  1668                              <1> 
  1669 00001B43 A2[CE660000]        <1> 	mov	[CRT_MODE], al  ; save mode in global variable
  1670                              <1> _sm_3:
  1671                              <1> 	; 04/08/2022 (TRDOS 386 v2.0.5)
  1672                              <1> 	; 30/07/2016
  1673                              <1> 	; 26/07/2016
  1674                              <1> 	; 25/07/2016
  1675                              <1> 	; set_mode_vga:
  1676                              <1> 	; 18/07/2016
  1677                              <1> 	; 14/07/2016
  1678                              <1> 	; 09/07/2016
  1679                              <1> 	; 04/07/2016
  1680                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  1681                              <1> 	; /// video mode 13h ///
  1682                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  1683                              <1> 	; vgabios-0.7a (2011)
  1684                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  1685                              <1> 	; 'vgabios.c', 'vgatables.h'
  1686                              <1> 	;
  1687                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  1688                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  1689                              <1> 	;
  1690 00001B48 88C4                <1> 	mov	ah, al
  1691 00001B4A B910000000          <1> 	mov	ecx, vga_mode_count
  1692 00001B4F BE[EA660000]        <1> 	mov	esi, vga_modes
  1693 00001B54 31DB                <1> 	xor	ebx, ebx
  1694                              <1> _sm_4:
  1695 00001B56 AC                  <1> 	lodsb
  1696 00001B57 38C4                <1> 	cmp	ah, al
  1697 00001B59 7406                <1> 	je	short _sm_5
  1698 00001B5B FEC3                <1> 	inc	bl
  1699 00001B5D E2F7                <1> 	loop	_sm_4
  1700                              <1> 
  1701                              <1> 	; UNIMPLEMENTED VIDEO MODE !
  1702                              <1> 	;xor	eax, eax
  1703                              <1>         ;mov	[video_eax], eax ; 0
  1704                              <1> 
  1705                              <1> 	; 26/11/2020
  1706 00001B5F F9                  <1> 	stc	; unimplemented video mode ! (cf=1)
  1707                              <1> 
  1708 00001B60 C3                  <1> 	retn
  1709                              <1> 
  1710                              <1> ;-----	EBX POINTS TO CORRECT ROW OF INITIALIZATION TABLE
  1711                              <1> 
  1712                              <1> _sm_5: 	; 25/07/2016
  1713                              <1> 	;mov	esi, ebx
  1714                              <1> 	;add	esi, vga_memmodel
  1715                              <1> 	;mov	al, [esi]
  1716                              <1> 	; 19/11/2020
  1717 00001B61 8A83[3A670000]      <1> 	mov	al, [ebx+vga_memmodel]
  1718 00001B67 A2[32840100]        <1> 	mov	[VGA_MTYPE], al
  1719                              <1> 
  1720 00001B6C 89DF                <1> 	mov	edi, ebx
  1721 00001B6E 81C7[4A670000]      <1> 	add	edi, vga_dac_s 	
  1722 00001B74 C0E302              <1> 	shl	bl, 2 ; byte -> dword
  1723 00001B77 81C3[FA660000]      <1> 	add	ebx, vga_mode_tbl_ptr
  1724                              <1> 
  1725                              <1> 	;mov	dword [VGA_BASE], 0B8000h
  1726                              <1> 	;cmp	ah, 0Dh ; [CRT_MODE]
  1727                              <1> 	;jb	short M9 
  1728                              <1> 	;mov	dword [VGA_BASE], 0A0000h
  1729                              <1> ;M9:
  1730 00001B7D 8B33                <1> 	mov	esi, [ebx]
  1731 00001B7F 89F3                <1> 	mov	ebx, esi
  1732 00001B81 83C614              <1> 	add	esi, vga_p_cm_pos ; ebx + 20
  1733 00001B84 668B06              <1> 	mov	ax, [esi]       ; get the cursor mode from the table
  1734 00001B87 66A3[E7660000]      <1> 	mov	[CURSOR_MODE], ax ; save cursor mode (initial value)
  1735                              <1> 	; al = 6, ah = 7
  1736                              <1> 	; al = 0Dh, ah = 0Eh ; 25/07/2016
  1737 00001B8D E893020000          <1> 	call	cursor_shape_fix
  1738                              <1> 	; al = 14, ah = 15 (If [CHAR_HEIGHT] = 16)
  1739 00001B92 668906              <1> 	mov	[esi], ax
  1740                              <1> 
  1741 00001B95 56                  <1> 	push	esi ; *	
  1742                              <1> 
  1743                              <1> 	; 17/04/2021
  1744 00001B96 B603                <1> 	mov	dh, 03h
  1745                              <1> 	;
  1746 00001B98 8A25[D5660000]      <1> 	mov	ah, [VGA_MODESET_CTL]
  1747 00001B9E 80E408              <1> 	and	ah, 8 ; default palette loading ?
  1748 00001BA1 7520                <1> 	jnz	short _sm_6
  1749                              <1> 	;mov	dx, 3C6h ; VGAREG_PEL_MASK (DAC mask register)
  1750                              <1> 	; 17/04/2021
  1751 00001BA3 B2C6                <1> 	mov	dl, 0C6h
  1752 00001BA5 B0FF                <1> 	mov	al, 0FFh ; PEL mask
  1753 00001BA7 EE                  <1> 	out	dx, al
  1754 00001BA8 8A27                <1> 	mov	ah, [edi] ; DAC model (selection number)
  1755 00001BAA E8F80F0000          <1> 	call	load_dac_palette
  1756                              <1> 	; ecx = 0
  1757 00001BAF F605[D5660000]02    <1> 	test	byte [VGA_MODESET_CTL], 2 ; gray scale summing
  1758 00001BB6 740B                <1> 	jz	short _sm_6
  1759 00001BB8 53                  <1> 	push	ebx
  1760 00001BB9 29DB                <1> 	sub	ebx, ebx ; sub bl, bl
  1761                              <1> 	;mov	cx, 256
  1762                              <1> 	; 02/08/2022
  1763                              <1> 	;sub	ecx, ecx
  1764                              <1> 	; ecx = 0
  1765 00001BBB FEC5                <1> 	inc	ch
  1766                              <1> 	; ecx = 256
  1767 00001BBD E837100000          <1> 	call	gray_scale_summing
  1768 00001BC2 5B                  <1> 	pop	ebx	
  1769                              <1> _sm_6:
  1770                              <1> 	; Reset Attribute Ctl flip-flop
  1771                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  1772                              <1>  	; 17/03/2021
  1773 00001BC3 B2DA                <1> 	mov	dl, 0DAh ; dx = 3DAh
  1774 00001BC5 EC                  <1> 	in	al, dx
  1775                              <1> 	; Set Attribute Ctl
  1776 00001BC6 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  1777 00001BC8 83C623              <1> 	add	esi, 35  ; actl regs
  1778 00001BCB 30E4                <1> 	xor	ah, ah ; 0
  1779                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  1780                              <1> 	; 17/04/2021
  1781 00001BCD B2C0                <1> 	mov	dl, 0C0h
  1782                              <1> _sm_7:
  1783 00001BCF 88E0                <1> 	mov	al, ah
  1784 00001BD1 EE                  <1> 	out	dx, al ; index
  1785 00001BD2 AC                  <1> 	lodsb
  1786                              <1> 	; DX = 3C0h = VGAREG_ACTL_WRITE_DATA
  1787 00001BD3 EE                  <1> 	out	dx, al ; value
  1788 00001BD4 FEC4                <1> 	inc	ah
  1789 00001BD6 80FC14              <1> 	cmp	ah, 20 ; number of actl registers
  1790 00001BD9 72F4                <1> 	jb	short _sm_7
  1791                              <1> 	;
  1792 00001BDB 88E0                <1> 	mov	al, ah ; 20
  1793 00001BDD EE                  <1> 	out	dx, al ; index
  1794 00001BDE 28C0                <1> 	sub	al, al ; 0
  1795 00001BE0 EE                  <1> 	out	dx, al ; value
  1796                              <1> 	;
  1797                              <1> 	; Set Sequencer Ctl
  1798 00001BE1 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  1799 00001BE3 83C605              <1> 	add	esi, 5 ; sequ regs
  1800                              <1> 	;
  1801                              <1> 	;mov	dx, 3C4h  ; VGAREG_SEQU_ADDRESS
  1802                              <1> 	; 17/04/2021
  1803 00001BE6 B2C4                <1> 	mov	dl, 0C4h
  1804 00001BE8 EE                  <1> 	out	dx, al ; 0
  1805                              <1> 	;inc	dx ; 3C5h ; VGAREG_SEQU_DATA
  1806                              <1> 	; 17/04/2021
  1807 00001BE9 FEC2                <1> 	inc	dl ; dx = 3C5h	
  1808 00001BEB B003                <1> 	mov	al, 3
  1809 00001BED EE                  <1> 	out	dx, al
  1810 00001BEE B401                <1> 	mov	ah, 1	
  1811                              <1> _sm_8:
  1812 00001BF0 88E0                <1> 	mov	al, ah
  1813                              <1> 	;mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  1814                              <1> 	;dec	dx
  1815                              <1> 	; 17/04/2021
  1816 00001BF2 FECA                <1> 	dec	dl ; dx = 3C4h
  1817 00001BF4 EE                  <1> 	out	dx, al ; index
  1818 00001BF5 AC                  <1> 	lodsb
  1819                              <1> 	;inc	dx ; 3C5h ; VGAREG_SEQU_DATA
  1820                              <1> 	; 17/04/2021
  1821 00001BF6 FEC2                <1> 	inc	dl
  1822 00001BF8 EE                  <1> 	out	dx, al
  1823 00001BF9 80FC04              <1> 	cmp	ah, 4 ; number of sequ regs
  1824 00001BFC 7304                <1> 	jnb	short _sm_9		
  1825 00001BFE FEC4                <1> 	inc	ah 
  1826 00001C00 EBEE                <1> 	jmp	short _sm_8
  1827                              <1> _sm_9:
  1828                              <1> 	; Set Grafx Ctl
  1829 00001C02 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  1830 00001C04 83C637              <1> 	add	esi, 55 ; grdc regs
  1831 00001C07 30E4                <1> 	xor	ah, ah ; 0
  1832                              <1> _sm_10:
  1833 00001C09 88E0                <1> 	mov	al, ah
  1834                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  1835                              <1> 	; 17/04/2021
  1836 00001C0B B2CE                <1> 	mov	dl, 0CEh
  1837 00001C0D EE                  <1> 	out	dx, al	
  1838 00001C0E AC                  <1> 	lodsb
  1839                              <1> 	;inc	dx ; 3CFh ; VGAREG_GRDC_DATA
  1840                              <1> 	; 17/04/2021
  1841 00001C0F FEC2                <1> 	inc	dl ; 3CFh
  1842 00001C11 EE                  <1> 	out	dx, al
  1843 00001C12 FEC4                <1> 	inc	ah
  1844 00001C14 80FC09              <1> 	cmp	ah, 9 ; number of grdc regs
  1845 00001C17 72F0                <1> 	jb	short _sm_10
  1846                              <1> 	;
  1847                              <1> 	; Disable CRTC write protection
  1848                              <1> 	;mov	dx, 3D4h  ; VGAREG_VGA_CRTC_ADDRESS
  1849                              <1> 	; 17/04/2021
  1850 00001C19 B2D4                <1> 	mov	dl, 0D4h
  1851                              <1> 	;mov	al, 11h
  1852                              <1> 	;out	dx, al
  1853                              <1> 	;inc	dx
  1854                              <1> 	;sub	al, al
  1855                              <1> 	;out	dx, al
  1856 00001C1B 66B81100            <1> 	mov	ax, 11h
  1857 00001C1F 66EF                <1> 	out	dx, ax
  1858 00001C21 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  1859 00001C23 83C60A              <1> 	add	esi, 10 ; crtc regs
  1860                              <1> 	; ah = 0
  1861                              <1> _sm_11:
  1862 00001C26 88E0                <1> 	mov	al, ah
  1863                              <1> 	; dx = 3D4h = VGAREG_VGA_CRTC_ADDRESS
  1864 00001C28 EE                  <1> 	out	dx, al ; index
  1865 00001C29 AC                  <1> 	lodsb
  1866                              <1> 	;inc	dx  ; VGAREG_VGA_CRTC_ADDRESS + 1
  1867                              <1> 	; 17/04/2021
  1868 00001C2A FEC2                <1> 	inc	dl
  1869 00001C2C EE                  <1> 	out	dx, al ; value
  1870 00001C2D 80FC18              <1> 	cmp	ah, 24 ; number of crtc registers - 1
  1871 00001C30 7306                <1> 	jnb	short _sm_12
  1872 00001C32 FEC4                <1> 	inc	ah
  1873                              <1> 	;dec	dx ; 3D4h
  1874                              <1> 	; 17/04/2021
  1875 00001C34 FECA                <1> 	dec	dl
  1876 00001C36 EBEE                <1> 	jmp	short _sm_11
  1877                              <1> _sm_12:
  1878                              <1> 	; Set the misc register
  1879                              <1> 	;mov	dx, 3CCh ; VGAREG_READ_MISC_OUTPUT
  1880                              <1> 	; 17/04/2021
  1881 00001C38 B2CC                <1> 	mov	dl, 0CCh
  1882 00001C3A 8A4309              <1> 	mov	al, [ebx+9] ; misc reg
  1883 00001C3D EE                  <1> 	out	dx, al
  1884                              <1> 	;
  1885                              <1> 	; Enable video
  1886                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  1887                              <1> 	; 17/04/2021
  1888 00001C3E B2C0                <1> 	mov	dl, 0C0h
  1889 00001C40 B020                <1> 	mov	al, 20h  
  1890 00001C42 EE                  <1>         out     dx, al   ; set bit 5 to 1
  1891                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  1892                              <1> 	; 17/04/2021
  1893 00001C43 B2DA                <1> 	mov	dl, 0DAh
  1894 00001C45 EC                  <1> 	in	al, dx
  1895                              <1> 	;
  1896                              <1> 	; 17/11/2020
  1897                              <1> 	;cmp	byte [noclearmem], 0
  1898                              <1>         ;ja	short _sm_15
  1899                              <1> 
  1900 00001C46 F605[1B840100]80    <1> 	test	byte [noclearmem], 80h
  1901 00001C4D 753B                <1> 	jnz	short _sm_15	
  1902                              <1> 
  1903                              <1> 	; 29/07/2016
  1904 00001C4F 31C0                <1> 	xor	eax, eax
  1905                              <1> 	;mov	ecx, 4000h ; 16K words (32K)
  1906                              <1> 	; 02/08/2022
  1907 00001C51 29C9                <1> 	sub	ecx, ecx
  1908 00001C53 B540                <1> 	mov	ch, 40h
  1909                              <1> 	; ecx = 4000h 
  1910 00001C55 803D[32840100]02    <1> 	cmp     byte [VGA_MTYPE], 2  ; CTEXT, MTEXT, CGA
  1911 00001C5C 7715                <1> 	ja	short _sm_14    ; no ? (0A0000h)
  1912 00001C5E BF00800B00          <1> 	mov	edi, 0B8000h
  1913 00001C63 7409                <1> 	je	short _sm_13	; CGA graphics mode
  1914                              <1> 	; 08/08/2016
  1915 00001C65 A3[2E840100]        <1> 	mov	[VGA_INT43H], eax ; 0 ; default font 
  1916 00001C6A 66B82007            <1> 	mov	ax, 0720h	; CGA text mode
  1917                              <1> _sm_13:
  1918 00001C6E F366AB              <1> 	rep	stosw
  1919 00001C71 EB17                <1> 	jmp	short _sm_15
  1920                              <1> 
  1921                              <1> _sm_14:
  1922 00001C73 BF00000A00          <1> 	mov	edi, 0A0000h
  1923                              <1> 	; ecx = 16384 dwords (64K)
  1924                              <1> 	;mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  1925                              <1> 	; 17/04/2021
  1926 00001C78 B2C4                <1> 	mov	dl, 0C4h
  1927 00001C7A B002                <1> 	mov	al, 2
  1928 00001C7C EE                  <1> 	out	dx, al
  1929                              <1> 	;mov	dx, 3C5h ; VGAREG_SEQU_DATA
  1930                              <1> 	;inc	dx
  1931                              <1> 	; 17/04/2021
  1932 00001C7D FEC2                <1> 	inc	dl ; 3C5h
  1933 00001C7F EC                  <1> 	in	al, dx ; mmask
  1934                              <1> 	;push	ax
  1935                              <1> 	; 12/04/2021
  1936 00001C80 50                  <1> 	push	eax
  1937 00001C81 B00F                <1> 	mov	al, 0Fh ; all planes
  1938 00001C83 EE                  <1> 	out	dx, al
  1939 00001C84 30C0                <1> 	xor	al, al ; 0
  1940 00001C86 F3AB                <1> 	rep	stosd	; ecx = 163684 (64K)
  1941                              <1> 	;pop	ax
  1942                              <1> 	; 12/04/2021
  1943 00001C88 58                  <1> 	pop	eax
  1944 00001C89 EE                  <1> 	out	dx, al  ; mmask
  1945                              <1> _sm_15:
  1946                              <1> 	; ebx = addr of params tbl for selected mode
  1947                              <1> 	; 10/08/2016
  1948 00001C8A 668B03              <1> 	mov	ax, [ebx] ; num of columns, 'twidth'
  1949 00001C8D A2[D0660000]        <1> 	mov	[CRT_COLS], al
  1950                              <1> 	;; 26/07/2016
  1951                              <1> 	;; CRTC_ADDRESS = 3D4h (always)
  1952                              <1> 	;mov	ah, [ebx+1] ; num of rows, 'theightm1'
  1953 00001C92 FEC4                <1> 	inc	ah ; 09/07/2016
  1954 00001C94 8825[D6660000]      <1> 	mov	[VGA_ROWS], ah
  1955                              <1> 	; 10/08/2016
  1956 00001C9A 8A4302              <1> 	mov	al, [ebx+2]
  1957 00001C9D A2[D2660000]        <1> 	mov	[CHAR_HEIGHT], al 
  1958                              <1> 	; 29/07/2016
  1959                              <1> 	; length of regen buffer in bytes
  1960 00001CA2 668B4B03            <1> 	mov	cx, [ebx+3] ; 'slength_l'
  1961 00001CA6 66890D[1C840100]    <1> 	mov	[CRT_LEN], cx
  1962                              <1> 	;
  1963                              <1> 	; 27/07/2016
  1964 00001CAD 30E4                <1> 	xor	ah, ah
  1965 00001CAF A0[B6770100]        <1> 	mov	al, [ACTIVE_PAGE] ; may be > 0 for mode 3
  1966                              <1> 	;mul	word [CRT_LEN] ; 4096 for mode 3
  1967 00001CB4 66F7E1              <1> 	mul	cx ; 29/07/2016
  1968 00001CB7 66A3[A4770100]      <1> 	mov	[CRT_START], ax
  1969                              <1> 	;
  1970 00001CBD B060                <1> 	mov	al, 60h
  1971                              <1> 	;cmp	byte [noclearmem], 0
  1972                              <1> 	;jna	short _sm_16
  1973                              <1> 	;add	al, 80h
  1974 00001CBF 0A05[1B840100]      <1> 	or	al, [noclearmem] ; 17/11/2020
  1975                              <1> _sm_16:
  1976 00001CC5 A2[D3660000]        <1> 	mov	[VGA_VIDEO_CTL], al
  1977 00001CCA C605[D4660000]F9    <1> 	mov	byte [VGA_SWITCHES], 0F9h
  1978 00001CD1 8025[D5660000]7F    <1> 	and	byte [VGA_MODESET_CTL], 7Fh
  1979                              <1> 
  1980 00001CD8 5E                  <1> 	pop	esi ; *
  1981                              <1> 
  1982                              <1> 	; 26/07/2016
  1983                              <1> 	; 07/07/2016
  1984 00001CD9 668B0D[E7660000]    <1> 	mov	cx, [CURSOR_MODE] ; restore cursor mode (initial value)
  1985 00001CE0 66870E              <1> 	xchg	cx, [esi] ; cl = start line, ch = end line
  1986                              <1> 			  ; reset to initial value
  1987 00001CE3 86E9                <1> 	xchg 	ch, cl  ; ch = start line, cl = end line  
  1988 00001CE5 66890D[E7660000]    <1> 	mov	[CURSOR_MODE], cx ; save (fixed) cursor mode
  1989                              <1> 
  1990                              <1> 	; 27/07/2016
  1991 00001CEC 803D[32840100]02    <1> 	cmp	byte [VGA_MTYPE], 2 ; CTEXT, MTEXT
  1992 00001CF3 7317                <1> 	jnb	short _sm_17
  1993                              <1> 
  1994                              <1> 	; Set cursor shape
  1995                              <1> 	;mov	cx, 0607h
  1996                              <1> 	;call	_set_ctype
  1997                              <1> 
  1998                              <1> 	; 29/07/2016
  1999 00001CF5 B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  2000 00001CF7 E81F060000          <1> 	call	m16	; output cx register
  2001                              <1> 	
  2002                              <1> 	; 25/07/2016
  2003 00001CFC 803D[CE660000]03    <1>         cmp     byte [CRT_MODE], 03h
  2004 00001D03 7507                <1> 	jne	short _sm_17
  2005                              <1> 	; 26/07/2016
  2006                              <1> 
  2007 00001D05 A0[B6770100]        <1> 	mov	al, [ACTIVE_PAGE]
  2008 00001D0A EB0B                <1> 	jmp	short _sm_18
  2009                              <1> _sm_17:
  2010                              <1> 	; Set cursor pos for page 0..7
  2011                              <1> 	;sub	ax, ax ; eax = 0
  2012 00001D0C 29C0                <1> 	sub	eax, eax ; 17/11/2020
  2013 00001D0E BF[A6770100]        <1> 	mov	edi, CURSOR_POSN
  2014 00001D13 AB                  <1> 	stosd	
  2015 00001D14 AB                  <1> 	stosd
  2016 00001D15 AB                  <1> 	stosd
  2017 00001D16 AB                  <1> 	stosd
  2018                              <1> 	;; Set active page 0
  2019                              <1> 	;mov	[ACTIVE_PAGE], al ; 0
  2020                              <1> _sm_18:
  2021                              <1> 	; 29/07/2016
  2022 00001D17 803D[32840100]02    <1> 	cmp	byte [VGA_MTYPE], 2 ; CTEXT, MTEXT
  2023                              <1> 	;jnb	_sm_23
  2024                              <1> 	; 04/08/2022
  2025 00001D1E 7205                <1> 	jb	short _sm_24
  2026 00001D20 E90C020000          <1> 	jmp	_set_active_page
  2027                              <1> _sm_24:
  2028                              <1> 	;cmp	byte [CHAR_HEIGHT], 16
  2029                              <1> 	;je	short _sm_19
  2030                              <1> 
  2031                              <1>  	;; copy and activate 8x16 font
  2032                              <1> 	
  2033                              <1> 	; 26/07/2016
  2034 00001D25 B004                <1> 	mov	al, 04h
  2035                              <1> 	;sub	bl, bl
  2036                              <1> 	; AX = 1104H ; Load ROM 8x16 Character Set
  2037                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  2038 00001D27 E844160000          <1> 	call	load_text_8_16_pat
  2039                              <1> 
  2040                              <1> 	; video_func_1103h:
  2041                              <1> 	; biosfn_set_text_block_specifier:
  2042                              <1> 	; BL = font block selector code	
  2043                              <1> 	; NOTE: TRDOS 386 only uses and sets font block 0
  2044                              <1> 	; (It is as BL = 0 for TRDOS 386)
  2045 00001D2C 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  2046                              <1> 	;;mov	ah, bl
  2047                              <1> 	;sub	ah, ah ; 0
  2048                              <1> 	;mov	al, 03h
  2049                              <1> 	; 19/11/2020
  2050 00001D30 66B80300            <1> 	mov	ax, 03h
  2051 00001D34 66EF                <1> 	out	dx, ax
  2052                              <1> _sm_19:
  2053                              <1> 	; 29/07/2016
  2054                              <1> 	; 26/07/2016
  2055                              <1> 	; 24/06/2016
  2056                              <1> 	;mov	edi, 0B8000h
  2057                              <1> 	;mov	cx, 4000h ; 16K words (32K)
  2058                              <1> 	;
  2059 00001D36 30C0                <1> 	xor	al, al
  2060 00001D38 3805[19840100]      <1>         cmp     [p_crt_mode], al ; 0 
  2061 00001D3E 7705                <1>         ja      short _sm_20 ; 03h, 80h or 83h
  2062                              <1> 
  2063                              <1> 	; case 1 - 19/11/2020
  2064                              <1> 	;
  2065                              <1> 	; If [pc_crt_mode] = 0, that means, previous mode is 03h
  2066                              <1> 	; and current mode is not 03h (case 1)
  2067                              <1> 
  2068                              <1> 	; 30/07/2016
  2069                              <1> 	; 24/06/2016
  2070                              <1> 	; TRDOS 386 (TRDOS v2) 'set mode' modification
  2071                              <1> 	; (for multiscreen feature):
  2072                              <1> 	; If '_set_mode' procedure is called for video mode 3
  2073                              <1> 	;     while video mode is 3, video page will be cleared
  2074                              <1> 	;     and cursor position of video page will be reset.
  2075                              <1> 	; If '_set_mode' procedure is called for a video mode
  2076                              <1> 	;     except video mode 3, while current video mode
  2077                              <1> 	;     is 3, all video pages of mode 3 will be copied 
  2078                              <1> 	;     to 98000h address as backup, before mode change.
  2079                              <1> 	; If '_set_mode' procedure is called for video mode 3
  2080                              <1> 	;     while video mode is not 3 and if there is video
  2081                              <1> 	;     page backup for video mode 3, all (of 8) mode 3
  2082                              <1> 	;     video pages will be restored from 98000h.
  2083                              <1> 
  2084                              <1> 	; 19/11/2020
  2085                              <1> 	;mov	[ACTIVE_PAGE], al ; 0
  2086                              <1> 
  2087                              <1> 	; Here,
  2088                              <1> 	; video memory already cleared if [noclearmem] <> 80h
  2089                              <1> 	
  2090                              <1> 	;mov	ax, 0720h
  2091                              <1> 	;mov	cx, 4000h ; 16K words (32K)
  2092                              <1> 	;mov	edi, 0B8000h
  2093                              <1> 	;rep	stosw
  2094                              <1> 	;sub	al, al
  2095                              <1> 	
  2096                              <1> 	;jmp	short _sm_23
  2097                              <1> 
  2098                              <1> 	; Set hardware side for the new active video page
  2099                              <1>  
  2100 00001D40 E9EC010000          <1> 	jmp	_set_active_page ; 19/11/2020	
  2101                              <1> 
  2102                              <1> _sm_20:
  2103                              <1> 	; 19/11/2020
  2104                              <1> 	; case 2 or case 3 or case 4 - 19/11/2020
  2105                              <1> 	
  2106                              <1> 	; 19/11/2020
  2107 00001D45 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 3  ; new video mode
  2108 00001D4C 754E                <1> 	jne	short _sm_22 ; al = 0 (& video mode <> 03h)
  2109                              <1> 			     ; case 4 - 19/11/2020
  2110                              <1> 			     ; ([p_crt_mode] = 83h)
  2111                              <1> 
  2112                              <1> 	; case 2 or case 3 - 19/11/2020	
  2113                              <1> 
  2114                              <1> 	;movzx	ebx, byte [ACTIVE_PAGE]
  2115                              <1> 	; 19/11/2020
  2116 00001D4E A0[1A840100]        <1> 	mov	al, [p_crt_page] ; previous mode 3 active page
  2117                              <1> 	;movzx	ebx, al
  2118                              <1> 	;shl	bl, 1 ; * 2
  2119                              <1> 	;add	ebx, CURSOR_POSN
  2120                              <1> 
  2121                              <1> 	; 29/07/2016
  2122 00001D53 F605[19840100]7F    <1> 	test    byte [p_crt_mode], 7Fh ; 83h or 80h or 03h
  2123 00001D5A 740F                <1> 	jz	short _sm_21	; do not restore video pages
  2124                              <1> 				; case 2 - 19/11/2020 
  2125                              <1> 	; case 3 - 19/11/2020
  2126                              <1> 
  2127                              <1> 	; ([p_crt_mode] = 03h)
  2128                              <1> 
  2129                              <1> 	; New video mode is 3 while current video mode is not 3
  2130                              <1> 	; (multi screen) video pages will be restored from 098000h
  2131                              <1> 
  2132                              <1> 	; 19/11/2020
  2133 00001D5C A2[B6770100]        <1> 	mov	[ACTIVE_PAGE], al ; current mode 3 active page
  2134                              <1> 
  2135                              <1> 	; 12/12/2020
  2136                              <1> 	;; restore video pages
  2137                              <1> 	;mov	esi, 98000h ; 30/07/2016 
  2138                              <1> 	;mov	edi, 0B8000h
  2139                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
  2140                              <1> 	;rep	movsd
  2141                              <1> 	;
  2142                              <1> 	;; 19/11/2020
  2143                              <1> 	;mov	[p_crt_mode], cl ; reset ('case 3' end condition)
  2144                              <1> 	;
  2145                              <1> 	;; restore cursor positions
  2146                              <1> 	;mov	esi, cursor_pposn
  2147                              <1> 	;mov	edi, CURSOR_POSN
  2148                              <1> 	;;mov	ecx, 4	; restore all cursor positions (16 bytes)
  2149                              <1> 	;mov	cl, 4
  2150                              <1> 	;rep 	movsd
  2151                              <1> 	
  2152                              <1> 	; 12/12/2020
  2153 00001D61 E89A000000          <1> 	call	_restore_mode3_multiscreen
  2154                              <1> 
  2155                              <1> 	;jmp	short _sm_23 ; do not clear current video pages
  2156                              <1> 
  2157                              <1> 	; 19/11/2020
  2158 00001D66 E9C6010000          <1> 	jmp	_set_active_page
  2159                              <1> 
  2160                              <1> _sm_21:
  2161                              <1> 	; 19/11/2020
  2162                              <1> 	; case 2 
  2163                              <1> 	;
  2164                              <1> 	; ([p_crt_mode] = 80h)
  2165                              <1> 	;
  2166                              <1> 	; User has requested to set video mode 3 again while
  2167                              <1> 	; current video mode is 3.. that means, set mode 03h
  2168                              <1> 	; parameters again and clear video page.
  2169                              <1> 	; ('noclearmem' option effects the result) 
  2170                              <1> 	
  2171                              <1> 	; 19/11/2020
  2172 00001D6B F605[1B840100]80    <1> 	test	byte [noclearmem], 80h
  2173 00001D72 7528                <1> 	jnz	short _sm_22	; 'do not clear video memory'
  2174                              <1> 				; continue with current text
  2175                              <1> 				; (user's option/choice) 
  2176                              <1> 	; clear video page
  2177                              <1> 	;mov	cx, [CRT_LEN] ; 4096
  2178                              <1> 	;shr	cx, 1 ; 2048 ; 16/11/2020
  2179 00001D74 66B82007            <1> 	mov	ax, 0720h
  2180                              <1> 	; 26/11/2020
  2181                              <1> 	;mov	ecx, 2048 ; 4096/2
  2182                              <1> 	; 02/08/2022
  2183 00001D78 29C9                <1> 	sub	ecx, ecx
  2184 00001D7A B508                <1> 	mov	ch, 08h
  2185                              <1> 	; ecx = 0800h
  2186 00001D7C BF00800B00          <1> 	mov	edi, 0B8000h ; [crt_base]
  2187 00001D81 66033D[A4770100]    <1> 	add	di, [CRT_START]
  2188 00001D88 F366AB              <1> 	rep	stosw	; FILL THE REGEN BUFFER WITH BLANKS
  2189                              <1> 	;
  2190                              <1> 	; 19/11/2020
  2191 00001D8B A0[B6770100]        <1> 	mov	al, [ACTIVE_PAGE] ; 0 to 7 (for video mode 3)
  2192 00001D90 0FB6D8              <1> 	movzx	ebx, al
  2193 00001D93 D0E3                <1> 	shl	bl, 1
  2194 00001D95 66898B[A6770100]    <1> 	mov	[ebx+CURSOR_POSN], cx ; reset cursor position
  2195                              <1> _sm_22:
  2196                              <1> 	;mov	[p_crt_mode], al ; 0 ; reset
  2197                              <1> 	; 19/11/2020
  2198                              <1> 	;and	byte [p_crt_mode], 3 ; 83h -> 3, 80h -> 0  
  2199 00001D9C 8025[19840100]7F    <1> 	and	byte [p_crt_mode], 7Fh ; 83h -> 3, 80h -> 0
  2200                              <1> _sm_23:
  2201                              <1> 	; al = video page number
  2202                              <1> 	; [CRT_LEN] = length of regen buffer in bytes
  2203                              <1> 	;call	_set_active_page
  2204                              <1> 	; 16/11/2020
  2205 00001DA3 E989010000          <1> 	jmp	_set_active_page
  2206                              <1> 
  2207                              <1> ;-----	NORMAL RETURN FROM ALL VIDEO RETURNS
  2208                              <1> 	;retn
  2209                              <1> 
  2210                              <1> save_mode3_multiscreen:
  2211                              <1> 	; 02/08/2022 (TRDOS v2.0.5)
  2212                              <1> 	; 12/12/2020 (TRDOS v2.0.3)
  2213                              <1> 	; save mode 03h video pages and cursor positions
  2214                              <1> 	;
  2215                              <1> 	; Modified registers: ecx (=0), esi, edi
  2216                              <1> 	
  2217                              <1> 	; 12/12/2020
  2218                              <1> 	; moved here from '_set_mode'	
  2219                              <1> 	; 03/07/2016
  2220                              <1> 	; save video pages
  2221 00001DA8 BE00800B00          <1> 	mov	esi, 0B8000h
  2222 00001DAD BF00800900          <1> 	mov	edi, 98000h ; 30/07/2016
  2223                              <1> 	;mov	ecx, (0B8000h-0B0000h)/4
  2224                              <1> 	; 02/08/2022
  2225 00001DB2 29C9                <1> 	sub	ecx, ecx
  2226 00001DB4 B520                <1> 	mov	ch, 20h
  2227                              <1> 	; ecx = 2000h 
  2228 00001DB6 F3A5                <1> 	rep	movsd
  2229                              <1> 	
  2230 00001DB8 C605[19840100]03    <1> 	mov	byte [p_crt_mode], 3 ; previous mode, backup sign
  2231                              <1> 	; 26/11/2020
  2232 00001DBF 860D[B6770100]      <1> 	xchg	cl, [ACTIVE_PAGE]
  2233 00001DC5 880D[1A840100]      <1> 	mov	[p_crt_page], cl  ; save as previous active page
  2234                              <1> 	
  2235                              <1> 	; save cursor positions
  2236 00001DCB BE[A6770100]        <1> 	mov	esi, CURSOR_POSN
  2237 00001DD0 BF[1E840100]        <1> 	mov	edi, cursor_pposn ; cursor positions backup
  2238 00001DD5 B104                <1> 	mov	cl, 4
  2239 00001DD7 F3A5                <1> 	rep	movsd
  2240 00001DD9 C3                  <1> 	retn
  2241                              <1> 
  2242                              <1> restore_mode3_multiscreen:
  2243                              <1> 	; 02/08/2022 (TRDOS v2.0.5)
  2244                              <1> 	; 12/12/2020 (TRDOS v2.0.3)
  2245                              <1> 	; restore mode 03h video pages and cursor positions
  2246                              <1> 	;
  2247                              <1> 	; Input:
  2248                              <1> 	;    settings from the last 'save_mode3_multiscreen'
  2249                              <1> 	;
  2250                              <1> 	; Output: 
  2251                              <1> 	;    AL = active video page = [ACTIVE_PAGE]
  2252                              <1> 	;
  2253                              <1> 	; Modified registers: al, ecx (=0), esi, edi
  2254                              <1> 
  2255 00001DDA A0[1A840100]        <1> 	mov	al, [p_crt_page] ; previous mode 3 active page
  2256 00001DDF A2[B6770100]        <1> 	mov	[ACTIVE_PAGE], al ; current mode 3 active page
  2257                              <1> 
  2258                              <1> 	; 12/12/2020
  2259                              <1> 	; moved here from 'vesa_vbe3_pmi'	
  2260                              <1> 
  2261                              <1> 	; 07/12/2020
  2262                              <1> 	; restore CRT_START according to ACTIVE_PAGE
  2263                              <1> 	;mov	[CRT_START], cx ; 0
  2264                              <1> 	; 12/12/2020
  2265 00001DE4 66C705[A4770100]00- <1> 	mov	word [CRT_START], 0
  2265 00001DEC 00                  <1>
  2266                              <1> 
  2267                              <1> 	; check active page and set it again if it is not 0
  2268 00001DED 08C0                <1> 	or	al, al
  2269                              <1> 	;;jz	short vbe3_pmi_7
  2270                              <1> 	;jz	short _restore_mode3_multiscreen
  2271 00001DEF 740F                <1> 	jz	short r_m3_ms_1
  2272 00001DF1 88C1                <1> 	mov	cl, al
  2273                              <1> ;vbe3_pmi_5:
  2274                              <1> r_m3_ms_0:
  2275 00001DF3 668105[A4770100]00- <1> 	add	word [CRT_START], 4096
  2275 00001DFB 10                  <1>
  2276 00001DFC FEC9                <1> 	dec	cl
  2277                              <1> 	;jnz	short vbe3_pmi_5
  2278 00001DFE 75F3                <1> 	jnz	short r_m3_ms_0
  2279                              <1> r_m3_ms_1:
  2280                              <1> 	; 12/12/2020
  2281                              <1> 	; moved here from '_set_mode'	
  2282                              <1> _restore_mode3_multiscreen:
  2283                              <1> 	; Modified registers: ecx, esi, edi
  2284                              <1> 
  2285                              <1> 	; restore video pages
  2286 00001E00 BE00800900          <1> 	mov	esi, 98000h ; 30/07/2016 
  2287 00001E05 BF00800B00          <1> 	mov	edi, 0B8000h
  2288                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
  2289                              <1> 	;mov	ecx, 2000h
  2290                              <1> 	; 02/08/2022
  2291 00001E0A 29C9                <1> 	sub	ecx, ecx
  2292 00001E0C B520                <1> 	mov	ch, 20h
  2293                              <1> 	; ecx = 2000h 
  2294 00001E0E F3A5                <1> 	rep	movsd
  2295                              <1> 
  2296                              <1> 	; 19/11/2020
  2297 00001E10 880D[19840100]      <1> 	mov	[p_crt_mode], cl ; reset ('case 3' end condition)
  2298                              <1> 
  2299                              <1> 	; restore cursor positions
  2300 00001E16 BE[1E840100]        <1> 	mov	esi, cursor_pposn
  2301 00001E1B BF[A6770100]        <1> 	mov	edi, CURSOR_POSN
  2302                              <1> 	;mov	ecx, 4	; restore all cursor positions (16 bytes)
  2303 00001E20 B104                <1> 	mov	cl, 4
  2304 00001E22 F3A5                <1> 	rep 	movsd
  2305 00001E24 C3                  <1> 	retn
  2306                              <1> 
  2307                              <1> cursor_shape_fix:
  2308                              <1> 	; 12/04/2021
  2309                              <1> 	; 07/07/2016
  2310                              <1> 	; (Cursor start and cursor end line values -6,7-
  2311                              <1> 	; will be fixed depending on character height)
  2312                              <1> 	;
  2313                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  2314                              <1> 	; vgabios-0.7a (2011)
  2315                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  2316                              <1> 	; 'vgabios.c', ' biosfn_set_cursor_shape (CH,CL)'
  2317                              <1> 	;
  2318                              <1> 	; INPUT ->
  2319                              <1> 	;	AL = cursor start line (=6)
  2320                              <1> 	;	AH = cursor end line (=7)
  2321                              <1> 	; OUTPUT ->
  2322                              <1> 	;	AL = cursor start line (=14)
  2323                              <1> 	;	AH = cursor end line (=15)
  2324                              <1> 	;
  2325                              <1> 	;; if((modeset_ctl&0x01)&&(cheight>8)&&(CL<8)&&(CH<0x20))
  2326                              <1> 
  2327                              <1> 	;test	byte [VGA_MODESET_CTL], 1 ; VGA active
  2328                              <1> 	;jz	short csf_3
  2329 00001E25 803D[D2660000]08    <1> 	cmp	byte [CHAR_HEIGHT], 8
  2330 00001E2C 7647                <1> 	jna	short csf_3
  2331 00001E2E 80FC08              <1> 	cmp	ah, 8
  2332 00001E31 7342                <1> 	jnb	short csf_3
  2333 00001E33 3C20                <1> 	cmp	al, 20h
  2334 00001E35 733E                <1> 	jnb	short csf_3
  2335                              <1> 	;
  2336                              <1> 	;push	ax
  2337                              <1> 	; 12/04/2021
  2338 00001E37 50                  <1> 	push	eax
  2339                              <1> 	; {
  2340                              <1>    	; if(CL!=(CH+1))	
  2341 00001E38 FEC0                <1> 	inc	al
  2342 00001E3A 38C4                <1> 	cmp	ah, al   ; ah != al + 1
  2343 00001E3C 740F                <1>         je      short csf_1
  2344                              <1> 	; CH = ((CH+1) * cheight / 8) -1;
  2345 00001E3E 8A25[D2660000]      <1> 	mov	ah, [CHAR_HEIGHT]
  2346 00001E44 F6E4                <1> 	mul	ah
  2347 00001E46 C0E803              <1> 	shr	al, 3 ; / 8
  2348 00001E49 FEC8                <1> 	dec	al ; - 1
  2349 00001E4B EB0E                <1> 	jmp	short csf_2 
  2350                              <1> csf_1: 	
  2351                              <1>  	; }
  2352                              <1>    	; else		; ah = al + 1
  2353                              <1>     	; {
  2354 00001E4D FEC4                <1> 	inc	ah	; ah = ah + 1   
  2355                              <1> 	; CH = ((CL+1) * cheight / 8) - 2;
  2356 00001E4F A0[D2660000]        <1> 	mov	al, [CHAR_HEIGHT]
  2357 00001E54 F6E4                <1> 	mul	ah
  2358 00001E56 C0E803              <1> 	shr	al, 3 ; / 8
  2359 00001E59 2C02                <1> 	sub	al, 2 ; - 2
  2360                              <1> 	; al = 14 (if [CHAR_HEIGHT] = 16)
  2361                              <1> csf_2:
  2362 00001E5B 880424              <1> 	mov	[esp], al
  2363 00001E5E 8A642401            <1> 	mov	ah, [esp+1]
  2364                              <1> 	; CL = ((CL+1) * cheight / 8) - 1;
  2365 00001E62 FEC4                <1> 	inc	ah 
  2366 00001E64 A0[D2660000]        <1> 	mov	al, [CHAR_HEIGHT]
  2367 00001E69 F6E4                <1> 	mul	ah
  2368 00001E6B C0E803              <1> 	shr	al, 3 ; / 8
  2369 00001E6E FEC8                <1> 	dec	al ; - 1
  2370 00001E70 88442401            <1> 	mov	[esp+1], al
  2371                              <1> 	; ah = 15 (if [CHAR_HEIGHT] = 16)
  2372                              <1> 	;
  2373                              <1> 	;pop	ax
  2374                              <1> 	; 12/04/2021
  2375 00001E74 58                  <1> 	pop	eax
  2376                              <1> csf_3:
  2377 00001E75 C3                  <1> 	retn
  2378                              <1> 
  2379                              <1> SET_CTYPE:
  2380                              <1> 	; 04/08/2022 (TRDOS 386 v2.0.5)
  2381                              <1> 	; 12/09/2016
  2382                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2383 00001E76 803D[CE660000]07    <1> 	cmp	byte [CRT_MODE], 7
  2384                              <1> 	;ja	VIDEO_RETURN ; 12/09/2016
  2385                              <1> 	; 04/08/2022
  2386 00001E7D 7738                <1> 	ja	short set_cpos_inv_vp
  2387 00001E7F E805000000          <1> 	call	_set_ctype
  2388 00001E84 E96CFCFFFF          <1>         jmp     VIDEO_RETURN
  2389                              <1> 
  2390                              <1> _set_ctype:
  2391                              <1> 	; 02/09/2014 (Retro UNIX 386 v1)
  2392                              <1> 	;
  2393                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2394                              <1> 
  2395                              <1> 	; (CH) = BITS 4-0 = START LINE FOR CURSOR
  2396                              <1> 	;  ** HARDWARE WILL ALWAYS CAUSE BLINK
  2397                              <1> 	;  ** SETTING BIT 5 OR 6 WILL CAUSE ERRATIC BLINKING
  2398                              <1> 	;     OR NO CURSOR AT ALL
  2399                              <1> 	; (CL) = BITS 4-0 = END LINE FOR CURSOR
  2400                              <1> 
  2401                              <1> ;------------------------------------------------
  2402                              <1> ; SET_CTYPE
  2403                              <1> ;	THIS ROUTINE SETS THE CURSOR VALUE
  2404                              <1> ; INPUT
  2405                              <1> ;	(CX) HAS CURSOR VALUE CH-START LINE, CL-STOP LINE
  2406                              <1> ; OUTPUT	
  2407                              <1> ;	NONE
  2408                              <1> ;------------------------------------------------
  2409                              <1> 	
  2410                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  2411                              <1> 	;
  2412                              <1> 	; 07/07/2016
  2413                              <1> 	; Fixing cursor start and stop line depending on
  2414                              <1> 	; current character height (=16)
  2415                              <1> 	; (Note: Default/initial values are 6 and 7.
  2416                              <1> 	; If set values are 6 (start) & 7 (stop) and 
  2417                              <1> 	; [CHAR_HEIGHT] = 16 :
  2418                              <1> 	; After fixing, start line will be 14, stop line
  2419                              <1> 	; will be 15.)
  2420                              <1> 
  2421                              <1> 	;mov	ax, cx
  2422                              <1> 	; 02/08/2022
  2423 00001E89 89C8                <1> 	mov	eax, ecx
  2424                              <1> 
  2425 00001E8B 86C4                <1> 	xchg	al, ah
  2426                              <1> 	; AL = start line, AH = stop line
  2427 00001E8D E893FFFFFF          <1> 	call	cursor_shape_fix
  2428                              <1> 	; AL = start line (fixed), AH = stop line (fixed)
  2429                              <1> 	;mov	cx, ax
  2430                              <1> 	; 02/08/2022
  2431 00001E92 89C1                <1> 	mov	ecx, eax
  2432 00001E94 86E9                <1> 	xchg	ch, cl
  2433                              <1> 	; CH = start line (fixed), CL = stop line (fixed)
  2434                              <1> 	;
  2435 00001E96 B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  2436 00001E98 66890D[E7660000]    <1> 	mov	[CURSOR_MODE], cx ; save in data area
  2437                              <1> 	;call	m16	; output cx register
  2438                              <1> 	;retn
  2439 00001E9F E977040000          <1>         jmp     m16
  2440                              <1> 
  2441                              <1> SET_CPOS:
  2442                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  2443                              <1> 	; 12/09/2016
  2444                              <1> 	; 07/07/2016
  2445                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2446 00001EA4 80FF07              <1> 	cmp	bh, 7 ; video page > 7 ; 07/07/2016
  2447                              <1> 	;ja	VIDEO_RETURN
  2448                              <1> 	; 02/08/2022
  2449 00001EA7 770E                <1> 	ja	short set_cpos_inv_vp
  2450                              <1> 	;
  2451 00001EA9 803D[CE660000]07    <1> 	cmp	byte [CRT_MODE], 7
  2452 00001EB0 770A                <1> 	ja	short vga_set_cpos ; 12/09/2016	
  2453 00001EB2 E839040000          <1> 	call	_set_cpos
  2454                              <1> set_cpos_inv_vp:   ; 02/08/2022
  2455 00001EB7 E939FCFFFF          <1>         jmp     VIDEO_RETURN
  2456                              <1> 
  2457                              <1> vga_set_cpos:
  2458                              <1> 	; 12/09/2016
  2459                              <1> 	; 09/07/2016
  2460                              <1> 	; set cursor position
  2461                              <1> 	; NOTE: Hardware cursor position will not be set
  2462                              <1> 	;   in any VGA modes (>7)
  2463                              <1> 	;   But, cursor position will be saved into
  2464                              <1> 	;   [CURSOR_POSN].
  2465                              <1> 	;   TRDOS 386 (TRDOS v2.0) uses only one page
  2466                              <1> 	;   (page 0) for all graphics modes.
  2467                              <1> 
  2468 00001EBC 668915[A6770100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  2469                              <1> 	; 04/08/2016
  2470                              <1> 	;mov	bh, [ACTIVE_PAGE] ; = 0
  2471                              <1> 	;call	_set_cpos
  2472 00001EC3 E92DFCFFFF          <1> 	jmp     VIDEO_RETURN
  2473                              <1> 
  2474                              <1> READ_CURSOR:
  2475                              <1> 	; 12/09/2016
  2476                              <1> 	; 07/07/2016
  2477                              <1> 	; 12/05/2016
  2478                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2479                              <1> 	;
  2480                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2481                              <1> 
  2482                              <1> ;------------------------------------------------------
  2483                              <1> ; READ_CURSOR
  2484                              <1> ;	THIS ROUTINE READS THE CURRENT CURSOR VALUE FROM THE
  2485                              <1> ;	845, FORMATS IT, AND SENDS IT BACK TO THE CALLER
  2486                              <1> ; INPUT
  2487                              <1> ;	BH - PAGE OF CURSOR
  2488                              <1> ; OUTPUT
  2489                              <1> ;	DX - ROW, COLUMN OF THE CURRENT CURSOR POSITION
  2490                              <1> ;	CX - CURRENT CURSOR MODE
  2491                              <1> ;------------------------------------------------------
  2492                              <1> 
  2493                              <1> 	; BH = Video page number (0 to 7)
  2494                              <1> 
  2495                              <1> 	; 07/07/2016
  2496 00001EC8 80FF07              <1> 	cmp	bh, 7 ; video page > 7 (invalid)
  2497 00001ECB 7606                <1> 	jna	short read_cursor_1
  2498                              <1> 	; invalid video page (input) 
  2499 00001ECD 31C9                <1> 	xor	ecx, ecx ; 0
  2500 00001ECF 31D2                <1> 	xor	edx, edx ; 0
  2501 00001ED1 EB15                <1> 	jmp	short read_cursor_2
  2502                              <1> read_cursor_1:
  2503                              <1> 	; 12/09/2016
  2504 00001ED3 803D[CE660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; vga mode
  2505 00001EDA 7727                <1> 	ja	short vga_get_cpos
  2506                              <1> 	;
  2507 00001EDC E815000000          <1> 	call	get_cpos
  2508 00001EE1 0FB70D[E7660000]    <1> 	movzx	ecx, word [CURSOR_MODE]
  2509                              <1> read_cursor_2:
  2510 00001EE8 5D                  <1> 	pop	ebp
  2511 00001EE9 5F                  <1> 	pop	edi
  2512 00001EEA 5E                  <1> 	pop	esi
  2513 00001EEB 5B                  <1> 	pop	ebx
  2514 00001EEC 58                  <1> 	pop	eax  ; DISCARD SAVED CX AND DX
  2515 00001EED 58                  <1> 	pop	eax
  2516 00001EEE A1[0C840100]        <1> 	mov	eax, [video_eax] ; 12/05/2016
  2517                              <1> 	;;15/01/2017
  2518                              <1> 	;;mov	byte [intflg], 0 ; 07/01/2017
  2519 00001EF3 1F                  <1> 	pop	ds
  2520 00001EF4 07                  <1> 	pop	es
  2521 00001EF5 CF                  <1> 	iretd
  2522                              <1> 
  2523                              <1> get_cpos:
  2524                              <1> 	; 12/05/2016
  2525                              <1> 	; 16/01/2016
  2526                              <1> 	; BH = Video page number (0 to 7)
  2527                              <1> 	;
  2528 00001EF6 D0E7                <1> 	shl	bh, 1 ; WORD OFFSET
  2529 00001EF8 0FB6F7              <1> 	movzx	esi, bh 
  2530 00001EFB 0FB796[A6770100]    <1> 	movzx	edx, word [esi+CURSOR_POSN]
  2531 00001F02 C3                  <1> 	retn
  2532                              <1> 
  2533                              <1> vga_get_cpos:
  2534                              <1> 	; 12/09/2016
  2535                              <1> 	; get cursor position (vga)
  2536 00001F03 0FB715[A6770100]    <1> 	movzx	edx, word [CURSOR_POSN] ; cursor pos for pg 0
  2537 00001F0A 31C9                <1> 	xor	ecx, ecx ; Cursor Mode = 0 (invalid)
  2538 00001F0C EBDA                <1> 	jmp     short read_cursor_2
  2539                              <1> 
  2540                              <1> ACT_DISP_PAGE:
  2541                              <1> 	; 07/07/2016
  2542                              <1> 	; 26/06/2016
  2543                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2544                              <1> 	;
  2545                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2546                              <1> 	;
  2547                              <1> ;-----------------------------------------------------
  2548                              <1> ; ACT_DISP_PAGE
  2549                              <1> ;	THIS ROUTINE SETS THE ACTIVE DISPLAY PAGE, ALLOWING
  2550                              <1> ;	THE FULL USE OF THE MEMORY SET ASIDE FOR THE VIDEO ATTACHMENT
  2551                              <1> ; INPUT
  2552                              <1> ;	AL HAS THE NEW ACTIVE DISPLAY PAGE
  2553                              <1> ; OUTPUT
  2554                              <1> ;	THE 6845 IS RESET TO DISPLAY THAT PAGE
  2555                              <1> ;-----------------------------------------------------
  2556                              <1> 	; 07/07/2016
  2557 00001F0E 3C07                <1> 	cmp	al, 7	; > 7 = invalid video page number
  2558                              <1> 	;ja	VIDEO_RETURN
  2559 00001F10 7715                <1>         ja	short adp_2 ; 18/11/2020
  2560                              <1> 	;cmp	byte [CRT_MODE], 3
  2561                              <1> 	;je	short adp_1
  2562                              <1> 	; 18/11/2020
  2563 00001F12 8A25[CE660000]      <1> 	mov	ah, [CRT_MODE]
  2564 00001F18 80FC03              <1> 	cmp	ah, 3
  2565 00001F1B 7605                <1> 	jna	short adp_1 ; mode 01h, 00h (01h), 02h (03h), 03h
  2566 00001F1D 80FC07              <1> 	cmp	ah, 7	    ; mode 07h (03h)
  2567 00001F20 7505                <1> 	jne	short adp_2
  2568                              <1> 	;and 	al, al
  2569                              <1>         ;jnz	VIDEO_RETURN
  2570                              <1> 	;;sub	al, al ; 0 ; force to page 0
  2571                              <1> adp_1:	
  2572 00001F22 E805000000          <1> 	call	set_active_page
  2573                              <1> adp_2:
  2574 00001F27 E9C9FBFFFF          <1>         jmp     VIDEO_RETURN
  2575                              <1> 
  2576                              <1> set_active_page:   ; tty_sw
  2577                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  2578                              <1> 	; 09/12/2017
  2579                              <1> 	; 26/07/2016
  2580                              <1> 	; 26/06/2016
  2581                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2582                              <1> 	; 30/06/2015
  2583                              <1> 	; 04/03/2014  (act_disp_page --> tty_sw)
  2584                              <1> 	; 10/12/2013
  2585                              <1> 	; 04/12/2013
  2586                              <1> 	;
  2587 00001F2C A2[B6770100]        <1> 	mov	[ACTIVE_PAGE], al ; save active page value ; [ptty]
  2588                              <1> _set_active_page:
  2589                              <1> 	; 27/06/2015
  2590                              <1> 	;movzx	ebx, al
  2591                              <1> 	; 02/08/2022
  2592 00001F31 0FB6C0              <1> 	movzx	eax, al
  2593 00001F34 89C3                <1> 	mov	ebx, eax
  2594                              <1> 	;
  2595                              <1> 	;cbw	; 07/09/2014 (ah=0)
  2596                              <1> 	; 02/08/2022
  2597                              <1> 	;sub	ah, ah ; 09/12/2017
  2598 00001F36 66F725[1C840100]    <1> 	mul	word [CRT_LEN]  ; get saved length of regen buffer
  2599                              <1> 				; display page times regen length
  2600                              <1> 	; 10/12/2013
  2601 00001F3D 66A3[A4770100]      <1> 	mov	[CRT_START], ax ; save start address for later
  2602                              <1> 	;mov	cx, ax ; start address to cx
  2603                              <1> 	; 02/08/2022
  2604 00001F43 89C1                <1> 	mov	ecx, eax
  2605                              <1> _M16:
  2606                              <1> 	;;sar	cx, 1
  2607                              <1> 	;shr	cx, 1	; divide by 2 for 6845 handling
  2608                              <1> 	; 02/08/2022
  2609 00001F45 D1E9                <1> 	shr	ecx, 1
  2610 00001F47 B40C                <1> 	mov	ah, 12	; 6845 register for start address
  2611 00001F49 E8CD030000          <1> 	call	m16
  2612                              <1> 	;sal	bx, 1
  2613                              <1> 	; 01/09/2014
  2614 00001F4E D0E3                <1> 	shl	bl, 1	; *2 for word offset
  2615 00001F50 81C3[A6770100]      <1> 	add	ebx, CURSOR_POSN
  2616 00001F56 668B13              <1> 	mov	dx, [ebx] ; get cursor for this page
  2617                              <1> 	; 16/01/2016
  2618                              <1> 	;call	m18
  2619                              <1> 	;retn
  2620 00001F59 E9A9030000          <1> 	jmp	m18
  2621                              <1> 
  2622                              <1> position:
  2623                              <1> 	; 02/08/2022 - TRDOS 386 v2.0.5
  2624                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  2625                              <1> 	; 24/06/2016
  2626                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  2627                              <1> 	; 27/06/2015
  2628                              <1> 	; 02/09/2014
  2629                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  2630                              <1> 	; 04/12/2013 (Retro UNIX 8086 v1)
  2631                              <1> 	;
  2632                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2633                              <1> 	;
  2634                              <1> ;-----------------------------------------
  2635                              <1> ; POSITION
  2636                              <1> ;	THIS SERVICE ROUTINE CALCULATES THE REGEN BUFFER ADDRESS
  2637                              <1> ;	OF A CHARACTER IN THE ALPHA MODE
  2638                              <1> ; INPUT
  2639                              <1> ;	AX = ROW, COLUMN POSITION
  2640                              <1> ; OUTPUT
  2641                              <1> ;	AX = OFFSET OF CHAR POSITION IN REGEN BUFFER
  2642                              <1> ;-----------------------------------------
  2643                              <1> 
  2644                              <1> 	; DX = ROW, COLUMN POSITION
  2645                              <1> 	;movzx	eax, byte [CRT_COLS] ; 27/06/2015
  2646 00001F5E 31C0                <1> 	xor	eax, eax ; 02/09/2014
  2647 00001F60 B050                <1> 	mov	al, 80   ; determine bytes to row	
  2648 00001F62 F6E6                <1> 	mul	dh	 ; row value
  2649                              <1> 	;xor	dh, dh   ; 0	
  2650                              <1> 	;add	ax, dx	 ; add column value to the result
  2651                              <1> 	; 16/04/2021
  2652 00001F64 00D0                <1> 	add	al, dl
  2653 00001F66 80D400              <1> 	adc	ah, 0
  2654                              <1> 	; 02/08/2022
  2655 00001F69 D1E0                <1> 	shl	eax, 1
  2656                              <1> 	;shl	ax, 1	; * 2 for attribute bytes
  2657                              <1> 		; EAX = AX = OFFSET OF CHAR POSITION IN REGEN BUFFER 
  2658 00001F6B C3                  <1> 	retn
  2659                              <1> 
  2660                              <1> find_position:
  2661                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  2662                              <1> 	; 24/06/2016
  2663                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  2664                              <1> 	; 27/06/2015
  2665                              <1> 	; 07/09/2014
  2666                              <1> 	; 02/09/2014
  2667                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  2668                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2669                              <1> 
  2670 00001F6C 0FB6CF              <1> 	movzx	ecx, bh ; video page number
  2671                              <1> 	; 17/04/2021
  2672                              <1> 	;mov	esi, ecx
  2673                              <1> 	;shl	si, 1
  2674                              <1> 	;mov	dx, [esi+CURSOR_POSN]
  2675                              <1> 	;jz	short p21
  2676                              <1> 	;xor	si, si
  2677                              <1> 	; 17/04/2021
  2678 00001F6F 31F6                <1> 	xor	esi, esi
  2679 00001F71 D0E1                <1> 	shl	cl, 1
  2680 00001F73 668B91[A6770100]    <1> 	mov	dx, [ecx+CURSOR_POSN]
  2681 00001F7A 740B                <1> 	jz	short p21
  2682 00001F7C D0E9                <1> 	shr	cl, 1
  2683                              <1> p20:
  2684 00001F7E 660335[1C840100]    <1> 	add	si, [CRT_LEN] ; 24/06/2016
  2685                              <1> 	;add	si, 80*25*2 ; add length of buffer for one page
  2686 00001F85 E2F7                <1> 	loop	p20
  2687                              <1> p21:
  2688 00001F87 6621D2              <1> 	and	dx, dx
  2689 00001F8A 7407                <1> 	jz	short p22
  2690 00001F8C E8CDFFFFFF          <1> 	call 	position ; determine location in regen in page
  2691 00001F91 01C6                <1> 	add	esi, eax ; add location to start of regen page
  2692                              <1> p22:	
  2693                              <1> 	;mov	dx, [addr_6845] ; get base address of active display
  2694                              <1> 	;mov	dx, 03D4h ; I/O address of color card
  2695                              <1> 	;add	dx, 6	; point at status port
  2696 00001F93 66BADA03            <1> 	mov	dx, 03DAh ; status port
  2697                              <1> 	; cx = 0
  2698 00001F97 C3                  <1> 	retn
  2699                              <1> 
  2700                              <1> SCROLL_UP:
  2701                              <1> 	; 04/08/2022 (TRDOS 386 v2.0.5)
  2702                              <1> 	; 07/07/2016
  2703                              <1> 	; 26/06/2016
  2704                              <1> 	; 12/05/2016
  2705                              <1> 	; 30/01/2016
  2706                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2707                              <1> 	; 07/09/2014
  2708                              <1> 	; 02/09/2014
  2709                              <1> 	; 01/09/2014 (Retro UNIX 386 v1 - beginning)
  2710                              <1> 	; 04/04/2014
  2711                              <1> 	; 04/12/2013
  2712                              <1> 	;
  2713                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2714                              <1> 	;
  2715                              <1> ;----------------------------------------------
  2716                              <1> ; SCROLL UP
  2717                              <1> ;	THIS ROUTINE MOVES A BLOCK OF CHARACTERS UP
  2718                              <1> ;	ON THE SCREEN
  2719                              <1> ; INPUT
  2720                              <1> ;	(AH) = CURRENT CRT MODE
  2721                              <1> ;	(AL) = NUMBER OF ROWS TO SCROLL
  2722                              <1> ;	(CX) = ROW/COLUMN OF UPPER LEFT CORNER
  2723                              <1> ;	(DX) = ROW/COLUMN OF LOWER RIGHT CORNER
  2724                              <1> ;	(BH) = ATTRIBUTE TO BE USED ON BLANKED LINE
  2725                              <1> ;	(DS) = DATA SEGMENT
  2726                              <1> ;	(ES) = REGEN BUFFER SEGMENT
  2727                              <1> ; OUTPUT
  2728                              <1> ;	NONE -- THE REGEN BUFFER IS MODIFIED
  2729                              <1> ;--------------------------------------------
  2730                              <1> 
  2731                              <1> 	; 07/07/2016
  2732 00001F98 38F5                <1> 	cmp	ch, dh
  2733                              <1> 	;ja	VIDEO_RETURN
  2734                              <1> 	; 04/08/2022
  2735 00001F9A 7709                <1> 	ja	short _s_u_retn
  2736                              <1> 
  2737 00001F9C 38D1                <1> 	cmp	cl, dl
  2738                              <1> 	;ja	VIDEO_RETURN
  2739                              <1> 	; 04/08/2022
  2740 00001F9E 7705                <1> 	ja	short _s_u_retn
  2741                              <1> 	;
  2742 00001FA0 E805000000          <1> 	call	_scroll_up
  2743                              <1> _s_u_retn:
  2744 00001FA5 E94BFBFFFF          <1>         jmp     VIDEO_RETURN
  2745                              <1> 
  2746                              <1> _scroll_up:  ; from 'write_tty'
  2747                              <1> 	;
  2748                              <1> 	; cl = left upper column
  2749                              <1> 	; ch = left upper row
  2750                              <1> 	; dl = right lower column
  2751                              <1> 	; dh = right lower row
  2752                              <1> 	;
  2753                              <1> 	; al = line count 
  2754                              <1> 	; bl = attribute to be used on blanked line
  2755                              <1> 	; bh = video page number (0 to 7)
  2756                              <1> 
  2757 00001FAA E89B000000          <1> 	call	test_line_count ; 16/01/2016
  2758                              <1> 
  2759 00001FAF 8A25[CE660000]      <1> 	mov	ah, [CRT_MODE] ; current video mode
  2760                              <1> 	;;cmp	byte [CRT_MODE], 4
  2761                              <1> 	;cmp	ah, 4 ; 07/07/2016
  2762                              <1> 	;jnb	GRAPHICS_UP ; 26/06/2016
  2763                              <1> 	; 18/11/2020
  2764 00001FB5 80FC04              <1> 	cmp	ah, 4
  2765 00001FB8 720A                <1>  	jb	short n0	
  2766 00001FBA 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD 
  2767                              <1> 		      ;	(80x25 text, mono)
  2768 00001FBD 7405                <1> 	je	short n0 ; same with mode 3 for TRDOS 386
  2769 00001FBF E91B050000          <1> 	jmp	GRAPHICS_UP
  2770                              <1> n0:
  2771                              <1> 	; 07/07/2016
  2772 00001FC4 80FF07              <1> 	cmp	bh, 7 ; video page number
  2773 00001FC7 7606                <1> 	jna	short n1
  2774 00001FC9 8A3D[B6770100]      <1> 	mov	bh, [ACTIVE_PAGE]
  2775                              <1> n1:
  2776 00001FCF 88DC                <1> 	mov	ah, bl ; attribute
  2777                              <1> 	;push	ax ; *
  2778                              <1> 	; 12/04/2021
  2779 00001FD1 50                  <1> 	push	eax ; *
  2780                              <1> 	;mov 	esi, [CRT_BASE]
  2781 00001FD2 BE00800B00          <1>         mov     esi, 0B8000h  
  2782 00001FD7 3A3D[B6770100]      <1>         cmp     bh, [ACTIVE_PAGE]
  2783 00001FDD 750B                <1> 	jne	short n2
  2784                              <1> 	;
  2785 00001FDF 66A1[A4770100]      <1>         mov     ax, [CRT_START]
  2786 00001FE5 6601C6              <1>         add     si, ax
  2787 00001FE8 EB11                <1>         jmp     short n4
  2788                              <1> n2:
  2789 00001FEA 20FF                <1>         and     bh, bh
  2790 00001FEC 740D                <1> 	jz	short n4
  2791 00001FEE 88F8                <1> 	mov	al, bh
  2792                              <1> n3:
  2793 00001FF0 660335[1C840100]    <1>         add	si, [CRT_LEN]
  2794 00001FF7 FEC8                <1>         dec	al
  2795 00001FF9 75F5                <1> 	jnz	short n3
  2796                              <1> n4:	
  2797 00001FFB E85B000000          <1> 	call	scroll_position ; 16/01/2016
  2798 00002000 7420                <1>         jz      short n6 
  2799                              <1> 
  2800 00002002 01CE                <1>         add     esi, ecx ; from address for scroll
  2801 00002004 88F5                <1> 	mov	ch, dh  ; #rows in block
  2802 00002006 28C5                <1> 	sub	ch, al	; #rows to be moved
  2803                              <1> n5:
  2804 00002008 E88A000000          <1> 	call	n10 ; 16/01/2016
  2805                              <1> 	
  2806 0000200D 51                  <1>         push	ecx
  2807 0000200E 0FB60D[D0660000]    <1> 	movzx	ecx, byte [CRT_COLS] 
  2808 00002015 00C9                <1> 	add	cl, cl
  2809 00002017 01CE                <1>         add	esi, ecx  ; next line
  2810 00002019 01CF                <1>         add	edi, ecx
  2811 0000201B 59                  <1> 	pop	ecx
  2812                              <1> 
  2813 0000201C FECD                <1> 	dec	ch	 ; count of lines to move
  2814 0000201E 75E8                <1> 	jnz	short n5 ; row loop
  2815                              <1> 	; ch = 0
  2816 00002020 88C6                <1> 	mov	dh, al	 ; #rows
  2817                              <1> n6:
  2818                              <1> 	; attribute in ah
  2819 00002022 B020                <1> 	mov	al, ' '	 ; fill with blanks
  2820                              <1> n7:
  2821 00002024 E87B000000          <1> 	call	n11 ; 16/01/2016
  2822                              <1> 
  2823 00002029 8A0D[D0660000]      <1> 	mov	cl, [CRT_COLS]
  2824 0000202F 00C9                <1> 	add	cl, cl
  2825 00002031 01CF                <1>         add	edi, ecx
  2826                              <1> 
  2827 00002033 FECE                <1> 	dec	dh
  2828 00002035 75ED                <1> 	jnz	short n7
  2829                              <1> n16:
  2830 00002037 3A3D[B6770100]      <1> 	cmp	bh, [ACTIVE_PAGE]
  2831 0000203D 750A                <1> 	jne	short n8
  2832                              <1> 	
  2833                              <1> 	;cmp	byte [CRT_MODE], 7 ; is this the black and white card
  2834                              <1> 	;je	short n8	   ; if so, skip the mode reset
  2835                              <1> 
  2836 0000203F A0[CF660000]        <1> 	mov	al, [CRT_MODE_SET] ; get the value of mode set
  2837 00002044 66BAD803            <1> 	mov	dx, 03D8h ; always set color card port
  2838 00002048 EE                  <1> 	out	dx, al
  2839                              <1> n8:
  2840 00002049 C3                  <1> 	retn
  2841                              <1> 
  2842                              <1> test_line_count:
  2843                              <1> 	; 12/04/2021
  2844                              <1> 	; 12/05/2016
  2845                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2846                              <1> 	; 07/09/2014 (scroll_up)
  2847 0000204A 08C0                <1> 	or	al, al
  2848 0000204C 740C                <1> 	jz	short al_set2
  2849                              <1> 	;push	dx
  2850                              <1> 	; 12/04/2021
  2851 0000204E 52                  <1> 	push	edx
  2852 0000204F 28EE                <1> 	sub	dh, ch  ; subtract upper row from lower row number
  2853 00002051 FEC6                <1> 	inc	dh	; adjust difference by 1
  2854 00002053 38C6                <1> 	cmp	dh, al 	; line count = amount of rows in window?
  2855 00002055 7502                <1> 	jne	short al_set1 ; if not the we're all set
  2856 00002057 30C0                <1> 	xor	al, al	; otherwise set al to zero
  2857                              <1> al_set1:
  2858                              <1> 	;pop	dx
  2859                              <1> 	; 12/04/2021
  2860 00002059 5A                  <1> 	pop	edx
  2861                              <1> al_set2:
  2862 0000205A C3                  <1> 	retn
  2863                              <1> 
  2864                              <1> scroll_position:
  2865                              <1> 	; 12/04/2021
  2866                              <1> 	; 26/06/2016
  2867                              <1> 	; 30/01/2016
  2868                              <1>         ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2869                              <1> 	; 07/09/2014 (scroll_up)
  2870                              <1> 
  2871                              <1> 	; (*) [esp+4] = ax (al = line count, ah = attribute)
  2872                              <1> 
  2873                              <1> 	;push	dx
  2874                              <1> 	; 12/04/2021
  2875 0000205B 52                  <1> 	push	edx
  2876 0000205C 6689CA              <1> 	mov	dx, cx	; now, upper left position in DX
  2877 0000205F E8FAFEFFFF          <1> 	call	position
  2878 00002064 01C6                <1> 	add	esi, eax
  2879 00002066 89F7                <1> 	mov	edi, esi
  2880                              <1> 	;pop	dx	; lower right position in DX
  2881                              <1> 	; 12/04/2021
  2882 00002068 5A                  <1> 	pop	edx
  2883 00002069 6629CA              <1> 	sub	dx, cx
  2884 0000206C FEC6                <1> 	inc	dh	; dh = #rows 
  2885 0000206E FEC2                <1> 	inc	dl	; dl = #cols in block
  2886 00002070 59                  <1> 	pop	ecx 	; return address
  2887                              <1> 	;pop	ax	; * ; al = line count, ah = attribute
  2888                              <1> 	; 12/04/2021
  2889 00002071 58                  <1> 	pop	eax ; (*)
  2890 00002072 51                  <1> 	push	ecx	; return address
  2891 00002073 0FB7C8              <1> 	movzx	ecx, ax
  2892 00002076 8A25[D0660000]      <1> 	mov	ah, [CRT_COLS]
  2893 0000207C F6E4                <1> 	mul	ah	; determine offset to from address
  2894                              <1> 	;add	ax, ax  ; *2 for attribute byte
  2895                              <1> 	; 02/08/2022
  2896                              <1> 	;shl	eax, 1
  2897 0000207E 01C0                <1> 	add	eax, eax
  2898                              <1> 	;
  2899                              <1> 	;push	ax	; offset 
  2900                              <1> 	;push	dx
  2901                              <1> 	; 12/04/2021
  2902 00002080 50                  <1> 	push	eax	; offset 
  2903 00002081 52                  <1> 	push	edx
  2904                              <1> 	;
  2905                              <1> 	; 04/04/2014
  2906 00002082 66BADA03            <1> 	mov	dx, 3DAh ; guaranteed to be color card here	
  2907                              <1> n9:                      ; wait_display_enable
  2908 00002086 EC                  <1>         in      al, dx   ; get port
  2909 00002087 A808                <1> 	test	al, RVRT ; wait for vertical retrace	
  2910 00002089 74FB                <1> 	jz	short n9 ; wait_display_enable
  2911 0000208B B025                <1> 	mov	al, 25h
  2912 0000208D B2D8                <1> 	mov	dl, 0D8h ; address control port
  2913 0000208F EE                  <1> 	out	dx, al	; turn off video during vertical retrace
  2914                              <1> 	;pop	dx	; #rows, #cols
  2915                              <1>        	;pop	ax	; offset
  2916                              <1> 	; 12/04/2021
  2917 00002090 5A                  <1> 	pop	edx	; #rows, #cols
  2918 00002091 58                  <1>        	pop	eax	; offset
  2919 00002092 6691                <1> 	xchg	ax, cx	; 
  2920                              <1> 	; ecx = offset, al = line count, ah = attribute
  2921                              <1> 	;
  2922 00002094 08C0                <1> 	or	al, al
  2923 00002096 C3                  <1> 	retn
  2924                              <1> n10:
  2925                              <1> 	; Move rows
  2926 00002097 88D1                <1> 	mov	cl, dl	; get # of cols to move
  2927 00002099 56                  <1> 	push	esi
  2928 0000209A 57                  <1> 	push	edi	; save start address
  2929                              <1> n10r:
  2930 0000209B 66A5                <1> 	movsw		; move that line on screen
  2931 0000209D FEC9                <1> 	dec	cl
  2932 0000209F 75FA                <1>         jnz     short n10r
  2933 000020A1 5F                  <1> 	pop	edi
  2934 000020A2 5E                  <1> 	pop	esi	; recover addresses
  2935 000020A3 C3                  <1> 	retn
  2936                              <1> n11:
  2937                              <1> 	; Clear rows
  2938                              <1>                 	; dh =  #rows
  2939 000020A4 88D1                <1>         mov	cl, dl	; get # of cols to clear
  2940 000020A6 57                  <1>         push    edi     ; save address
  2941                              <1> n11r:
  2942 000020A7 66AB                <1>         stosw           ; store fill character
  2943 000020A9 FEC9                <1> 	dec	cl
  2944 000020AB 75FA                <1>         jnz     short n11r
  2945 000020AD 5F                  <1>         pop     edi     ; recover address
  2946 000020AE C3                  <1> 	retn
  2947                              <1> 
  2948                              <1> SCROLL_DOWN:
  2949                              <1> 	; 12/04/2021
  2950                              <1> 	; 07/07/2016
  2951                              <1> 	; 27/06/2016
  2952                              <1> 	; 26/06/2016
  2953                              <1> 	; 12/05/2016
  2954                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2955                              <1> 	;
  2956                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2957                              <1> 
  2958                              <1> ;------------------------------------------
  2959                              <1> ; SCROLL DOWN
  2960                              <1> ;	THIS ROUTINE MOVES THE CHARACTERS WITHIN A DEFINED
  2961                              <1> ;	BLOCK DOWN ON THE SCREEN, FILLING THE TOP LINES
  2962                              <1> ;	WITH A DEFINED CHARACTER
  2963                              <1> ; INPUT
  2964                              <1> ;	(AH) = CURRENT CRT MODE
  2965                              <1> ;	(AL) = NUMBER OF LINES TO SCROLL
  2966                              <1> ;	(CX) = UPPER LEFT CORNER OF RECION
  2967                              <1> ;	(DX) = LOWER RIGHT CORNER OF REGION
  2968                              <1> ;	(BH) = FILL CHARACTER
  2969                              <1> ;	(DS) = DATA SEGMENT
  2970                              <1> ;	(ES) = REGEN SEGMENT
  2971                              <1> ; OUTPUT
  2972                              <1> ;	NONE -- SCREEN IS SCROLLED
  2973                              <1> ;------------------------------------------
  2974                              <1> 
  2975                              <1> 	; 07/07/2016
  2976 000020AF 38F5                <1> 	cmp	ch, dh
  2977                              <1> 	;ja	VIDEO_RETURN
  2978 000020B1 7709                <1> 	ja	short _s_d_retn ; 18/11/2020
  2979 000020B3 38D1                <1> 	cmp	cl, dl
  2980                              <1> 	;ja	VIDEO_RETURN
  2981 000020B5 7705                <1> 	ja	short _s_d_retn ; 18/11/2020
  2982                              <1> 	;
  2983 000020B7 E805000000          <1> 	call	_scroll_down
  2984                              <1> _s_d_retn:
  2985 000020BC E934FAFFFF          <1>         jmp     VIDEO_RETURN
  2986                              <1> 
  2987                              <1> _scroll_down: ; 27/06/2016
  2988                              <1> 
  2989                              <1> 	; cl = left upper column
  2990                              <1> 	; ch = left upper row
  2991                              <1> 	; dl = right lower column
  2992                              <1> 	; dh = right lower row
  2993                              <1> 	;
  2994                              <1> 	; al = line count 
  2995                              <1> 	; bl = attribute to be used on blanked line
  2996                              <1> 	; bh = video page number (0 to 7)
  2997                              <1> 
  2998                              <1> 	; !!!!
  2999 000020C1 FD                  <1> 	std		; DIRECTION FOR SCROLL DOWN
  3000                              <1> 	; !!!!
  3001 000020C2 E883FFFFFF          <1> 	call	test_line_count ; 16/01/2016
  3002                              <1> 	
  3003 000020C7 8A25[CE660000]      <1> 	mov	ah, [CRT_MODE] ; current video mode
  3004                              <1> 	;;cmp	byte [CRT_MODE], 4
  3005                              <1> 	;cmp	ah, 4 ; 07/07/2016
  3006                              <1> 	;jnb	GRAPHICS_DOWN ; 26/06/2016
  3007                              <1> 	; 18/11/2020
  3008 000020CD 80FC04              <1> 	cmp	ah, 4
  3009 000020D0 720A                <1>  	jb	short _n0	
  3010 000020D2 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD 
  3011                              <1> 		      ;	(80x25 text, mono)
  3012 000020D5 7405                <1> 	je	short _n0 ; same with mode 3 for TRDOS 386
  3013 000020D7 E9D5060000          <1> 	jmp	GRAPHICS_DOWN
  3014                              <1> _n0:
  3015                              <1> 	; 07/07/2016
  3016 000020DC 80FF07              <1> 	cmp	bh, 7 ; video page number
  3017 000020DF 7606                <1> 	jna	short n12
  3018 000020E1 8A3D[B6770100]      <1> 	mov	bh, [ACTIVE_PAGE]
  3019                              <1> 	;
  3020                              <1> n12:			; CONTINUE_DOWN
  3021 000020E7 88DC                <1> 	mov	ah, bl
  3022                              <1> 	;push	ax	; * ; save attribute in ah
  3023                              <1> 	; 12/04/2021
  3024 000020E9 50                  <1> 	push	eax
  3025 000020EA 6689D0              <1> 	mov	ax, dx	; LOWER RIGHT CORNER
  3026 000020ED E869FFFFFF          <1> 	call	scroll_position	; GET REGEN LOCATION
  3027 000020F2 741F                <1> 	jz	short n14
  3028 000020F4 29CE                <1> 	sub	esi, ecx  ; SI IS FROM ADDRESS
  3029 000020F6 88F5                <1> 	mov	ch, dh  ; #rows in block
  3030 000020F8 28C5                <1> 	sub	ch, al	; #rows to be moved
  3031                              <1> n13:
  3032 000020FA E898FFFFFF          <1> 	call	n10	; MOVE ONE ROW
  3033                              <1> 
  3034 000020FF 51                  <1> 	push	ecx
  3035 00002100 8A0D[D0660000]      <1> 	mov	cl, [CRT_COLS] 
  3036 00002106 00C9                <1> 	add	cl, cl
  3037 00002108 29CE                <1>         sub	esi, ecx  ; next line
  3038 0000210A 29CF                <1>         sub	edi, ecx
  3039 0000210C 59                  <1>         pop	ecx
  3040                              <1> 	
  3041 0000210D FECD                <1> 	dec	ch	 ; count of lines to move
  3042 0000210F 75E9                <1> 	jnz	short n13 ; row loop
  3043                              <1> 	; ch = 0
  3044 00002111 88C6                <1> 	mov	dh, al	 ; #rows
  3045                              <1> n14:
  3046                              <1> 	; attribute in ah
  3047 00002113 B020                <1> 	mov	al, ' '	 ; fill with blanks
  3048                              <1> n15:
  3049 00002115 E88AFFFFFF          <1> 	call	n11 ; 16/01/2016
  3050                              <1> 
  3051 0000211A 8A0D[D0660000]      <1> 	mov	cl, [CRT_COLS]
  3052 00002120 00C9                <1> 	add	cl, cl
  3053 00002122 29CF                <1>         sub	edi, ecx
  3054                              <1>         
  3055 00002124 FECE                <1> 	dec	dh
  3056 00002126 75ED                <1> 	jnz	short n15
  3057                              <1> 	;
  3058                              <1> 	; 18/11/2020
  3059 00002128 FC                  <1> 	cld	; clear direction flag	
  3060                              <1> 	;
  3061 00002129 E909FFFFFF          <1> 	jmp	n16 ; 27/06/2016
  3062                              <1> 
  3063                              <1> ;	cmp	bh, [ACTIVE_PAGE]
  3064                              <1> ;	jne	short n16
  3065                              <1> ;
  3066                              <1> ;	;cmp	byte [CRT_MODE], 7	; is this the black and white card
  3067                              <1> ;	;je	short n16		; if so, skip the mode reset
  3068                              <1> ;
  3069                              <1> ;	mov	al, [CRT_MODE_SET] ; get the value of mode set
  3070                              <1> ;	mov	dx, 03D8h ; always set color card port
  3071                              <1> ;	out	dx, al
  3072                              <1> ;n16:
  3073                              <1> ;	; !!!!
  3074                              <1> ;	cld		; Clear direction flag !
  3075                              <1> ;	; !!!!
  3076                              <1> ;	retn
  3077                              <1> 
  3078                              <1> READ_AC_CURRENT:
  3079                              <1> 	; 08/07/2016
  3080                              <1> 	; 26/06/2016
  3081                              <1> 	; 12/05/2016
  3082                              <1> 	; 18/01/2016
  3083                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  3084                              <1> 	;
  3085                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  3086                              <1> 	;
  3087                              <1> 	; 08/07/2016
  3088 0000212E 803D[CE660000]07    <1>         cmp     byte [CRT_MODE], 7 ; 6!?
  3089 00002135 7607                <1> 	jna	short read_ac_c
  3090 00002137 31C0                <1> 	xor	eax, eax
  3091 00002139 E9BCF9FFFF          <1>         jmp     _video_return 
  3092                              <1> read_ac_c:
  3093 0000213E E805000000          <1> 	call	_read_ac_current
  3094                              <1> 	; 12/05/2016
  3095                              <1>         ;jmp     VIDEO_RETURN
  3096 00002143 E9B2F9FFFF          <1> 	jmp	_video_return
  3097                              <1> 
  3098                              <1> ;------------------------------------------------------------------------
  3099                              <1> ; READ_AC_CURRENT							:
  3100                              <1> ;	THIS ROUTINE READS THE ATTRIBUTE AND CHARACTER AT THE CURRENT	:
  3101                              <1> ;	CURSOR POSITION AND RETURNS THEM TO THE CALLER			:
  3102                              <1> ; INPUT									:
  3103                              <1> ;	(AH) = CURRENT CRT MODE						:
  3104                              <1> ;	(BH) = DISPLAY PAGE ( ALPHA MODES ONLY )			:
  3105                              <1> ;	(DS) = DATA SEGMENT						:
  3106                              <1> ;	(ES) = REGEN SEGMENT						:
  3107                              <1> ; OUTPUT								:
  3108                              <1> ;	(AL) = CHARACTER READ						:
  3109                              <1> ;	(AH) = ATTRIBUTE READ						:
  3110                              <1> ;------------------------------------------------------------------------
  3111                              <1> 
  3112                              <1> _read_ac_current:
  3113                              <1> 	; 26/06/2016
  3114                              <1> 	; 12/05/2016 
  3115                              <1> 	; 18/01/2016
  3116                              <1> 
  3117 00002148 8A25[CE660000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  3118 0000214E 80FC04              <1> 	cmp	ah, 4
  3119 00002151 720A                <1>  	jb	short p10
  3120                              <1> 	; 18/11/2020
  3121                              <1> 	;cmp	byte [CRT_MODE], 4
  3122                              <1> 	;jnb	GRAPHICS_READ ; 26/06/2016
  3123                              <1> 
  3124 00002153 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD (80x25 monochrome text)
  3125 00002156 7405                <1> 	je	short p10	 ; same with mode 3 in TRDOS 386
  3126 00002158 E9A0080000          <1> 	jmp	GRAPHICS_READ
  3127                              <1> p10:
  3128 0000215D E80AFEFFFF          <1> 	call	find_position	; GET REGEN LOCATION AND PORT ADDRESS
  3129                              <1> 	;
  3130                              <1> 	; esi = regen location
  3131                              <1> 	; dx = status port
  3132                              <1> 	;
  3133                              <1> 
  3134                              <1> 	; 18/11/2020
  3135                              <1> 	; convert display mode to a zero value 
  3136                              <1> 	; for 80 column color mode
  3137                              <1> 	;mov	ah, [CRT_MODE]	
  3138                              <1> 	;sub	ah, 2
  3139                              <1> 	;shr	ah, 1
  3140                              <1> 	;jnz	short p13
  3141                              <1> 
  3142                              <1> 	; 05/12/2020
  3143                              <1> 	; 18/11/2020 (TRDOS 386 v2.0.3)
  3144                              <1> 	;xor	bl, bl	; 0
  3145 00002162 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 03h ; 80x25 color text
  3146                              <1> 	;je	short p11    ; Note: Only mode 03h and mode 01h are
  3147                              <1> 	;inc	bl	; 1  ;       in use by TRDOS 386 as text modes	
  3148                              <1> 	;jmp	short p14    ;       (07h, 00h and 02h are redirected)		
  3149 00002169 7516                <1> 	jne	short p13
  3150                              <1> 
  3151                              <1> 	; 05/12/2020
  3152 0000216B 3A3D[B6770100]      <1> 	cmp     bh, [ACTIVE_PAGE]
  3153 00002171 750E                <1> 	jne	short p13 
  3154                              <1> 
  3155                              <1> 	; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80
  3156                              <1> p11:
  3157 00002173 FB                  <1> 	sti		; enable interrupts first
  3158                              <1> 	; 05/12/2020
  3159 00002174 90                  <1> 	nop
  3160                              <1> 	; 18/11/2020
  3161                              <1> 	;or	bl, bl
  3162                              <1> 	;jnz	short p13 ; mode 01h (and mode 00h) - 40x25 color text
  3163 00002175 FA                  <1> 	cli 		; block interrupts for single loop
  3164 00002176 EC                  <1> 	in	al, dx	; get status from the adapter
  3165 00002177 A801                <1> 	test	al, RHRZ ; is horizontal retrace low
  3166 00002179 75F8                <1> 	jnz	short p11 ; wait until it is
  3167                              <1> p12:			;  wait for either retrace high
  3168 0000217B EC                  <1> 	in	al, dx ; get status again
  3169 0000217C A809                <1> 	test	al, RVRT+RHRZ ; is horizontal or vertical retrace high
  3170 0000217E 74FB                <1> 	jz	short p12 ; wait until either retrace active
  3171                              <1> ;p14:
  3172 00002180 FB                  <1> 	sti
  3173                              <1> p13:
  3174 00002181 81C600800B00        <1> 	add	esi, 0B8000h 
  3175 00002187 668B06              <1> 	mov	ax, [esi]
  3176                              <1> 
  3177 0000218A C3                  <1> 	retn	; 18/01/2016
  3178                              <1> 
  3179                              <1> WRITE_AC_CURRENT:
  3180                              <1> 	; 08/07/2016
  3181                              <1> 	; 26/06/2016
  3182                              <1> 	; 24/06/2016
  3183                              <1> 	; 12/05/2016
  3184                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  3185                              <1> 	;
  3186                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  3187                              <1> 	;
  3188                              <1> ;----------------------------------------------------------------
  3189                              <1> ; WRITE_AC_CURRENT						:
  3190                              <1> ;	THTS ROUTINE WRITES THE ATTRIBUTE AND CHARACTER		:
  3191                              <1> ;	AT THE CURRENT CURSOR POSITION				:
  3192                              <1> ; INPUT								:
  3193                              <1> ;	(AH) = CURRENT CRT MODE					:
  3194                              <1> ;	(BH) = DISPLAY PAGE					:
  3195                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE			:
  3196                              <1> ;	(AL) = CHAR TO WRITE					:
  3197                              <1> ;	(BL) = ATTRIBUTE OF CHAR TO WRITE			:
  3198                              <1> ;	(DS) = DATA SEGMENT					:
  3199                              <1> ;	(ES) = REGEN SEGMENT					:
  3200                              <1> ; OUTPUT							:
  3201                              <1> ;	DISPLAY REGEN BUFFER UPDATED				:
  3202                              <1> ;----------------------------------------------------------------
  3203                              <1> 
  3204                              <1> 	; 08/07/2016
  3205 0000218B 803D[CE660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6!?
  3206 00002192 760A                <1> 	jna	short write_ac_c
  3207                              <1> 
  3208 00002194 E8B60A0000          <1> 	call	vga_write_char_attr
  3209 00002199 E957F9FFFF          <1> 	jmp     VIDEO_RETURN	
  3210                              <1> 
  3211                              <1> write_ac_c:
  3212 0000219E E834000000          <1> 	call	_write_c_current
  3213                              <1> 
  3214 000021A3 0FB6F7              <1> 	movzx	esi, bh ; video page number (0 to 7)	
  3215 000021A6 889E[D7660000]      <1> 	mov	[esi+chr_attrib], bl ; color/attribute
  3216                              <1> 
  3217 000021AC E944F9FFFF          <1>         jmp     VIDEO_RETURN
  3218                              <1> 
  3219                              <1> WRITE_C_CURRENT:
  3220                              <1> 	; 08/07/2016
  3221                              <1> 	; 26/06/2016
  3222                              <1> 	; 12/05/2016
  3223                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  3224                              <1> 	;
  3225                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  3226                              <1> 	;
  3227                              <1> ;----------------------------------------------------------------
  3228                              <1> ; WRITE_C_CURRENT						:
  3229                              <1> ;	THIS ROUTINE WRITES THE CHARACTER AT			:
  3230                              <1> ;	THE CURRENT CURSOR POSITION, ATTRIBUTE UNCHANGED	:
  3231                              <1> ; INPUT								:
  3232                              <1> ;	(AH) = CURRENT CRT MODE					:
  3233                              <1> ;	(BH) = DISPLAY PAGE					:
  3234                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE			:
  3235                              <1> ;	(AL) = CHAR TO WRITE					:
  3236                              <1> ;	(DS) = DATA SEGMENT					:
  3237                              <1> ;	(ES) = REGEN SEGMENT					:
  3238                              <1> ; OUTPUT							:
  3239                              <1> ;	DISPLAY REGEN BUFFER UPDATED				:
  3240                              <1> ;----------------------------------------------------------------
  3241                              <1> 
  3242                              <1> 	; 08/07/2016
  3243 000021B1 803D[CE660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6!?
  3244 000021B8 760A                <1> 	jna	short write_c_c
  3245                              <1> 
  3246 000021BA E8900A0000          <1> 	call	vga_write_char_only
  3247 000021BF E931F9FFFF          <1> 	jmp     VIDEO_RETURN	
  3248                              <1> 
  3249                              <1> write_c_c:
  3250                              <1> 	;and	bh, 7 ; video page number (<= 7)
  3251 000021C4 0FB6F7              <1> 	movzx	esi, bh	
  3252 000021C7 8A9E[D7660000]      <1> 	mov	bl, [esi+chr_attrib]
  3253                              <1> 
  3254 000021CD E805000000          <1> 	call	_write_c_current
  3255 000021D2 E91EF9FFFF          <1>         jmp     VIDEO_RETURN
  3256                              <1> 
  3257                              <1> _write_c_current:  ; from 'write_tty'
  3258                              <1> 	; 12/04/2021
  3259                              <1> 	; 18/11/2020
  3260                              <1> 	; 26/06/2016
  3261                              <1> 	; 24/06/2016
  3262                              <1> 	; 12/05/2016
  3263                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  3264                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  3265                              <1> 	; 18/01/2014
  3266                              <1> 	; 04/12/2013
  3267                              <1> 	;
  3268                              <1> 	; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS
  3269                              <1> 
  3270                              <1> 	; 18/11/2020
  3271 000021D7 8A25[CE660000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  3272 000021DD 80FC04              <1> 	cmp	ah, 4
  3273 000021E0 720A                <1>  	jb	short p40
  3274                              <1> 	
  3275                              <1> 	;cmp	byte [CRT_MODE], 4
  3276                              <1>         ;jnb	GRAPHICS_WRITE ; 26/06/2016
  3277                              <1> 
  3278 000021E2 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD
  3279 000021E5 7405                <1> 	je	short p40
  3280 000021E7 E963070000          <1> 	jmp	GRAPHICS_WRITE
  3281                              <1> p40:
  3282                              <1> 	; al = character
  3283                              <1> 	; bl = color/attribute
  3284                              <1> 	; bh = video page
  3285                              <1> 	; cx = count of characters to write
  3286                              <1> 	;push	dx
  3287                              <1> 	; 12/04/2021
  3288 000021EC 52                  <1> 	push	edx ; *
  3289 000021ED 88DC                <1> 	mov	ah, bl  ; color/attribute (12/05/2016)
  3290                              <1> 	;push	ax	; save character & attribute/color
  3291                              <1> 	;push	cx
  3292                              <1> 	; 12/04/2021
  3293 000021EF 50                  <1> 	push	eax ; ** ; save character & attribute/color
  3294 000021F0 51                  <1> 	push	ecx ; ***
  3295 000021F1 E876FDFFFF          <1> 	call 	find_position  ; get regen location and port address
  3296                              <1> 	;pop	cx
  3297                              <1> 	; 12/04/2021
  3298 000021F6 59                  <1> 	pop	ecx ; ***
  3299                              <1> 	; esi = regen location
  3300                              <1> 	; dx = status port
  3301                              <1> 	;
  3302 000021F7 81C600800B00        <1> 	add	esi, 0B8000h ; 30/08/2014 (crt_base) 
  3303                              <1> 	;
  3304                              <1> 	; 18/11/2020
  3305                              <1> 	; convert display mode to a zero value 
  3306                              <1> 	; for 80 column color mode
  3307                              <1> 	;mov	ah, [CRT_MODE]	
  3308                              <1> 	;sub	ah, 2
  3309                              <1> 	;shr	ah, 1
  3310                              <1> 	;jnz	short p44    ; 26/06/2016
  3311                              <1> 
  3312                              <1> 	; 05/12/2020
  3313                              <1> 	; 18/11/2020 (TRDOS 386 v2.0.3)
  3314                              <1> 	;xor	bl, bl	; 0
  3315 000021FD 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 03h ; 80x25 color text
  3316                              <1> 	;je	short p41    ; Note: Only mode 03h and mode 01h are
  3317                              <1> 	;inc	bl	; 1  ;       in use by TRDOS 386 as text modes	
  3318                              <1> 	;jmp	short p43    ;       (07h, 00h and 02h are redirected)			
  3319                              <1> 	; 05/12/2020
  3320 00002204 751A                <1> 	jne	short p44
  3321                              <1> p46:
  3322                              <1> 	; 05/12/2020
  3323 00002206 3A3D[B6770100]      <1> 	cmp     bh, [ACTIVE_PAGE]
  3324 0000220C 7512                <1> 	jne	short p44
  3325                              <1> 
  3326                              <1> 	; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80
  3327                              <1> p41:
  3328                              <1> 	; 05/12/2020
  3329 0000220E FB                  <1> 	sti		; enable interrupts first
  3330 0000220F 90                  <1> 	nop
  3331                              <1> 	; 18/11/2020
  3332                              <1> 	;or	bl, bl
  3333                              <1> 	;jnz	short p44 ; mode 01h (and mode 00h) - 40x25 color text
  3334 00002210 FA                  <1> 	cli 		; block interrupts for single loop
  3335 00002211 EC                  <1> 	in	al, dx	; get status from the adapter
  3336 00002212 A808                <1> 	test	al, RVRT ; check for vertical retrace first
  3337 00002214 7509                <1> 	jnz	short p43 ; Do fast write now if vertical retrace
  3338 00002216 A801                <1> 	test	al, RHRZ ; is horizontal retrace low
  3339 00002218 75F4                <1> 	jnz	short p41 ; wait until it is
  3340                              <1> p42:			;  wait for either retrace high
  3341 0000221A EC                  <1> 	in	al, dx ; get status again
  3342 0000221B A809                <1> 	test	al, RVRT+RHRZ ; is horizontal or vertical retrace high
  3343 0000221D 74FB                <1> 	jz	short p42 ; wait until either retrace active
  3344                              <1> p43:	
  3345 0000221F FB                  <1> 	sti
  3346                              <1> p44:
  3347 00002220 668B0424            <1> 	mov	ax, [esp] ; restore the character (al) & attribute (ah)
  3348 00002224 668906              <1> 	mov	[esi], ax
  3349                              <1> 
  3350 00002227 6649                <1> 	dec	cx
  3351 00002229 740D                <1> 	jz	short p45
  3352                              <1> 
  3353 0000222B 46                  <1> 	inc	esi
  3354 0000222C 46                  <1> 	inc	esi
  3355                              <1> 
  3356                              <1> 	; 05/12/2020
  3357 0000222D 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 03h
  3358 00002234 75EA                <1> 	jne	short p44
  3359                              <1> 	;jmp	short p41
  3360 00002236 EBCE                <1> 	jmp	short p46
  3361                              <1> p45:	
  3362                              <1> 	;pop	ax
  3363                              <1> 	;pop	dx
  3364                              <1> 	; 12/04/2021
  3365 00002238 58                  <1> 	pop	eax ; **
  3366 00002239 5A                  <1> 	pop	edx ; *
  3367 0000223A C3                  <1> 	retn
  3368                              <1> 
  3369                              <1> ; 09/07/2016
  3370                              <1> ; 26/06/2016
  3371                              <1> ; 24/06/2016
  3372                              <1> ; 12/05/2016
  3373                              <1> ; 18/01/2016
  3374                              <1> ; 16/01/2016 - TRDOS 386 (TRDOS v2.0)
  3375                              <1> ; 30/06/2015
  3376                              <1> ; 27/06/2015
  3377                              <1> ; 11/03/2015
  3378                              <1> ; 02/09/2014
  3379                              <1> ; 30/08/2014
  3380                              <1> ; VIDEO FUNCTIONS
  3381                              <1> ; (write_tty - Retro UNIX 8086 v1 - U9.ASM, 01/02/2014)
  3382                              <1> 
  3383                              <1> WRITE_TTY:
  3384                              <1> 	; 09/12/2017
  3385                              <1> 	; 09/07/2016
  3386                              <1> 	; 01/07/2016
  3387                              <1> 	; 26/06/2016
  3388                              <1> 	; 24/06/2016
  3389                              <1> 	; 13/05/2016
  3390                              <1> 	; 12/05/2016
  3391                              <1> 	; 30/01/2016
  3392                              <1> 	; 18/01/2016
  3393                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  3394                              <1> 	; 13/08/2015
  3395                              <1> 	; 02/09/2014
  3396                              <1> 	; 30/08/2014 (Retro UNIX 386 v1 - beginning)
  3397                              <1> 	; 01/02/2014 (Retro UNIX 8086 v1 - last update)
  3398                              <1> 	; 03/12/2013 (Retro UNIX 8086 v1 - beginning)	
  3399                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI, EDI)
  3400                              <1> 	;
  3401                              <1> 	; INPUT -> AL = Character to be written
  3402                              <1> 	;	   BL = Color (Forecolor, Backcolor)
  3403                              <1> 	;	   BH = Video Page (0 to 7)
  3404                              <1> 
  3405                              <1> 	; 09/07/2016
  3406 0000223B 803D[CE660000]07    <1>         cmp     byte [CRT_MODE], 7
  3407 00002242 760A                <1> 	jna 	short write_tty_cga
  3408                              <1> 
  3409 00002244 E8EB0C0000          <1> 	call	vga_write_teletype
  3410 00002249 E9A7F8FFFF          <1> 	jmp	VIDEO_RETURN
  3411                              <1> 
  3412                              <1> write_tty_cga:
  3413                              <1> 	; 13/05/2016
  3414                              <1> 	;call	_write_tty
  3415                              <1> 	; 01/07/2016
  3416 0000224E E818000000          <1> 	call	_write_tty_m3
  3417 00002253 E99DF8FFFF          <1> 	jmp	VIDEO_RETURN
  3418                              <1> 
  3419                              <1> RVRT	equ	00001000b	; VIDEO VERTICAL RETRACE BIT
  3420                              <1> RHRZ	equ	00000001b	; VIDEO HORIZONTAL RETRACE BIT
  3421                              <1> 
  3422                              <1> ; Derived from "WRITE_TTY" procedure of IBM "pc-at" rombios source code
  3423                              <1> ; (06/10/1985), 'video.asm', INT 10H, VIDEO_IO
  3424                              <1> ;
  3425                              <1> ; 06/10/85  VIDEO DISPLAY BIOS
  3426                              <1> ;
  3427                              <1> ;--- WRITE_TTY ------------------------------------------------------------------
  3428                              <1> ;										:
  3429                              <1> ;   THIS INTERFACE PROVIDES A TELETYPE LIKE INTERFACE TO THE			:
  3430                              <1> ;   VIDEO CARDS. THE INPUT CHARACTER IS WRITTEN TO THE CURRENT			:
  3431                              <1> ;   CURSOR POSITION, AND THE CURSOR IS MOVED TO THE NEXT POSITION.		:
  3432                              <1> ;   IF THE CURSOR LEAVES THE LAST COLUMN OF THE FIELD, THE COLUMN		:
  3433                              <1> ;   IS SET TO ZERO, AND THE ROW VALUE IS INCREMENTED. IF THE ROW		:
  3434                              <1> ;   ROW VALUE LEAVES THE FIELD, THE CURSOR IS PLACED ON THE LAST ROW,		:
  3435                              <1> ;   FIRST COLUMN, AND THE ENTIRE SCREEN IS SCROLLED UP ONE LINE.		:
  3436                              <1> ;   WHEN THE SCREEN IS SCROLLED UP, THE ATTRIBUTE FOR FILLING THE		:
  3437                              <1> ;   NEWLY BLANKED LINE IS READ FROM THE CURSOR POSITION ON THE PREVIOUS		:
  3438                              <1> ;   LINE BEFORE THE SCROLL, IN CHARACTER MODE. IN GRAPHICS MODE,		:
  3439                              <1> ;   THE 0 COLOR IS USED.							:
  3440                              <1> ;   ENTRY --									:
  3441                              <1> ;     (AH) = CURRENT CRT MODE							:
  3442                              <1> ;     (AL) = CHARACTER TO BE WRITTEN						:
  3443                              <1> ;	    NOTE THAT BACK SPACE, CARRIAGE RETURN, BELL AND LINE FEED ARE	:
  3444                              <1> ;	    HANDLED AS COMMANDS RATHER THAN AS DISPLAY GRAPHICS CHARACTERS	:
  3445                              <1> ;     (BL) = FOREGROUND COLOR FOR CHAR WRITE IF CURRENTLY IN A GRAPHICS MODE	:
  3446                              <1> ;   EXIT -- 									:
  3447                              <1> ;     ALL REGISTERS SAVED							:
  3448                              <1> ;--------------------------------------------------------------------------------
  3449                              <1> 
  3450                              <1> ; 02/08/2022 (TRDOS 386 v2.0.5)
  3451                              <1> ; 18/11/2020 (TRDOS 386 v2.0.3)
  3452                              <1> ; 09/12/2017
  3453                              <1> ; 08/07/2016
  3454                              <1> ; 26/06/2016
  3455                              <1> ; 24/06/2016
  3456                              <1> _write_tty:
  3457                              <1> 	; 13/05/2016
  3458                              <1> 	; --- 18/11/2020 ---
  3459                              <1> 	; NOTE:
  3460                              <1> 	; Only kernel calls "_write_tty" procedure...
  3461                              <1> 	; TRDOS 386 v2 kernel uses video mode 3 for displaying
  3462                              <1> 	; (some error) messages and also mainprog command interpreter
  3463                              <1> 	; (in kernel) uses "_write_tty".
  3464                              <1> 	; So, here video mode must be set to 3 if it is not 3.
  3465                              <1>  
  3466 00002258 FA                  <1> 	cli	; disable interrupts
  3467                              <1> 	;
  3468                              <1> 	; 01/09/2014
  3469 00002259 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 3
  3470 00002260 7409                <1> 	je	short _write_tty_m3
  3471                              <1> 	;
  3472                              <1> set_mode_3:
  3473 00002262 53                  <1> 	push	ebx
  3474 00002263 50                  <1> 	push	eax
  3475                              <1> 	;call	_set_mode
  3476                              <1> 	; 18/11/2020 
  3477 00002264 E89BF8FFFF          <1> 	call	set_txt_mode  ; set video mode to 03h 
  3478 00002269 58                  <1> 	pop	eax
  3479 0000226A 5B                  <1> 	pop	ebx
  3480                              <1> 	;
  3481                              <1> _write_tty_m3: ; 24/06/2016 (m3 -> _write_tty_m3)
  3482 0000226B 0FB6F7              <1> 	movzx 	esi, bh ; 12/05/2016
  3483                              <1> 	;shl	si, 1
  3484                              <1> 	; 02/08/2022
  3485 0000226E D1E6                <1> 	shl	esi, 1
  3486 00002270 81C6[A6770100]      <1> 	add	esi, CURSOR_POSN
  3487 00002276 668B16              <1> 	mov	dx, [esi]
  3488                              <1> 	;
  3489                              <1> 	; dx now has the current cursor position
  3490                              <1> 	;
  3491 00002279 3C0D                <1> 	cmp	al, 0Dh	; CR	; is it carriage return or control character
  3492                              <1> 	;jbe	short u8
  3493                              <1> 	; 17/04/2021
  3494 0000227B 7241                <1> 	jb	short u8
  3495 0000227D 746F                <1> 	je	short u9
  3496                              <1> 	;
  3497                              <1> 	; write the char to the screen
  3498                              <1> u0:	
  3499                              <1> 	; al = character
  3500                              <1> 	; bl = attribute/color
  3501                              <1> 	; bh = video page number (0 to 7)
  3502                              <1> 	;
  3503                              <1> 	;mov	cx, 1  ; 24/06/2016
  3504                              <1> 	; 02/08/2022
  3505 0000227F 29C9                <1> 	sub	ecx, ecx
  3506 00002281 FEC1                <1> 	inc	cl ; ecx = 1
  3507                              <1> 	; cx = count of characters to write
  3508                              <1> 	;
  3509 00002283 E84FFFFFFF          <1> 	call	_write_c_current ; 16/01/2015
  3510                              <1> 	;
  3511                              <1> 	; position the cursor for next char
  3512 00002288 FEC2                <1> 	inc	dl		; next column
  3513 0000228A 3A15[D0660000]      <1> 	cmp	dl, [CRT_COLS]  ; test for column overflow 
  3514                              <1> 	;jne	_set_cpos
  3515                              <1> 	; 02/08/2022
  3516 00002290 7402                <1> 	je	short u13
  3517 00002292 EB5C                <1> 	jmp	_set_cpos
  3518                              <1> u13:
  3519 00002294 B200                <1> 	mov	dl, 0		; column = 0
  3520                              <1> u10:				; (line feed found)
  3521 00002296 80FE18              <1> 	cmp	dh, 25-1 	; check for last row
  3522 00002299 721F                <1> 	jb 	short u6
  3523                              <1> 	;
  3524                              <1> 	; scroll required
  3525                              <1> u1:	
  3526                              <1> 	; SET CURSOR POSITION (04/12/2013)
  3527 0000229B E850000000          <1> 	call	_set_cpos
  3528                              <1> 	;
  3529                              <1> 	; determine value to fill with during scroll
  3530                              <1> u2:
  3531                              <1> 	; bh = video page number
  3532                              <1> 	;
  3533 000022A0 E8A3FEFFFF          <1> 	call	_read_ac_current ; 18/01/2016
  3534                              <1> 	;
  3535                              <1> 	; al = character, ah = attribute
  3536                              <1> 	; bh = video page number
  3537                              <1> 	; 18/11/2020
  3538 000022A5 88E3                <1> 	mov	bl, ah ; color/attribute 	
  3539                              <1> u3:
  3540                              <1> 	;;mov	ax, 0601h 	; scroll one line
  3541                              <1> 	;;sub	cx, cx		; upper left corner
  3542                              <1> 	;;mov	dh, 25-1 	; lower right row
  3543                              <1> 	;;;mov	dl, [CRT_COLS]
  3544                              <1> 	;mov	dl, 80		; lower right column	
  3545                              <1> 	;;dec	dl
  3546                              <1> 	;;mov	dl, 79
  3547                              <1> 
  3548                              <1> 	;;call	scroll_up	; 04/12/2013
  3549                              <1> 	;;; 11/03/2015
  3550                              <1> 	; 02/09/2014
  3551                              <1> 	;;;mov	cx, [crt_ulc] ; Upper left corner  (0000h)
  3552                              <1> 	;;;mov	dx, [crt_lrc] ; Lower right corner (184Fh)
  3553                              <1> 	; 11/03/2015
  3554                              <1> 	;sub	cx, cx
  3555                              <1> 	; 17/04/2021
  3556 000022A7 29C9                <1> 	sub	ecx, ecx
  3557                              <1> 	;mov	dx, 184Fh ; dl = 79 (column), dh = 24 (row)
  3558                              <1> 	; 18/11/2020
  3559 000022A9 B618                <1> 	mov	dh, 25-1
  3560 000022AB 8A15[D0660000]      <1> 	mov	dl, [CRT_COLS]
  3561 000022B1 FECA                <1> 	dec	dl
  3562                              <1> 	;
  3563 000022B3 B001                <1> 	mov	al, 1		; scroll 1 line up
  3564                              <1> 		; ah = attribute
  3565                              <1> 	;mov	bl, al ; 12/05/2016
  3566 000022B5 E9F0FCFFFF          <1> 	jmp	_scroll_up	; 16/01/2016
  3567                              <1> ;u4:
  3568                              <1> 	;;int	10h		; video-call return
  3569                              <1> 				; scroll up the screen
  3570                              <1> 				; tty return
  3571                              <1> ;u5:
  3572                              <1> 	;retn			; return to the caller
  3573                              <1> 
  3574                              <1> u6:				; set-cursor-inc
  3575 000022BA FEC6                <1> 	inc	dh		; next row
  3576                              <1> 				; set cursor
  3577                              <1> ;u7:					
  3578                              <1> 	;;mov	ah, 02h
  3579                              <1> 	;;jmp	short u4 	; establish the new cursor
  3580                              <1> 	;call	_set_cpos
  3581                              <1> 	;jmp 	short u5
  3582 000022BC EB32                <1> 	jmp     _set_cpos
  3583                              <1> 
  3584                              <1> 	; check for control characters
  3585                              <1> u8:
  3586                              <1> 	;je	short u9 ; 17/04/2021
  3587 000022BE 3C0A                <1> 	cmp	al, 0Ah		; is it a line feed (0Ah)
  3588 000022C0 74D4                <1> 	je	short u10
  3589 000022C2 3C07                <1> 	cmp	al, 07h 	; is it a bell
  3590 000022C4 747C                <1> 	je	short u11
  3591 000022C6 3C08                <1> 	cmp	al, 08h		; is it a backspace
  3592                              <1> 	;jne	short u0
  3593 000022C8 741C                <1> 	je	short bs	; 12/12/2013
  3594                              <1> 	; 12/12/2013 (tab stop)
  3595 000022CA 3C09                <1> 	cmp	al, 09h		; is it a tab stop
  3596 000022CC 75B1                <1> 	jne	short u0
  3597 000022CE 88D0                <1> 	mov	al, dl
  3598                              <1> 	;cbw
  3599 000022D0 30E4                <1> 	xor	ah, ah ; 09/12/2017
  3600 000022D2 B108                <1> 	mov	cl, 8
  3601 000022D4 F6F1                <1> 	div	cl
  3602 000022D6 28E1                <1> 	sub	cl, ah
  3603                              <1> ts:
  3604                              <1> 	; 02/09/2014
  3605                              <1> 	; 01/09/2014
  3606                              <1> 	;mov	al, 20h
  3607                              <1> tsloop:
  3608                              <1> 	;push	cx
  3609                              <1> 	; 12/04/2021
  3610 000022D8 51                  <1> 	push	ecx ; *
  3611                              <1> 	; 18/11/2020
  3612                              <1> 	;push	ax
  3613                              <1> 	;;mov	bh, [ACTIVE_PAGE]
  3614                              <1> 	; 05/12/2020
  3615                              <1> 	;push	bx
  3616 000022D9 B020                <1> 	mov	al, 20h ; al = space (blank) 
  3617                              <1> 			; bl = color/attribute
  3618 000022DB E88BFFFFFF          <1> 	call	_write_tty_m3 ; 24/06/2016 (m3 -> _write_tty_m3)
  3619                              <1> 	; 05/12/2020
  3620                              <1> 	; bx is preserved in '_write_tty_m3'
  3621                              <1> 	; 18/11/2020
  3622                              <1> 	;pop	bx  ; BL = color/attribute, Bh = video page 
  3623                              <1> 	;pop	ax  ; AL = character
  3624                              <1> 	; 12/04/2021
  3625                              <1> 	;pop	cx
  3626 000022E0 59                  <1> 	pop	ecx ; *
  3627 000022E1 FEC9                <1> 	dec	cl
  3628 000022E3 75F3                <1> 	jnz	short tsloop
  3629 000022E5 C3                  <1> 	retn
  3630                              <1> bs:	
  3631                              <1> 	; back space found
  3632                              <1> 
  3633 000022E6 08D2                <1> 	or	dl, dl 		; is it already at start of line
  3634                              <1> 	;je	short u7 	; set_cursor
  3635 000022E8 7406                <1> 	jz	short _set_cpos
  3636                              <1> 	;dec	dx     		; no -- just move it back
  3637                              <1> 	; 17/04/2021
  3638 000022EA FECA                <1> 	dec	dl		; move to 1 column back
  3639                              <1> 	;jmp	short u7
  3640 000022EC EB02                <1> 	jmp	short _set_cpos
  3641                              <1> 
  3642                              <1> 	; carriage return found
  3643                              <1> u9:
  3644 000022EE B200                <1> 	mov	dl, 0 		; move to first column
  3645                              <1> 	;jmp	short u7
  3646                              <1> 	;jmp	short _set_cpos ; 30/01/2016
  3647                              <1> 
  3648                              <1> 	; line feed found
  3649                              <1> ;u10:
  3650                              <1> ;	cmp	dh, 25-1 	; bottom of screen
  3651                              <1> ;	jne	short u6 	; no, just set the cursor
  3652                              <1> ;       jmp     u1              ; yes, scroll the screen
  3653                              <1> 
  3654                              <1> _set_cpos:
  3655                              <1> 	; 02/08/2022 - TRDOS 386 v2.0.5
  3656                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  3657                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  3658                              <1> 	; 27/06/2015
  3659                              <1> 	; 01/09/2014
  3660                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  3661                              <1> 	;
  3662                              <1> 	; 04/12/2013 - 12/12/2013 (Retro UNIX 8086 v1) 
  3663                              <1> 	;
  3664                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  3665                              <1> 	;
  3666                              <1> ;----------------------------------------------
  3667                              <1> ; SET_CPOS
  3668                              <1> ;	THIS ROUTINE SETS THE CURRENT CURSOR POSITION TO THE
  3669                              <1> ;	NEW X-Y VALUES PASSED
  3670                              <1> ; INPUT
  3671                              <1> ;	DX - ROW,COLUMN OF NEW CURSOR
  3672                              <1> ;	BH - DISPLAY PAGE OF CURSOR
  3673                              <1> ; OUTPUT
  3674                              <1> ;	CURSOR ID SET AT 6845 IF DISPLAY PAGE IS CURRENT DISPLAY
  3675                              <1> ;----------------------------------------------
  3676                              <1> 	;
  3677 000022F0 BE[A6770100]        <1> 	mov	esi, CURSOR_POSN
  3678 000022F5 0FB6C7              <1>         movzx   eax, bh	; BH = video page number
  3679                              <1> ;	or	al, al
  3680                              <1> ;	jz	short _set_cpos_0
  3681 000022F8 D0E0                <1>         shl     al, 1   ; word offset
  3682 000022FA 01C6                <1>         add     esi, eax
  3683                              <1> ;_set_cpos_0:
  3684 000022FC 668916              <1> 	mov	[esi], dx ; save the pointer
  3685 000022FF 383D[B6770100]      <1> 	cmp	[ACTIVE_PAGE], bh
  3686 00002305 7532                <1> 	jne	short m17
  3687                              <1> 	;call	m18	; CURSOR SET
  3688                              <1> ;m17:			; SET_CPOS_RETURN
  3689                              <1> 	; 01/09/2014
  3690                              <1> ;	retn
  3691                              <1> 		; DX = row/column
  3692                              <1> m18:
  3693 00002307 E852FCFFFF          <1> 	call	position ; determine location in regen buffer	
  3694 0000230C 668B0D[A4770100]    <1> 	mov	cx, [CRT_START]
  3695 00002313 6601C1              <1> 	add	cx, ax  ; add char position in regen buffer
  3696                              <1> 			; to the start address (offset) for this page
  3697 00002316 66D1E9              <1> 	shr	cx, 1	; divide by 2 for char only count
  3698 00002319 B40E                <1> 	mov	ah, 14	; register number for cursor
  3699                              <1> 	;call	m16	; output value to the 6845	
  3700                              <1> 	;retn
  3701                              <1> 
  3702                              <1> 	;-----	THIS ROUTINE OUTPUTS THE CX REGISTER
  3703                              <1> 	;	TO THE 6845 REGISTERS NAMED IN (AH)
  3704                              <1> m16:
  3705 0000231B FA                  <1> 	cli
  3706                              <1> 	;mov	dx, [addr_6845] ; address register
  3707 0000231C 66BAD403            <1> 	mov 	dx, 03D4h ; I/O address of color card
  3708 00002320 88E0                <1> 	mov	al, ah	; get value
  3709 00002322 EE                  <1> 	out	dx, al	; register set
  3710                              <1> 	;inc	dx	; data register
  3711                              <1> 	; 17/04/2021
  3712 00002323 FEC2                <1> 	inc	dl
  3713 00002325 EB00                <1> 	jmp	$+2	; i/o delay
  3714 00002327 88E8                <1> 	mov	al, ch	; data
  3715 00002329 EE                  <1> 	out	dx, al	
  3716                              <1> 	;dec	dx	
  3717                              <1> 	; 17/04/2021
  3718 0000232A FECA                <1> 	dec	dl
  3719 0000232C 88E0                <1> 	mov	al, ah
  3720 0000232E FEC0                <1> 	inc	al	; point to other data register
  3721 00002330 EE                  <1> 	out	dx, al	; set for second register
  3722                              <1> 	;inc	dx
  3723                              <1> 	; 17/04/2021
  3724 00002331 FEC2                <1> 	inc	dl
  3725 00002333 EB00                <1> 	jmp	$+2	; i/o delay
  3726 00002335 88C8                <1> 	mov	al, cl	; second data value
  3727 00002337 EE                  <1> 	out	dx, al
  3728 00002338 FB                  <1> 	sti
  3729                              <1> m17:
  3730 00002339 C3                  <1> 	retn
  3731                              <1> 
  3732                              <1> _beep:
  3733                              <1> 	; 12/02/2021 (TRDOS v2.0.3)
  3734 0000233A FA                  <1> 	cli
  3735 0000233B E811000000          <1> 	call	beep
  3736 00002340 FB                  <1> 	sti
  3737 00002341 C3                  <1> 	retn
  3738                              <1> 
  3739                              <1> beeper: 
  3740                              <1> 	; 04/08/2016
  3741                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  3742                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  3743                              <1> 	; 18/01/2014
  3744                              <1> 	; 03/12/2013
  3745                              <1> 	; bell found
  3746                              <1> u11:
  3747 00002342 FB                  <1> 	sti
  3748 00002343 3A3D[B6770100]      <1> 	cmp	bh, [ACTIVE_PAGE]
  3749 00002349 7552                <1> 	jne	short u12	; Do not sound the beep 
  3750                              <1> 				; if it is not written on the active page
  3751                              <1> beeper_gfx: ; 04/08/2016
  3752 0000234B 66B93305            <1> 	mov	cx, 1331 	; divisor for 896 hz tone
  3753 0000234F B31F                <1> 	mov	bl, 31		; set count for 31/64 second for beep
  3754                              <1> 	;call	beep		; sound the pod bell
  3755                              <1> 	;jmp	short u5 	; tty_return
  3756                              <1> 	;retn
  3757                              <1> 	
  3758                              <1> TIMER	equ 	040h   		; 8254 TIMER - BASE ADDRESS
  3759                              <1> PORT_B	equ	061h		; PORT B READ/WRITE DIAGNOSTIC REGISTER
  3760                              <1> GATE2	equ	00000001b	; TIMER 2 INPUT CATE CLOCK BIT
  3761                              <1> SPK2	equ	00000010b	; SPEAKER OUTPUT DATA ENABLE BIT
  3762                              <1> 
  3763                              <1> beep:
  3764                              <1> 	; 12/02/2021
  3765                              <1> 	; 07/02/2015
  3766                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  3767                              <1> 	; 18/01/2014
  3768                              <1> 	; 03/12/2013
  3769                              <1> 	;
  3770                              <1> 	; TEST4.ASM - 06/10/85  POST AND BIOS UTILITY ROUTINES
  3771                              <1> 	;
  3772                              <1> 	; ROUTINE TO SOUND THE BEEPER USING TIMER 2 FOR TONE
  3773                              <1> 	;
  3774                              <1> 	; ENTRY:
  3775                              <1> 	;    (BL) = DURATION COUNTER ( 1 FOR 1/64 SECOND )
  3776                              <1> 	;    (CX) = FREQUENCY DIVISOR (1193180/FREQUENCY) (1331 FOR 886 HZ)
  3777                              <1> 	; EXIT:				:
  3778                              <1> 	;    (AX),(BL),(CX) MODIFIED.
  3779                              <1> 
  3780 00002351 9C                  <1> 	pushfd  ; 18/01/2014	; save interrupt status
  3781 00002352 FA                  <1> 	cli			; block interrupts during update
  3782 00002353 B0B6                <1> 	mov	al, 10110110b	; select timer 2, lsb, msb binary
  3783 00002355 E643                <1> 	out	TIMER+3, al 	; write timer mode register
  3784 00002357 EB00                <1> 	jmp	$+2		; I/O delay
  3785 00002359 88C8                <1> 	mov	al, cl		; divisor for hz (low)
  3786 0000235B E642                <1> 	out	TIMER+2,AL	; write timer 2 count - lsb
  3787 0000235D EB00                <1> 	jmp	$+2		; I/O delay
  3788 0000235F 88E8                <1> 	mov	al, ch		; divisor for hz (high)
  3789 00002361 E642                <1> 	out	TIMER+2, al	; write timer 2 count - msb
  3790 00002363 E461                <1> 	in	al, PORT_B	; get current setting of port
  3791 00002365 88C4                <1> 	mov	ah, al		; save that setting
  3792 00002367 0C03                <1> 	or	al, GATE2+SPK2	; gate timer 2 and turn speaker on
  3793 00002369 E661                <1> 	out	PORT_B, al	; and restore interrupt status
  3794                              <1> 	; 12/02/2021
  3795 0000236B 9D                  <1> 	popfd	; 18/01/2014
  3796                              <1> 	;sti
  3797                              <1> g7:				; 1/64 second per count (bl)
  3798 0000236C B90B040000          <1> 	mov	ecx, 1035	; delay count for 1/64 of a second
  3799 00002371 E828000000          <1> 	call	waitf		; go to beep delay 1/64 count
  3800 00002376 FECB                <1> 	dec	bl		; (bl) length count expired?
  3801 00002378 75F2                <1> 	jnz	short g7	; no - continue beeping speaker
  3802                              <1> 	;
  3803 0000237A 9C                  <1> 	pushfd	; 12/02/2021	; save interrupt status
  3804 0000237B FA                  <1> 	cli  	; 18/01/2014	; block interrupts during update
  3805 0000237C E461                <1> 	in	al, PORT_B	; get current port value
  3806                              <1>         ;or	al, not (GATE2+SPK2) ; isolate current speaker bits in case
  3807 0000237E 0CFC                <1>         or      al, ~(GATE2+SPK2)
  3808 00002380 20C4                <1>         and	ah, al		; someone turned them off during beep
  3809 00002382 88E0                <1> 	mov	al, ah		; recover value of port
  3810                              <1>         ;or	al, not (GATE2+SPK2) ; force speaker data off
  3811 00002384 0CFC                <1> 	or 	al, ~(GATE2+SPK2) ; isolate current speaker bits in case
  3812 00002386 E661                <1> 	out	PORT_B, al	; and stop speaker timer
  3813 00002388 9D                  <1> 	popfd	; 12/02/2021		; restore interrupt flag state
  3814                              <1> 	;sti
  3815                              <1> 	;mov	ecx, 1035	; force 1/64 second delay (short)
  3816                              <1> 	; 17/04/2021
  3817 00002389 66B90B04            <1> 	mov	cx, 1035
  3818 0000238D E80C000000          <1> 	call	waitf		; minimum delay between all beeps
  3819 00002392 9C                  <1> 	pushfd			; save interrupt status
  3820 00002393 FA                  <1> 	cli			; block interrupts during update
  3821 00002394 E461                <1> 	in	al, PORT_B	; get current port value in case
  3822 00002396 2403                <1> 	and	al, GATE2+SPK2	; someone turned them on
  3823 00002398 08E0                <1> 	or	al, ah		; recover value of port_b
  3824 0000239A E661                <1> 	out	PORT_B, al	; restore speaker status
  3825 0000239C 9D                  <1> 	popfd			; restore interrupt flag state
  3826                              <1> u12:	
  3827 0000239D C3                  <1> 	retn
  3828                              <1> 
  3829                              <1> REFRESH_BIT equ	00010000b 	; REFRESH TEST BIT
  3830                              <1> 
  3831                              <1> WAITF:
  3832                              <1> waitf:
  3833                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  3834                              <1> 	; 03/12/2013
  3835                              <1> 	;
  3836                              <1> ;	push	ax		; save work register (ah)
  3837                              <1> ;waitf1:
  3838                              <1> 				; use timer 1 output bits
  3839                              <1> ;	in	al, PORT_B	; read current counter output status
  3840                              <1> ;	and	al, REFRESH_BIT	; mask for refresh determine bit
  3841                              <1> ;	cmp	al, ah		; did it just change
  3842                              <1> ;	je	short waitf1	; wait for a change in output line
  3843                              <1> ;	;
  3844                              <1> ;	mov	ah, al		; save new lflag state
  3845                              <1> ;	loop	waitf1		; decrement half cycles till count end
  3846                              <1> ;	;
  3847                              <1> ;	pop	ax		; restore (ah)
  3848                              <1> ;	retn			; return (cx)=0
  3849                              <1> 
  3850                              <1> ; 06/02/2015 (unix386.s <-- dsectrm2.s)
  3851                              <1> ; 17/12/2014 (dsectrm2.s)
  3852                              <1> ; WAITF
  3853                              <1> ; /// IBM PC-XT Model 286 System BIOS Source Code - Test 4 - 06/10/85 ///
  3854                              <1> ;
  3855                              <1> ;---WAITF-----------------------------------------------------------------------
  3856                              <1> ;	FIXED TIME WAIT ROUTINE (HARDWARE CONTROLLED - NOT PROCESSOR)
  3857                              <1> ; ENTRY:
  3858                              <1> ;	(CX) =	COUNT OF 15.085737 MICROSECOND INTERVALS TO WAIT
  3859                              <1> ;	      	MEMORY REFRESH TIMER 1 OUTPUT USED AS REFERENCE
  3860                              <1> ; EXIT:
  3861                              <1> ;	       	AFTER (CX) TIME COUNT (PLUS OR MINUS 16 MICROSECONDS)
  3862                              <1> ;	(CX) = 0	
  3863                              <1> ;-------------------------------------------------------------------------------
  3864                              <1> 
  3865                              <1> ; Refresh period: 30 micro seconds (15-80 us)
  3866                              <1> ; (16/12/2014 - AWARDBIOS 1999 - ATORGS.ASM, WAIT_REFRESH)
  3867                              <1> 
  3868                              <1> ;WAITF:					; DELAY FOR (CX)*15.085737 US
  3869                              <1> 	;push	AX			; SAVE WORK REGISTER (AH)
  3870                              <1> 	; 11/04/2021
  3871 0000239E 50                  <1> 	push	eax
  3872                              <1> 	; 16/12/2014
  3873                              <1> 	;shr	cx, 1			; convert to count of 30 micro seconds
  3874 0000239F D1E9                <1> 	shr	ecx, 1	; 21/02/2015
  3875                              <1> ;17/12/2014	
  3876                              <1> ;WAITF1:
  3877                              <1> ;	in	al, PORT_B   ;061h	; READ CURRENT COUNTER OUTPUT STATUS
  3878                              <1> ;	and	al, REFRESH_BIT	;00010000b ; MASK FOR REFRESH DETERMINE BIT
  3879                              <1> ;	cmp	al, ah			; DID IT JUST CHANGE
  3880                              <1> ;	je	short WAITF1		; WAIT FOR A CHANGE IN OUTPUT LINE
  3881                              <1> ;	mov	ah, al			; SAVE NEW FLAG STATE
  3882                              <1> ;	loop	WAITF1			; DECREMENT HALF CYCLES TILL COUNT END		
  3883                              <1> 	;
  3884                              <1> 	; 17/12/2014
  3885                              <1> 	;
  3886                              <1> 	; Modification from 'WAIT_REFRESH' procedure of AWARD BIOS - 1999
  3887                              <1> 	;
  3888                              <1> ;WAIT_REFRESH:  Uses port 61, bit 4 to have CPU speed independent waiting.
  3889                              <1> ;   	INPUT:  CX = number of refresh periods to wait
  3890                              <1> ;     	       (refresh periods = 1 per 30 microseconds on most machines)
  3891                              <1> WR_STATE_0:
  3892 000023A1 E461                <1> 	in	al, PORT_B		; IN AL,SYS1
  3893 000023A3 A810                <1> 	test	al, 010h
  3894 000023A5 74FA                <1> 	JZ	short WR_STATE_0
  3895                              <1> WR_STATE_1:
  3896 000023A7 E461                <1> 	in	al, PORT_B		; IN AL,SYS1
  3897 000023A9 A810                <1> 	test	al, 010h
  3898 000023AB 75FA                <1> 	jnz	short WR_STATE_1
  3899 000023AD E2F2                <1>         loop    WR_STATE_0
  3900                              <1> 	;
  3901                              <1> 	;pop	ax			; RESTORE (AH)
  3902                              <1> 	; 11/04/2021
  3903 000023AF 58                  <1> 	pop	eax
  3904 000023B0 C3                  <1> 	retn				; (CX) = 0
  3905                              <1> 
  3906                              <1> ; 03/08/2022
  3907                              <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5
  3908                              <1> ; 09/07/2016
  3909                              <1> ; 01/07/2016
  3910                              <1> ; 24/06/2016
  3911                              <1> ; 23/06/2016 - TRDOS 386 (TRDOS v2.0)
  3912                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3913                              <1> ;-------------------------------------------------------------------------------
  3914                              <1> ; WRITE_STRING								       :
  3915                              <1> ;	THIS ROUTINE WRITES A STRING OF CHARACTERS TO THE CRT.		       :
  3916                              <1> ; INPUT 								       :
  3917                              <1> ;	(AL) = WRITE STRING COMMAND  0 - 3				       :
  3918                              <1> ;	(BH) = DISPLAY PAGE (ACTIVE PAGE)				       :
  3919                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE, IF (CX) = 0 THEN RETURN	       :
  3920                              <1> ;	(DX) = CURSOR POSITION FOR START OF STRING WRITE		       :
  3921                              <1> ;	(BL) = ATTRIBUTE OF CHARACTER TO WRITE IF (AL) = 0  OR	(AL) = 1       :
  3922                              <1> ;	(EBP) = SOURCE STRING OFFSET					       :
  3923                              <1> ; OUTPUT								       :
  3924                              <1> ;	NONE								       :
  3925                              <1> ;-------------------------------------------------------------------------------
  3926                              <1> 
  3927                              <1> ; AL = 00h: Assign all characters the attribute in BL; do not update cursor
  3928                              <1> ; AL = 01h: Assign all characters the attribute in BL; update cursor
  3929                              <1> ; AL = 02h: Use attributes in string; do not update cursor
  3930                              <1> ; AL = 03h: Use attributes in string; update cursor
  3931                              <1> 
  3932                              <1> WRITE_STRING:
  3933                              <1> 	; 03/08/2022
  3934                              <1> 	; 02/08/2022
  3935                              <1> 	; 12/09/2016
  3936                              <1> 	; 09/07/2016
  3937                              <1> 	;cmp	byte [CRT_MODE], 7 ; 6?!
  3938                              <1> 	;ja	VIDEO_RETURN		; not a valid function for VGA modes
  3939                              <1> 	;
  3940 000023B1 A2[18840100]        <1> 	mov	[w_str_cmd], al		; save (AL) command
  3941 000023B6 3C04                <1> 	cmp	al, 4			; TEST FOR INVALID WRITE STRING OPTION
  3942                              <1> 	;jnb	VIDEO_RETURN		; IF OPTION INVALID THEN RETURN
  3943                              <1> 	; 02/08/2022
  3944 000023B8 7361                <1> 	jnb	short P55
  3945                              <1> 
  3946                              <1>         ;jcxz	VIDEO_RETURN		; IF ZERO LENGTH STRING THEN RETURN
  3947                              <1> 
  3948 000023BA 67E35E              <1>         jcxz    P55			; 01/07/2016
  3949                              <1> 
  3950                              <1> 	; 01/07/2016
  3951                              <1> 	;and	ecx, 0FFFFh
  3952                              <1> 	; ecx = byte count
  3953                              <1> 	;push	ecx
  3954 000023BD 89EE                <1> 	mov	esi, ebp ; user buffer
  3955 000023BF BF00000700          <1> 	mov	edi, Cluster_Buffer  ; system buffer
  3956 000023C4 E8DAE90000          <1> 	call	transfer_from_user_buffer
  3957                              <1> 	;pop	ecx
  3958                              <1> 	;jc	VIDEO_RETURN
  3959                              <1> 	; 02/08/2022
  3960 000023C9 7250                <1> 	jc	short P55
  3961                              <1> 	; ecx = transfer (byte) count = character count
  3962 000023CB BD00000700          <1> 	mov	ebp, Cluster_Buffer
  3963                              <1> 	; 12/09/2016
  3964 000023D0 803D[CE660000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6?!
  3965                              <1> 	;ja	vga_write_string
  3966                              <1> 	; 02/08/2022
  3967 000023D7 7605                <1> 	jna	short P57
  3968 000023D9 E99C000000          <1> 	jmp	vga_write_string
  3969                              <1> P57:
  3970 000023DE 0FB6F7              <1> 	movzx	esi, bh			; GET CURRENT CURSOR PAGE
  3971                              <1> 	;sal	si, 1			; CONVERT TO PAGE OFFSET (SI = PAGE)
  3972                              <1> 	; 02/08/2022
  3973 000023E1 D1E6                <1> 	sal	esi, 1
  3974                              <1> 	; *****
  3975 000023E3 66FFB6[A6770100]    <1> 	push	word [esi+CURSOR_POSN]	; SAVE CURRENT CURSOR POSITION IN STACK
  3976                              <1> 
  3977                              <1> 	;mov	ax, 0200h		; SET NEW CURSOR POSITION
  3978                              <1> 	;int	10h
  3979                              <1> P50next:	
  3980 000023EA 51                  <1> 	push	ecx ; ****
  3981 000023EB 53                  <1> 	push	ebx ; *** ; 18/11/2020
  3982 000023EC 56                  <1> 	push	esi ; **
  3983 000023ED 52                  <1> 	push	edx ; *
  3984 000023EE E8FDFEFFFF          <1> 	call	_set_cpos
  3985                              <1> P50:
  3986 000023F3 8A4500              <1> 	mov	al, [ebp]		; GET CHARACTER FROM INPUT STRING
  3987 000023F6 45                  <1> 	inc	ebp			; BUMP POINTER TO CHARACTER
  3988                              <1> 
  3989                              <1> ;-----	TEST FOR SPECIAL CHARACTER'S
  3990                              <1> 
  3991 000023F7 3C08                <1> 	cmp	al, 08h			; IS IT A BACKSPACE
  3992 000023F9 7410                <1> 	je	short P51		; BACK_SPACE
  3993 000023FB 3C0D                <1> 	cmp	al, 0Dh ; CR		; IS IT CARRIAGE RETURN
  3994 000023FD 740C                <1> 	je	short P51		; CAR_RET
  3995 000023FF 3C0A                <1> 	cmp	al, 0Ah ; LF		; IS IT A LINE FEED
  3996 00002401 7408                <1> 	je	short P51		; LINE_FEED
  3997                              <1> 	; 18/11/2020
  3998 00002403 3C09                <1> 	cmp	al, 09h			; is it a tab stop
  3999 00002405 7404                <1> 	je	short P51
  4000                              <1> 	;
  4001 00002407 3C07                <1> 	cmp	al, 07h			; IS IT A BELL
  4002 00002409 7515                <1> 	jne	short P52		; IF NOT THEN DO WRITE CHARACTER
  4003                              <1> P51:
  4004                              <1> 	;mov	ah, 0Eh			; TTY_CHARACTER_WRITE
  4005                              <1> 	;int	10h			; WRITE TTY CHARACTER TO THE CRT
  4006                              <1> 	
  4007 0000240B E85BFEFFFF          <1> 	call	_write_tty_m3
  4008                              <1> 
  4009 00002410 5A                  <1> 	pop	edx ; *
  4010 00002411 5E                  <1> 	pop	esi ; **
  4011                              <1> 
  4012 00002412 668B96[A6770100]    <1> 	mov	dx, [esi+CURSOR_POSN]	; GET CURRENT CURSOR POSITION
  4013 00002419 EB44                <1> 	jmp	short P54		; SET CURSOR POSITION AND CONTINUE
  4014                              <1> P55:
  4015 0000241B E9D5F6FFFF          <1> 	jmp	VIDEO_RETURN
  4016                              <1> P52:
  4017                              <1> 	;mov	cx, 1			; SET CHARACTER WRITE AMOUNT TO ONE
  4018                              <1> 	; 02/08/2022
  4019 00002420 29C9                <1> 	sub	ecx, ecx
  4020 00002422 FEC1                <1> 	inc	cl
  4021                              <1> 	; ecx = 1
  4022 00002424 803D[18840100]02    <1> 	cmp	byte [w_str_cmd], 2	; IS THE ATTRIBUTE IN THE STRING
  4023 0000242B 7204                <1> 	jb	short P53		; IF NOT THEN SKIP
  4024 0000242D 8A5D00              <1> 	mov	bl, [ebp]		; ELSE GET NEW ATTRIBUTE
  4025 00002430 45                  <1> 	inc	ebp			; BUMP STRING POINTER
  4026                              <1> P53:
  4027                              <1> 	;mov	ah, 09h			; GOT_CHARACTER
  4028                              <1> 	;int	10h			; WRITE CHARACTER TO THE CRT
  4029                              <1> 
  4030 00002431 E8A1FDFFFF          <1> 	call	_write_c_current
  4031                              <1> 	
  4032 00002436 5A                  <1> 	pop	edx ; *	
  4033                              <1> 
  4034                              <1> 	; 05/12/2020
  4035                              <1> 	; bx is preserved in '_write_c_current'
  4036                              <1> 	; 18/11/2020
  4037                              <1> 	;mov	ebx, [esp+4]	; ***
  4038                              <1> 
  4039 00002437 0FB6F7              <1> 	movzx	esi, bh ; video page number (0 to 7)	
  4040 0000243A 889E[D7660000]      <1> 	mov	[esi+chr_attrib], bl ; color/attribute
  4041                              <1> 
  4042 00002440 FEC2                <1> 	inc	dl			; INCREMENT COLUMN COUNTER
  4043 00002442 3A15[D0660000]      <1> 	cmp	dl, [CRT_COLS]		; IF COLS ARE WITHIN RANGE FOR THIS MODE
  4044                              <1> 	;jb	short P54		;    THEN GO TO COLUMNS SET
  4045 00002448 7214                <1> 	jb	short P56 ; 05/12/2020
  4046 0000244A FEC6                <1> 	inc	dh			; BUMP ROW COUNTER BY ONE
  4047 0000244C 28D2                <1> 	sub	dl, dl			; SET COLUMN COUNTER TO ZERO
  4048 0000244E 80FE19              <1> 	cmp	dh, 25			; IF ROWS ARE LESS THAN 25 THEN
  4049                              <1> 	;jb	short P54		; GO TO ROWS_COLUMNS_SET
  4050 00002451 720B                <1> 	jb	short P56 ; 05/12/2020
  4051                              <1> 
  4052                              <1> 	; 18/11/2020
  4053                              <1> 	;mov	ax, 0E0Ah		; ELSE SCROLL SCREEN
  4054                              <1> 	;int	10h			; RESET ROW COUNTER TO 24
  4055                              <1> 
  4056                              <1> 	; 18/11/2020
  4057 00002453 B00A                <1> 	mov	al, 0Ah	; line feed
  4058                              <1> 
  4059 00002455 E811FEFFFF          <1> 	call	_write_tty_m3
  4060                              <1> 	
  4061 0000245A 66BA0018            <1> 	mov	dx, 1800h		; Column = 0, Row = 24
  4062                              <1> P56:	
  4063                              <1> 	; 05/12/2020
  4064                              <1> 	; 18/11/2020
  4065 0000245E 5E                  <1> 	pop	esi ; **
  4066                              <1> P54:					; ROW_COLUMNS_SET
  4067                              <1> 	;mov	ax, 0200h		; SET NEW CURSOR POSITION COMMAND
  4068                              <1> 	;int	10h			; ESTABLISH NEW CURSOR POSITION
  4069                              <1> 
  4070                              <1> 	; 18/11/2020
  4071 0000245F 5B                  <1> 	pop	ebx ; ***
  4072 00002460 59                  <1> 	pop	ecx ; ****
  4073                              <1> 
  4074                              <1> 	;loop	P50			; DO IT ONCE MORE UNTIL (CX) = ZERO
  4075 00002461 6649                <1> 	dec	cx
  4076 00002463 7585                <1> 	jnz	short P50next
  4077                              <1> 
  4078 00002465 665A                <1> 	pop	dx  ; *****		; RESTORE OLD CURSOR COORDINATES
  4079                              <1> 	
  4080 00002467 F605[18840100]01    <1> 	test	byte [w_str_cmd], 1	; IF CURSOR WAS NOT TO BE MOVED
  4081                              <1> 	;jnz	VIDEO_RETURN		; THEN EXIT WITHOUT RESETTING OLD VALUE
  4082                              <1> 	; 03/08/2022
  4083 0000246E 7505                <1> 	jnz	short P58
  4084                              <1> 	
  4085                              <1> 	;mov	ax, 0200h		; ELSE RESTORE OLD CURSOR POSITION
  4086                              <1> 	;int	10h
  4087                              <1> 					; DONE - EXIT WRITE STRING
  4088 00002470 E87BFEFFFF          <1> 	call	_set_cpos
  4089                              <1> P58:
  4090 00002475 E97BF6FFFF          <1> 	jmp	VIDEO_RETURN		; RETURN TO CALLER
  4091                              <1> 
  4092                              <1> vga_write_string:
  4093                              <1> 	; 04/08/2022 - TRDOS 386 Kernel v2.0.5
  4094                              <1> 	; 12/09/2016 - TRDOS 386 (TRDOS v2.0)
  4095                              <1> 	;
  4096                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4097                              <1> 	; vgabios-0.7a (2011)
  4098                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4099                              <1> 	; 'vgabios.c', ' biosfn_write_string'
  4100                              <1> 
  4101                              <1> 	; INPUT 								  :
  4102                              <1> 	;	(AL) = WRITE STRING COMMAND  0 - 3				  :
  4103                              <1> 	;	(BH) = DISPLAY PAGE (ACTIVE PAGE)				  :
  4104                              <1> 	;	(CX) = COUNT OF CHARACTERS TO WRITE, IF (CX) = 0 THEN RETURN	  :
  4105                              <1> 	;	(DX) = CURSOR POSITION FOR START OF STRING WRITE		  :
  4106                              <1> 	;	(BL) = ATTRIBUTE OF CHARACTER TO WRITE IF (AL) = 0  OR	(AL) = 1  :
  4107                              <1> 	;	(EBP) = SOURCE STRING OFFSET					  :
  4108                              <1> 	; OUTPUT								  :
  4109                              <1> 	;	NONE								  :
  4110                              <1> 	;-------------------------------------------------------------------------;
  4111                              <1> 
  4112                              <1> 	; AL = 00h: Assign all characters the attribute in BL; do not update cursor
  4113                              <1> 	; AL = 01h: Assign all characters the attribute in BL; update cursor
  4114                              <1> 	; AL = 02h: Use attributes in string; do not update cursor
  4115                              <1> 	; AL = 03h: Use attributes in string; update cursor
  4116                              <1> 	
  4117                              <1> 	; biosfn_write_string(GET_AL(),GET_BH(),GET_BL(),CX,GET_DH(),GET_DL(),ES,BP);
  4118                              <1> 	; static void biosfn_write_string (flag,page,attr,count,row,col,seg,offset) 
  4119                              <1> 
  4120                              <1> 	; // Read curs info for the page
  4121                              <1>  	; biosfn_get_cursor_pos(page,&dummy,&oldcurs);
  4122                              <1> 	; bh = video page = 0
  4123                              <1> 	;movzx	esi, word [CURSOR_POSN] ; current cursor position for video page 0
  4124                              <1> 	
  4125                              <1> 	; // if row=0xff special case : use current cursor position
  4126                              <1> 	; if(row==0xff)
  4127                              <1> 	;  {col=oldcurs&0x00ff;
  4128                              <1> 	;   row=(oldcurs&0xff00)>>8;
  4129                              <1> 	;  }
  4130                              <1> 
  4131                              <1> 	;mov	al, [w_str_cmd]
  4132                              <1> 
  4133 0000247A 80FEFF              <1> 	cmp	dh, 0FFh
  4134 0000247D 7407                <1> 	je	short vga_wstr_1 ; user current cursor position
  4135                              <1> vga_wstr_0:
  4136                              <1> 	; set cursor position
  4137 0000247F 668915[A6770100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  4138                              <1> vga_wstr_1:
  4139 00002486 66FF35[A6770100]    <1> 	push	word [CURSOR_POSN] ; *
  4140                              <1> 
  4141                              <1> 	; ebp = string offset in system buffer (user buffer was copied to)
  4142                              <1> 	
  4143                              <1> 	; while(count--!=0)
  4144                              <1> 	;  {
  4145                              <1> 	;   car=read_byte(seg,offset++);
  4146                              <1> 	;   if((flag&0x02)!=0)
  4147                              <1> 	;    attr=read_byte(seg,offset++);
  4148                              <1> 	;    biosfn_write_teletype(car,page,attr,WITH_ATTR);
  4149                              <1> 	;  }
  4150                              <1> 
  4151                              <1> 	;push	eax ; **
  4152                              <1> 	;test	al, 2
  4153 0000248D F605[18840100]02    <1> 	test	byte [w_str_cmd], 2
  4154 00002494 751D                <1> 	jnz	short vga_wstr_3
  4155 00002496 881D[B7770100]      <1> 	mov	[ccolor], bl
  4156                              <1> vga_wstr_2:
  4157 0000249C 51                  <1> 	push	ecx
  4158 0000249D 8A4500              <1> 	mov	al, [ebp]
  4159 000024A0 E88F0A0000          <1> 	call	vga_write_teletype
  4160 000024A5 59                  <1> 	pop	ecx
  4161 000024A6 6649                <1> 	dec	cx
  4162 000024A8 741E                <1> 	jz	short vga_wstr_4
  4163 000024AA 45                  <1> 	inc	ebp
  4164 000024AB 8A1D[B7770100]      <1> 	mov	bl, [ccolor]
  4165 000024B1 EBE9                <1> 	jmp	short vga_wstr_2
  4166                              <1> vga_wstr_3:
  4167 000024B3 51                  <1> 	push	ecx
  4168 000024B4 8A4500              <1> 	mov	al, [ebp]
  4169 000024B7 45                  <1> 	inc	ebp
  4170 000024B8 8A5D00              <1> 	mov	bl, [ebp]
  4171 000024BB E8740A0000          <1> 	call	vga_write_teletype
  4172 000024C0 59                  <1> 	pop	ecx
  4173 000024C1 6649                <1> 	dec	cx
  4174 000024C3 7403                <1> 	jz	short vga_wstr_4
  4175 000024C5 45                  <1> 	inc	ebp
  4176 000024C6 EBEB                <1> 	jmp	short vga_wstr_3
  4177                              <1> vga_wstr_4:
  4178                              <1> 	; // Set back curs pos 
  4179                              <1> 	; if((flag&0x01)==0)
  4180                              <1> 	;  biosfn_set_cursor_pos(page,oldcurs);
  4181                              <1> 	; }
  4182                              <1> 	;pop	eax ; **
  4183 000024C8 665A                <1> 	pop	dx ; word [CURSOR_POSN] ; *
  4184                              <1> 	;test	al, 1
  4185 000024CA F605[18840100]01    <1> 	test	byte [w_str_cmd], 1
  4186                              <1> 	;jnz	VIDEO_RETURN
  4187                              <1> 	; 04/08/2022
  4188 000024D1 7507                <1> 	jnz	short vga_wstr_5
  4189 000024D3 668915[A6770100]    <1> 	mov 	[CURSOR_POSN], dx
  4190                              <1> vga_wstr_5:
  4191 000024DA E916F6FFFF          <1> 	jmp	VIDEO_RETURN
  4192                              <1> 
  4193                              <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5
  4194                              <1> ; 07/07/2016
  4195                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  4196                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  4197                              <1> ;------------------------------------------------------
  4198                              <1> ;  SCROLL UP
  4199                              <1> ;   THIS ROUTINE SCROLLS UP THE INFORMATION ON THE CRT
  4200                              <1> ; ENTRY ---
  4201                              <1> ;  CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL
  4202                              <1> ;  DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL
  4203                              <1> ;   BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS
  4204                              <1> ;  BH = FILL VALUE FOR BLANKED LINES
  4205                              <1> ;  AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD)
  4206                              <1> ;  DS = DATA SEGMENT
  4207                              <1> ;  ES = REGEN SEGMENT
  4208                              <1> ; EXIT --
  4209                              <1> ;  NOTHING, THE SCREEN IS SCROLLED
  4210                              <1> ;--------------------------------------------------------
  4211                              <1> 
  4212                              <1> 	; cl = upper left column
  4213                              <1> 	; ch = upper left row
  4214                              <1> 	; dl = lower rigth column
  4215                              <1> 	; dh = lower right row
  4216                              <1> 	;
  4217                              <1> 	; al = line count (AL=0 means blank entire fields)
  4218                              <1> 	; bl = fill value for blanked lines	
  4219                              <1> 	; bh = unused
  4220                              <1> 
  4221                              <1> GRAPHICS_UP:
  4222                              <1> 	; 07/07/2016
  4223                              <1> 	; AH = Current video mode, [CRT_MODE]
  4224 000024DF 80FC07              <1> 	cmp	ah, 7
  4225 000024E2 7762                <1> 	ja	short vga_graphics_up
  4226                              <1> 	;je	n0
  4227                              <1> 
  4228 000024E4 88C7                <1> 	mov	bh, al			; save line count in BH
  4229                              <1> 	;mov	ax, cx			; GET UPPER LEFT POSITION INTO AX REG
  4230                              <1> 	; 03/08/2022
  4231 000024E6 89C8                <1> 	mov	eax, ecx
  4232                              <1> 
  4233                              <1> ;-----	USE CHARACTER SUBROUTINE FOR POSITIONING
  4234                              <1> ;-----	ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE
  4235                              <1> 
  4236 000024E8 E8BA050000          <1> 	call	GRAPH_POSN
  4237                              <1> 	;movzx	edi, ax			; SAVE RESULT AS DESTINATION ADDRESS
  4238                              <1> 	; 03/08/2022
  4239 000024ED 89C7                <1> 	mov	edi, eax
  4240                              <1> 
  4241                              <1> ;-----	DETERMINE SIZE OF WINDOW
  4242                              <1> 
  4243 000024EF 6629CA              <1> 	sub	dx, cx
  4244 000024F2 6681C20101          <1>         add     dx, 101h                ; ADJUST VALUES
  4245 000024F7 C0E602              <1> 	sal	dh, 2			; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR
  4246                              <1> 					; AND EVEN/ODD ROWS
  4247                              <1> ;-----	DETERMINE CRT MODE
  4248                              <1> 
  4249 000024FA 803D[CE660000]06    <1> 	cmp	byte [CRT_MODE], 6	; TEST FOR MEDIUM RES
  4250 00002501 7304                <1>         jnc	short _R7_              ; FIND_SOURCE
  4251                              <1> 
  4252                              <1> ;-----	MEDIUM RES UP
  4253 00002503 D0E2                <1> 	sal	dl, 1			; # COLUMNS * 2, SINCE 2 BYTES/CHAR
  4254                              <1> 	;sal	di, 1			; OFFSET *2 SINCE 2 BYTES/CHAR
  4255                              <1> 	; 03/08/2022
  4256 00002505 D1E7                <1> 	sal	edi, 1
  4257                              <1> 
  4258                              <1> ;-----	DETERMINE THE SOURCE ADDRESS IN THE BUFFER
  4259                              <1> _R7_:                                   ; FIND_SOURCE
  4260 00002507 81C700800B00        <1> 	add	edi, 0B8000h
  4261 0000250D C0E702              <1> 	sal	bh, 2			; multiply number of lines by 4
  4262 00002510 7430                <1>         jz	short _R11              ; IF ZERO, THEN BLANK ENTIRE FIELD
  4263 00002512 B050                <1> 	mov	al, 80			; 80 BYTES/ROW
  4264 00002514 F6E7                <1> 	mul	bh			; determine offset to source
  4265                              <1> 	;movzx	esi, ax			; offset to source
  4266                              <1> 	; 03/08/2022
  4267 00002516 89C6                <1> 	mov	esi, eax
  4268 00002518 01FE                <1> 	add	esi, edi		; SET UP SOURCE
  4269 0000251A 88F4                <1> 	mov	ah, dh			; NUMBER OF ROWS IN FIELD
  4270 0000251C 28FC                <1> 	sub	ah, bh			; determine number to move
  4271                              <1> 
  4272                              <1> ;-----	LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS
  4273                              <1> _R8:                                    ; ROW_LOOP
  4274 0000251E E8FD030000          <1>         call    _R17                    ; MOVE ONE ROW
  4275 00002523 6681EEB01F          <1> 	sub	si, 2000h-80		; MOVE TO NEXT ROW
  4276 00002528 6681EFB01F          <1> 	sub	di, 2000h-80
  4277 0000252D FECC                <1> 	dec	ah			; NUMBER OF ROWS TO MOVE
  4278 0000252F 75ED                <1>         jnz     short _R8               ; CONTINUE TILL ALL MOVED
  4279                              <1> 
  4280                              <1> ;-----	FILL IN THE VACATED LINE(S)
  4281                              <1> _R9:                                    ; CLEAR ENTRY
  4282 00002531 88D8                <1> 	mov	al, bl			; attribute to fill with
  4283                              <1> _R10_:
  4284 00002533 E804040000          <1>         call    _R18                    ; CLEAR THAT ROW
  4285 00002538 6681EFB01F          <1> 	sub	di, 2000h-80		; POINT TO NEXT LINE
  4286 0000253D FECF                <1> 	dec	bh			; number of lines to fill
  4287 0000253F 75F2                <1> 	jnz	short _R10_             ; CLEAR LOOP
  4288 00002541 C3                  <1> 	retn				; EVERYYHING DONE
  4289                              <1> 
  4290                              <1> _R11:                                   ; BLANK_FIELD
  4291 00002542 88F7                <1> 	mov	bh, dh			; set blank count to everything in field
  4292 00002544 EBEB                <1>         jmp     short _R9               ; CLEAR THE FIELD
  4293                              <1> 
  4294                              <1> vga_graphics_up:
  4295                              <1> 	; 03/08/2022 - TRDOS 386 Kertnel v2.0.5
  4296                              <1> 	; 12/04/2021
  4297                              <1> 	; 08/08/2016
  4298                              <1> 	; 07/08/2016
  4299                              <1> 	; 04/08/2016
  4300                              <1> 	; 01/08/2016
  4301                              <1> 	; 31/07/2016
  4302                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4303                              <1> 	;
  4304                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4305                              <1> 	; vgabios-0.7a (2011)
  4306                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4307                              <1> 	; 'vgabios.c', 'biosfn_scroll'
  4308                              <1> 	;
  4309                              <1> 
  4310                              <1> 	; cl = upper left column
  4311                              <1> 	; ch = upper left row
  4312                              <1> 	; dl = lower rigth column
  4313                              <1> 	; dh = lower right row
  4314                              <1> 	;
  4315                              <1> 	; al = line count (AL=0 means blank entire fields)
  4316                              <1> 	; bl = fill value for blanked lines	
  4317                              <1> 	; bh = unused
  4318                              <1> 	;
  4319                              <1> 	; ah = [CRT_MODE], current video mode	
  4320                              <1> 
  4321 00002546 88C7                <1> 	mov	bh, al ; 31/07/2016
  4322 00002548 BE[F2660000]        <1> 	mov	esi, vga_g_modes
  4323 0000254D 89F7                <1> 	mov	edi, esi
  4324 0000254F 83C708              <1> 	add	edi, vga_g_mode_count
  4325                              <1> vga_g_up_0:
  4326 00002552 AC                  <1> 	lodsb
  4327 00002553 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  4328 00002555 7405                <1> 	je	short vga_g_up_1
  4329 00002557 39FE                <1> 	cmp	esi, edi
  4330 00002559 72F7                <1> 	jb	short vga_g_up_0
  4331                              <1> 	;xor	bh, bh ; 31/07/2016)
  4332 0000255B C3                  <1> 	retn	; nothing to do
  4333                              <1> vga_g_up_1:
  4334 0000255C 88F8                <1> 	mov	al, bh ; 31/07/2016
  4335 0000255E 83C64F              <1> 	add	esi, vga_g_memmodel - (vga_g_modes + 1)  
  4336                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  4337                              <1> 	
  4338                              <1> 	; if(rlr>=nbrows)rlr=nbrows-1;
  4339                              <1>  	; if(clr>=nbcols)clr=nbcols-1;
  4340                              <1>  	; if(nblines>nbrows)nblines=0;
  4341                              <1>  	; cols=clr-cul+1;
  4342                              <1> 
  4343 00002561 3A35[D6660000]      <1> 	cmp	dh, [VGA_ROWS]
  4344 00002567 7208                <1> 	jb	short vga_g_up_2
  4345 00002569 8A35[D6660000]      <1> 	mov	dh, [VGA_ROWS]
  4346 0000256F FECE                <1> 	dec	dh
  4347                              <1> vga_g_up_2:
  4348 00002571 3A15[D0660000]      <1> 	cmp	dl, [CRT_COLS]  ; = [VGA_COLS]
  4349 00002577 7208                <1> 	jb	short vga_g_up_3
  4350 00002579 8A15[D0660000]      <1> 	mov	dl, [CRT_COLS]
  4351 0000257F FECA                <1> 	dec	dl
  4352                              <1> vga_g_up_3:	
  4353 00002581 3A05[D6660000]      <1> 	cmp	al, [VGA_ROWS]
  4354 00002587 7602                <1> 	jna	short vga_g_up_4
  4355 00002589 28C0                <1> 	sub	al, al ; 0
  4356                              <1> vga_g_up_4:
  4357 0000258B 88D7                <1> 	mov	bh, dl ; clr
  4358 0000258D 28CF                <1> 	sub	bh, cl ; cul
  4359 0000258F FEC7                <1> 	inc	bh ; cols = clr-cul+1
  4360                              <1> 
  4361 00002591 20C0                <1> 	and	al, al ; nblines = 0
  4362 00002593 7559                <1> 	jnz	short vga_g_up_6
  4363 00002595 20ED                <1> 	and	ch, ch ; rul = 0
  4364 00002597 7555                <1> 	jnz	short vga_g_up_6
  4365 00002599 20C9                <1> 	and	cl, cl ; cul = 0
  4366 0000259B 7551                <1> 	jnz	short vga_g_up_6
  4367                              <1> 
  4368                              <1> 	;push	ax
  4369                              <1> 	; 12/04/2021
  4370 0000259D 50                  <1> 	push	eax
  4371 0000259E A0[D6660000]        <1> 	mov	al, [VGA_ROWS]
  4372 000025A3 FEC8                <1> 	dec	al  
  4373 000025A5 38C6                <1> 	cmp	dh, al ; rlr = nbrows-1
  4374 000025A7 7545                <1> 	jne	short vga_g_up_5
  4375 000025A9 A0[D0660000]        <1>         mov     al, [CRT_COLS]  ; = VGA_COLS
  4376 000025AE FEC8                <1> 	dec	al 
  4377 000025B0 38C2                <1>  	cmp	dl, al ; clr = nbcols-1
  4378                              <1> 	;jne	short vga_g_up_5
  4379                              <1> 	;;pop	ax
  4380                              <1> 	; 12/04/2021
  4381 000025B2 58                  <1> 	pop	eax
  4382 000025B3 7539                <1> 	jne	short vga_g_up_5
  4383                              <1> 
  4384 000025B5 66B80502            <1> 	mov	ax, 0205h
  4385 000025B9 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4386 000025BD 66EF                <1> 	out	dx, ax
  4387 000025BF A0[D6660000]        <1> 	mov	al, [VGA_ROWS]
  4388 000025C4 8A25[D0660000]      <1> 	mov	ah, [CRT_COLS] ; = [VGA_COLS]
  4389 000025CA F6E4                <1> 	mul	ah
  4390 000025CC 0FB7D0              <1> 	movzx	edx, ax
  4391                              <1> 	; 08/08/2016
  4392 000025CF 0FB605[D2660000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  4393 000025D6 F7E2                <1> 	mul	edx
  4394                              <1> 	; eax = byte count	
  4395 000025D8 89C1                <1> 	mov	ecx, eax
  4396                              <1> 	;; 07/08/2016
  4397                              <1> 	;shl	dx, 3 ; * 8 ; * [CHAR_HEIGHT]
  4398                              <1> 	;mov	ecx, edx
  4399 000025DA 88D8                <1> 	mov	al, bl ; fill value for blanked lines
  4400 000025DC BF00000A00          <1> 	mov	edi, 0A0000h
  4401 000025E1 F3AA                <1> 	rep	stosb		
  4402                              <1> 	
  4403                              <1> 	;mov	ax, 5
  4404                              <1> 	; 03/08/2022
  4405 000025E3 30E4                <1> 	xor	ah, ah
  4406 000025E5 B005                <1> 	mov	al, 5
  4407                              <1> 
  4408 000025E7 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4409 000025EB 66EF                <1> 	out	dx, ax ; 0005h	
  4410                              <1> 
  4411 000025ED C3                  <1> 	retn
  4412                              <1> 
  4413                              <1> vga_g_up_5:
  4414                              <1> 	;;pop	ax
  4415                              <1> 	; 12/04/2021
  4416                              <1> 	;pop	eax
  4417                              <1> 
  4418                              <1> vga_g_up_6:
  4419                              <1> 	; [ESI] = VGA memory model number for current video mode
  4420                              <1>         ;
  4421                              <1>         ; LINEAR8 equ 5
  4422                              <1>         ; PLANAR4 equ 4
  4423                              <1>         ; PLANAR1 equ 3
  4424                              <1> 
  4425 000025EE 803E04              <1> 	cmp	byte [esi], PLANAR4
  4426 000025F1 7424                <1> 	je	short vga_g_up_planar
  4427 000025F3 803E03              <1> 	cmp	byte [esi], PLANAR1
  4428 000025F6 741F                <1> 	je	short vga_g_up_planar
  4429                              <1> vga_g_up_linear8:
  4430                              <1> 	; 07/07/2016 (TEMPORARY)
  4431                              <1> 	;
  4432                              <1> 	; cl = upper left column ; cul
  4433                              <1> 	; ch = upper left row ; rul
  4434                              <1> 	; dl = lower rigth column ; clr
  4435                              <1> 	; dh = lower right row ; rlr
  4436                              <1> 
  4437                              <1> vga_g_up_l0:
  4438                              <1>  	;{for(i=rul;i<=rlr;i++)
  4439                              <1>   	; if((i+nblines>rlr)||(nblines==0))
  4440 000025F8 08C0                <1> 	or	al, al
  4441 000025FA 7414                <1> 	jz	short vga_g_up_l2
  4442 000025FC 88C4                <1> 	mov	ah, al
  4443 000025FE 00EC                <1> 	add	ah, ch ; i+nblines
  4444                              <1> 	;jc	short vga_g_up_l2	
  4445 00002600 38F4                <1> 	cmp	ah, dh
  4446 00002602 770C                <1> 	ja	short vga_g_up_l2
  4447                              <1> 	; else
  4448                              <1> 	;  vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight);
  4449 00002604 E8F2000000          <1> 	call	vgamem_copy_l8
  4450                              <1> vga_g_up_l1:
  4451 00002609 FEC5                <1> 	inc	ch
  4452 0000260B 38F5                <1> 	cmp	ch, dh
  4453 0000260D 76E9                <1> 	jna	short vga_g_up_l0
  4454 0000260F C3                  <1> 	retn
  4455                              <1> vga_g_up_l2:
  4456                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  4457 00002610 E84C010000          <1> 	call	vgamem_fill_l8
  4458 00002615 EBF2                <1> 	jmp	short vga_g_up_l1
  4459                              <1> 
  4460                              <1> vga_g_up_planar:
  4461                              <1> 	; cl = upper left column ; cul
  4462                              <1> 	; ch = upper left row ; rul
  4463                              <1> 	; dl = lower rigth column ; clr
  4464                              <1> 	; dh = lower right row ; rlr
  4465                              <1> vga_g_up_pl0:
  4466                              <1>  	;{for(i=rul;i<=rlr;i++)
  4467                              <1>   	; if((i+nblines>rlr)||(nblines==0))
  4468 00002617 20C0                <1> 	and	al, al
  4469 00002619 7414                <1> 	jz	short vga_g_up_pl2	
  4470 0000261B 88C4                <1> 	mov	ah, al
  4471 0000261D 00EC                <1> 	add	ah, ch ; i+nblines
  4472                              <1> 	;jc	short vga_g_up_pl2
  4473 0000261F 38F4                <1> 	cmp	ah, dh
  4474 00002621 770C                <1> 	ja	short vga_g_up_pl2
  4475                              <1> 	; else
  4476                              <1> 	;  vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight);
  4477 00002623 E80E000000          <1> 	call	vgamem_copy_pl4
  4478                              <1> vga_g_up_pl1:
  4479 00002628 FEC5                <1> 	inc	ch 
  4480 0000262A 38F5                <1> 	cmp	ch, dh
  4481 0000262C 76E9                <1> 	jna	short vga_g_up_pl0
  4482 0000262E C3                  <1> 	retn
  4483                              <1> vga_g_up_pl2:
  4484                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  4485 0000262F E870000000          <1> 	call	vgamem_fill_pl4
  4486 00002634 EBF2                <1> 	jmp	short vga_g_up_pl1
  4487                              <1> 
  4488                              <1> vgamem_copy_pl4:
  4489                              <1> 	; 08/08/2016
  4490                              <1> 	; 07/08/2016
  4491                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4492                              <1> 	;
  4493                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4494                              <1> 	; vgabios-0.7a (2011)
  4495                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4496                              <1> 	; 'vgabios.c', 'vgamem_copy_pl4'
  4497                              <1> 	;
  4498                              <1> 	; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight)
  4499                              <1> 	; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i),
  4500                              <1> 	; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  4501                              <1> 
  4502                              <1> 	; src=ysrc*cheight*nbcols+xstart;
  4503                              <1> 	; dest=ydest*cheight*nbcols+xstart;
  4504                              <1> 
  4505 00002636 52                  <1> 	push	edx
  4506 00002637 50                  <1> 	push	eax
  4507                              <1> 
  4508                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0105)
  4509 00002638 66B80501            <1> 	mov	ax, 0105h
  4510 0000263C 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4511 00002640 66EF                <1> 	out	dx, ax
  4512                              <1> 
  4513                              <1> 	; 07/08/2016
  4514                              <1>  	;mov     ah, [esp+1]
  4515                              <1> 	;movzx	edx, ah ; ysrc
  4516 00002642 0FB6542401          <1> 	movzx	edx, byte [esp+1]
  4517                              <1> 	; 08/08/2016
  4518 00002647 0FB605[D2660000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  4519 0000264E 8A25[D0660000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  4520 00002654 F6E4                <1> 	mul	ah 
  4521                              <1> 	;; 07/08/2016
  4522                              <1> 	;movzx	eax, byte [CRT_COLS]
  4523                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  4524 00002656 50                  <1> 	push	eax ; cheight * nbcols
  4525 00002657 F7E2                <1> 	mul	edx ; * ysrc
  4526                              <1> 	; eax = ysrc * cheight * nbcols
  4527                              <1> 	; edx = 0
  4528 00002659 88CA                <1> 	mov	dl, cl ; edx = xstart	
  4529 0000265B 01D0                <1>  	add	eax, edx
  4530 0000265D 89C6                <1> 	mov	esi, eax ; src
  4531 0000265F 88EA                <1> 	mov	dl, ch ; ydest
  4532 00002661 58                  <1> 	pop	eax ; cheight * nbcols
  4533 00002662 F7E2                <1> 	mul	edx
  4534                              <1> 	; eax = ydest * cheight * nbcols
  4535 00002664 88CA                <1> 	mov	dl, cl ; edx = xstart	
  4536 00002666 01D0                <1>  	add	eax, edx
  4537 00002668 89C7                <1> 	mov	edi, eax ; dest
  4538                              <1> 	; esi = src
  4539                              <1> 	; edi = dest
  4540                              <1> 	; for(i=0;i<cheight;i++)
  4541                              <1>   	; {
  4542                              <1>    	;  memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols);
  4543                              <1>   	; }
  4544 0000266A 51                  <1> 	push	ecx
  4545 0000266B B900000A00          <1> 	mov	ecx, 0A0000h
  4546 00002670 01CE                <1> 	add	esi, ecx
  4547 00002672 01CF                <1> 	add	edi, ecx
  4548                              <1> 	; 08/08/2016
  4549 00002674 8A35[D2660000]      <1> 	mov	dh, [CHAR_HEIGHT]
  4550                              <1> 	;; 07/08/2016
  4551                              <1> 	;mov	dh, 8 ; 07/08/2016
  4552 0000267A 28D2                <1> 	sub	dl, dl ; i
  4553                              <1> vgamem_copy_pl4_0:
  4554 0000267C 56                  <1> 	push	esi
  4555 0000267D 57                  <1> 	push	edi
  4556 0000267E 0FB605[D0660000]    <1> 	movzx	eax, byte [CRT_COLS]
  4557 00002685 F6E2                <1> 	mul	dl
  4558                              <1> 	; eax = i * nbcols
  4559 00002687 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  4560 00002689 01C6                <1> 	add	esi, eax
  4561 0000268B 0FB6CF              <1> 	movzx	ecx, bh ; cols
  4562 0000268E F3A4                <1> 	rep	movsb
  4563 00002690 5F                  <1> 	pop	edi
  4564 00002691 5E                  <1> 	pop	esi
  4565 00002692 FECE                <1> 	dec	dh
  4566 00002694 75E6                <1> 	jnz	short vgamem_copy_pl4_0
  4567                              <1> vgamem_copy_pl4_1:
  4568 00002696 59                  <1> 	pop	ecx
  4569                              <1> 
  4570                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  4571 00002697 66B80500            <1> 	mov	ax, 0005h
  4572 0000269B 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4573 0000269F 66EF                <1> 	out	dx, ax
  4574                              <1> 
  4575 000026A1 58                  <1> 	pop	eax
  4576 000026A2 5A                  <1> 	pop	edx
  4577                              <1> 
  4578 000026A3 C3                  <1> 	retn	
  4579                              <1> 
  4580                              <1> vgamem_fill_pl4:
  4581                              <1> 	; 08/08/2016
  4582                              <1> 	; 07/08/2016
  4583                              <1> 	; 04/08/2016
  4584                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4585                              <1> 	;
  4586                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4587                              <1> 	; vgabios-0.7a (2011)
  4588                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4589                              <1> 	; 'vgabios.c', 'vgamem_fill_pl4'
  4590                              <1> 	;
  4591                              <1> 	; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr)
  4592                              <1> 	; cl = xstart, edi = ch = ystart, bh = cols,
  4593                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0
  4594                              <1> 
  4595                              <1> 	; dest=ystart*cheight*nbcols+xstart;
  4596 000026A4 52                  <1> 	push	edx
  4597 000026A5 50                  <1> 	push	eax
  4598                              <1> 
  4599                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205)
  4600 000026A6 66B80502            <1> 	mov	ax, 0205h
  4601 000026AA 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4602 000026AE 66EF                <1> 	out	dx, ax
  4603                              <1> 
  4604                              <1>       	; 08/08/2016
  4605 000026B0 0FB605[D2660000]    <1> 	movzx   eax, byte [CHAR_HEIGHT]
  4606 000026B7 F6E5                <1> 	mul	ch
  4607                              <1> 	;; 07/08/2016
  4608                              <1> 	;movzx	eax, ch
  4609                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  4610 000026B9 0FB615[D0660000]    <1> 	movzx	edx, byte [CRT_COLS] ; = [VGA_COLS]
  4611 000026C0 F7E2                <1> 	mul	edx
  4612                              <1> 	; edx  = 0
  4613 000026C2 88CA                <1> 	mov	dl, cl 
  4614 000026C4 01D0                <1> 	add	eax, edx
  4615 000026C6 89C7                <1> 	mov	edi, eax
  4616                              <1> 	; edi = dest
  4617                              <1> 	; for(i=0;i<cheight;i++)
  4618                              <1>   	; {
  4619                              <1>    	;  memsetb(0xa000,dest+i*nbcols,attr,cols);
  4620                              <1>   	; }
  4621 000026C8 81C700000A00        <1> 	add	edi, 0A0000h
  4622 000026CE 51                  <1> 	push	ecx
  4623                              <1> 	; 08/08/2016
  4624 000026CF 8A35[D2660000]      <1> 	mov	dh, [CHAR_HEIGHT]
  4625                              <1> 	;; 07/08/2016
  4626                              <1> 	;mov	dh, 8 ; 07/08/2016
  4627 000026D5 28D2                <1> 	sub	dl, dl ; i
  4628                              <1> vgamem_fill_pl4_0:
  4629 000026D7 57                  <1> 	push	edi
  4630 000026D8 0FB605[D0660000]    <1> 	movzx	eax, byte [CRT_COLS]
  4631 000026DF F6E2                <1> 	mul	dl
  4632                              <1> 	; eax = i * nbcols
  4633 000026E1 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  4634 000026E3 88D8                <1> 	mov	al, bl ; attr ; 04/08/2016
  4635 000026E5 0FB6CF              <1> 	movzx	ecx, bh ; cols
  4636 000026E8 F3AA                <1>  	rep	stosb
  4637 000026EA 5F                  <1> 	pop	edi
  4638 000026EB 75EA                <1> 	jnz	short vgamem_fill_pl4_0
  4639                              <1> vgamem_fill_pl4_1:
  4640 000026ED 59                  <1> 	pop	ecx
  4641                              <1> 
  4642                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  4643 000026EE 66B80500            <1> 	mov	ax, 0005h
  4644 000026F2 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4645 000026F6 66EF                <1> 	out	dx, ax
  4646                              <1> 
  4647 000026F8 58                  <1> 	pop	eax
  4648 000026F9 5A                  <1> 	pop	edx 
  4649                              <1> 	
  4650 000026FA C3                  <1> 	retn
  4651                              <1> 
  4652                              <1> vgamem_copy_l8:
  4653                              <1> 	; 02/08/2022 - TRDOS 386 Kernel v2.0.5
  4654                              <1> 	; 08/08/2016
  4655                              <1> 	; 07/08/2016
  4656                              <1> 	; 06/08/2016
  4657                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4658                              <1> 	;
  4659                              <1> 	; TEMPORARY
  4660                              <1> 	;
  4661                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4662                              <1> 	; vgabios-0.7a (2011)
  4663                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4664                              <1> 	; 'vgabios.c', 'vgamem_copy_pl4'
  4665                              <1> 	;
  4666                              <1> 	; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight)
  4667                              <1> 	; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i),
  4668                              <1> 	; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  4669                              <1> 
  4670                              <1> 	; src=ysrc*cheight*nbcols+xstart;
  4671                              <1> 	; dest=ydest*cheight*nbcols+xstart;
  4672                              <1> 
  4673 000026FB 52                  <1> 	push	edx
  4674 000026FC 50                  <1> 	push	eax
  4675                              <1> 
  4676                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0105)
  4677                              <1> 	;mov	ax, 0105h
  4678                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4679                              <1> 	;out	dx, ax
  4680                              <1> 
  4681                              <1> 	;mov	ah, [esp+1]
  4682                              <1> 
  4683 000026FD 0FB6D4              <1> 	movzx	edx, ah ; ysrc
  4684                              <1> 	; 08/08/2016
  4685 00002700 0FB605[D2660000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  4686 00002707 8A25[D0660000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  4687 0000270D F6E4                <1> 	mul	ah 
  4688                              <1> 	;; 07/08/2016
  4689                              <1> 	;movzx	eax, byte [CRT_COLS]
  4690                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  4691 0000270F 50                  <1> 	push	eax ; cheight * nbcols
  4692 00002710 F7E2                <1> 	mul	edx ; * ysrc
  4693                              <1> 	; eax = ysrc * cheight * nbcols
  4694                              <1> 	; edx = 0
  4695 00002712 88CA                <1> 	mov	dl, cl ; edx = xstart
  4696 00002714 01D0                <1>  	add	eax, edx
  4697 00002716 89C6                <1> 	mov	esi, eax ; src
  4698                              <1> 	;shl	si, 3 ; * 8 ; 06/08/2016
  4699                              <1> 	; 02/08/2022
  4700 00002718 C1E603              <1> 	shl	esi, 3
  4701 0000271B 88EA                <1> 	mov	dl, ch ; ydest
  4702 0000271D 58                  <1> 	pop	eax ; cheight * nbcols
  4703 0000271E F7E2                <1> 	mul	edx
  4704                              <1> 	; eax = ydest * cheight * nbcols
  4705 00002720 88CA                <1> 	mov	dl, cl ; edx = xstart	
  4706 00002722 01D0                <1>  	add	eax, edx
  4707 00002724 89C7                <1> 	mov	edi, eax ; dest
  4708                              <1> 	;shl	di, 3 ; * 8 ; 06/08/2016
  4709                              <1> 	; 02/08/2022
  4710 00002726 C1E703              <1> 	shl	edi, 3
  4711                              <1> 	; esi = src
  4712                              <1> 	; edi = dest
  4713                              <1> 	; for(i=0;i<cheight;i++)
  4714                              <1>   	; {
  4715                              <1>    	;  memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols);
  4716                              <1>   	; }
  4717 00002729 51                  <1> 	push	ecx
  4718 0000272A B900000A00          <1> 	mov	ecx, 0A0000h
  4719 0000272F 01CE                <1> 	add	esi, ecx
  4720 00002731 01CF                <1> 	add	edi, ecx
  4721                              <1> 	; 08/08/2016
  4722 00002733 8A35[D2660000]      <1> 	mov	dh, [CHAR_HEIGHT]
  4723                              <1> 	;; 07/08/2016
  4724                              <1> 	;mov	dh, 8 ; 07/08/2016
  4725 00002739 28D2                <1> 	sub	dl, dl ; i
  4726                              <1> vgamem_copy_l8_0:
  4727 0000273B 56                  <1> 	push	esi
  4728 0000273C 57                  <1> 	push	edi
  4729 0000273D 0FB605[D0660000]    <1> 	movzx	eax, byte [CRT_COLS]
  4730 00002744 F6E2                <1> 	mul	dl
  4731                              <1> 	; eax = i * nbcols
  4732                              <1> 	;shl	ax, 3 ; * 8 ; 06/08/2016
  4733                              <1> 	; 02/08/2022
  4734 00002746 C1E003              <1> 	shl	eax, 3
  4735 00002749 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  4736 0000274B 01C6                <1> 	add	esi, eax
  4737 0000274D 0FB6CF              <1> 	movzx	ecx, bh ; cols
  4738                              <1> 	;shl	cx, 3 ; * 8 ; 06/08/2016
  4739                              <1> 	; 02/08/2022
  4740 00002750 C1E103              <1> 	shl	ecx, 3
  4741 00002753 F3A4                <1> 	rep	movsb
  4742 00002755 5F                  <1> 	pop	edi
  4743 00002756 5E                  <1> 	pop	esi
  4744 00002757 FEC2                <1> 	inc	dl ; 06/08/2016
  4745 00002759 FECE                <1> 	dec	dh
  4746 0000275B 75DE                <1> 	jnz	short vgamem_copy_l8_0
  4747                              <1> vgamem_copy_l8_1:
  4748 0000275D 59                  <1> 	pop	ecx
  4749                              <1> 
  4750                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  4751                              <1> 	;mov	ax, 0005h
  4752                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4753                              <1> 	;out	dx, ax
  4754                              <1> 
  4755 0000275E 58                  <1> 	pop	eax
  4756 0000275F 5A                  <1> 	pop	edx
  4757                              <1> 
  4758 00002760 C3                  <1> 	retn
  4759                              <1> 
  4760                              <1> vgamem_fill_l8:
  4761                              <1> 	; 02/08/2022 - TRDOS 386 Kernel v2.0.5
  4762                              <1> 	; 08/08/2016
  4763                              <1> 	; 07/08/2016
  4764                              <1> 	; 06/08/2016
  4765                              <1> 	; 04/08/2016
  4766                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4767                              <1> 	;
  4768                              <1> 	; TEMPORARY
  4769                              <1> 	;
  4770                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4771                              <1> 	; vgabios-0.7a (2011)
  4772                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4773                              <1> 	; 'vgabios.c', 'vgamem_fill_pl4'
  4774                              <1> 	;
  4775                              <1> 	; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr)
  4776                              <1> 	; cl = xstart, edi = ch = ystart, bh = cols,
  4777                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0
  4778                              <1> 
  4779                              <1> 	; dest=ystart*cheight*nbcols+xstart;
  4780 00002761 52                  <1> 	push	edx
  4781 00002762 50                  <1> 	push	eax
  4782                              <1> 
  4783                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0205)
  4784                              <1> 	;mov	ax, 0205h
  4785                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4786                              <1> 	;out	dx, ax
  4787                              <1> 
  4788                              <1>         ; 08/08/2016
  4789 00002763 0FB605[D2660000]    <1> 	movzx   eax, byte [CHAR_HEIGHT]
  4790 0000276A F6E5                <1> 	mul	ch
  4791                              <1> 	;; 07/08/2016
  4792                              <1> 	;movzx	eax, ch
  4793                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  4794 0000276C 0FB615[D0660000]    <1> 	movzx	edx, byte [CRT_COLS] ; = [VGA_COLS]
  4795 00002773 F7E2                <1> 	mul	edx
  4796                              <1> 	; edx  = 0
  4797 00002775 88CA                <1> 	mov	dl, cl 
  4798 00002777 01D0                <1> 	add	eax, edx
  4799 00002779 89C7                <1> 	mov	edi, eax
  4800                              <1> 	;shl	di, 3 ; * 8 ; 06/08/2016
  4801                              <1> 	; 02/08/2022
  4802 0000277B C1E703              <1> 	shl	edi, 3
  4803                              <1> 	; edi = dest
  4804                              <1> 	; for(i=0;i<cheight;i++)
  4805                              <1>   	; {
  4806                              <1>    	;  memsetb(0xa000,dest+i*nbcols,attr,cols);
  4807                              <1>   	; }
  4808 0000277E 81C700000A00        <1> 	add	edi, 0A0000h
  4809 00002784 51                  <1> 	push	ecx
  4810                              <1> 	; 08/08/2016
  4811 00002785 8A35[D2660000]      <1> 	mov	dh, [CHAR_HEIGHT]
  4812                              <1> 	;; 07/08/2016
  4813                              <1> 	;mov	dh, 8 ; 07/08/2016
  4814 0000278B 28D2                <1> 	sub	dl, dl ; i
  4815                              <1> vgamem_fill_l8_0:
  4816 0000278D 57                  <1> 	push	edi
  4817 0000278E 0FB605[D0660000]    <1> 	movzx	eax, byte [CRT_COLS]
  4818 00002795 F6E2                <1> 	mul	dl
  4819                              <1> 	; eax = i * nbcols
  4820                              <1> 	;shl	ax, 3 ; * 8 ; 06/08/2016
  4821                              <1> 	; 02/08/2022
  4822 00002797 C1E003              <1> 	shl	eax, 3
  4823 0000279A 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  4824 0000279C 88D8                <1> 	mov	al, bl ; attr ; 04/08/2016
  4825 0000279E 0FB6CF              <1> 	movzx	ecx, bh ; cols
  4826                              <1> 	;shl	cx, 3 ; * 8 ; 06/08/2016
  4827                              <1>  	; 02/08/2022
  4828 000027A1 C1E103              <1> 	shl	ecx, 3
  4829 000027A4 F3AA                <1> 	rep	stosb
  4830 000027A6 5F                  <1> 	pop	edi
  4831 000027A7 FEC2                <1> 	inc	dl ; 06/08/2016
  4832 000027A9 FECE                <1> 	dec	dh
  4833 000027AB 75E0                <1> 	jnz	short vgamem_fill_l8_0
  4834                              <1> vgamem_fill_l8_1:
  4835 000027AD 59                  <1> 	pop	ecx
  4836                              <1> 
  4837                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  4838                              <1> 	;mov	ax, 0005h
  4839                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4840                              <1> 	;out	dx, ax
  4841                              <1> 
  4842 000027AE 58                  <1> 	pop	eax
  4843 000027AF 5A                  <1> 	pop	edx 
  4844                              <1> 
  4845 000027B0 C3                  <1> 	retn
  4846                              <1> 
  4847                              <1> ; 03/08/2022 - TRDOS 386 Kernel V2.0.5
  4848                              <1> ; 07/07/2016
  4849                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  4850                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  4851                              <1> ;------------------------------------------------------
  4852                              <1> ; SCROLL DOWN
  4853                              <1> ;  THIS ROUTINE SCROLLS DOWN THE INFORMATION ON THE CRT
  4854                              <1> ; ENTRY --
  4855                              <1> ;  CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL
  4856                              <1> ;  DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL
  4857                              <1> ;   BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS
  4858                              <1> ;  BH = FILL VALUE FOR BLANKED LINES
  4859                              <1> ;  AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD)
  4860                              <1> ;  DS = DATA SEGMENT
  4861                              <1> ;  ES = REGEN SEGMENT
  4862                              <1> ; EXIT --
  4863                              <1> ;  NOTHING, THE SCREEN IS SCROLLED
  4864                              <1> ;--------------------------------------------------------
  4865                              <1> 
  4866                              <1> 	; cl = upper left column
  4867                              <1> 	; ch = upper left row
  4868                              <1> 	; dl = lower rigth column
  4869                              <1> 	; dh = lower right row
  4870                              <1> 	;
  4871                              <1> 	; al = line count (AL=0 means blank entire fields)
  4872                              <1> 	; bl = fill value for blanked lines	
  4873                              <1> 	; bh = unused
  4874                              <1> 
  4875                              <1> GRAPHICS_DOWN:
  4876                              <1> 	; 07/07/2016
  4877                              <1> 	; ah = Current video mode, [CRT_MODE]
  4878                              <1> 	; std				; SET DIRECTION
  4879 000027B1 80FC07              <1> 	cmp	ah, 7
  4880 000027B4 7769                <1>         ja	short vga_graphics_down ; 03/08/2022
  4881                              <1> 	;je	_n0
  4882                              <1> 
  4883 000027B6 88C7                <1> 	mov	bh, al			; save line count in BH
  4884                              <1> 	;mov	ax, dx			; GET LOWER RIGHT POSITION INTO AX REG
  4885                              <1> 	; 03/08/2022
  4886 000027B8 89D0                <1> 	mov	eax, edx
  4887                              <1> 
  4888                              <1> ;-----	USE CHARACTER SUBROUTINE FOR POSITIONING
  4889                              <1> ;-----	ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE
  4890                              <1> 
  4891 000027BA E8E8020000          <1> 	call	GRAPH_POSN
  4892                              <1> 	;movzx	edi, ax			; SAVE RESULT AS DESTINATION ADDRESS
  4893                              <1> 	; 03/08/2022
  4894 000027BF 89C7                <1> 	mov	edi, eax
  4895                              <1> 
  4896                              <1> ;-----	DETERMINE SIZE OF WINDOW
  4897                              <1> 
  4898 000027C1 6629CA              <1> 	sub	dx, cx
  4899 000027C4 6681C20101          <1>         add     dx, 101h                ; ADJUST VALUES
  4900 000027C9 C0E602              <1> 	sal	dh, 2			; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR
  4901                              <1> 					; AND EVEN/ODD ROWS
  4902                              <1> ;-----	DETERMINE CRT MODE
  4903                              <1> 
  4904 000027CC 803D[CE660000]06    <1> 	cmp	byte [CRT_MODE], 6	; TEST FOR MEDIUM RES
  4905 000027D3 7305                <1> 	jnc	short _R12              ; FIND_SOURCE_DOWN
  4906                              <1> 
  4907                              <1> ;-----	MEDIUM RES DOWN
  4908 000027D5 D0E2                <1> 	sal	dl, 1			; # COLUMNS * 2, SINCE 2 BYTES/CHAR
  4909                              <1> 	;sal	di, 1			; OFFSET *2 SINCE 2 BYTES/CHAR
  4910                              <1> 	; 03/08/2022
  4911 000027D7 D1E7                <1> 	sal	edi, 1
  4912                              <1> 	;inc	di			; POINT TO LAST BYTE
  4913                              <1> 	; 03/08/2022
  4914 000027D9 47                  <1> 	inc	edi
  4915                              <1> 
  4916                              <1> ;-----	DETERMINE THE SOURCE ADDRESS IN THE BUFFER
  4917                              <1> 
  4918                              <1> _R12:                                   ; FIND_SOURCE_DOWN
  4919 000027DA 81C700800B00        <1> 	add	edi, 0B8000h		
  4920 000027E0 6681C7F000          <1> 	add	di, 240			; POINT TO LAST ROW OF PIXELS
  4921 000027E5 C0E702              <1> 	sal	bh, 2			; multiply number of lines by 4
  4922 000027E8 74(06)              <1> 	jz	short 6			; IF ZERO, THEN BLANK ENTIRE FIELD
  4923 000027EA B050                <1> 	mov	al, 80			; 80 BYTES/ROW
  4924 000027EC F6E7                <1> 	mul	bh			; determine offset to source
  4925 000027EE 89FE                <1> 	mov	esi, edi		; SET UP SOURCE
  4926                              <1> 	;sub	si, ax			; SUBTRACT THE OFFSET
  4927                              <1> 	; 03/08/2022
  4928 000027F0 29C6                <1> 	sub	esi, eax
  4929 000027F2 88F4                <1> 	mov	ah, dh			; NUMBER OF ROWS IN FIELD
  4930 000027F4 28FC                <1> 	sub	ah, bh			; determine number to move
  4931                              <1> 
  4932                              <1> ;-----	LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS
  4933                              <1> 
  4934                              <1> _R13:                                   ; ROW_LOOP_DOWN
  4935 000027F6 E825010000          <1>         call    _R17                    ; MOVE ONE ROW
  4936 000027FB 6681EE5020          <1> 	sub	si, 2000h+80		; MOVE TO NEXT ROW
  4937 00002800 6681EF5020          <1> 	sub	di, 2000h+80
  4938 00002805 FECC                <1> 	dec	ah			; NUMBER OF ROWS TO MOVE
  4939 00002807 75ED                <1> 	jnz	short _R13              ; CONTINUE TILL ALL MOVED
  4940                              <1> 
  4941                              <1> ;-----	FILL IN THE VACATED LINE(S)
  4942                              <1> _R14:                                   ; CLEAR_ENTRY_DOWN
  4943 00002809 88D8                <1> 	mov	al, bl			; attribute to fill with
  4944                              <1> _R15_:                                  ; CLEAR_LOOP_DOWN
  4945 0000280B E82C010000          <1> 	call	_R18			; CLEAR A ROW
  4946 00002810 6681EF5020          <1> 	sub	di, 2000h+80		; POINT TO NEXT LINE
  4947 00002815 FECF                <1> 	dec	bh			; number of lines to fill
  4948 00002817 75F2                <1>         jnz	short _R15_             ; CLEAR_LOOP_DOWN
  4949                              <1> 	; 18/11/2020
  4950 00002819 FC                  <1> 	cld				; RESET THE DIRECTION FLAG
  4951                              <1> 	
  4952 0000281A C3                  <1> 	retn				; EVERYTHING DONE
  4953                              <1> 
  4954                              <1> _R16:                                   ; BLANK_FIELD_DOWN
  4955 0000281B 88F7                <1> 	mov	bh, dh			; set blank count to everything in field
  4956 0000281D EBEA                <1>         jmp     short _R14              ; CLEAR THE FIELD
  4957                              <1> 
  4958                              <1> vga_graphics_down:
  4959                              <1> 	; 03/08/2022 - TRDOS 386 Kertnel v2.0.5
  4960                              <1> 	; 12/04/2021
  4961                              <1> 	; 08/08/2016
  4962                              <1> 	; 07/08/2016
  4963                              <1> 	; 31/07/2016
  4964                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4965                              <1> 	;
  4966                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4967                              <1> 	; vgabios-0.7a (2011)
  4968                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4969                              <1> 	; 'vgabios.c', 'biosfn_scroll'
  4970                              <1> 	;
  4971                              <1> 
  4972                              <1> 	; cl = upper left column
  4973                              <1> 	; ch = upper left row
  4974                              <1> 	; dl = lower rigth column
  4975                              <1> 	; dh = lower right row
  4976                              <1> 	;
  4977                              <1> 	; al = line count (AL=0 means blank entire fields)
  4978                              <1> 	; bl = fill value for blanked lines	
  4979                              <1> 	; bh = unused
  4980                              <1> 	;
  4981                              <1> 	; ah = [CRT_MODE], current video mode	
  4982                              <1> 
  4983 0000281F FC                  <1>         cld     ; !!! Clear direction flag !!! 
  4984                              <1> 
  4985 00002820 88C7                <1> 	mov	bh, al ; 31/07/2016
  4986                              <1> 
  4987 00002822 BE[EA660000]        <1> 	mov	esi, vga_modes
  4988 00002827 89F7                <1> 	mov	edi, esi
  4989 00002829 83C710              <1> 	add	edi, vga_mode_count
  4990                              <1> vga_g_down_0:
  4991 0000282C AC                  <1> 	lodsb
  4992 0000282D 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  4993 0000282F 7405                <1> 	je	short vga_g_down_1
  4994 00002831 39FE                <1> 	cmp	esi, edi
  4995 00002833 72F7                <1> 	jb	short vga_g_down_0
  4996                              <1> 	; xor 	bh, bh	; 31/07/2016
  4997 00002835 C3                  <1> 	retn	; nothing to do
  4998                              <1> vga_g_down_1:
  4999 00002836 88F8                <1> 	mov	al, bh ; 31/07/2016
  5000 00002838 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  5001                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  5002                              <1> 	
  5003                              <1> 	; if(rlr>=nbrows)rlr=nbrows-1;
  5004                              <1>  	; if(clr>=nbcols)clr=nbcols-1;
  5005                              <1>  	; if(nblines>nbrows)nblines=0;
  5006                              <1>  	; cols=clr-cul+1;
  5007                              <1> 
  5008 0000283B 3A35[D6660000]      <1> 	cmp	dh, [VGA_ROWS]
  5009 00002841 7208                <1> 	jb	short vga_g_down_2
  5010 00002843 8A35[D6660000]      <1> 	mov	dh, [VGA_ROWS]
  5011 00002849 FECE                <1> 	dec	dh
  5012                              <1> vga_g_down_2:
  5013 0000284B 3A15[D0660000]      <1> 	cmp	dl, [CRT_COLS]  ; = [VGA_COLS]
  5014 00002851 7208                <1> 	jb	short vga_g_down_3
  5015 00002853 8A15[D0660000]      <1> 	mov	dl, [CRT_COLS]
  5016 00002859 FECA                <1> 	dec	dl
  5017                              <1> vga_g_down_3:	
  5018 0000285B 3A05[D6660000]      <1> 	cmp	al, [VGA_ROWS]
  5019 00002861 7602                <1> 	jna	short vga_g_down_4
  5020 00002863 28C0                <1> 	sub	al, al ; 0
  5021                              <1> vga_g_down_4:
  5022 00002865 88F7                <1> 	mov	bh, dh ; clr
  5023 00002867 28CF                <1> 	sub	bh, cl ; cul
  5024 00002869 FEC7                <1> 	inc	bh ; cols = clr-cul+1
  5025                              <1> 
  5026 0000286B 20C0                <1> 	and	al, al ; nblines = 0
  5027 0000286D 7559                <1> 	jnz	short vga_g_down_6
  5028 0000286F 20ED                <1> 	and	ch, ch ; rul = 0
  5029 00002871 7555                <1> 	jnz	short vga_g_down_6
  5030 00002873 20C9                <1> 	and	cl, cl ; cul = 0
  5031 00002875 7551                <1> 	jnz	short vga_g_down_6
  5032                              <1> 
  5033 00002877 50                  <1> 	push	eax ; push ax ; 12/04/2021
  5034 00002878 A0[D6660000]        <1> 	mov	al, [VGA_ROWS]
  5035 0000287D FEC8                <1> 	dec	al  
  5036 0000287F 38C6                <1> 	cmp	dh, al ; rlr = nbrows-1
  5037 00002881 7545                <1> 	jne	short vga_g_down_5
  5038 00002883 A0[D0660000]        <1>         mov     al, [CRT_COLS]  ; = VGA_COLS
  5039 00002888 FEC8                <1> 	dec	al 
  5040 0000288A 38C2                <1>  	cmp	dl, al ; clr = nbcols-1
  5041                              <1> 	;jne	short vga_g_down_5
  5042                              <1>  	; 12/04/2021
  5043 0000288C 58                  <1> 	pop	eax ; pop ax
  5044 0000288D 7539                <1> 	jne	short vga_g_down_5
  5045                              <1> 
  5046 0000288F 66B80502            <1> 	mov	ax, 0205h
  5047 00002893 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  5048 00002897 66EF                <1> 	out	dx, ax
  5049 00002899 A0[D6660000]        <1> 	mov	al, [VGA_ROWS]
  5050 0000289E 8A25[D0660000]      <1> 	mov	ah, [CRT_COLS] ; = [VGA_COLS]
  5051 000028A4 F6E4                <1> 	mul	ah
  5052 000028A6 0FB7D0              <1> 	movzx	edx, ax
  5053                              <1> 	; 08/08/2016
  5054 000028A9 0FB605[D2660000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  5055 000028B0 F7E2                <1> 	mul	edx
  5056                              <1> 	; eax = byte count	
  5057 000028B2 89C1                <1> 	mov	ecx, eax
  5058                              <1> 	;; 07/08/2016
  5059                              <1> 	;shl	dx, 3 ; * 8 ; * [CHAR_HEIGHT]
  5060                              <1> 	;mov	ecx, edx
  5061 000028B4 88D8                <1> 	mov	al, bl ; fill value for blanked lines
  5062 000028B6 BF00000A00          <1> 	mov	edi, 0A0000h
  5063 000028BB F3AA                <1> 	rep	stosb			
  5064                              <1> 	
  5065                              <1> 	; 03/08/2022
  5066 000028BD 30E4                <1> 	xor	ah, ah ; 0 
  5067                              <1> 	
  5068 000028BF B005                <1> 	mov	al, 5
  5069 000028C1 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  5070 000028C5 66EF                <1> 	out	dx, ax ; 0005h	
  5071                              <1> 
  5072 000028C7 C3                  <1> 	retn
  5073                              <1> 
  5074                              <1> vga_g_down_5:
  5075                              <1> 	; 12/04/2021
  5076                              <1> 	;pop	eax  ; pop ax
  5077                              <1> 
  5078                              <1> vga_g_down_6:
  5079                              <1> 	; [ESI] = VGA memory model number for current video mode
  5080                              <1>         ;
  5081                              <1>         ; LINEAR8 equ 5
  5082                              <1>         ; PLANAR4 equ 4
  5083                              <1>         ; PLANAR1 equ 3
  5084                              <1> 
  5085 000028C8 803E04              <1> 	cmp	byte [esi], PLANAR4
  5086 000028CB 742C                <1> 	je	short vga_g_down_planar
  5087 000028CD 803E03              <1> 	cmp	byte [esi], PLANAR1
  5088 000028D0 7427                <1> 	je	short vga_g_down_planar
  5089                              <1> vga_g_down_linear8:
  5090                              <1> 	; 07/07/2016 (TEMPORARY)
  5091                              <1> 	;
  5092                              <1> 	; cl = upper left column ; cul
  5093                              <1> 	; ch = upper left row ; rul
  5094                              <1> 	; dl = lower rigth column ; clr
  5095                              <1> 	; dh = lower right row ; rlr
  5096                              <1> 
  5097                              <1> vga_g_down_l0:
  5098                              <1> 	;{for(i=rlr;i>=rul;i--)
  5099                              <1>         ; if((i<rul+nblines)||(nblines==0))
  5100 000028D2 08C0                <1> 	or	al, al
  5101 000028D4 741C                <1> 	jz	short vga_g_down_l2
  5102 000028D6 88C4                <1> 	mov	ah, al
  5103 000028D8 00EC                <1> 	add	ah, ch
  5104                              <1> 	;jc	short vga_g_down_l2	
  5105 000028DA 86EE                <1> 	xchg	ch, dh
  5106 000028DC 38E5                <1> 	cmp	ch, ah
  5107 000028DE 7212                <1> 	jb	short vga_g_down_l2
  5108 000028E0 88EC                <1> 	mov	ah, ch
  5109 000028E2 28C4                <1> 	sub	ah, al ; ah = i - nblines
  5110                              <1> 	; else
  5111                              <1> 	; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight);
  5112 000028E4 E812FEFFFF          <1> 	call	vgamem_copy_l8
  5113                              <1> vga_g_down_l1:
  5114 000028E9 86F5                <1> 	xchg	dh, ch
  5115 000028EB FECE                <1> 	dec	dh 
  5116 000028ED 38EE                <1> 	cmp	dh, ch
  5117 000028EF 73E1                <1> 	jnb	short vga_g_down_l0
  5118 000028F1 C3                  <1> 	retn
  5119                              <1> 
  5120                              <1> vga_g_down_l2:
  5121                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  5122 000028F2 E86AFEFFFF          <1> 	call	vgamem_fill_l8
  5123 000028F7 EBF0                <1> 	jmp	short vga_g_down_l1
  5124                              <1> 		 
  5125                              <1> vga_g_down_planar:
  5126                              <1> 	; cl = upper left column ; cul
  5127                              <1> 	; ch = upper left row ; rul
  5128                              <1> 	; dl = lower rigth column ; clr
  5129                              <1> 	; dh = lower right row ; rlr
  5130                              <1> vga_g_down_pl0:
  5131                              <1>  	;{for(i=rlr;i>=rul;i--)
  5132                              <1>         ; if((i<rul+nblines)||(nblines==0))
  5133 000028F9 08C0                <1> 	or	al, al
  5134 000028FB 741C                <1> 	jz	short vga_g_down_pl2
  5135 000028FD 88C4                <1> 	mov	ah, al
  5136 000028FF 00EC                <1> 	add	ah, ch
  5137                              <1> 	;jc	short vga_g_down_pl2	
  5138 00002901 86EE                <1> 	xchg	ch, dh
  5139 00002903 38E5                <1> 	cmp	ch, ah
  5140 00002905 7212                <1> 	jb	short vga_g_down_pl2
  5141 00002907 88EC                <1> 	mov	ah, ch
  5142 00002909 28C4                <1> 	sub	ah, al ; ah = i - nblines
  5143                              <1> 	; else
  5144                              <1> 	; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight);
  5145 0000290B E826FDFFFF          <1> 	call	vgamem_copy_pl4
  5146                              <1> vga_g_down_pl1:
  5147 00002910 86F5                <1> 	xchg	dh, ch
  5148 00002912 FECE                <1> 	dec	dh 
  5149 00002914 38EE                <1> 	cmp	dh, ch
  5150 00002916 73E1                <1> 	jnb	short vga_g_down_pl0
  5151 00002918 C3                  <1> 	retn
  5152                              <1> 
  5153                              <1> vga_g_down_pl2:
  5154                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  5155 00002919 E886FDFFFF          <1> 	call	vgamem_fill_pl4
  5156 0000291E EBF0                <1> 	jmp	short vga_g_down_pl1
  5157                              <1> 
  5158                              <1> 
  5159                              <1> 
  5160                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  5161                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5162                              <1> 
  5163                              <1> ;-----	ROUTINE TO MOVE ONE ROW OF INFORMATION
  5164                              <1> 
  5165                              <1> _R17:
  5166 00002920 0FB6CA              <1> 	movzx	ecx, dl			; NUMBER OF BYTES IN THE ROW
  5167 00002923 56                  <1> 	push	esi
  5168 00002924 57                  <1> 	push	edi			; SAVE POINTERS
  5169 00002925 F3A4                <1> 	rep	movsb			; MOVE THE EVEN FIELD
  5170 00002927 5F                  <1> 	pop	edi
  5171 00002928 5E                  <1> 	pop	esi
  5172 00002929 6681C60020          <1> 	add	si, 2000h
  5173 0000292E 6681C70020          <1> 	add	di, 2000h		; POINT TO THE ODD FIELD
  5174 00002933 56                  <1> 	push	esi
  5175 00002934 57                  <1> 	push	edi			; SAVE THE POINTERS
  5176 00002935 88D1                <1> 	mov	cl, dl			; COUNT BACK
  5177 00002937 F3A4                <1> 	rep	movsb			; MOVE THE ODD FIELD
  5178 00002939 5F                  <1> 	pop	edi
  5179 0000293A 5E                  <1> 	pop	esi			; POINTERS BACK
  5180 0000293B C3                  <1> 	retn				; RETURN TO CALLER
  5181                              <1> 
  5182                              <1> ;-----	CLEAR A SINGLE ROW
  5183                              <1> 
  5184                              <1> _R18:
  5185 0000293C 0FB6CA              <1> 	movzx	ecx, dl			; NUMBER OF BYTES IN FIELD
  5186 0000293F 57                  <1> 	push	edi			; SAVE POINTER
  5187 00002940 F3AA                <1> 	rep	stosb			; STORE THE NEW VALUE
  5188 00002942 5F                  <1> 	pop	edi			; POINTER BACK
  5189 00002943 6681C70020          <1> 	add	di, 2000h		; POINT TO ODD FIELD
  5190 00002948 57                  <1> 	push	edi
  5191 00002949 88D1                <1> 	mov	cl, dl
  5192 0000294B F3AA                <1> 	rep	stosb			; FILL THE ODD FIELD
  5193 0000294D 5F                  <1> 	pop	edi
  5194 0000294E C3                  <1> 	retn				; RETURN TO CALLER
  5195                              <1> 
  5196                              <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5
  5197                              <1> ; 04/07/2016
  5198                              <1> ; 01/07/2016
  5199                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  5200                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5201                              <1> ;--------------------------------------------------
  5202                              <1> ; GRAPHICS WRITE
  5203                              <1> ;  THIS ROUTINE WRITES THE ASCII CHARACTER TO THE CURRENT
  5204                              <1> ;  POSITION ON THE SCREEN.
  5205                              <1> ; ENTRY --
  5206                              <1> ;  AL = CHARACTER TO WRITE
  5207                              <1> ;  BL = COLOR ATTRIBUTE TO BE USED FOR FOREGROUND COLOR
  5208                              <1> ;	IF BIT 7 IS SET, THE CHAR IS XOR'D INTO THE REGEN BUFFER
  5209                              <1> ;	(0 IS USED FOR THE BACKGROUND COLOR)
  5210                              <1> ;  CX = NUMBER OF CHARS TO WRITE
  5211                              <1> ;  DS = DATA SEGMENT
  5212                              <1> ;  ES = REGEN SEGMENT
  5213                              <1> ; EXIT --
  5214                              <1> ;  NOTHING IS RETURNED
  5215                              <1> ;
  5216                              <1> ; GRAPHICS READ
  5217                              <1> ;  THIS ROUTINE READS THE ASCII CHARACTER AT THE CURRENT CURSOR
  5218                              <1> ;  POSITION ON THE SCREEN BY MATCHING THE DOTS ON THE SCREEN TO THE
  5219                              <1> ;  CHARACTER GENERATOR CODE POINTS
  5220                              <1> ; ENTRY --
  5221                              <1> ;  NONE (0 IS ASSUMED AS THE BACKGROUND COLOR)
  5222                              <1> ; EXIT --
  5223                              <1> ;  AL = CHARACTER READ AT THAT POSITION (0 RETURNED IF NONE FOUND)
  5224                              <1> ;
  5225                              <1> ; FOR BOTH ROUTINES, THE IMAGES USED TO FORM CHARS ARE CONTAINED IN ROM
  5226                              <1> ;  FOR THE 1ST 128 CHARS.  TO ACCESS CHARS IN THE SECOND HALF, THE USER
  5227                              <1> ;  MUST INITIALIZE THE VECTOR AT INTERRUPT 1FH (LOCATION 0007CH) TO
  5228                              <1> ;  POINT TO THE USER SUPPLIED TABLE OF GRAPHIC IMAGES (8X8 BOXES).
  5229                              <1> ;  FAILURE TO DO SO WILL CAUSE IN STRANGE RESULTS
  5230                              <1> ;-----------------------------------------------------
  5231                              <1> 
  5232                              <1> GRAPHICS_WRITE:
  5233 0000294F 25FF000000          <1> 	and 	eax, 0FFh		; ZERO TO HIGH OF CODE POINT
  5234 00002954 50                  <1> 	push	eax			; SAVE CODE POINT VALUE
  5235                              <1> 
  5236                              <1> ;-----	DETERMINE POSITION IN REGEN BUFFER TO PUT CODE POINTS
  5237                              <1> 
  5238 00002955 E846010000          <1> 	call	S26			; FIND LOCATION IN REGEN BUFFER
  5239 0000295A 89C7                <1> 	mov	edi, eax		; REGEN POINTER IN DI
  5240                              <1> 
  5241                              <1> ;-----	DETERMINE REGION TO GET CODE POINTS FROM
  5242                              <1> 
  5243 0000295C 58                  <1> 	pop	eax			; RECOVER CODE POINT
  5244                              <1> 
  5245 0000295D BE[1C4E0100]        <1> 	mov	esi, CRT_CHAR_GEN	; OFFSET OF IMAGES
  5246                              <1> 
  5247                              <1> ;-----	DETERMINE GRAPHICS MODE IN OPERATION
  5248                              <1> 					; DETERMINE_MODE
  5249                              <1> 	;sal	ax, 3			; MULTIPLY CODE POINT VALUE BY 8
  5250                              <1> 	; 03/08/2022
  5251 00002962 C1E003              <1> 	sal	eax, 3
  5252 00002965 01C6                <1> 	add	esi, eax		; SI HAS OFFSET OF DESIRED CODES
  5253                              <1> 	
  5254 00002967 803D[CE660000]06    <1> 	cmp	byte [CRT_MODE], 6
  5255 0000296E 7231                <1> 	jc	short S6		; TEST FOR MEDIUM RESOLUTION MODE
  5256                              <1> 
  5257                              <1> ;-----	HIGH RESOLUTION MODE
  5258                              <1> 
  5259 00002970 81C700800B00        <1> 	add	edi, 0B8000h
  5260                              <1> S1:					; HIGH_CHAR
  5261 00002976 57                  <1> 	push	edi			; SAVE REGEN POINTER
  5262 00002977 56                  <1> 	push	esi			; SAVE CODE POINTER
  5263 00002978 B604                <1> 	mov	dh, 4			; NUMBER OF TIMES THROUGH LOOP
  5264                              <1> S2:
  5265 0000297A AC                  <1> 	lodsb				; GET BYTE FROM CODE POINTS
  5266 0000297B F6C380              <1> 	test	bl, 80h			; SHOULD WE USE THE FUNCTION
  5267 0000297E 7515                <1> 	jnz	short S5		; TO PUT CHAR IN
  5268 00002980 AA                  <1> 	stosb				; STORE IN REGEN BUFFER
  5269 00002981 AC                  <1> 	lodsb
  5270                              <1> S4:
  5271 00002982 8887FF1F0000        <1> 	mov	[edi+2000h-1], al	; STORE IN SECOND HALF
  5272 00002988 83C74F              <1> 	add	edi, 79			; MOVE TO NEXT ROW IN REGEN
  5273 0000298B FECE                <1> 	dec	dh			; DONE WITH LOOP
  5274 0000298D 75EB                <1> 	jnz	short S2
  5275 0000298F 5E                  <1> 	pop	esi
  5276 00002990 5F                  <1> 	pop	edi			; RECOVER REGEN POINTER
  5277 00002991 47                  <1> 	inc	edi			; POINT TO NEXT CHAR POSITION
  5278 00002992 E2E2                <1> 	loop	S1			; MORE CHARS TO WRITE
  5279 00002994 C3                  <1> 	retn
  5280                              <1> 
  5281                              <1> S5:
  5282 00002995 3207                <1> 	xor	al, [edi]		; EXCLUSIVE OR WITH CURRENT
  5283 00002997 AA                  <1> 	stosb				; STORE THE CODE POINT
  5284 00002998 AC                  <1> 	lodsb				; AGAIN FOR ODD FIELD
  5285 00002999 3287FF1F0000        <1> 	xor	al, [edi+2000h-1]
  5286 0000299F EBE1                <1> 	jmp	short S4		; BACK TO MAINSTREAM
  5287                              <1> 
  5288                              <1> ;-----	MEDIUM RESOLUTION WRITE
  5289                              <1> S6:					; MED_RES_WRITE
  5290 000029A1 88DA                <1> 	mov	dl, bl			; SAVE HIGH COLOR BIT
  5291                              <1> 	; 03/08/2022
  5292 000029A3 D1E7                <1> 	sal	edi, 1
  5293                              <1> 	;sal	di, 1			; OFFSET*2 SINCE 2 BYTES/CHAR
  5294                              <1> 					; EXPAND BL TO FULL WORD OF COLOR
  5295 000029A5 80E303              <1> 	and	bl, 3			; ISOLATE THE COLOR BITS ( LOW 2 BITS )
  5296 000029A8 B055                <1> 	mov	al, 055h		; GET BIT CONVERSION MULTIPLIER
  5297 000029AA F6E3                <1> 	mul	bl			; EXPAND 2 COLOR BITS TO 4 REPLICATIONS
  5298 000029AC 88C3                <1> 	mov	bl, al			; PLACE BACK IN WORK REGISTER
  5299 000029AE 88C7                <1> 	mov	bh, al			; EXPAND TO 8 REPLICATIONS OF COLOR BITS
  5300 000029B0 81C700800B00        <1> 	add	edi, 0B8000h
  5301                              <1> S7:                                     ; MED_CHAR
  5302 000029B6 57                  <1> 	push	edi			; SAVE REGEN POINTER
  5303 000029B7 56                  <1> 	push	esi			; SAVE THE CODE POINTER
  5304 000029B8 B604                <1> 	mov	dh, 4			; NUMBER OF LOOPS
  5305                              <1> S8:
  5306 000029BA AC                  <1> 	lodsb				; GET CODE POINT
  5307 000029BB E8B1000000          <1> 	call	S21			; DOUBLE UP ALL THE BITS
  5308 000029C0 6621D8              <1> 	and	ax, bx			; CONVERT TO FOREGROUND COLOR ( 0 BACK )
  5309 000029C3 86E0                <1> 	xchg	ah, al			; SWAP HIGH/LOW BYTES FOR WORD MOVE
  5310 000029C5 F6C280              <1> 	test	dl, 80h			; IS THIS XOR FUNCTION
  5311 000029C8 7403                <1> 	jz	short S9		; NO, STORE IT IN AS IS
  5312 000029CA 663307              <1> 	xor	ax, [edi]		; DO FUNCTION WITH LOW/HIGH
  5313                              <1> S9:
  5314 000029CD 668907              <1> 	mov	[edi], ax		; STORE FIRST BYTE HIGH, SECOND LOW
  5315 000029D0 AC                  <1> 	lodsb				; GET CODE POINT
  5316 000029D1 E89B000000          <1> 	call	S21
  5317 000029D6 6621D8              <1> 	and	ax, bx			; CONVERT TO COLOR
  5318 000029D9 86E0                <1> 	xchg	ah, al			; SWAP HIGH/LOW BYTES FOR WORD MOVE
  5319 000029DB F6C280              <1> 	test	dl, 80h			; AGAIN, IS THIS XOR FUNCTION
  5320 000029DE 7407                <1> 	jz	short _S10		; NO, JUST STORE THE VALUES
  5321 000029E0 66338700200000      <1> 	xor	ax, [edi+2000h]		; FUNCTION WITH FIRST HALF LOW
  5322                              <1> _S10:
  5323 000029E7 66898700200000      <1> 	mov	[edi+2000h], ax		; STORE SECOND PORTION HIGH
  5324 000029EE 6683C750            <1> 	add	di, 80			; POINT TO NEXT LOCATION
  5325 000029F2 FECE                <1> 	dec	dh
  5326 000029F4 75C4                <1> 	jnz	short S8		; KEEP GOING
  5327 000029F6 5E                  <1> 	pop	esi			; RECOVER CODE POINTER
  5328 000029F7 5F                  <1> 	pop	edi			; RECOVER REGEN POINTER
  5329 000029F8 47                  <1> 	inc	edi			; POINT TO NEXT CHAR POSITION
  5330 000029F9 47                  <1> 	inc	edi
  5331 000029FA E2BA                <1> 	loop	S7			; MORE TO WRITE
  5332 000029FC C3                  <1> 	retn
  5333                              <1> 
  5334                              <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5
  5335                              <1> ; 04/07/2016
  5336                              <1> ; 01/07/2016
  5337                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  5338                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5339                              <1> ;----------------------------------------
  5340                              <1> ; GRAPHICS READ
  5341                              <1> ;----------------------------------------
  5342                              <1> GRAPHICS_READ:
  5343 000029FD E89E000000          <1> 	call	S26			; CONVERTED TO OFFSET IN REGEN
  5344 00002A02 89C6                <1> 	mov	esi, eax		; SAVE IN SI
  5345 00002A04 81C600800B00        <1> 	add	esi, 0B8000h		; 01/07/2016
  5346 00002A0A 83EC08              <1> 	sub	esp, 8			; ALLOCATE SPACE FOR THE READ CODE POINT
  5347 00002A0D 89E5                <1> 	mov	ebp, esp		; POINTER TO SAVE AREA
  5348                              <1> 
  5349                              <1> ;-----	DETERMINE GRAPHICS MODES
  5350 00002A0F B604                <1> 	mov	dh, 4			; number of passes ; 01/07/2016
  5351 00002A11 803D[CE660000]06    <1> 	cmp	byte [CRT_MODE], 6
  5352 00002A18 7219                <1> 	jc	short S12		; MEDIUM RESOLUTION
  5353                              <1> 
  5354                              <1> ;-----	HIGH RESOLUTION READ
  5355                              <1> ;-----	GET VALUES FROM REGEN BUFFER AND CONVERT TO CODE POINT
  5356                              <1> 	;mov	dh,4			; NUMBER OF PASSES
  5357                              <1> S11:
  5358 00002A1A 8A06                <1> 	mov	al, [esi] 		; GET FIRST BYTE
  5359 00002A1C 884500              <1> 	mov	[ebp], al 		; SAVE IN STORAGE AREA
  5360 00002A1F 45                  <1> 	inc	ebp			; NEXT LOCATION
  5361 00002A20 8A8600200000        <1> 	mov	al, [esi+2000h]		; GET LOWER REGION BYTE
  5362 00002A26 884500              <1> 	mov	[ebp], al 		; ADJUST AND STORE
  5363 00002A29 45                  <1> 	inc	ebp
  5364 00002A2A 83C650              <1> 	add	esi, 80			; POINTER INTO REGEN
  5365 00002A2D FECE                <1> 	dec	dh			; LOOP CONTROL
  5366 00002A2F 75E9                <1> 	jnz	short S11		; DO IT SOME MORE
  5367 00002A31 EB1C                <1> 	jmp	short S14		; GO MATCH THE SAVED CODE POINTS
  5368                              <1> 
  5369                              <1> ;-----	MEDIUM RESOLUTION READ
  5370                              <1> S12:	
  5371                              <1> 	;sal	si, 1			; OFFSET*2 SINCE 2 BYTES/CHAR
  5372                              <1> 	; 03/08/2022
  5373 00002A33 D1E6                <1> 	sal	esi, 1
  5374                              <1> 	;mov	dh, 4			; NUMBER OF PASSES
  5375                              <1> S13:
  5376 00002A35 E84B000000          <1> 	call	S23			; GET BYTES FROM REGEN INTO SINGLE SAVE
  5377 00002A3A 81C6FE1F0000        <1> 	add	esi, 2000h-2		; GO TO LOWER REGION
  5378 00002A40 E840000000          <1> 	call	S23			; GET THIS PAIR INTO SAVE
  5379 00002A45 81EEB21F0000        <1> 	sub	esi, 2000h-80+2		; ADJUST POINTER BACK INTO UPPER
  5380 00002A4B FECE                <1> 	dec	dh
  5381 00002A4D 75E6                <1> 	jnz	short S13		; KEEP GOING UNTIL ALL 8 DONE
  5382                              <1> 
  5383                              <1> ;-----	SAVE AREA HAS CHARACTER IN IT, MATCH IT
  5384                              <1> S14:					; FIND_CHAR
  5385 00002A4F BF[1C4E0100]        <1> 	mov	edi, CRT_CHAR_GEN	; ESTABLISH ADDRESSING
  5386 00002A54 83ED08              <1> 	sub	ebp, 8			; ADJUST POINTER TO START OF SAVE AREA
  5387 00002A57 89EE                <1> 	mov	esi, ebp
  5388                              <1> S15:
  5389                              <1> 	;mov	ax, 256			; NUMBER TO TEST AGAINST
  5390                              <1> 	; 03/08/2022
  5391 00002A59 29C0                <1> 	sub	eax, eax
  5392 00002A5B FEC4                <1> 	inc	ah
  5393                              <1> 	; eax = 256
  5394                              <1> S16:
  5395 00002A5D 56                  <1> 	push	esi			; SAVE SAVE AREA POINTER
  5396 00002A5E 57                  <1> 	push	edi			; SAVE CODE POINTER
  5397                              <1> 	;mov	ecx, 4			; NUMBER OF WORDS TO MATCH
  5398                              <1> 	;repe	cmpsw			; COMPARE THE 8 BYTES AS WORDS
  5399 00002A5F A7                  <1> 	cmpsd				; compare first 4 bytes 
  5400 00002A60 7501                <1> 	jne	short S17		; 
  5401 00002A62 A7                  <1> 	cmpsd				; compare last 4 bytes
  5402                              <1> S17:
  5403 00002A63 5F                  <1> 	pop	edi			; RECOVER THE POINTERS
  5404 00002A64 5E                  <1> 	pop	esi
  5405                              <1> 	;jz	short S18		; IF ZERO FLAG SET, THEN MATCH OCCURRED
  5406 00002A65 7406                <1> 	je	short S18
  5407                              <1> 	;				; NO MATCH, MOVE ON TO NEXT
  5408 00002A67 83C708              <1> 	add	edi, 8			; NEXT CODE POINT
  5409                              <1> 	;dec	ax			; LOOP CONTROL
  5410                              <1> 	; 03/08/2022
  5411 00002A6A 48                  <1> 	dec	eax
  5412 00002A6B 75F0                <1> 	jnz	short S16		; DO ALL OF THEM
  5413                              <1> 
  5414                              <1> ;-----	CHARACTER IS FOUND ( AL=0 IF NOT FOUND )
  5415                              <1> S18:	
  5416 00002A6D 83C408              <1> 	add	esp, 8			; READJUST THE STACK, THROW AWAY SAVE
  5417 00002A70 C3                  <1> 	retn				; ALL DONE
  5418                              <1> 
  5419                              <1> ; 12/04/2021
  5420                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  5421                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5422                              <1> ;--------------------------------------------
  5423                              <1> ; EXPAND BYTE
  5424                              <1> ;  THIS ROUTINE TAKES THE BYTE IN AL AND DOUBLES ALL
  5425                              <1> ;  OF THE BITS, TURNING THE 8 BITS INTO 16 BITS.
  5426                              <1> ;  THE RESULT IS LEFT IN AX
  5427                              <1> ;--------------------------------------------
  5428                              <1> S21:
  5429                              <1> 	; 03/08/2022
  5430                              <1> 	;push	cx			; SAVE REGISTER
  5431                              <1> 	; 12/04/2021
  5432 00002A71 51                  <1> 	push	ecx
  5433                              <1> 	;;mov	cx, 8			; SHIFT COUNT REGISTER FOR ONE BYTE
  5434                              <1> 	;mov	cl, 8
  5435 00002A72 B408                <1> 	mov	ah, 8
  5436                              <1> S22:
  5437 00002A74 D0C8                <1> 	ror	al, 1			; SHIFT BITS, LOW BIT INTO CARRY FLAG
  5438                              <1> 	;rcr	bp, 1			; MOVE CARRY FLAG (LOW BIT INTO RESULTS
  5439                              <1> 	;sar	bp, 1			; SIGN EXTEND HIGH BIT (DOUBLE IT)
  5440                              <1> 	; 03/08/2022
  5441 00002A76 66D1D9              <1> 	rcr	cx, 1
  5442 00002A79 66D1F9              <1> 	sar	cx, 1
  5443                              <1> 
  5444                              <1> 	;;loop	S22			; REPEAT FOR ALL 8 BITS
  5445                              <1> 	;dec	cl
  5446                              <1> 	;jnz	short S22
  5447                              <1> 	;xchg	ax, bp			; MOVE RESULTS TO PARAMETER REGISTER
  5448                              <1> 	; 03/08/5022
  5449 00002A7C FECC                <1> 	dec	ah
  5450 00002A7E 75F4                <1> 	jnz	short S22
  5451 00002A80 6689C8              <1> 	mov	ax, cx
  5452                              <1> 	;pop	cx			; RECOVER REGISTER
  5453                              <1> 	; 12/04/2021
  5454 00002A83 59                  <1> 	pop	ecx
  5455 00002A84 C3                  <1> 	retn				; ALL DONE
  5456                              <1> 
  5457                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  5458                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5459                              <1> ;--------------------------------------------------
  5460                              <1> ; MED_READ_BYTE
  5461                              <1> ; THIS ROUTINE WILL TAKE 2 BYTES FROM THE REGEN BUFFER,
  5462                              <1> ;  COMPARE AGAINST THE CURRENT FOREGROUND COLOR, AND PLACE
  5463                              <1> ;  THE CORRESPONDING ON/OFF BIT PATTERN INTO THE CURRENT
  5464                              <1> ;  POSITION IN THE SAVE AREA
  5465                              <1> ; ENTRY --
  5466                              <1> ;  SI,DS = POINTER TO REGEN AREA OF INTEREST
  5467                              <1> ;  BX = EXPANDED FOREGROUND COLOR
  5468                              <1> ;  BP = POINTER TO SAVE AREA
  5469                              <1> ; EXIT --
  5470                              <1> ;  SI AND BP ARE INCREMENTED
  5471                              <1> ;----------------------------------------------------
  5472                              <1> S23:
  5473 00002A85 66AD                <1> 	lodsw				; GET FIRST BYTE AND SECOND BYTES
  5474 00002A87 86C4                <1> 	xchg	al, ah			; SWAP FOR COMPARE
  5475                              <1> 	;mov	cx, 0C000h		; 2 BIT MASK TO TEST THE ENTRIES
  5476                              <1> 	; 02/08/2022
  5477 00002A89 29C9                <1> 	sub	ecx, ecx
  5478 00002A8B B5C0                <1> 	mov	ch, 0C0h
  5479                              <1> 	; ecx = 0C000h
  5480                              <1> 	;mov	dl, 0			; RESULT REGISTER
  5481                              <1> 	; 03/08/2022
  5482 00002A8D 28D2                <1> 	sub	dl, dl
  5483                              <1> S24:
  5484                              <1> 	;test	ax, cx			; IS THIS SECTION BACKCROUND?
  5485                              <1>         ; 03/08/2022
  5486 00002A8F 85C8                <1> 	test	eax, ecx
  5487 00002A91 7401                <1> 	jz	short S25               ; IF ZERO, IT IS BACKGROUND (CARRY=0)
  5488 00002A93 F9                  <1> 	stc				; WASN'T, SO SET CARRY
  5489                              <1> S25:
  5490 00002A94 D0D2                <1> 	rcl	dl, 1			; MOVE THAT BIT INTO THE RESULT
  5491                              <1> 	;shr	cx, 2			; MOVE THE MASK TO THE RIGHT BY 2 BITS
  5492                              <1> 	; 02/08/2022
  5493 00002A96 C1E902              <1> 	shr	ecx, 2
  5494 00002A99 73F4                <1> 	jnc	short S24		; DO IT AGAIN IF MASK DIDN'T FALL OUT
  5495 00002A9B 885500              <1> 	mov	[ebp], dl 		; STORE RESULT IN SAVE AREA
  5496 00002A9E 45                  <1> 	inc	ebp			; ADJUST POINTER
  5497 00002A9F C3                  <1> 	retn				; ALL DONE
  5498                              <1> 
  5499                              <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5
  5500                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  5501                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5502                              <1> ;-----------------------------------------
  5503                              <1> ; V4_POSITION
  5504                              <1> ;  THIS ROUTINE TAKES THE CURSOR POSITION CONTAINED IN
  5505                              <1> ;  THE MEMORY LOCATION, AND CONVERTS IT INTO AN OFFSET
  5506                              <1> ;  INTO THE REGEN BUFFER, ASSUMING ONE BYTE/CHAR.
  5507                              <1> ;  FOR MEDIUM RESOLUTION GRAPHICS, THE NUMBER MUST
  5508                              <1> ;  BE DOUBLED.
  5509                              <1> ; ENTRY -- NO REGISTERS,MEMORY LOCATION @CURSOR_POSN IS USED
  5510                              <1> ; EXIT--
  5511                              <1> ;  AX CONTAINS OFFSET INTO REGEN BUFFER
  5512                              <1> ;-----------------------------------------
  5513                              <1> S26:
  5514 00002AA0 0FB705[A6770100]    <1> 	movzx	eax, word [CURSOR_POSN]	; GET CURRENT CURSOR
  5515                              <1> GRAPH_POSN:
  5516 00002AA7 53                  <1> 	push	ebx			; SAVE REGISTER
  5517 00002AA8 0FB6D8              <1> 	movzx	ebx, al			; SAVE A COPY OF CURRENT CURSOR
  5518 00002AAB A0[D0660000]        <1> 	mov	al, [CRT_COLS]		; GET BYTES PER COLUMN
  5519 00002AB0 F6E4                <1> 	mul	ah			; MULTIPLY BY ROWS
  5520                              <1> 	;shl	ax, 2			; MULTIPLY * 4 SINCE 4 ROWS/BYTE
  5521                              <1> 	; 02/08/2022
  5522 00002AB2 C1E002              <1> 	shl	eax, 2
  5523 00002AB5 01D8                <1> 	add	eax, ebx		; DETERMINE OFFSET
  5524 00002AB7 5B                  <1> 	pop	ebx			; RECOVER POINTER
  5525 00002AB8 C3                  <1> 	retn				; ALL DONE
  5526                              <1> 
  5527                              <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5
  5528                              <1> ; 09/07/2016
  5529                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  5530                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5531                              <1> ;---------------------------------------------
  5532                              <1> ; SET_COLOR
  5533                              <1> ;	THIS ROUTINE WILL ESTABLISH THE BACKGROUND COLOR, THE OVERSCAN COLOR,
  5534                              <1> ;	AND THE FOREGROUND COLOR SET FOR MEDIUM RESOLUTION GRAPHICS
  5535                              <1> ; INPUT
  5536                              <1> ;	(BH) HAS COLOR ID
  5537                              <1> ;		IF BH=0, THE BACKGROUND COLOR VALUE IS SET
  5538                              <1> ;			FROM THE LOW BITS OF BL (0-31)
  5539                              <1> ;		IF BH=1, THE PALETTE SELECTION IS MADE
  5540                              <1> ;			BASED ON THE LOW BIT OF BL:
  5541                              <1> ;				0 = GREEN, RED, YELLOW FOR COLORS 1,2,3
  5542                              <1> ;				1 = BLUE, CYAN, MAGENTA FOR COLORS 1,2,3
  5543                              <1> ;	(BL) HAS THE COLOR VALUE TO BE USED
  5544                              <1> ; OUTPUT
  5545                              <1> ;	THE COLOR SELECTION IS UPDATED
  5546                              <1> ;----------------------------------------------
  5547                              <1> SET_COLOR:
  5548 00002AB9 803D[CE660000]07    <1>         cmp     byte [CRT_MODE], 7      ; 09/07/2016
  5549                              <1> 	;ja	VIDEO_RETURN		; nothing to do for VGA modes
  5550                              <1> 	; 03/08/2022
  5551 00002AC0 7605                <1> 	jna	short M21
  5552 00002AC2 E92EF0FFFF          <1> 	jmp	VIDEO_RETURN
  5553                              <1> M21:
  5554                              <1> 	;mov	dx, [ADDR_6845]		; I/O PORT FOR PALETTE
  5555                              <1> 	;mov	dx, 3D4h
  5556                              <1> 	;add	dx, 5			; OVERSCAN PORT
  5557 00002AC7 66BAD903            <1> 	mov	dx, 3D9h
  5558 00002ACB A0[D1660000]        <1> 	mov	al, [CRT_PALETTE] 	; GET THE CURRENT PALETTE VALUE
  5559 00002AD0 08FF                <1> 	or	bh, bh			; IS THIS COLOR 0?
  5560 00002AD2 7512                <1> 	jnz	short M20		; OUTPUT COLOR 1
  5561                              <1> 
  5562                              <1> ;-----	HANDLE COLOR 0 BY SETTING THE BACKGROUND COLOR
  5563                              <1> 
  5564 00002AD4 24E0                <1> 	and	al, 0E0h 		; TURN OFF LOW 5 BITS OF CURRENT
  5565 00002AD6 80E31F              <1> 	and	bl, 01Fh 		; TURN OFF HIGH 3 BITS OF INPUT VALUE
  5566 00002AD9 08D8                <1> 	or	al, bl			; PUT VALUE INTO REGISTER
  5567                              <1> M19:					; OUTPUT THE PALETTE
  5568 00002ADB EE                  <1> 	out	dx, al			; OUTPUT COLOR SELECTION TO 3D9 PORT
  5569 00002ADC A2[D1660000]        <1> 	mov	[CRT_PALETTE], al 	; SAVE THE COLOR VALUE
  5570 00002AE1 E90FF0FFFF          <1> 	jmp	VIDEO_RETURN
  5571                              <1> 
  5572                              <1> ;-----	HANDLE COLOR 1 BY SELECTING THE PALETTE TO BE USED
  5573                              <1> 
  5574                              <1> M20:
  5575 00002AE6 24DF                <1> 	and	al, 0DFH 		; TURN OFF PALETTE SELECT BIT
  5576 00002AE8 D0EB                <1> 	shr	bl, 1			; TEST THE LOW ORDER BIT OF BL
  5577 00002AEA 73EF                <1> 	jnc	short M19		; ALREADY DONE
  5578 00002AEC 0C20                <1> 	or	al, 20H			; TURN ON PALETTE SELECT BIT
  5579 00002AEE EBEB                <1> 	jmp	short M19		; GO DO IT
  5580                              <1> 
  5581                              <1> ; 03/08/2022 - TRDOS 386 Kernel v2.0.5
  5582                              <1> ; 09/07/2016
  5583                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  5584                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5585                              <1> ;--------------------------------------------
  5586                              <1> ; READ DOT -- WRITE DOT
  5587                              <1> ; THESE ROUTINES WILL WRITE A DOT, OR READ THE
  5588                              <1> ;  DOT AT THE INDICATED LOCATION
  5589                              <1> ; ENTRY --
  5590                              <1> ;   DX = ROW (0-199)	(THE ACTUAL VALUE DEPENDS ON THE MODE)
  5591                              <1> ;   CX = COLUMN ( 0-639) ( THE VALUES ARE NOT RANGE CHECKED )
  5592                              <1> ;   AL = DOT VALUE TO WRITE (1,2 OR 4 BITS DEPENDING ON MODE,
  5593                              <1> ;	REQUIRED FOR WRITE DOT ONLY, RIGHT JUSTIFIED)
  5594                              <1> ;	BIT 7 OF AL = 1 INDICATES XOR THE VALUE INTO THE LOCATION
  5595                              <1> ;   DS = DATA SEGMENT
  5596                              <1> ;   ES = REGEN SEGMENT
  5597                              <1> ;
  5598                              <1> ; EXIT
  5599                              <1> ;	AL = DOT VALUE READ, RIGHT JUSTIFIED, READ ONLY
  5600                              <1> ;----------------------------------------------
  5601                              <1> 
  5602                              <1> READ_DOT:
  5603                              <1> 	; 09/07/2016
  5604 00002AF0 8A25[CE660000]      <1> 	mov	ah,  [CRT_MODE]
  5605 00002AF6 80FC07              <1> 	cmp	ah, 7 ; 6!?
  5606 00002AF9 760A                <1> 	jna	short read_dot_cga
  5607                              <1> 
  5608 00002AFB E8B3030000          <1> 	call	vga_read_pixel
  5609                              <1> 	; al = pixel value
  5610                              <1> read_dot_retn:	; 03/08/2022
  5611 00002B00 E9F5EFFFFF          <1> 	jmp	_video_return
  5612                              <1> 
  5613                              <1> read_dot_cga:
  5614                              <1> 	;je	VIDEO_RETURN ; 7	
  5615 00002B05 80FC04              <1> 	cmp	ah, 4 ; graphics ? 
  5616                              <1> 	;jb	VIDEO_RETURN ; no, text mode, nothing to do
  5617                              <1> 	; 03/08/2022
  5618 00002B08 72F6                <1> 	jb	short read_dot_retn
  5619                              <1> 
  5620 00002B0A E84F000000          <1> 	call	R3			; DETERMINE BYTE POSITION OF DOT
  5621 00002B0F 8A06                <1> 	mov	al, [esi]		; GET THE BYTE
  5622 00002B11 20E0                <1> 	and	al, ah			; MASK OFF THE OTHER BITS IN THE BYTE
  5623 00002B13 D2E0                <1> 	shl	al, cl			; LEFT JUSTIFY THE VALUE
  5624 00002B15 88F1                <1> 	mov	cl, dh			; GET NUMBER OF BITS IN RESULT
  5625 00002B17 D2C0                <1> 	rol	al, cl			; RIGHT JUSTIFY THE RESULT
  5626                              <1> 	;jmp	VIDEO_RETURN		; RETURN FROM VIDEO I/O
  5627 00002B19 0FB6C0              <1> 	movzx	eax, al
  5628 00002B1C E9D9EFFFFF          <1> 	jmp	_video_return
  5629                              <1> 
  5630                              <1> ; 03/08/2022
  5631                              <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5
  5632                              <1> ; 12/04/2021
  5633                              <1> ; 09/07/2016
  5634                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  5635                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5636                              <1> 
  5637                              <1> WRITE_DOT:
  5638                              <1> 	; 09/07/2016
  5639 00002B21 8A25[CE660000]      <1> 	mov	ah, [CRT_MODE]
  5640 00002B27 80FC07              <1> 	cmp	ah, 7 ; 6!?
  5641 00002B2A 760A                <1> 	jna	short write_dot_cga
  5642                              <1> 	
  5643 00002B2C E8F2020000          <1> 	call	vga_write_pixel
  5644                              <1> write_dot_retn:	; 03/08/2022
  5645 00002B31 E9BFEFFFFF          <1> 	jmp	VIDEO_RETURN
  5646                              <1> 
  5647                              <1> write_dot_cga:
  5648                              <1> 	;je	VIDEO_RETURN ; 7	
  5649 00002B36 80FC04              <1> 	cmp	ah, 4 ; graphics ? 
  5650                              <1> 	;jb	VIDEO_RETURN ; no, text mode, nothing to do
  5651                              <1> 	; 03/08/2022
  5652 00002B39 72F6                <1> 	jb	short write_dot_retn
  5653                              <1> 
  5654                              <1> 	;;push	ax			; SAVE DOT VALUE
  5655                              <1> 	;push	ax			; TWICE
  5656                              <1> 	; 12/04/2021
  5657 00002B3B 50                  <1> 	push	eax
  5658 00002B3C E81D000000          <1> 	call	R3			; DETERMINE BYTE POSITION OF THE DOT
  5659 00002B41 D2E8                <1> 	shr	al, cl			; SHIFT TO SET UP THE BITS FOR OUTPUT
  5660 00002B43 20E0                <1> 	and	al, ah			; STRIP OFF THE OTHER BITS
  5661 00002B45 8A0E                <1> 	mov	cl, [esi]		; GET THE CURRENT BYTE
  5662                              <1> 	;pop	bx			; RECOVER XOR FLAG
  5663                              <1> 	; 12/04/2021
  5664 00002B47 5B                  <1> 	pop	ebx
  5665 00002B48 F6C380              <1> 	test	bl, 80h			; IS IT ON
  5666 00002B4B 750D                <1> 	jnz	short R2		; YES, XOR THE DOT
  5667 00002B4D F6D4                <1> 	not	ah			; SET MASK TO REMOVE THE INDICATED BITS
  5668 00002B4F 20E1                <1> 	and	cl, ah
  5669 00002B51 08C8                <1> 	or	al, cl			; OR IN THE NEW VALUE OF THOSE BITS
  5670                              <1> R1:					; FINISH_DOT
  5671 00002B53 8806                <1> 	mov	[esi], al		; RESTORE THE BYTE IN MEMORY
  5672                              <1> 	;;pop	AX
  5673 00002B55 E99BEFFFFF          <1> 	jmp	VIDEO_RETURN		; RETURN FROM VIDEO I/O
  5674                              <1> R2:					; XOR_DOT
  5675 00002B5A 30C8                <1> 	xor	al, cl			; EXCLUSIVE OR THE DOTS
  5676 00002B5C EBF5                <1> 	jmp	short R1		; FINISH UP THE WRITING
  5677                              <1> 
  5678                              <1> ; 02/08/2022 - TRDOS 386 Kernel v2.0.5
  5679                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  5680                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5681                              <1> 
  5682                              <1> ;----------------------------------------------
  5683                              <1> ; THIS SUBROUTINE DETERMINES THE REGEN BYTE LOCATION OF THE
  5684                              <1> ; INDICATED ROW COLUMN VALUE IN GRAPHICS MODE.
  5685                              <1> ; ENTRY --
  5686                              <1> ;  DX = ROW VALUE (0-199)
  5687                              <1> ;  CX = COLUMN VALUE (0-639)
  5688                              <1> ; EXIT --
  5689                              <1> ;  SI = OFFSET INTO REGEN BUFFER FOR BYTE OF INTEREST
  5690                              <1> ;  AH = MASK TO STRIP OFF THE BITS OF INTEREST
  5691                              <1> ;  CL = BITS TO SHIFT TO RIGHT JUSTIFY THE MASK IN AH
  5692                              <1> ;  DH = # BITS IN RESULT
  5693                              <1> ;  BX = MODIFIED
  5694                              <1> ;-----------------------------------------------
  5695                              <1> R3:
  5696                              <1> 
  5697                              <1> ;-----	DETERMINE 1ST BYTE IN INDICATED ROW BY MULTIPLYING ROW VALUE BY 40
  5698                              <1> ;-----	 ( LOW BIT OF ROW DETERMINES EVEN/ODD, 80 BYTES/ROW )
  5699                              <1> 
  5700 00002B5E 0FB7F0              <1> 	movzx	esi, ax			; WILL SAVE AL AND AH DURING OPERATION
  5701 00002B61 B028                <1> 	mov	al, 40
  5702 00002B63 F6E2                <1> 	mul	dl			; AX= ADDRESS OF START OF INDICATED ROW
  5703 00002B65 A808                <1> 	test	al, 08H 		; TEST FOR EVEN/ODD ROW CALCULATED
  5704 00002B67 7404                <1> 	JZ	short R4		; JUMP IF EVEN ROW
  5705 00002B69 6605D81F            <1> 	add	ax, 2000h-40		; OFFSET TO LOCATION OF ODD ROWS ADJUST
  5706                              <1> R4:					; EVEN_ROW
  5707                              <1> 	;xchg	si, ax			; MOVE POINTER TO (SI) AND RECOVER (AX)
  5708                              <1> 	; 02/08/2022
  5709 00002B6D 96                  <1> 	xchg	esi, eax
  5710 00002B6E 81C600800B00        <1> 	add	esi, 0B8000h
  5711                              <1> 	;mov	dx, cx			; COLUMN VALUE TO DX
  5712 00002B74 0FB7D1              <1> 	movzx	edx, cx
  5713                              <1> 
  5714                              <1> ;-----	DETERMINE GRAPHICS MODE CURRENTLY IN EFFECT
  5715                              <1> 
  5716                              <1> ; SET UP THE REGISTERS ACCORDING TO THE MODE
  5717                              <1> ; CH = MASK FOR LOW OF COLUMN ADDRESS ( 7/3 FOR HIGH/MED RES )
  5718                              <1> ; CL = # OF ADDRESS BITS IN COLUMN VALUE ( 3/2 FOR H/M )
  5719                              <1> ; BL = MASK TO SELECT BITS FROM POINTED BYTE ( 80H/C0H FOR H/M )
  5720                              <1> ; BH = NUMBER OF VALID BITS IN POINTED BYTE ( 1/2 FOR H/M )
  5721                              <1> 
  5722 00002B77 66BBC002            <1> 	mov	bx, 2C0h
  5723 00002B7B 66B90203            <1> 	mov	cx, 302h 		; SET PARMS FOR MED RES
  5724 00002B7F 803D[CE660000]06    <1> 	cmp	byte [CRT_MODE], 6
  5725 00002B86 7208                <1> 	jc	short R5		; HANDLE IF MED RES
  5726 00002B88 66BB8001            <1> 	mov	bx, 180h
  5727 00002B8C 66B90307            <1> 	mov	cx, 703h 		; SET PARMS FOR HIGH RES
  5728                              <1> 
  5729                              <1> ;-----	DETERMINE BIT OFFSET IN BYTE FROM COLUMN MASK
  5730                              <1> R5:
  5731 00002B90 20D5                <1> 	and	ch, dl			; ADDRESS OF PEL WITHIN BYTE TO CH
  5732                              <1> 
  5733                              <1> ;-----	DETERMINE BYTE OFFSET FOR THIS LOCATION IN COLUMN
  5734                              <1> 
  5735                              <1> 	;shr	dx, cl			; SHIFT BY CORRECT AMOUNT
  5736                              <1> 	;add	si, dx			; INCREMENT THE POINTER
  5737                              <1> 	; 02/08/2022
  5738 00002B92 D3EA                <1> 	shr	edx, cl
  5739 00002B94 01D6                <1> 	add	esi, edx
  5740 00002B96 88FE                <1> 	mov	dh, bh			; GET THE # OF BITS IN RESULT TO DH
  5741                              <1> 
  5742                              <1> ;-----	MULTIPLY BH (VALID BITS IN BYTE) BY CH (BIT OFFSET)
  5743                              <1> 
  5744 00002B98 28C9                <1> 	sub	cl, cl			; ZERO INTO STORAGE LOCATION
  5745                              <1> R6:
  5746 00002B9A D0C8                <1> 	ror	al, 1			; LEFT JUSTIFY VALUE IN AL (FOR WRITE)
  5747 00002B9C 00E9                <1> 	add	cl, ch			; ADD IN THE BIT OFFSET VALUE
  5748 00002B9E FECF                <1> 	dec	bh			; LOOP CONTROL
  5749 00002BA0 75F8                <1> 	jnz	short R6		; ON EXIT, CL HAS COUNT TO RESTORE BITS
  5750 00002BA2 88DC                <1> 	mov	ah, bl			;  GET MASK TO AH
  5751 00002BA4 D2EC                <1> 	shr	ah, cl			;  MOVE THE MASK TO CORRECT LOCATION
  5752 00002BA6 C3                  <1> 	retn				;  RETURN WITH EVERYTHING SET UP
  5753                              <1> 
  5754                              <1> load_dac_palette:
  5755                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  5756                              <1> 	; 29/07/2016
  5757                              <1> 	; 23/07/2016
  5758                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  5759                              <1> 	; (set_mode_vga)
  5760                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5761                              <1> 	; vgabios-0.7a (2011)
  5762                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5763                              <1> 	; 'vgabios.c', 'load_dac_palette'
  5764                              <1> 	;
  5765                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  5766                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  5767                              <1> 	;
  5768                              <1> 	; INPUT -> AH = DAC selection number (3, 2 or 1)
  5769                              <1> 	; OUTPUT -> ECX = 0, AX = 0
  5770                              <1> 	; (Modifed registers: EAX, ECX, EDX, ESI)
  5771                              <1> 	;
  5772 00002BA7 66BAC803            <1> 	mov	dx, 3C8h  ; VGAREG_DAC_WRITE_ADDRESS
  5773 00002BAB 28C0                <1> 	sub	al, al ; 0
  5774 00002BAD EE                  <1> 	out	dx, al ; 0 ; color index, always 0 at the beginning
  5775                              <1> 	;inc	dx   ; 3C9h ; VGAREG_DAC_DATA
  5776                              <1> 	; 02/08/2022
  5777 00002BAE FEC2                <1> 	inc	dl ; dx = 3C9h
  5778                              <1> 	;mov	ecx, 256   ; always 256*3 values
  5779                              <1> 	; 02/08/2022
  5780 00002BB0 31C9                <1> 	xor	ecx, ecx
  5781 00002BB2 FEC5                <1> 	inc	ch	
  5782                              <1> 	; ecx = 256
  5783                              <1> 
  5784                              <1> 	;push	esi
  5785 00002BB4 88E0                <1> 	mov	al, ah
  5786 00002BB6 B43F                <1> 	mov	ah, 3Fh	; 3Fh except DAC selection number 3
  5787 00002BB8 3C02                <1> 	cmp 	al, 2
  5788 00002BBA 7414                <1> 	je	short l_dac_p_2
  5789 00002BBC 7719                <1> 	ja	short l_dac_p_3
  5790 00002BBE 20C0                <1> 	and	al, al
  5791 00002BC0 7507                <1> 	jnz	short l_dac_p_1
  5792                              <1> l_dac_p_0:
  5793 00002BC2 BE[DC480100]        <1> 	mov	esi, palette0
  5794 00002BC7 EB15                <1> 	jmp	short l_dac_p_4	
  5795                              <1> l_dac_p_1:
  5796 00002BC9 BE[9C490100]        <1> 	mov	esi, palette1
  5797 00002BCE EB0E                <1> 	jmp	short l_dac_p_4
  5798                              <1> l_dac_p_2:
  5799 00002BD0 BE[5C4A0100]        <1> 	mov	esi, palette2
  5800 00002BD5 EB07                <1> 	jmp	short l_dac_p_4
  5801                              <1> l_dac_p_3:
  5802 00002BD7 B4FF                <1> 	mov	ah, 0FFh ; dac registers
  5803 00002BD9 BE[1C4B0100]        <1> 	mov	esi, palette3
  5804                              <1> l_dac_p_4:
  5805 00002BDE AC                  <1> 	lodsb
  5806 00002BDF EE                  <1> 	out	dx, al  ; Red
  5807 00002BE0 AC                  <1> 	lodsb
  5808 00002BE1 EE                  <1> 	out	dx, al	; Green
  5809 00002BE2 AC                  <1> 	lodsb
  5810 00002BE3 EE                  <1> 	out	dx, al	; Blue
  5811 00002BE4 20E4                <1> 	and	ah, ah
  5812 00002BE6 7405                <1> 	jz	short l_dac_p_5	
  5813 00002BE8 FECC                <1> 	dec	ah
  5814 00002BEA E2F2                <1> 	loop	l_dac_p_4
  5815                              <1> 	;pop	esi
  5816 00002BEC C3                  <1> 	retn
  5817                              <1> l_dac_p_5:
  5818                              <1> 	; 29/07/2016
  5819 00002BED FEC9                <1> 	dec	cl
  5820 00002BEF 7407                <1> 	jz	short l_dac_p_7
  5821                              <1> 	;
  5822 00002BF1 28C0                <1> 	sub	al, al ; 0
  5823                              <1> l_dac_p_6:
  5824 00002BF3 EE                  <1> 	out	dx, al ; outb(VGAREG_DAC_DATA,0);
  5825 00002BF4 EE                  <1> 	out	dx, al
  5826 00002BF5 EE                  <1> 	out	dx, al
  5827 00002BF6 E2FB                <1> 	loop	l_dac_p_6
  5828                              <1> l_dac_p_7:
  5829                              <1> 	;pop	esi
  5830 00002BF8 C3                  <1> 	retn
  5831                              <1> 
  5832                              <1> gray_scale_summing:
  5833                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
  5834                              <1> 	; 12/04/2021
  5835                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  5836                              <1> 	; (set_mode_vga)
  5837                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5838                              <1> 	; vgabios-0.7a (2011)
  5839                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5840                              <1> 	; 'vgabios.c', 'biosfn_perform_gray_scale_summing'
  5841                              <1> 	;
  5842                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  5843                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  5844                              <1> 	;
  5845                              <1> 
  5846                              <1> 	; INPUT -> EBX = Start address (color index <= 255)
  5847                              <1> 	;	   ECX = Count (<= 256)
  5848                              <1> 	; OUTPUT -> (E)CX = 0
  5849                              <1> 	; (Modifed registers: EAX, ECX, EDX, EBX)
  5850                              <1> 
  5851 00002BF9 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  5852 00002BFD EC                  <1> 	in	al, dx
  5853 00002BFE 30C0                <1> 	xor	al, al ; 0
  5854                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  5855                              <1> 	; 03/08/2022
  5856 00002C00 B2C0                <1> 	mov	dl, 0C0h
  5857 00002C02 EE                  <1> 	out	dx, al	; clear bit 5
  5858                              <1> 			; (while loading palette registers)
  5859                              <1> 	; set read address and switch to read mode
  5860                              <1> g_s_s_1:
  5861                              <1> 	;mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  5862                              <1> 	; 03/08/2022
  5863 00002C03 B2C7                <1> 	mov	dl, 0C7h
  5864 00002C05 88D8                <1> 	mov	al, bl
  5865 00002C07 EE                  <1> 	out	dx, al
  5866                              <1> 	; get 6-bit wide RGB data values
  5867                              <1>  	; intensity = (0.3*Red)+(0.59*Green)+(0.11*Blue)
  5868                              <1> 	; i = ( ( 77*r + 151*g + 28*b ) + 0x80 ) >> 8;
  5869                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
  5870                              <1> 	; 03/08/2022
  5871 00002C08 B2C9                <1> 	mov	dl, 0C9h
  5872 00002C0A EC                  <1> 	in	al, dx ; red
  5873 00002C0B B44D                <1> 	mov	ah, 77 ; 0.3* Red
  5874 00002C0D F6E4                <1> 	mul	ah
  5875                              <1> 	;push	ax
  5876                              <1> 	; 12/04/2021
  5877 00002C0F 50                  <1> 	push	eax
  5878 00002C10 EC                  <1> 	in	al, dx ; green
  5879 00002C11 B497                <1> 	mov	ah, 151  ; 0.59 * Green
  5880 00002C13 F6E4                <1> 	mul	ah
  5881                              <1> 	;push	ax
  5882                              <1> 	; 12/04/2021
  5883 00002C15 50                  <1> 	push	eax
  5884 00002C16 EC                  <1> 	in	al, dx ; blue
  5885 00002C17 B41C                <1> 	mov	ah, 28 ; 0.11 * Blue
  5886 00002C19 F6E4                <1> 	mul	ah
  5887                              <1> 	;pop	dx
  5888                              <1> 	; 12/04/2021
  5889 00002C1B 5A                  <1> 	pop	edx
  5890 00002C1C 6601D0              <1> 	add	ax, dx
  5891                              <1> 	;pop	dx
  5892                              <1> 	; 12/04/2021
  5893 00002C1F 5A                  <1> 	pop	edx
  5894 00002C20 6601D0              <1> 	add	ax, dx
  5895 00002C23 66058000            <1> 	add	ax, 80h  
  5896 00002C27 B03F                <1> 	mov	al, 3Fh
  5897 00002C29 38C4                <1> 	cmp	ah, al	; if(i>0x3f)i=0x3f
  5898 00002C2B 7602                <1> 	jna	short g_s_s_2
  5899 00002C2D 88C4                <1> 	mov	ah, al
  5900                              <1> g_s_s_2:
  5901                              <1> 	;mov	dx, 3C8h  ; VGAREG_DAC_WRITE_ADDRESS
  5902                              <1> 	; 03/08/2022
  5903 00002C2F B2C8                <1> 	mov	dl, 0C8h
  5904 00002C31 88D8                <1> 	mov	al, bl ; color index
  5905 00002C33 EE                  <1> 	out	dx, al
  5906 00002C34 88E0                <1> 	mov	al, ah ; intensity
  5907                              <1> 	;inc	dx ; 3C9h ; VGAREG_DAC_DATA
  5908                              <1> 	; 03/08/2022
  5909 00002C36 FEC2                <1> 	inc	dl
  5910 00002C38 EE                  <1> 	out	dx, al ; R (R=G=B)
  5911 00002C39 88E0                <1> 	mov	al, ah ; intensity
  5912 00002C3B EE                  <1> 	out	dx, al ; G (R=G=B)
  5913 00002C3C 88E0                <1>  	mov	al, ah ; intensity
  5914 00002C3E EE                  <1> 	out	dx, al ; B (R=G=B)
  5915                              <1> 	;dec	cx
  5916                              <1> 	; 03/08/2022
  5917 00002C3F 49                  <1> 	dec	ecx
  5918 00002C40 7404                <1> 	jz	short g_s_s_3
  5919 00002C42 FEC3                <1> 	inc	bl    ; next color index value
  5920 00002C44 EBBD                <1> 	jmp	short g_s_s_1
  5921                              <1> g_s_s_3:
  5922                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  5923                              <1> 	; 03/08/2022
  5924 00002C46 B2DA                <1> 	mov	dl, 0DAh
  5925 00002C48 EC                  <1> 	in	al, dx
  5926 00002C49 B020                <1> 	mov	al, 20h
  5927                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  5928                              <1> 	; 03/08/2022
  5929 00002C4B B2C0                <1> 	mov	dl, 0C0h 
  5930 00002C4D EE                  <1> 	out	dx, al ; 20h -> set bit 5
  5931                              <1> 		        ; (after loading palette regs)
  5932 00002C4E C3                  <1> 	retn
  5933                              <1> 
  5934                              <1> vga_write_char_attr:
  5935                              <1> vga_write_char_only: 
  5936                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  5937                              <1> 	;
  5938                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5939                              <1> 	; vgabios-0.7a (2011)
  5940                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5941                              <1> 	; 'vgabios.c', 'biosfn_write_char_attr'
  5942                              <1> 	; 'biosfn_write_char_only'
  5943                              <1> 
  5944                              <1> 	; INPUT ->
  5945                              <1> 	; [CRT_MODE] = current video mode (>7)
  5946                              <1> 	; CX = Count of characters to write
  5947                              <1> 	; AL = Character to write
  5948                              <1> 	; BL = Color of character
  5949                              <1> 	; OUTPUT ->
  5950                              <1> 	; Regen buffer updated
  5951                              <1>  
  5952 00002C4F 8A25[CE660000]      <1> 	mov 	ah, [CRT_MODE]
  5953 00002C55 668B15[A6770100]    <1> 	mov	dx, [CURSOR_POSN] ; cursor pos for page 0
  5954                              <1> 
  5955 00002C5C BE[EA660000]        <1> 	mov	esi, vga_modes
  5956 00002C61 89F7                <1> 	mov	edi, esi
  5957 00002C63 83C710              <1> 	add	edi, vga_mode_count
  5958                              <1> vga_wca_0:
  5959 00002C66 AC                  <1> 	lodsb
  5960 00002C67 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  5961 00002C69 7405                <1> 	je	short vga_wca_2
  5962 00002C6B 39FE                <1> 	cmp	esi, edi
  5963 00002C6D 72F7                <1> 	jb	short vga_wca_0
  5964                              <1> vga_wca_1:
  5965 00002C6F C3                  <1> 	retn	; nothing to do
  5966                              <1> vga_wca_2:
  5967 00002C70 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  5968                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  5969                              <1> 
  5970                              <1> 	; biosfn_write_char_attr (car,page,attr,count) 
  5971                              <1> 	; AL = car, page = 0, BL = attr, CX = count
  5972 00002C73 803E04              <1> 	cmp	byte [esi], PLANAR4
  5973 00002C76 741D                <1> 	je	short vga_wca_planar
  5974 00002C78 803E03              <1> 	cmp	byte [esi], PLANAR1
  5975 00002C7B 7418                <1> 	je	short vga_wca_planar
  5976                              <1> vga_wca_linear8:
  5977                              <1> 	; while((count-->0) && (xcurs<nbcols))
  5978                              <1> 	; CX = count
  5979 00002C7D 6621C9              <1> 	and	cx, cx
  5980 00002C80 74ED                <1> 	jz	short vga_wca_1
  5981 00002C82 3A15[D0660000]      <1> 	cmp	dl, [CRT_COLS]
  5982 00002C88 73E5                <1> 	jnb	short vga_wca_1
  5983                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols);
  5984                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  5985                              <1> 	; [CRT_COLS] = nbcols
  5986 00002C8A E81E000000          <1> 	call	write_gfx_char_lin	 
  5987 00002C8F 6649                <1> 	dec	cx ; count
  5988 00002C91 FEC2                <1> 	inc	dl ; xcurs
  5989 00002C93 EBE8                <1> 	jmp	short vga_wca_linear8
  5990                              <1> vga_wca_planar:
  5991                              <1> 	; while((count-->0) && (xcurs<nbcols))
  5992                              <1> 	; CX = count
  5993 00002C95 6621C9              <1> 	and	cx, cx
  5994 00002C98 74D5                <1> 	jz	short vga_wca_1
  5995 00002C9A 3A15[D0660000]      <1> 	cmp	dl, [CRT_COLS]
  5996 00002CA0 73CD                <1> 	jnb	short vga_wca_1
  5997                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight);
  5998                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  5999                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  6000 00002CA2 E8A7000000          <1> 	call	write_gfx_char_pl4
  6001 00002CA7 6649                <1> 	dec	cx ; count
  6002 00002CA9 FEC2                <1> 	inc	dl ; xcurs
  6003 00002CAB EBE8                <1> 	jmp	short vga_wca_planar
  6004                              <1> 
  6005                              <1> write_gfx_char_lin:
  6006                              <1> 	; 02/08/2022 (TRDOS 386 v2.0.5)
  6007                              <1> 	; 08/01/2021
  6008                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  6009                              <1> 	; 08/08/2016
  6010                              <1> 	; 31/07/2016
  6011                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  6012                              <1> 	;
  6013                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6014                              <1> 	; vgabios-0.7a (2011)
  6015                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6016                              <1> 	; 'vgabios.c', 'write_gfx_char_lin'
  6017                              <1> 
  6018                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols)
  6019                              <1> 	; INPUT ->
  6020                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  6021                              <1> 	; [CRT_COLS] = nbcols
  6022                              <1> 	; OUTPUT ->
  6023                              <1> 	; Regen buffer updated
  6024                              <1> 
  6025 00002CAD 51                  <1> 	push	ecx
  6026 00002CAE 53                  <1> 	push	ebx
  6027 00002CAF 52                  <1> 	push	edx
  6028 00002CB0 50                  <1> 	push	eax
  6029                              <1> 	; addr=xcurs*8+ycurs*nbcols*64;
  6030                              <1> 	; 08/08/2016
  6031 00002CB1 0FB6F0              <1> 	movzx	esi, al ; car
  6032                              <1> 	; 08/01/2021
  6033                              <1> 	;movzx	eax, dh ; ycurs
  6034                              <1> 	;mov	ah, [CRT_COLS] ; nbcols
  6035                              <1> 	;mul	ah
  6036 00002CB4 A0[D0660000]        <1> 	mov	al, [CRT_COLS]
  6037 00002CB9 F6E6                <1> 	mul	dh
  6038                              <1> 	;shl	ax, 6 ; * 64
  6039                              <1> 	;shl	ax, 3 ; 8 * ycurs * [CRT_COLS]
  6040                              <1> 	; 02/08/2022
  6041 00002CBB C1E003              <1> 	shl	eax, 3
  6042                              <1> 	;sub	dh, dh
  6043                              <1> 	;shl	dx, 3 ; xcurs * 8
  6044                              <1> 	;movzx	edi, dx
  6045 00002CBE BF00000A00          <1> 	mov	edi, 0A0000h
  6046 00002CC3 30F6                <1> 	xor	dh, dh
  6047 00002CC5 6689D7              <1> 	mov	di, dx
  6048                              <1> 	;movzx	edi, dl
  6049 00002CC8 66C1E703            <1> 	shl	di, 3 ; xcurs * 8
  6050                              <1> 	;xor	dh, dh
  6051 00002CCC 8A15[D2660000]      <1> 	mov	dl, [CHAR_HEIGHT]
  6052 00002CD2 66F7E2              <1> 	mul	dx
  6053                              <1> 	; eax = ycurs*nbcols*8*[CHAR_HEIGHT]
  6054                              <1> 	;add	edi, eax ; addr
  6055                              <1> 	;add	edi, 0A0000h
  6056 00002CD5 6601C7              <1> 	add	di, ax
  6057                              <1> 	;shl	si, 3 ; car * 8
  6058 00002CD8 30E4                <1> 	xor	ah, ah
  6059 00002CDA A0[D2660000]        <1> 	mov	al, [CHAR_HEIGHT]
  6060 00002CDF 66F7E6              <1> 	mul	si
  6061 00002CE2 6689C6              <1> 	mov	si, ax
  6062                              <1> 	;; esi = src = car * 8
  6063                              <1> 	; esi = src = car * [CHAR_HEIGHT]
  6064                              <1> 	; i = 0
  6065                              <1> 	;add	esi, vgafont8 ; fdata [src+i]
  6066                              <1> 	; 08/08/2016
  6067 00002CE5 A1[2E840100]        <1> 	mov	eax, [VGA_INT43H]
  6068 00002CEA 09C0                <1> 	or	eax, eax ; 0 ?
  6069 00002CEC 743E                <1> 	jz	short wfxl_7 ; yes, default font
  6070                              <1> 	;cmp	eax, vgafont16
  6071                              <1>         ;je	short wgfxl_0
  6072                              <1> 	;cmp	eax, vgafont14
  6073                              <1> 	;je	short wgfxl_0
  6074                              <1> 	;cmp	eax, vgafont8
  6075                              <1> 	;je	short wgfxl_0
  6076                              <1> 	;; 05/01/2021 (TRDOS 386 v2.0.3)
  6077                              <1> 	;; user font  
  6078                              <1> 	;mov	eax, VGAFONTUSR ; 8x16 or 8x8 or 8x14 font
  6079                              <1> 	;			; (256 characters)
  6080                              <1> wgfxl_0:
  6081 00002CEE 01C6                <1> 	add	esi, eax
  6082                              <1> wgfxl_1:
  6083 00002CF0 28FF                <1> 	sub	bh, bh ; i = 0
  6084                              <1> wgfxl_2:
  6085                              <1> 	; for(i=0;i<8;i++)
  6086 00002CF2 57                  <1> 	push	edi ; addr
  6087 00002CF3 0FB605[D0660000]    <1> 	movzx	eax, byte [CRT_COLS] ; nbcols
  6088 00002CFA F6E7                <1> 	mul	bh ; nbcols*i
  6089                              <1> 	;shl	ax, 3 ; i*nbcols*8
  6090                              <1>  	; 02/08/2022
  6091 00002CFC C1E003              <1> 	shl	eax, 3
  6092                              <1> 	; dest=addr+i*nbcols*8;
  6093 00002CFF 01C7                <1> 	add	edi, eax ; dest + j ; j = 0
  6094 00002D01 B180                <1> 	mov	cl, 80h ; mask = 0x80;
  6095                              <1> 	; esi = fdata + src + i
  6096                              <1> 	; for(j=0;j<8;j++)
  6097 00002D03 29D2                <1> 	sub	edx, edx ; j = 0
  6098                              <1> wgfxl_3:
  6099 00002D05 8A06                <1> 	mov	al, [esi] ; al = fdata[src+i]
  6100 00002D07 20C8                <1> 	and	al, cl ; if (fdata[src+i] & mask)
  6101 00002D09 7402                <1> 	jz	short wgfxl_4  ; data = 0, zf = 1
  6102 00002D0B 88D8                <1> 	mov	al, bl ; data = attr;
  6103                              <1> wgfxl_4:
  6104                              <1> 	; write_byte(0xa000,dest+j,data);		
  6105 00002D0D AA                  <1> 	stosb  ; dest + j (+ 0A0000h)
  6106                              <1> 	;inc	dl ; j++
  6107                              <1> 	;cmp	dl, 8
  6108 00002D0E 80FA07              <1> 	cmp	dl, 7
  6109 00002D11 720E                <1> 	jb	short wgfxl_5
  6110 00002D13 5F                  <1> 	pop	edi
  6111                              <1> 	; 08/08/2016
  6112                              <1> 	;cmp	bh, 7
  6113                              <1> 	;jnb	short wgfxl_6
  6114 00002D14 FEC7                <1> 	inc	bh ; i++
  6115 00002D16 3A3D[D2660000]      <1> 	cmp	bh, [CHAR_HEIGHT]
  6116 00002D1C 7309                <1> 	jnb	short wgfxl_6
  6117 00002D1E 46                  <1> 	inc	esi
  6118 00002D1F EBD1                <1> 	jmp	short wgfxl_2
  6119                              <1> wgfxl_5:
  6120 00002D21 D0E9                <1> 	shr	cl, 1 ; mask >>= 1;
  6121 00002D23 FEC2                <1> 	inc	dl ; j++
  6122 00002D25 EBDE                <1>         jmp     short wgfxl_3
  6123                              <1> wgfxl_6:
  6124 00002D27 58                  <1> 	pop	eax
  6125 00002D28 5A                  <1> 	pop	edx
  6126 00002D29 5B                  <1> 	pop	ebx
  6127 00002D2A 59                  <1> 	pop	ecx
  6128 00002D2B C3                  <1> 	retn
  6129                              <1> wfxl_7:
  6130                              <1> 	; 08/01/2021
  6131                              <1> 	; 05/01/2021
  6132                              <1> 	; Default font (8x8 or 8x14 or 8x16)
  6133 00002D2C A0[D2660000]        <1> 	mov	al, [CHAR_HEIGHT]
  6134 00002D31 3C08                <1> 	cmp	al, 8
  6135 00002D33 7507                <1> 	jne	short wfxl_8
  6136 00002D35 B8[1C4E0100]        <1> 	mov	eax, vgafont8
  6137 00002D3A EBB2                <1> 	jmp	short wgfxl_0
  6138                              <1> wfxl_8:
  6139 00002D3C 3C0E                <1> 	cmp	al, 14
  6140 00002D3E 7507                <1> 	jne	short wfxl_9
  6141 00002D40 B8[1C560100]        <1> 	mov	eax, vgafont14
  6142 00002D45 EBA7                <1> 	jmp	short wgfxl_0
  6143                              <1> wfxl_9:
  6144 00002D47 B8[1C640100]        <1> 	mov	eax, vgafont16
  6145 00002D4C EBA0                <1> 	jmp	short wgfxl_0
  6146                              <1> 
  6147                              <1> write_gfx_char_pl4:
  6148                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  6149                              <1> 	; 08/08/2016
  6150                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  6151                              <1> 	;
  6152                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6153                              <1> 	; vgabios-0.7a (2011)
  6154                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6155                              <1> 	; 'vgabios.c', 'write_gfx_char_pl4'
  6156                              <1> 
  6157                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight)
  6158                              <1> 	; INPUT ->
  6159                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  6160                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  6161                              <1> 	; OUTPUT ->
  6162                              <1> 	; Regen buffer updated
  6163                              <1> 
  6164 00002D4E 51                  <1> 	push	ecx
  6165 00002D4F 53                  <1> 	push	ebx
  6166 00002D50 52                  <1> 	push	edx
  6167 00002D51 50                  <1> 	push	eax
  6168                              <1> wgfxpl_f0:
  6169                              <1> 	; switch(cheight)
  6170 00002D52 8A25[D2660000]      <1> 	mov	ah, [CHAR_HEIGHT]
  6171 00002D58 80FC10              <1> 	cmp	ah, 16 ; case 16:
  6172 00002D5B 7507                <1> 	jne	short wgfxpl_f1
  6173                              <1> 	; fdata = &vgafont16;
  6174 00002D5D BE[1C640100]        <1> 	mov	esi, vgafont16
  6175 00002D62 EB13                <1> 	jmp	short wgfxpl_f3
  6176                              <1> wgfxpl_f1:
  6177 00002D64 80FC0E              <1> 	cmp	ah, 14 ; case 14:
  6178 00002D67 7507                <1> 	jne	short wgfxpl_f2
  6179 00002D69 BE[1C560100]        <1> 	mov	esi, vgafont14
  6180 00002D6E EB07                <1> 	jmp	short wgfxpl_f3
  6181                              <1> wgfxpl_f2:
  6182                              <1> 	; default:
  6183                              <1> 	;  fdata = &vgafont8;
  6184 00002D70 BE[1C4E0100]        <1> 	mov	esi, vgafont8
  6185 00002D75 B408                <1> 	mov	ah, 8	
  6186                              <1> wgfxpl_f3:
  6187                              <1> 	; al = car
  6188 00002D77 F6E4                <1> 	mul	ah ; ah = cheight
  6189 00002D79 25FFFF0000          <1> 	and	eax, 0FFFFh ; car * cheight
  6190                              <1> 	; src = car * cheight;
  6191 00002D7E 01C6                <1> 	add	esi, eax ; esi = fdata[src+i]
  6192                              <1> 	; addr=xcurs*8+ycurs*nbcols*64;
  6193 00002D80 88F0                <1> 	mov	al, dh ; ycurs
  6194 00002D82 8A25[D0660000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  6195 00002D88 F6E4                <1> 	mul	ah
  6196                              <1> 	; 08/08/2016
  6197                              <1> 	;shl	ax, 6 ; * 64
  6198                              <1> 	;shl	ax, 3 ; * 8
  6199                              <1> 	; 02/08/2022
  6200 00002D8A C1E003              <1> 	shl	eax, 3
  6201                              <1> 	;sub	dh, dh ; 0
  6202                              <1> 	;shl	dx, 3 ; xcurs * 8
  6203                              <1> 	;movzx	edi, dx
  6204 00002D8D 0FB6FA              <1> 	movzx	edi, dl
  6205                              <1> 	;shl	di, 3 ; xcurs * 8
  6206                              <1> 	; 02/08/2022
  6207 00002D90 C1E703              <1> 	shl	edi, 3
  6208 00002D93 30F6                <1> 	xor	dh, dh
  6209 00002D95 8A15[D2660000]      <1> 	mov	dl, [CHAR_HEIGHT]
  6210 00002D9B 66F7E2              <1> 	mul	dx
  6211                              <1> 	; eax = ycurs*nbcols*8*[CHAR_HEIGHT]
  6212 00002D9E 01C7                <1> 	add	edi, eax ; addr
  6213 00002DA0 81C700000A00        <1> 	add	edi, 0A0000h
  6214                              <1> 	;
  6215                              <1> 	; outw(VGAREG_SEQU_ADDRESS, 0x0f02);
  6216                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205);
  6217 00002DA6 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  6218 00002DAA 66B8020F            <1> 	mov	ax, 0F02h
  6219 00002DAE 66EF                <1> 	out	dx, ax
  6220 00002DB0 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6221 00002DB4 66B80502            <1> 	mov	ax, 0205h
  6222 00002DB8 66EF                <1> 	out	dx, ax
  6223                              <1> 	;
  6224 00002DBA 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6225 00002DBE F6C380              <1> 	test	bl, 80h ; if(attr&0x80)
  6226 00002DC1 7406                <1> 	jz	short wgfxpl_f4 ; else
  6227                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x1803);
  6228 00002DC3 66B80318            <1> 	mov	ax, 1803h
  6229 00002DC7 EB04                <1> 	jmp	short wgfxpl_f5
  6230                              <1> wgfxpl_f4:
  6231                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0003);
  6232 00002DC9 66B80300            <1> 	mov	ax, 0003h	
  6233                              <1> wgfxpl_f5:
  6234 00002DCD 66EF                <1> 	out	dx, ax
  6235                              <1> 	;	
  6236 00002DCF 28FF                <1> 	sub	bh, bh ; i = 0
  6237                              <1> wgfxpl_0:
  6238                              <1> 	; for(i=0;i<cheight;i++)
  6239 00002DD1 57                  <1> 	push	edi ; addr
  6240 00002DD2 0FB605[D0660000]    <1> 	movzx	eax, byte [CRT_COLS] ; nbcols
  6241 00002DD9 F6E7                <1> 	mul	bh ; nbcols*i
  6242                              <1> 	; dest=addr+i*nbcols
  6243 00002DDB 01C7                <1> 	add	edi, eax ; dest
  6244 00002DDD B580                <1> 	mov	ch, 80h ; mask = 0x80;
  6245                              <1> 	; for(j=0;j<8;j++)
  6246 00002DDF 28C9                <1> 	sub	cl, cl ; j = 0
  6247                              <1> wgfxpl_1:
  6248 00002DE1 D2ED                <1> 	shr	ch, cl ; mask=0x80>>j;
  6249                              <1> 	;
  6250                              <1> 	; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
  6251                              <1>      	; read_byte(0xa000,dest);
  6252                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6253 00002DE3 88EC                <1> 	mov	ah, ch
  6254 00002DE5 B008                <1> 	mov	al, 8
  6255 00002DE7 66EF                <1> 	out	dx, ax
  6256 00002DE9 8A07                <1> 	mov	al, [edi] ; ? (io delay?)
  6257                              <1> 	;
  6258 00002DEB 28C0                <1> 	sub	al, al ; attr = 0
  6259                              <1> 	; if (fdata[src+i] & mask)
  6260 00002DED 842E                <1> 	test	byte [esi], ch
  6261 00002DEF 7404                <1> 	jz	short wgfxpl_2  ; zf = 1
  6262                              <1> 	; write_byte(0xa000,dest,attr&0x0f);
  6263 00002DF1 88D8                <1> 	mov	al, bl ; attr;
  6264 00002DF3 240F                <1> 	and	al, 0Fh	; attr&0x0f
  6265                              <1> wgfxpl_2:
  6266                              <1> 	; write_byte(0xa000,dest,0x00);		
  6267 00002DF5 8807                <1> 	mov	[edi], al ; dest (+ 0A0000h)
  6268 00002DF7 FEC1                <1> 	inc	cl ; j++
  6269 00002DF9 80F908              <1> 	cmp	cl, 8
  6270 00002DFC 72E3                <1> 	jb	short wgfxpl_1
  6271 00002DFE 5F                  <1> 	pop	edi
  6272                              <1> 	; 08/08/2016
  6273                              <1> 	;cmp	bh, 7
  6274                              <1> 	;jnb	short wgfxpl_3
  6275 00002DFF FEC7                <1> 	inc	bh ; i++
  6276 00002E01 3A3D[D2660000]      <1> 	cmp	bh, [CHAR_HEIGHT]
  6277 00002E07 7303                <1> 	jnb	short wgfxpl_3
  6278 00002E09 46                  <1> 	inc	esi
  6279 00002E0A EBC5                <1> 	jmp	short wgfxpl_0
  6280                              <1> wgfxpl_3:
  6281                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6282 00002E0C 66B808FF            <1>   	mov	ax, 0FF08h
  6283 00002E10 66EF                <1> 	out	dx, ax
  6284 00002E12 66B80500            <1> 	mov	ax, 0005h
  6285 00002E16 66EF                <1> 	out	dx, ax
  6286 00002E18 66B80300            <1> 	mov	ax, 0003h
  6287 00002E1C 66EF                <1> 	out	dx, ax
  6288                              <1> 	;
  6289 00002E1E 58                  <1> 	pop	eax
  6290 00002E1F 5A                  <1> 	pop	edx
  6291 00002E20 5B                  <1> 	pop	ebx
  6292 00002E21 59                  <1> 	pop	ecx
  6293 00002E22 C3                  <1> 	retn
  6294                              <1> 
  6295                              <1> vga_write_pixel:
  6296                              <1> 	; 02/08/2022 (TRDOS 386 Kerbel v2.0.5)
  6297                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  6298                              <1> 	;
  6299                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6300                              <1> 	; vgabios-0.7a (2011)
  6301                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6302                              <1> 	; 'vgabios.c', 'biosfn_write_pixel'
  6303                              <1> 
  6304                              <1> 	; INPUT ->
  6305                              <1> 	; 	DX = row (0-239)
  6306                              <1> 	; 	CX = column (0-799)
  6307                              <1> 	; 	AL = pixel value
  6308                              <1> 	;	(AH = [CRT_MODE])
  6309                              <1> 	; OUTPUT ->
  6310                              <1> 	; 	none
  6311                              <1>  
  6312 00002E23 88C3                <1> 	mov	bl, al ; pixel value
  6313                              <1> 	;mov 	ah, [CRT_MODE]
  6314 00002E25 BE[EA660000]        <1> 	mov	esi, vga_modes
  6315 00002E2A 89F7                <1> 	mov	edi, esi
  6316 00002E2C 83C710              <1> 	add	edi, vga_mode_count
  6317                              <1> vga_wp_0:
  6318 00002E2F AC                  <1> 	lodsb
  6319 00002E30 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  6320 00002E32 7405                <1> 	je	short vga_wp_1
  6321 00002E34 39FE                <1> 	cmp	esi, edi
  6322 00002E36 72F7                <1> 	jb	short vga_wp_0
  6323 00002E38 C3                  <1> 	retn	; nothing to do
  6324                              <1> vga_wp_1:
  6325 00002E39 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  6326                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  6327 00002E3C BF00000A00          <1> 	mov	edi, 0A0000h
  6328                              <1> 	;
  6329 00002E41 803E04              <1> 	cmp	byte [esi], PLANAR4
  6330 00002E44 741C                <1> 	je	short vga_wp_planar
  6331 00002E46 803E03              <1> 	cmp	byte [esi], PLANAR1
  6332 00002E49 7417                <1> 	je	short vga_wp_planar
  6333                              <1> vga_wp_linear8:
  6334                              <1> 	; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8);
  6335 00002E4B 0FB605[D0660000]    <1> 	movzx	eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols
  6336                              <1>      	;shl	ax, 3 ; * 8
  6337                              <1> 	; 02/08/2022
  6338 00002E52 C1E003              <1> 	shl	eax, 3
  6339 00002E55 66F7E2              <1> 	mul	dx
  6340 00002E58 50                  <1> 	push	eax
  6341                              <1> 	;mov	edi, 0A0000h
  6342 00002E59 6601CF              <1> 	add	di, cx
  6343 00002E5C 58                  <1> 	pop	eax
  6344 00002E5D 01C7                <1> 	add	edi, eax ; addr
  6345                              <1> 	; write_byte(0xa000,addr,AL);
  6346 00002E5F 881F                <1> 	mov	[edi], bl
  6347 00002E61 C3                  <1> 	retn    
  6348                              <1> vga_wp_planar:
  6349                              <1> 	; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS);
  6350 00002E62 0FB7C1              <1> 	movzx	eax, cx
  6351 00002E65 66C1E803            <1> 	shr	ax, 3 ; CX/8
  6352 00002E69 50                  <1> 	push	eax
  6353 00002E6A 28E4                <1> 	sub	ah, ah ; 0
  6354 00002E6C A0[D0660000]        <1> 	mov	al, [CRT_COLS] ; = [VGA_COLS] ; nbcols
  6355 00002E71 66F7E2              <1> 	mul	dx
  6356                              <1> 	;mov	edi, 0A0000h
  6357 00002E74 6601C7              <1>         add     di, ax
  6358 00002E77 58                  <1> 	pop	eax
  6359 00002E78 01C7                <1> 	add	edi, eax ; addr
  6360 00002E7A 80E107              <1> 	and	cl, 7
  6361 00002E7D B580                <1> 	mov	ch, 80h ; mask
  6362 00002E7F D2ED                <1> 	shr	ch, cl 	; mask = 0x80 >> (CX & 0x07);
  6363                              <1> 	
  6364                              <1> 	; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
  6365 00002E81 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6366 00002E85 88EC                <1> 	mov	ah, ch
  6367 00002E87 B008                <1> 	mov	al, 8
  6368 00002E89 66EF                <1> 	out	dx, ax
  6369                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205);
  6370 00002E8B 66B80502            <1> 	mov	ax, 0205h
  6371 00002E8F 66EF                <1> 	out	dx, ax
  6372                              <1> 	; data = read_byte(0xa000,addr);
  6373 00002E91 8A07                <1> 	mov	al, [edi] ; (delay?)	
  6374                              <1> 	; if (AL & 0x80)
  6375                              <1> 	; {
  6376                              <1> 	;  outw(VGAREG_GRDC_ADDRESS, 0x1803);
  6377                              <1> 	; }
  6378 00002E93 F6C380              <1> 	test	bl, 80h
  6379 00002E96 7406                <1> 	jz	short vga_wp_2
  6380 00002E98 66B80318            <1> 	mov	ax, 1803h
  6381 00002E9C 66EF                <1> 	out	dx, ax
  6382                              <1> vga_wp_2:	
  6383                              <1> 	; write_byte(0xa000,addr,AL);
  6384 00002E9E 881F                <1> 	mov	[edi], bl
  6385                              <1> 	;
  6386                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6387 00002EA0 66B808FF            <1>   	mov	ax, 0FF08h
  6388 00002EA4 66EF                <1> 	out	dx, ax
  6389 00002EA6 66B80500            <1> 	mov	ax, 0005h
  6390 00002EAA 66EF                <1> 	out	dx, ax
  6391 00002EAC 66B80300            <1> 	mov	ax, 0003h
  6392 00002EB0 66EF                <1> 	out	dx, ax
  6393                              <1> 	;
  6394 00002EB2 C3                  <1> 	retn
  6395                              <1> 
  6396                              <1> vga_read_pixel: 
  6397                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  6398                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  6399                              <1> 	;
  6400                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6401                              <1> 	; vgabios-0.7a (2011)
  6402                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6403                              <1> 	; 'vgabios.c', 'biosfn_read_pixel'
  6404                              <1> 
  6405                              <1> 	; INPUT ->
  6406                              <1> 	; 	DX = row (0-239)
  6407                              <1> 	; 	CX = column (0-799)
  6408                              <1> 	;	(AH = [CRT_MODE])
  6409                              <1> 	; OUTPUT ->
  6410                              <1> 	; 	AL = pixel value
  6411                              <1> 	 
  6412                              <1> 	;mov 	ah, [CRT_MODE]
  6413 00002EB3 BE[EA660000]        <1> 	mov	esi, vga_modes
  6414 00002EB8 89F7                <1> 	mov	edi, esi
  6415 00002EBA 83C710              <1> 	add	edi, vga_mode_count
  6416                              <1> vga_rp_0:
  6417 00002EBD AC                  <1> 	lodsb
  6418 00002EBE 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  6419 00002EC0 7405                <1> 	je	short vga_rp_1
  6420 00002EC2 39FE                <1> 	cmp	esi, edi
  6421 00002EC4 72F7                <1> 	jb	short vga_rp_0
  6422 00002EC6 C3                  <1> 	retn	; nothing to do
  6423                              <1> vga_rp_1:
  6424 00002EC7 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  6425                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  6426 00002ECA BF00000A00          <1> 	mov	edi, 0A0000h
  6427                              <1> 	;
  6428 00002ECF 803E04              <1> 	cmp	byte [esi], PLANAR4
  6429 00002ED2 741C                <1> 	je	short vga_rp_planar
  6430 00002ED4 803E03              <1> 	cmp	byte [esi], PLANAR1
  6431 00002ED7 7417                <1> 	je	short vga_rp_planar
  6432                              <1> vga_rp_linear8:
  6433                              <1> 	; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8);
  6434 00002ED9 0FB605[D0660000]    <1> 	movzx	eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols
  6435                              <1>      	;shl	ax, 3 ; * 8
  6436                              <1> 	; 02/08/2022
  6437 00002EE0 C1E003              <1> 	shl	eax, 3
  6438 00002EE3 66F7E2              <1> 	mul	dx
  6439 00002EE6 50                  <1> 	push	eax
  6440                              <1> 	;mov	edi, 0A0000h
  6441 00002EE7 6601CF              <1> 	add	di, cx
  6442 00002EEA 58                  <1> 	pop	eax
  6443 00002EEB 01C7                <1> 	add	edi, eax ; addr
  6444                              <1> 	; attr=read_byte(0xa000,addr);
  6445 00002EED 8A07                <1> 	mov	al, [edi] ; pixel value
  6446 00002EEF C3                  <1> 	retn    
  6447                              <1> vga_rp_planar:
  6448                              <1> 	; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS);
  6449 00002EF0 0FB7C1              <1> 	movzx	eax, cx
  6450 00002EF3 66C1E803            <1> 	shr	ax, 3 ; CX/8
  6451 00002EF7 50                  <1> 	push	eax
  6452 00002EF8 28E4                <1> 	sub	ah, ah ; 0
  6453 00002EFA A0[D0660000]        <1> 	mov	al, [CRT_COLS] ; = [VGA_COLS] ; nbcols
  6454 00002EFF 66F7E2              <1> 	mul	dx
  6455                              <1> 	;mov	edi, 0A0000h
  6456 00002F02 6601C7              <1>         add     di, ax
  6457 00002F05 58                  <1> 	pop	eax
  6458 00002F06 01C7                <1> 	add	edi, eax ; addr
  6459 00002F08 80E107              <1> 	and	cl, 7
  6460 00002F0B B580                <1> 	mov	ch, 80h ; mask
  6461 00002F0D D2ED                <1> 	shr	ch, cl 	; mask = 0x80 >> (CX & 0x07);
  6462                              <1> 	; attr = 0x00;
  6463 00002F0F 30DB                <1> 	xor	bl, bl ; attr = bl = 0, 
  6464 00002F11 30C9                <1> 	xor	cl, cl ; i = cl = 0
  6465                              <1> 	; for(i=0;i<4;i++)
  6466                              <1>       	; {
  6467                              <1>        	;  outw(VGAREG_GRDC_ADDRESS, (i << 8) | 0x04);
  6468                              <1>        	;  data = read_byte(0xa000,addr) & mask;
  6469                              <1>        	;  if (data > 0) attr |= (0x01 << i);
  6470                              <1>       	; }
  6471                              <1> vga_rp_2:
  6472 00002F13 88CC                <1> 	mov	ah, cl ; i << 8
  6473 00002F15 B004                <1> 	mov	al, 4  ; | 0x04
  6474 00002F17 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6475 00002F1B 66EF                <1> 	out	dx, ax
  6476                              <1> 	; data = read_byte(0xa000,addr) & mask;
  6477 00002F1D 8A07                <1> 	mov	al, [edi]
  6478 00002F1F 20E8                <1> 	and	al, ch ; & mask
  6479                              <1> 	; if (data > 0) attr |= (0x01 << i);
  6480 00002F21 08C0                <1> 	or	al, al
  6481 00002F23 7408                <1> 	jz	short vga_rp_3 ; al = 0 
  6482 00002F25 B701                <1> 	mov	bh, 1
  6483 00002F27 D2E7                <1> 	shl	bh, cl ; (0x01 << i)
  6484 00002F29 08FB                <1> 	or	bl, bh ; attr |= (0x01 << i)
  6485 00002F2B 88D8                <1> 	mov	al, bl ; pixel value	
  6486                              <1> vga_rp_3:	
  6487 00002F2D C3                  <1> 	retn
  6488                              <1> 
  6489                              <1> vga_beeper:
  6490                              <1> 	; 04/08/2016  (TRDOS 386 = TRDOS v2.0)
  6491 00002F2E FB                  <1> 	sti
  6492                              <1> 	;mov	bh, [ACTIVE_PAGE]
  6493 00002F2F E917F4FFFF          <1>         jmp     beeper_gfx
  6494                              <1> 
  6495                              <1> vga_write_teletype:
  6496                              <1> 	; 03/08/2022 (TRDOS 386 Kernel v2.0.5)
  6497                              <1> 	; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop)
  6498                              <1> 	; 09/12/2017
  6499                              <1> 	; 06/08/2016
  6500                              <1> 	; 04/08/2016
  6501                              <1> 	; 01/08/2016
  6502                              <1> 	; 31/07/2016
  6503                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  6504                              <1> 	;
  6505                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6506                              <1> 	; vgabios-0.7a (2011)
  6507                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6508                              <1> 	; 'vgabios.c', 'biosfn_write_teletype'
  6509                              <1> 	; 'biosfn_write_char_only'
  6510                              <1> 
  6511                              <1> 	; INPUT ->
  6512                              <1> 	; [CRT_MODE] = current video mode (>7)
  6513                              <1> 	; AL = Character to write
  6514                              <1> 	; BL = Color of character
  6515                              <1> 	; OUTPUT ->
  6516                              <1> 	; Regen buffer updated
  6517                              <1> 
  6518                              <1> 	; biosfn_write_teletype (car, page, attr, flag) 
  6519                              <1> 	; car = character (AL)
  6520                              <1> 	; page = 0
  6521                              <1> 	; attr = color (BL)
  6522                              <1> 	; 'flag' not used
  6523                              <1> 
  6524 00002F34 8A25[CE660000]      <1> 	mov 	ah, [CRT_MODE]
  6525 00002F3A 88C7                <1> 	mov	bh, al ; character
  6526 00002F3C 668B15[A6770100]    <1> 	mov	dx, [CURSOR_POSN] ; cursor pos for page 0
  6527                              <1> 
  6528 00002F43 BE[F2660000]        <1> 	mov	esi, vga_g_modes
  6529 00002F48 89F7                <1> 	mov	edi, esi
  6530 00002F4A 83C708              <1> 	add	edi, vga_g_mode_count
  6531                              <1> vga_wtty_0:
  6532 00002F4D AC                  <1> 	lodsb
  6533 00002F4E 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  6534 00002F50 7405                <1> 	je	short vga_wtty_2
  6535 00002F52 39FE                <1> 	cmp	esi, edi
  6536 00002F54 72F7                <1> 	jb	short vga_wtty_0
  6537                              <1> vga_wtty_1:
  6538 00002F56 C3                  <1> 	retn	; nothing to do
  6539                              <1> vga_wtty_2:
  6540 00002F57 80FF07              <1> 	cmp	bh, 07h ; bell (beep)
  6541 00002F5A 74D2                <1> 	je	short vga_beeper  ; u11
  6542 00002F5C 80FF08              <1> 	cmp	bh, 08h ; backspace
  6543 00002F5F 7508                <1> 	jne	short vga_wtty_3
  6544                              <1> 	; if(xcurs>0)xcurs--;
  6545 00002F61 08D2                <1> 	or	dl, dl ; xcurs (column)
  6546 00002F63 74F1                <1> 	jz	short vga_wtty_1
  6547 00002F65 FECA                <1> 	dec	dl ; xcurs--;
  6548 00002F67 EB55                <1>         jmp     short vga_wtty_12 
  6549                              <1> vga_wtty_3:			
  6550 00002F69 80FF0D              <1> 	cmp	bh, 0Dh ; carriage return (\r)
  6551 00002F6C 7504                <1> 	jne	short vga_wtty_4
  6552                              <1> 	; xcurs=0;
  6553 00002F6E 28D2                <1> 	sub	dl, dl ; 0
  6554 00002F70 EB4C                <1>         jmp     short vga_wtty_12 
  6555                              <1> vga_wtty_4:	
  6556 00002F72 80FF0A              <1> 	cmp	bh, 0Ah ; new line (\n)
  6557 00002F75 7504                <1> 	jne	short vga_wtty_5
  6558                              <1> 	; ycurs++;
  6559 00002F77 FEC6                <1> 	inc	dh ; next row
  6560 00002F79 EB5E                <1>         jmp     short vga_wtty_11
  6561                              <1> vga_wtty_5:
  6562 00002F7B 80FF09              <1> 	cmp 	bh, 09h ; tab stop
  6563 00002F7E 7523                <1> 	jne	short vga_wtty_8
  6564 00002F80 88D0                <1> 	mov	al, dl
  6565                              <1> 	;cbw
  6566 00002F82 30E4                <1> 	xor	ah, ah ; 09/12/2017
  6567 00002F84 B108                <1> 	mov	cl, 8
  6568 00002F86 F6F1                <1> 	div	cl
  6569 00002F88 28E1                <1> 	sub	cl, ah
  6570                              <1> 	;
  6571 00002F8A B720                <1> 	mov	bh, 20h ; space
  6572                              <1> vga_wtty_6: ; tab stop loop
  6573                              <1> 	;push	cx
  6574                              <1> 	;push	bx
  6575                              <1> 	; 12/04/2021
  6576 00002F8C 51                  <1> 	push	ecx
  6577 00002F8D 53                  <1> 	push	ebx
  6578 00002F8E E810000000          <1> 	call	vga_wtty_8
  6579                              <1> 	;pop	bx  ; bh = character, bl = color
  6580                              <1> 	;pop	cx
  6581                              <1> 	; 12/04/2021
  6582 00002F93 5B                  <1> 	pop	ebx  ; bh = character, bl = color
  6583 00002F94 59                  <1> 	pop	ecx
  6584 00002F95 FEC9                <1> 	dec	cl
  6585 00002F97 7409                <1> 	jz	short vga_wtty_7
  6586 00002F99 668B15[A6770100]    <1> 	mov	dx, [CURSOR_POSN] ; new cursor position (pg 0)
  6587 00002FA0 EBEA                <1> 	jmp	short vga_wtty_6
  6588                              <1> vga_wtty_7:
  6589 00002FA2 C3                  <1> 	retn
  6590                              <1> 	;
  6591                              <1> vga_wtty_8:
  6592 00002FA3 83C64F              <1> 	add	esi, vga_g_memmodel - (vga_g_modes + 1)  
  6593                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  6594 00002FA6 BF00000A00          <1> 	mov	edi, 0A0000h
  6595                              <1> 	;
  6596 00002FAB 88F8                <1> 	mov	al, bh ; character
  6597                              <1> 	;
  6598 00002FAD 803E04              <1> 	cmp	byte [esi], PLANAR4
  6599 00002FB0 7414                <1> 	je	short vga_wtty_planar
  6600 00002FB2 803E03              <1> 	cmp	byte [esi], PLANAR1
  6601 00002FB5 740F                <1> 	je	short vga_wtty_planar
  6602                              <1> vga_wtty_linear8:
  6603                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols);
  6604                              <1> 	; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 
  6605                              <1> 	; [CRT_COLS] = nbcols
  6606 00002FB7 E8F1FCFFFF          <1> 	call	write_gfx_char_lin
  6607 00002FBC EB0D                <1> 	jmp	short vga_wtty_9
  6608                              <1> 
  6609                              <1> vga_wtty_12:
  6610                              <1> 	; 09/07/2016
  6611                              <1> 	; set cursor position
  6612                              <1> 	; NOTE: Hardware cursor position will not be set
  6613                              <1> 	;   in any VGA modes (>7)
  6614                              <1> 	;   But, cursor position will be saved into
  6615                              <1> 	;   [CURSOR_POSN].
  6616                              <1> 	;   TRDOS 386 (TRDOS v2.0) uses only one page
  6617                              <1> 	;   (page 0) for all graphics modes.
  6618                              <1> 
  6619 00002FBE 668915[A6770100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  6620                              <1> 	; 04/08/2016
  6621                              <1> 	;mov	bh, [ACTIVE_PAGE] ; = 0
  6622                              <1> 	;call	_set_cpos
  6623 00002FC5 C3                  <1> 	retn
  6624                              <1> 
  6625                              <1> vga_wtty_planar:
  6626                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight);
  6627                              <1> 	; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 
  6628                              <1> 	; [CRT_COLS]= nbcols, [CHAR_HEIGHT] = cheight
  6629 00002FC6 E883FDFFFF          <1> 	call	write_gfx_char_pl4
  6630                              <1> vga_wtty_9:
  6631 00002FCB FEC2                <1> 	inc	dl ; xcurs++;
  6632                              <1> vga_wtty_10:
  6633                              <1> 	; Do we need to wrap ?
  6634                              <1> 	; if(xcurs==nbcols)
  6635 00002FCD 3A15[D0660000]      <1> 	cmp	dl, [CRT_COLS] ; [VGA_COLS]
  6636 00002FD3 7204                <1> 	jb	short vga_wtty_11 ; no
  6637 00002FD5 28D2                <1> 	sub	dl, dl ; xcurs=0;
  6638 00002FD7 FEC6                <1> 	inc	dh ;  ycurs++;
  6639                              <1> vga_wtty_11:
  6640                              <1> 	; Do we need to scroll ?
  6641                              <1> 	; if(ycurs==nbrows)
  6642 00002FD9 3A35[D6660000]      <1> 	cmp	dh, [VGA_ROWS]
  6643 00002FDF 72DD                <1> 	jb	short vga_wtty_12 ; no
  6644                              <1> 	;
  6645                              <1> 	; biosfn_scroll (nblines,attr,rul,cul,rlr,clr,page,dir)
  6646                              <1> 	; al = nblines = 1, bl = attr (color) = 0
  6647                              <1> 	; ch = rul, cl = cul, dh = rlr, dl = clr, page = 0
  6648                              <1> 	; dir = SCROLL_UP
  6649                              <1> 	
  6650 00002FE1 B001                <1> 	mov	al, 1
  6651 00002FE3 28DB                <1> 	sub	bl, bl ; 0 ; blank/black line (attr=0) will be used
  6652                              <1> 	;sub	cx, cx ; 0,0
  6653                              <1> 	; 03/08/2022
  6654 00002FE5 29C9                <1> 	sub	ecx, ecx
  6655                              <1> 
  6656                              <1> 	; 06/08/2016
  6657 00002FE7 8A35[D6660000]      <1> 	mov	dh, [VGA_ROWS]
  6658 00002FED FECE                <1> 	dec	dh ; nbrows -1
  6659                              <1> 
  6660                              <1> 	;push	dx ; 04/08/2016
  6661                              <1> 	; 12/04/2021
  6662 00002FEF 52                  <1> 	push	edx
  6663 00002FF0 8A15[D0660000]      <1> 	mov	dl, [CRT_COLS]
  6664 00002FF6 FECA                <1> 	dec	dl ; nbcols -1
  6665                              <1> 	
  6666 00002FF8 8A25[CE660000]      <1> 	mov	ah, [CRT_MODE]
  6667                              <1> 	
  6668                              <1> 	; biosfn_scroll(0x01,0x00,0,0,nbrows-1,nbcols-1,page,SCROLL_UP);
  6669 00002FFE E843F5FFFF          <1> 	call	vga_graphics_up
  6670                              <1> 	; 04/08/2016
  6671                              <1> 	;pop	dx
  6672                              <1> 	; 12/04/2021
  6673 00003003 5A                  <1> 	pop	edx
  6674                              <1> 
  6675                              <1> 	;dec	dh ; ycurs-=1
  6676 00003004 EBB8                <1> 	jmp	short vga_wtty_12 
  6677                              <1> 
  6678                              <1> font_setup:
  6679                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
  6680                              <1> 	; 09/01/2021 (TRDOS 386 v2.0.3)
  6681                              <1> 	; 09/07/2016
  6682                              <1> 	; character generator (font loading) functions
  6683                              <1> 	;
  6684                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6685                              <1> 	; vgabios-0.7a (2011)
  6686                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6687                              <1> 	; 'vgabios.c', 'int10_func'
  6688                              <1> 
  6689                              <1> 	; AX = 1100H ; Load User-Defined Font (EGA/VGA)
  6690                              <1> 	;
  6691                              <1>         ; BH =  height of each character (bytes per character definition)
  6692                              <1>         ; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  6693                              <1> 	; CX =  number of characters to redefine (<=256)
  6694                              <1>         ; DX =  ASCII code of the first character defined at ES:BP
  6695                              <1>         ; EBP =	address of font-definition information
  6696                              <1> 	;	(in user's memory space)
  6697                              <1> 
  6698                              <1> 	; case 0x11:
  6699                              <1>      	; switch(GET_AL())
  6700                              <1>       	; {
  6701                              <1> 	; case 0x00:
  6702                              <1>         ; case 0x10:
  6703                              <1>         ; biosfn_load_text_user_pat(GET_AL(),ES,BP,CX,DX,GET_BL(),GET_BH());
  6704                              <1>         ; break;
  6705                              <1> 
  6706                              <1> 	; AX = 1110H ; Load and Activate User-Defined Font (EGA/VGA)
  6707 00003006 08C0                <1> 	or	al, al ; 0
  6708 00003008 7404                <1> 	jz	short font_setup_0
  6709 0000300A 3C10                <1> 	cmp	al, 10h
  6710 0000300C 7511                <1> 	jne	short font_setup_1	
  6711                              <1> font_setup_0:
  6712 0000300E E8CE000000          <1> 	call	transfer_user_fonts
  6713 00003013 721C                <1> 	jc	short font_setup_error
  6714 00003015 E8AD010000          <1> 	call	load_text_user_pat
  6715 0000301A E9D6EAFFFF          <1>         jmp     VIDEO_RETURN 
  6716                              <1> font_setup_1:
  6717                              <1> 	; AX = 1101H ; Load ROM 8x14 Character Set (EGA/VGA)
  6718                              <1> 	; case 0x01:
  6719                              <1>         ; case 0x11:
  6720                              <1>         ; biosfn_load_text_8_14_pat(GET_AL(),GET_BL());
  6721                              <1>         ; break;
  6722 0000301F 3C01                <1> 	cmp	al, 1
  6723 00003021 7404                <1> 	je	short font_setup_2
  6724 00003023 3C11                <1> 	cmp	al, 11h
  6725 00003025 7511                <1> 	jne	short font_setup_3	
  6726                              <1> font_setup_2:
  6727                              <1> 	; AX = 1111H ; Load and Activate ROM 8x14 Character Set (EGA/VGA)
  6728                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  6729 00003027 E8C9020000          <1> 	call	load_text_8_14_pat
  6730 0000302C E9C4EAFFFF          <1>         jmp     VIDEO_RETURN
  6731                              <1> font_setup_error:
  6732 00003031 29C0                <1> 	sub	eax, eax ; 0 -> fonts could not be loaded
  6733 00003033 E9C2EAFFFF          <1> 	jmp	_video_return
  6734                              <1> font_setup_3:
  6735                              <1> 	; AX = 1102H ; Load ROM 8x8 Character Set (EGA/VGA)
  6736                              <1> 	; case 0x02:
  6737                              <1>         ; case 0x12:
  6738                              <1>         ; biosfn_load_text_8_8_pat(GET_AL(),GET_BL());
  6739                              <1>         ; break;
  6740 00003038 3C02                <1> 	cmp	al, 2
  6741 0000303A 7404                <1> 	je	short font_setup_4
  6742 0000303C 3C12                <1> 	cmp	al, 12h
  6743 0000303E 750A                <1> 	jne	short font_setup_5	
  6744                              <1> font_setup_4:
  6745                              <1> 	; AX = 1112H ; Load and Activate ROM 8x8 Character Set (EGA/VGA)
  6746                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  6747 00003040 E8E1020000          <1> 	call	load_text_8_8_pat
  6748 00003045 E9ABEAFFFF          <1>         jmp     VIDEO_RETURN
  6749                              <1> font_setup_5:
  6750                              <1> 	; AX = 1104H ; Load ROM 8x16 Character Set (EGA/VGA)
  6751                              <1> 	; case 0x04:
  6752                              <1>         ; case 0x14:
  6753                              <1>         ; biosfn_load_text_8_16_pat(GET_AL(),GET_BL());
  6754                              <1>         ; break;
  6755 0000304A 3C04                <1> 	cmp	al, 4
  6756 0000304C 7404                <1> 	je	short font_setup_6
  6757 0000304E 3C14                <1> 	cmp	al, 14h
  6758 00003050 750A                <1> 	jne	short font_setup_7	
  6759                              <1> font_setup_6:
  6760                              <1> 	; AX = 1114H ; Load and Activate ROM 8x16 Character Set (EGA/VGA)
  6761                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  6762 00003052 E819030000          <1> 	call	load_text_8_16_pat
  6763 00003057 E999EAFFFF          <1>         jmp     VIDEO_RETURN
  6764                              <1> font_setup_7:
  6765                              <1> 	; Note: AX=1120h (Setup INT 1Fh, EXT_PTR) is not needed
  6766                              <1> 	; for TRDOS 386 (TRDOS v2.0) video functionality;
  6767                              <1> 	; because, originally EXT_PTR (font address) was used for
  6768                              <1> 	; chars 80h to 0FFh (after the first 128 ASCII char fonts), for
  6769                              <1> 	; CGA graphics mode; currenty, 'vgafont8' address has 256 chars!
  6770                              <1> 	; 
  6771                              <1> 	; case 0x20:
  6772                              <1>         ; biosfn_load_gfx_8_8_chars(ES,BP);
  6773                              <1>         ; break; 
  6774                              <1> 	; case 0x21:
  6775                              <1>         ; biosfn_load_gfx_user_chars(ES,BP,CX,GET_BL(),GET_DL());
  6776                              <1>         ; break;
  6777                              <1> 	; AX = 1121H ; Setup User-Defined Font for Graphics Mode (VGA)
  6778                              <1> 	; BL   screen rows code: 00H = user-specified (in DL)
  6779                              <1>         ;                        01H = 14 rows
  6780                              <1>         ;                        02H = 25 rows
  6781                              <1>         ;                        03H = 43 rows
  6782                              <1>         ; CX   bytes per character definition
  6783                              <1>         ; DL   (when BL=0) custom number of character rows on screen
  6784                              <1>         ; EBP  address of font-definition information (user's mem space)
  6785                              <1> 
  6786 0000305C 3C21                <1> 	cmp	al, 21h
  6787 0000305E 7531                <1> 	jne	short font_setup_9
  6788                              <1> 
  6789                              <1> 	; TRDOS 386 modification !
  6790                              <1> 	; dh = 0 -> 256 characters
  6791                              <1> 	; dh = 80h -> second 128 characters
  6792                              <1> 	; dh = 0FFh -> first 128 characters
  6793                              <1> 
  6794                              <1> 	; 09/01/2021 (TRDOS 386 v2.0.3)
  6795                              <1> 	;push	ebx
  6796 00003060 51                  <1> 	push	ecx
  6797 00003061 52                  <1> 	push	edx
  6798 00003062 30D2                <1> 	xor	dl, dl
  6799 00003064 88CF                <1> 	mov	bh, cl ; character height
  6800                              <1> 	;mov	cx, 100h ; 256
  6801                              <1> 	; 03/08/2022
  6802 00003066 31C9                <1> 	xor 	ecx, ecx
  6803 00003068 FEC5                <1> 	inc	ch
  6804                              <1> 	; ecx = 100h
  6805 0000306A 08F6                <1> 	or	dh, dh ; 0
  6806 0000306C 7410                <1> 	jz	short  font_setup_8
  6807 0000306E FECD                <1> 	dec	ch ; cx = 0
  6808 00003070 80FEFF              <1> 	cmp	dh, 0FFh
  6809 00003073 7409                <1> 	je	short font_setup_8 ; 1st 128 chars
  6810                              <1> 	; 2nd 128 chars
  6811 00003075 80FE80              <1> 	cmp	dh, 80h
  6812 00003078 75B7                <1> 	jne	short font_setup_error ; invalid !
  6813 0000307A 88F1                <1> 	mov	cl, dh
  6814 0000307C 86D6                <1> 	xchg	dl, dh
  6815                              <1> 	; number of chars, cx = 80h 
  6816                              <1> 	; start char, dl = 80h
  6817                              <1> font_setup_8:	
  6818 0000307E E85E000000          <1> 	call	transfer_user_fonts
  6819 00003083 5A                  <1> 	pop	edx
  6820 00003084 59                  <1> 	pop	ecx
  6821                              <1> 	;pop	ebx
  6822 00003085 72AA                <1> 	jc	short font_setup_error
  6823                              <1> 	; ebp = user's font data address in system's memory space
  6824 00003087 E82F030000          <1> 	call	load_gfx_user_chars
  6825 0000308C E964EAFFFF          <1>         jmp     VIDEO_RETURN 
  6826                              <1> font_setup_9:
  6827                              <1> 	; case 0x22:
  6828                              <1>         ; biosfn_load_gfx_8_14_chars(GET_BL());
  6829                              <1>         ; break;
  6830 00003091 3C22                <1> 	cmp	al, 22h
  6831 00003093 750A                <1> 	jne	short font_setup_10
  6832 00003095 E85D030000          <1> 	call	load_gfx_8_14_chars	
  6833 0000309A E956EAFFFF          <1>         jmp     VIDEO_RETURN 
  6834                              <1> font_setup_10:	
  6835                              <1> 	; case 0x23:
  6836                              <1>         ; biosfn_load_gfx_8_8_dd_chars(GET_BL());
  6837                              <1>         ; break;
  6838 0000309F 3C23                <1> 	cmp	al, 23h
  6839 000030A1 750A                <1> 	jne	short font_setup_11
  6840 000030A3 E890030000          <1> 	call	load_gfx_8_8_chars	
  6841 000030A8 E948EAFFFF          <1>         jmp     VIDEO_RETURN 
  6842                              <1> font_setup_11:	
  6843                              <1> 	; case 0x24:
  6844                              <1>         ; biosfn_load_gfx_8_16_chars(GET_BL());
  6845                              <1>         ; break;
  6846 000030AD 3C24                <1> 	cmp	al, 24h
  6847 000030AF 750A                <1> 	jne	short font_setup_12
  6848 000030B1 E8C3030000          <1> 	call	load_gfx_8_16_chars	
  6849 000030B6 E93AEAFFFF          <1>         jmp     VIDEO_RETURN 
  6850                              <1> font_setup_12:
  6851                              <1>  	; case 0x30:
  6852                              <1>         ; biosfn_get_font_info(GET_BH(),&ES,&BP,&CX,&DX);
  6853                              <1>         ; break;
  6854 000030BB 3C30                <1> 	cmp	al, 30h
  6855 000030BD 750A                <1> 	jne	short font_setup_13			
  6856 000030BF E8F6030000          <1> 	call	get_font_info
  6857                              <1> 	; eax = return value (info: 4 bytes for 4 parms)
  6858                              <1> 	; eax = 0 -> invalid function (input)
  6859 000030C4 E931EAFFFF          <1>         jmp     _video_return
  6860                              <1> font_setup_13:
  6861 000030C9 3C03                <1> 	cmp	al, 03h ; AX = 1103h	
  6862 000030CB 750D                <1> 	jne	short font_setup_14
  6863                              <1> 	; biosfn_set_text_block_specifier:
  6864                              <1> 	; BL = font block selector code	
  6865                              <1> 	; NOTE: TRDOS 386 only uses and sets font block 0
  6866                              <1> 	; (It is as BL = 0 for TRDOS 386)
  6867 000030CD 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  6868                              <1> 	;mov	ah, bl
  6869 000030D1 28E4                <1> 	sub	ah, ah ; 0
  6870                              <1> 	;mov	al, 03h
  6871 000030D3 66EF                <1> 	out	dx, ax
  6872 000030D5 E91BEAFFFF          <1> 	jmp     VIDEO_RETURN 
  6873                              <1> 	
  6874                              <1> font_setup_14:
  6875 000030DA 29C0                <1> 	sub	eax, eax ; 0 = invalid function
  6876 000030DC E919EAFFFF          <1>         jmp     _video_return
  6877                              <1> 
  6878                              <1> transfer_user_fonts:
  6879                              <1> 	; 02/08/2022 (TRDOS 386 Kernel v2.0.5)
  6880                              <1> 	; 19/01/2021
  6881                              <1> 	; 09/01/2021
  6882                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  6883                              <1> 
  6884                              <1> 	; BH =  height of each character (bytes per character)
  6885                              <1> 	; CX =  number of characters to redefine (<=256)
  6886                              <1>         ; DX =  ASCII code of the first character defined at EBP
  6887                              <1>         ; EBP =	address of font-definition information
  6888                              <1> 	;	(in user's memory space)
  6889                              <1> 
  6890                              <1> 	; Modified registers: eax, edx, ecx, esi, edi, ebp
  6891                              <1> 	;
  6892                              <1> 	; output:
  6893                              <1> 	;	ebp = user font data address in system memory
  6894                              <1> 
  6895 000030E1 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  6896 000030E7 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
  6897 000030ED 7537                <1> 	jnz	short transfer_user_fonts_5
  6898                              <1> 
  6899 000030EF 09D2                <1> 	or	edx, edx
  6900 000030F1 7531                <1> 	jnz	short transfer_user_fonts_4
  6901 000030F3 09ED                <1> 	or	ebp, ebp
  6902 000030F5 752D                <1> 	jnz	short transfer_user_fonts_4
  6903                              <1> 
  6904                              <1> 	; cx = 0, dx = 0, ebp = 0
  6905                              <1> 	; copy system font to user font
  6906                              <1> 
  6907 000030F7 B140                <1> 	mov	cl, 64 ; 64 dwords
  6908                              <1> 	
  6909 000030F9 80FF10              <1> 	cmp	bh, 16
  6910 000030FC 7417                <1> 	je	short transfer_user_fonts_2
  6911 000030FE 80FF08              <1> 	cmp	bh, 8
  6912 00003101 7406                <1> 	je	short transfer_user_fonts_1
  6913                              <1> 
  6914 00003103 BD[1C560100]        <1> 	mov	ebp, vgafont14
  6915 00003108 C3                  <1> 	retn 
  6916                              <1> 
  6917                              <1> transfer_user_fonts_1:
  6918 00003109 BF00500900          <1> 	mov	edi, VGAFONT8USER
  6919 0000310E BE[1C4E0100]        <1> 	mov	esi, vgafont8
  6920 00003113 EB0A                <1> 	jmp	short transfer_user_fonts_3
  6921                              <1> 
  6922                              <1> transfer_user_fonts_2:
  6923 00003115 BF00400900          <1> 	mov	edi, VGAFONT16USER
  6924 0000311A BE[1C640100]        <1> 	mov	esi, vgafont16
  6925                              <1> transfer_user_fonts_3:
  6926 0000311F 89FD                <1> 	mov	ebp, edi
  6927 00003121 F3A5                <1> 	rep	movsd
  6928 00003123 C3                  <1> 	retn
  6929                              <1> 
  6930                              <1> transfer_user_fonts_4:
  6931 00003124 F9                  <1> 	stc	
  6932 00003125 C3                  <1> 	retn
  6933                              <1> 	
  6934                              <1> transfer_user_fonts_5:
  6935 00003126 09ED                <1> 	or	ebp, ebp
  6936 00003128 74FA                <1> 	jz	short transfer_user_fonts_4 ; invalid address !
  6937                              <1> 
  6938 0000312A 6681F90001          <1> 	cmp	cx, 256
  6939 0000312F 77F3                <1> 	ja	short transfer_user_fonts_4
  6940 00003131 29D1                <1> 	sub	ecx, edx
  6941 00003133 76EF                <1> 	jna	short transfer_user_fonts_4
  6942                              <1> 
  6943 00003135 80FF0E              <1> 	cmp	bh, 14 ; 8x14 font
  6944                              <1> 		       ; (there is not an alternative buffer)
  6945 00003138 7524                <1> 	jne	short transfer_user_fonts_6
  6946                              <1> 	
  6947                              <1> 	; use system's 8x14 font space if permission flag is 1
  6948 0000313A F605[32100300]80    <1> 	test	byte [ufont], 80h
  6949 00003141 74E1                <1> 	jz	short transfer_user_fonts_4 ; not allowed
  6950                              <1> 
  6951                              <1> 	; permission is given (for vgafont14 location etc.)
  6952                              <1> 	; (for permanent font modification)
  6953                              <1> 	;
  6954                              <1> 	; 19/01/2021
  6955                              <1> 	; Note: Permission flag can be set by 'root' while
  6956                              <1> 	;	system is not in multi tasking/user mode
  6957                              <1> 	;	while [multi_tasking] = 0 and [u.uid] = 0
  6958                              <1> 
  6959                              <1> 	;push	edx	
  6960                              <1> 	; 02/08/2022
  6961 00003143 87D1                <1> 	xchg	edx, ecx
  6962                              <1> 	;xor	ah, ah
  6963                              <1> 	; 02/08/2022
  6964 00003145 31C0                <1> 	xor	eax, eax
  6965 00003147 88F8                <1> 	mov	al, bh ; mov al, 14 
  6966                              <1> 	;mul	cx 
  6967                              <1> 	; 02/08/2022
  6968 00003149 F7E2                <1> 	mul	edx  ; char count * 14	
  6969                              <1> 	; 02/08/2022
  6970 0000314B 89CA                <1> 	mov	edx, ecx ; ascii code
  6971 0000314D 89C1                <1> 	mov	ecx, eax
  6972                              <1> 		; ecx = byte count 
  6973                              <1> 	;pop	edx
  6974                              <1> 	; 02/08/2022
  6975                              <1> 	;xor	eax, eax	
  6976 0000314F 30E4                <1> 	xor	ah, ah
  6977 00003151 88F8                <1> 	mov	al, bh ; mov ax, 14 ; bytes per character
  6978                              <1> 	;mul	dx
  6979                              <1> 	;mov	dx, ax ; char offset
  6980                              <1> 	; 02/08/2022
  6981 00003153 F7E2                <1> 	mul	edx
  6982 00003155 89C2                <1> 	mov	edx, eax ; char offset
  6983 00003157 BF[1C560100]        <1> 	mov	edi, vgafont14
  6984 0000315C EB48                <1> 	jmp	short transfer_user_fonts_8			
  6985                              <1> transfer_user_fonts_6:
  6986 0000315E 80FF08              <1> 	cmp	bh, 8 ; 8x8 font
  6987 00003161 7520                <1> 	jne	short transfer_user_fonts_7 ; 8x16 font
  6988                              <1> 	;shl	dx, 3 ; * 8
  6989                              <1> 	;shl	cx, 3 ; * 8
  6990                              <1> 	; 02/08/2022
  6991 00003163 C1E203              <1> 	shl	edx, 3 ; byte offset
  6992 00003166 C1E103              <1> 	shl	ecx, 3 ; byte count
  6993                              <1> 	; 09/01/2021
  6994 00003169 BF00500900          <1> 	mov	edi, VGAFONT8USER
  6995 0000316E F605[32100300]08    <1> 	test	byte [ufont], 8  ; already loaded ?	
  6996 00003175 752F                <1> 	jnz	short transfer_user_fonts_8 ; yes
  6997 00003177 BE[1C4E0100]        <1> 	mov	esi, vgafont8
  6998 0000317C E839000000          <1> 	call	transfer_user_fonts_10
  6999 00003181 EB23                <1> 	jmp	short transfer_user_fonts_8
  7000                              <1> transfer_user_fonts_7:
  7001 00003183 80FF10              <1> 	cmp	bh, 16 ; 8x16 font
  7002 00003186 759C                <1> 	jne	short transfer_user_fonts_4  ; invalid !
  7003                              <1> 	;shl	dx, 4 ; * 16
  7004                              <1> 	;shl	cx, 4 ; * 16
  7005                              <1> 	; 02/08/2022
  7006 00003188 C1E204              <1> 	shl	edx, 4 ; byte offset
  7007 0000318B C1E104              <1> 	shl	ecx, 4 ; byte count
  7008 0000318E BF00400900          <1>  	mov	edi, VGAFONT16USER
  7009 00003193 F605[32100300]10    <1> 	test	byte [ufont], 16  ; already loaded ?	
  7010 0000319A 750A                <1> 	jnz	short transfer_user_fonts_8 ; yes
  7011 0000319C BE[1C640100]        <1> 	mov	esi, vgafont16
  7012 000031A1 E814000000          <1> 	call	transfer_user_fonts_10
  7013                              <1> transfer_user_fonts_8:
  7014 000031A6 01D7                <1> 	add	edi, edx ; char offset
  7015                              <1> 	; 09/07/2016
  7016                              <1> 	;and	ecx, 0FFFFh
  7017                              <1> 	; ECX = byte count
  7018                              <1> 	;push	ecx
  7019 000031A8 89EE                <1> 	mov	esi, ebp ; user's font buffer
  7020                              <1> 	; 09/01/2021
  7021 000031AA 89FD                <1> 	mov	ebp, edi ; system addr for user's font
  7022                              <1> 	; 05/01/2021
  7023                              <1> 	;mov	edi, Cluster_Buffer  ; system buffer
  7024 000031AC E8F2DB0000          <1> 	call	transfer_from_user_buffer
  7025                              <1> 	;pop	ecx
  7026                              <1> 	; ecx = transfer (byte) count = character count
  7027 000031B1 7206                <1> 	jc	short transfer_user_fonts_9
  7028                              <1> 	; 05/01/2021
  7029                              <1> 	;mov	ebp, Cluster_Buffer
  7030                              <1> 	
  7031 000031B3 083D[32100300]      <1> 	or	byte [ufont], bh 
  7032                              <1> 			; 8x8 or 8x16 user font ready 
  7033                              <1> transfer_user_fonts_9:
  7034 000031B9 C3                  <1> 	retn
  7035                              <1> 
  7036                              <1> transfer_user_fonts_10:
  7037                              <1> 	; 02/08/2022
  7038                              <1> 	; 09/01/2021
  7039 000031BA 56                  <1> 	push	esi
  7040 000031BB 57                  <1> 	push	edi
  7041 000031BC 51                  <1> 	push	ecx
  7042                              <1> 	;mov	cx, 64
  7043                              <1> 	; 02/08/2022
  7044 000031BD 31C9                <1> 	xor	ecx, ecx
  7045 000031BF B140                <1> 	mov	cl, 64
  7046 000031C1 F3A5                <1> 	rep	movsd
  7047 000031C3 59                  <1> 	pop	ecx
  7048 000031C4 5F                  <1> 	pop	edi
  7049 000031C5 5E                  <1> 	pop	esi
  7050 000031C6 C3                  <1> 	retn
  7051                              <1> 
  7052                              <1> load_text_user_pat:
  7053                              <1> 	; 02/08/2022 (TRDOS 3386 v2.0.5)
  7054                              <1> 	; 26/07/2016
  7055                              <1> 	; 09/07/2016
  7056                              <1> 	; load user defined (EGA/VGA) text fonts
  7057                              <1> 	;
  7058                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7059                              <1> 	; vgabios-0.7a (2011)
  7060                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7061                              <1> 	; 'vgabios.c', 'biosfn_load_text_user_pat'
  7062                              <1> 
  7063                              <1> 	; biosfn_load_text_user_pat (AL,ES,BP,CX,DX,BL,BH)
  7064                              <1> 
  7065                              <1> 	; get_font_access();
  7066                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  7067                              <1> 	; for(i=0;i<CX;i++)
  7068                              <1> 	; {
  7069                              <1> 	;  src = BP + i * BH;
  7070                              <1> 	;  dest = blockaddr + (DX + i) * 32;
  7071                              <1> 	;  memcpyb(0xA000, dest, ES, src, BH);
  7072                              <1> 	; }
  7073                              <1> 	; release_font_access();
  7074                              <1> 	; if(AL>=0x10)
  7075                              <1> 	; {
  7076                              <1> 	; set_scan_lines(BH);
  7077                              <1> 	; }
  7078                              <1> 
  7079 000031C7 50                  <1> 	push	eax
  7080 000031C8 E839000000          <1> 	call	get_font_access
  7081 000031CD 28DB                <1> 	sub	bl, bl ; i = 0
  7082                              <1> 	; 02/08/2022
  7083                              <1> 	; ecx <= 256
  7084 000031CF 30ED                <1> 	xor	ch, ch
  7085                              <1> ltup_1:
  7086 000031D1 88D8                <1> 	mov	al, bl
  7087 000031D3 F6E7                <1> 	mul	bh	
  7088                              <1> 	;movzx	esi, ax
  7089                              <1> 	; 02/08/2022
  7090 000031D5 89C6                <1> 	mov	esi, eax
  7091 000031D7 01EE                <1> 	add	esi, ebp
  7092 000031D9 88D8                <1> 	mov	al, bl
  7093 000031DB 28E4                <1> 	sub	ah, ah
  7094                              <1> 	;add	ax, dx ; (DX + i)
  7095                              <1> 	;shl	ax, 5  ; * 32
  7096                              <1> 	; 02/08/2022
  7097 000031DD 01D0                <1> 	add	eax, edx
  7098 000031DF C1E005              <1> 	shl	eax, 5
  7099                              <1> 	;movzx	edi, ax
  7100                              <1> 	; 02/08/2022
  7101 000031E2 89C7                <1> 	mov	edi, eax
  7102 000031E4 81C700000A00        <1> 	add	edi, 0A0000h
  7103 000031EA 51                  <1> 	push	ecx
  7104                              <1> 	;movzx	ecx, bh
  7105                              <1> 	; 02/08/2022
  7106 000031EB 88F9                <1> 	mov	cl, bh
  7107 000031ED F3A4                <1> 	rep	movsb
  7108 000031EF 59                  <1> 	pop	ecx
  7109 000031F0 FEC3                <1> 	inc	bl
  7110 000031F2 38CB                <1> 	cmp	bl, cl
  7111 000031F4 75DB                <1> 	jne	short ltup_1
  7112                              <1> 	;
  7113 000031F6 E83E000000          <1> 	call	release_font_access
  7114                              <1> 	;
  7115 000031FB 58                  <1> 	pop	eax
  7116                              <1> 	; if(AL>=0x10)
  7117 000031FC 3C10                <1> 	cmp	al, 10h
  7118 000031FE 7205                <1> 	jb	short ltup_2
  7119                              <1>    	; set_scan_lines(BH);
  7120 00003200 E86F000000          <1> 	call	set_scan_lines
  7121                              <1> ltup_2:
  7122 00003205 C3                  <1> 	retn
  7123                              <1> 
  7124                              <1> get_font_access:
  7125                              <1> 	; 02/08/2022
  7126                              <1> 	; 09/07/2016
  7127                              <1> 	;
  7128                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7129                              <1> 	; vgabios-0.7a (2011)
  7130                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7131                              <1> 	; 'vgabios.c', 'get_font_access'
  7132                              <1> 
  7133                              <1> 	; get_font_access()
  7134 00003206 52                  <1> 	push	edx
  7135 00003207 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  7136                              <1> 	; 02/08/2022
  7137 0000320B 31C0                <1>  	xor	eax, eax
  7138                              <1> 	;mov	ax, 0100h
  7139 0000320D B401                <1> 	mov	ah, 1
  7140                              <1> 	; ax = 0100h
  7141 0000320F 66EF                <1> 	out	dx, ax
  7142 00003211 66B80204            <1> 	mov	ax, 0402h
  7143 00003215 66EF                <1> 	out	dx, ax
  7144 00003217 66B80407            <1> 	mov	ax, 0704h
  7145 0000321B 66EF                <1> 	out	dx, ax
  7146 0000321D 66B80003            <1> 	mov	ax, 0300h
  7147 00003221 66EF                <1> 	out	dx, ax
  7148                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  7149                              <1> 	; 02/08/2022
  7150 00003223 B2CE                <1> 	mov	dl, 0CEh
  7151 00003225 66B80402            <1> 	mov	ax, 0204h
  7152 00003229 66EF                <1> 	out	dx, ax
  7153 0000322B 66B80500            <1> 	mov	ax, 0005h
  7154 0000322F 66EF                <1> 	out	dx, ax
  7155 00003231 66B80604            <1> 	mov	ax, 0406h
  7156 00003235 66EF                <1> 	out	dx, ax
  7157 00003237 5A                  <1> 	pop	edx
  7158 00003238 C3                  <1> 	retn
  7159                              <1> 
  7160                              <1> release_font_access:
  7161                              <1> 	; 02/08/2022
  7162                              <1> 	; 29/07/2016
  7163                              <1> 	; 09/07/2016
  7164                              <1> 	;
  7165                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7166                              <1> 	; vgabios-0.7a (2011)
  7167                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7168                              <1> 	; 'vgabios.c', 'release_font_access'
  7169                              <1> 
  7170 00003239 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  7171                              <1> 	;mov	ax, 0100h
  7172                              <1> 	; 02/08/2022
  7173 0000323D 29C0                <1> 	sub	eax, eax
  7174 0000323F B401                <1> 	mov	ah, 1
  7175                              <1> 	; ax = 0100h
  7176 00003241 66EF                <1> 	out	dx, ax
  7177 00003243 66B80203            <1> 	mov	ax, 0302h
  7178 00003247 66EF                <1> 	out	dx, ax
  7179 00003249 66B80403            <1> 	mov	ax, 0304h
  7180 0000324D 66EF                <1> 	out	dx, ax
  7181 0000324F 66B80003            <1> 	mov	ax, 0300h
  7182 00003253 66EF                <1> 	out	dx, ax
  7183                              <1> 	;mov	dx, 3CCh ; VGAREG_READ_MISC_OUTPUT
  7184                              <1>  	; 02/08/2022
  7185 00003255 B2CC                <1> 	mov	dl, 0CCh
  7186 00003257 EC                  <1> 	in	al, dx
  7187 00003258 2401                <1> 	and	al, 01h
  7188 0000325A C0E002              <1> 	shl	al, 2
  7189 0000325D 0C0A                <1> 	or	al, 0Ah
  7190 0000325F 88C4                <1> 	mov	ah, al
  7191 00003261 B006                <1> 	mov	al, 06h
  7192                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  7193                              <1> 	; 02/08/2022
  7194 00003263 B2CE                <1> 	mov	dl, 0CEh
  7195 00003265 66EF                <1> 	out	dx, ax
  7196 00003267 66B80400            <1> 	mov	ax, 0004h
  7197 0000326B 66EF                <1> 	out	dx, ax
  7198 0000326D 66B80510            <1> 	mov	ax, 1005h
  7199 00003271 66EF                <1> 	out	dx, ax
  7200 00003273 C3                  <1> 	retn
  7201                              <1> 
  7202                              <1> set_scan_lines:
  7203                              <1> 	; 02/08/2022
  7204                              <1> 	; 09/07/2016
  7205                              <1> 	;
  7206                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7207                              <1> 	; vgabios-0.7a (2011)
  7208                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7209                              <1> 	; 'vgabios.c', 'set_scan_lines'
  7210                              <1> 
  7211                              <1> 	; set_scan_lines(lines)
  7212                              <1> 	; BH = lines
  7213                              <1> 
  7214                              <1> 	; outb(crtc_addr, 0x09);
  7215 00003274 66BAD403            <1> 	mov	dx, 3D4h ; CRTC_ADDRESS = 3D4h (always)
  7216 00003278 B009                <1> 	mov	al, 09h
  7217 0000327A EE                  <1> 	out	dx, al
  7218                              <1> 	; crtc_r9 = inb(crtc_addr+1);
  7219                              <1> 	;inc	dx ; 3D5h
  7220                              <1> 	; 02/08/2022
  7221 0000327B FEC2                <1> 	inc	dl
  7222 0000327D EC                  <1> 	in	al, dx
  7223                              <1> 	; crtc_r9 = (crtc_r9 & 0xe0) | (lines - 1);
  7224 0000327E 24E0                <1> 	and	al, 0E0h
  7225 00003280 FECF                <1> 	dec	bh ; lines - 1
  7226 00003282 08F8                <1> 	or	al, bh
  7227                              <1> 	; outb(crtc_addr+1, crtc_r9);
  7228 00003284 EE                  <1> 	out	dx, al
  7229                              <1> 	;inc	bh 
  7230                              <1> 	; if(lines==8)
  7231                              <1> 	;cmp	bh, 8
  7232 00003285 80FF07              <1> 	cmp	bh, 7
  7233 00003288 7506                <1> 	jne	short ssl_1
  7234                              <1> 	; biosfn_set_cursor_shape(0x06,0x07);
  7235 0000328A 66B90706            <1> 	mov	cx, 0607h
  7236 0000328E EB06                <1> 	jmp	short ssl_2
  7237                              <1> ssl_1:
  7238                              <1> 	; biosfn_set_cursor_shape(lines-4,lines-3);
  7239 00003290 88F9                <1> 	mov	cl, bh ; lines - 1
  7240 00003292 88CD                <1> 	mov	ch, cl ; lines - 1 (16 -> 15)
  7241 00003294 FECD                <1> 	dec	ch  ; lines - 2 (16 -> 14)
  7242                              <1> ssl_2:
  7243                              <1> 	; CH = start line, CL = stop line
  7244 00003296 B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  7245 00003298 66890D[E7660000]    <1> 	mov	[CURSOR_MODE], cx ; save in data area
  7246 0000329F E877F0FFFF          <1> 	call	m16	; output cx register
  7247                              <1> 	; write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, lines);
  7248 000032A4 FEC7                <1> 	inc	bh ; lines
  7249 000032A6 883D[D2660000]      <1> 	mov	[CHAR_HEIGHT], bh
  7250                              <1> 	;  outb(crtc_addr, 0x12);
  7251 000032AC 66BAD403            <1> 	mov	dx, 3D4h ; CRTC_ADDRESS
  7252 000032B0 B012                <1> 	mov	al, 12h
  7253 000032B2 EE                  <1> 	out	dx, al
  7254                              <1> 	; vde = inb(crtc_addr+1);
  7255                              <1> 	;inc	dx
  7256                              <1> 	; 02/08/2022
  7257 000032B3 FEC2                <1> 	inc	dl
  7258 000032B5 EC                  <1> 	in	al, dx
  7259 000032B6 88C4                <1> 	mov	ah, al
  7260                              <1> 	; outb(crtc_addr, 0x07);
  7261                              <1> 	;dec	dx
  7262                              <1> 	; 02/08/2022
  7263 000032B8 FECA                <1> 	dec	dl
  7264 000032BA B007                <1> 	mov	al, 07h
  7265 000032BC EE                  <1> 	out	dx, al
  7266                              <1> 	; ovl = inb(crtc_addr+1);
  7267                              <1> 	;inc	dx
  7268                              <1> 	; 02/08/2022
  7269 000032BD FEC2                <1> 	inc	dl
  7270 000032BF EC                  <1> 	in	al, dx
  7271                              <1> 	; vde += (((ovl & 0x02) << 7) + ((ovl & 0x40) << 3) + 1);
  7272 000032C0 88E2                <1> 	mov	dl, ah ; vde
  7273 000032C2 88C6                <1> 	mov	dh, al ; ovl
  7274                              <1> 	;and	ax, 02h
  7275                              <1> 	;shl	ax, 7
  7276                              <1> 	; 02/08/2022
  7277 000032C4 31C0                <1> 	xor	eax, eax
  7278 000032C6 88F0                <1> 	mov	al, dh
  7279 000032C8 2402                <1> 	and	al, 2
  7280 000032CA C1E007              <1> 	shl	eax, 7
  7281                              <1> 	;mov	cx, ax ; (ovl & 0x02) << 7)	
  7282                              <1> 	; 02/08/2022
  7283 000032CD 89C1                <1> 	mov	ecx, eax
  7284 000032CF 28E4                <1> 	sub	ah, ah
  7285 000032D1 88F0                <1> 	mov	al, dh ; ovl
  7286                              <1> 	;and	ax, 40h			
  7287                              <1> 	;shl	ax, 3  ; (ovl & 0x40) << 3)
  7288                              <1> 	;inc	ax ; + 1 
  7289                              <1> 	;add	ax, cx
  7290                              <1> 	; 02/08/2022	
  7291 000032D3 2440                <1> 	and	al, 40h
  7292 000032D5 C1E003              <1> 	shl	eax, 3
  7293 000032D8 40                  <1> 	inc	eax
  7294 000032D9 01C8                <1> 	add	eax, ecx
  7295 000032DB 30F6                <1> 	xor	dh, dh
  7296                              <1> 	;add	ax, dx ; + vde
  7297                              <1> 	; 02/08/2022
  7298 000032DD 01D0                <1> 	add	eax, edx
  7299                              <1> 	; rows = vde / lines;
  7300 000032DF F6F7                <1> 	div	bh
  7301                              <1> 	;dec	al ; rows -1
  7302                              <1> 	; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, rows-1);
  7303 000032E1 A2[D6660000]        <1> 	mov	[VGA_ROWS], al ; rows (not 'rows-1' !)
  7304                              <1> 	; write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, rows * cols * 2);
  7305                              <1> 	;mov	ah, [CRT_COLS]
  7306                              <1> 	;mul	ah
  7307                              <1> 	; 17/11/2020
  7308 000032E6 F625[D0660000]      <1> 	mul	byte [CRT_COLS]
  7309                              <1> 	;shl	ax, 1
  7310                              <1> 	; 02/08/2022
  7311 000032EC D1E0                <1> 	shl	eax, 1
  7312 000032EE 66A3[1C840100]      <1> 	mov 	[CRT_LEN], ax	
  7313 000032F4 C3                  <1> 	retn
  7314                              <1> 
  7315                              <1> load_text_8_14_pat:
  7316                              <1> 	; 02/08/2022 (TRDOS 3386 v2.0.5)
  7317                              <1> 	; 26/07/2016
  7318                              <1> 	; 25/07/2016
  7319                              <1> 	; 23/07/2016
  7320                              <1> 	; 09/07/2016
  7321                              <1> 	; load user defined (EGA/VGA) text fonts
  7322                              <1> 	;
  7323                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7324                              <1> 	; vgabios-0.7a (2011)
  7325                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7326                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_14_pat'
  7327                              <1> 
  7328                              <1> 	; biosfn_load_text_8_14_pat (AL,BL)
  7329                              <1> 
  7330                              <1> 	; get_font_access();
  7331                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  7332                              <1> 	; for(i=0;i<0x100;i++)
  7333                              <1> 	; {
  7334                              <1> 	;  src = i * 14;
  7335                              <1> 	;  dest = blockaddr + i * 32;
  7336                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont14+src, 14);
  7337                              <1> 	; }
  7338                              <1> 	; release_font_access();
  7339                              <1> 	; if(AL>=0x10)
  7340                              <1> 	; {
  7341                              <1> 	; set_scan_lines(14);
  7342                              <1> 	; }
  7343                              <1> 
  7344 000032F5 50                  <1> 	push	eax
  7345 000032F6 E80BFFFFFF          <1> 	call	get_font_access
  7346                              <1> 
  7347                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  7348                              <1> 	;mov	dl, bl
  7349                              <1> 	;and	dl, 3
  7350                              <1> 	;shl	dx, 14
  7351                              <1> 	;xchg	dx, bx
  7352                              <1> 	;and	dl, 4
  7353                              <1> 	;shl	dx, 11
  7354                              <1> 	;add	dx, bx 	
  7355                              <1>  
  7356                              <1> 	;xor	dx, dx  ; blockaddr = 0
  7357                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
  7358                              <1> 
  7359 000032FB 28DB                <1> 	sub	bl, bl ; i = 0
  7360 000032FD B70E                <1> 	mov	bh, 14
  7361 000032FF BE[1C560100]        <1> 	mov	esi, vgafont14
  7362 00003304 BF00000A00          <1> 	mov	edi, 0A0000h
  7363                              <1> 	; 02/08/2022
  7364 00003309 29C9                <1> 	sub	ecx, ecx		
  7365                              <1> lt8_14_1:
  7366                              <1> 	;mov	al, bl
  7367                              <1> 	;mul	bh
  7368                              <1> 	;movzx	esi, ax
  7369                              <1> 	;add	esi, vgafont14
  7370                              <1> 	;mov	al, bl
  7371                              <1> 	;sub	ah, ah
  7372                              <1> 	;shl	ax, 5 ; * 32
  7373                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  7374                              <1> 	;movzx	edi, ax ; dest
  7375                              <1> 	;add	edi, 0A0000h
  7376                              <1> 	;02/08/2022
  7377                              <1> 	;movzx	ecx, bh
  7378 0000330B 88F9                <1> 	mov	cl, bh
  7379 0000330D F3A4                <1> 	rep	movsb
  7380 0000330F 83C712              <1> 	add	edi, 18 ; 32 - 14
  7381 00003312 FEC3                <1> 	inc	bl
  7382 00003314 75F5                <1> 	jnz	short lt8_14_1	
  7383                              <1> 	;
  7384 00003316 E81EFFFFFF          <1> 	call	release_font_access
  7385                              <1> 	;
  7386 0000331B 58                  <1> 	pop	eax
  7387                              <1> 	; if(AL>=0x10)
  7388 0000331C 3C10                <1> 	cmp	al, 10h
  7389 0000331E 7205                <1> 	jb	short lt8_14_4
  7390                              <1> 	; BH = 14
  7391                              <1>    	; set_scan_lines(14);
  7392 00003320 E84FFFFFFF          <1> 	call	set_scan_lines
  7393                              <1> lt8_14_4:
  7394 00003325 C3                  <1> 	retn
  7395                              <1> 
  7396                              <1> load_text_8_8_pat:
  7397                              <1> 	; 02/08/2022 (TRDOS 3386 v2.0.5)
  7398                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  7399                              <1> 	; 26/07/2016
  7400                              <1> 	; 25/07/2016
  7401                              <1> 	; 23/07/2016
  7402                              <1> 	; 09/07/2016
  7403                              <1> 	; load user defined (EGA/VGA) text fonts
  7404                              <1> 	;
  7405                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7406                              <1> 	; vgabios-0.7a (2011)
  7407                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7408                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_8_pat'
  7409                              <1> 
  7410                              <1> 	; biosfn_load_text_8_8_pat (AL,BL)
  7411                              <1> 
  7412                              <1> 	; get_font_access();
  7413                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  7414                              <1> 	; for(i=0;i<0x100;i++)
  7415                              <1> 	; {
  7416                              <1> 	;  src = i * 8;
  7417                              <1> 	;  dest = blockaddr + i * 32;
  7418                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont8+src, 8);
  7419                              <1> 	; }
  7420                              <1> 	; release_font_access();
  7421                              <1> 	; if(AL>=0x10)
  7422                              <1> 	; {
  7423                              <1> 	; set_scan_lines(8);
  7424                              <1> 	; }
  7425                              <1> 
  7426 00003326 50                  <1> 	push	eax
  7427 00003327 E8DAFEFFFF          <1> 	call	get_font_access
  7428                              <1> 
  7429                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  7430                              <1> 	;mov	dl, bl
  7431                              <1> 	;and	dl, 3
  7432                              <1> 	;shl	dx, 14
  7433                              <1> 	;xchg	dx, bx
  7434                              <1> 	;and	dl, 4
  7435                              <1> 	;shl	dx, 11
  7436                              <1> 	;add	dx, bx 	
  7437                              <1>  
  7438                              <1> 	;xor	dx, dx  ; blockaddr = 0
  7439                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
  7440                              <1> 
  7441 0000332C 28DB                <1> 	sub	bl, bl ; i = 0
  7442 0000332E B708                <1> 	mov	bh, 8
  7443                              <1> 	;mov	esi, vgafont8
  7444 00003330 BF00000A00          <1> 	mov	edi, 0A0000h
  7445                              <1> 
  7446                              <1> 	; 02/08/2022
  7447 00003335 29C9                <1> 	sub	ecx, ecx
  7448                              <1> 
  7449                              <1> 	; 05/01/2021
  7450 00003337 F605[32100300]80    <1> 	test	byte [ufont], 80h
  7451 0000333E 7410                <1> 	jz	short lt8_8_0
  7452                              <1> 		; user font permission (after set mode)
  7453 00003340 F605[32100300]08    <1>  	test	byte [ufont], 8
  7454 00003347 7407                <1> 	jz	short lt8_8_0
  7455 00003349 BE00500900          <1> 	mov	esi, VGAFONT8USER
  7456 0000334E EB05                <1> 	jmp	short lt8_8_1
  7457                              <1> lt8_8_0:
  7458 00003350 BE[1C4E0100]        <1> 	mov	esi, vgafont8	
  7459                              <1> lt8_8_1:
  7460                              <1> 	;mov	al, bl
  7461                              <1> 	;mul	bh
  7462                              <1> 	;movzx	esi, ax
  7463                              <1> 	;add	esi, vgafont8
  7464                              <1> 	;mov	al, bl
  7465                              <1> 	;sub	ah, ah
  7466                              <1> 	;shl	ax, 5 ; * 32
  7467                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  7468                              <1> 	;movzx	edi, ax ; dest
  7469                              <1> 	;add	edi, 0A0000h
  7470                              <1> 	; 02/08/2022
  7471                              <1> 	;movzx	ecx, bh 		
  7472 00003355 88F9                <1> 	mov	cl, bh
  7473 00003357 F3A4                <1> 	rep	movsb
  7474 00003359 83C718              <1> 	add	edi, 24 ; 32 - 8
  7475 0000335C FEC3                <1> 	inc	bl
  7476 0000335E 75F5                <1> 	jnz	short lt8_8_1
  7477                              <1> 	;
  7478 00003360 E8D4FEFFFF          <1> 	call	release_font_access
  7479                              <1> 	;
  7480 00003365 58                  <1> 	pop	eax
  7481                              <1> 	; if(AL>=0x10)
  7482 00003366 3C10                <1> 	cmp	al, 10h
  7483 00003368 7205                <1> 	jb	short lt8_8_2
  7484                              <1> 	; BH = 8
  7485                              <1>    	; set_scan_lines(8);
  7486 0000336A E805FFFFFF          <1> 	call	set_scan_lines
  7487                              <1> lt8_8_2:
  7488 0000336F C3                  <1> 	retn
  7489                              <1> 
  7490                              <1> load_text_8_16_pat:
  7491                              <1> 	; 02/08/2022 (TRDOS 3386 v2.0.5)
  7492                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  7493                              <1> 	; 26/07/2016
  7494                              <1> 	; 25/07/2016
  7495                              <1> 	; 23/07/2016
  7496                              <1> 	; 09/07/2016
  7497                              <1> 	; load user defined (EGA/VGA) text fonts
  7498                              <1> 	;
  7499                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7500                              <1> 	; vgabios-0.7a (2011)
  7501                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7502                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_16_pat'
  7503                              <1> 
  7504                              <1> 	; biosfn_load_text_8_16_pat (AL,BL)
  7505                              <1> 
  7506                              <1> 	; get_font_access();
  7507                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  7508                              <1> 	; for(i=0;i<0x100;i++)
  7509                              <1> 	; {
  7510                              <1> 	;  src = i * 16;
  7511                              <1> 	;  dest = blockaddr + i * 32;
  7512                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont16+src, 16);
  7513                              <1> 	; }
  7514                              <1> 	; release_font_access();
  7515                              <1> 	; if(AL>=0x10)
  7516                              <1> 	; {
  7517                              <1> 	; set_scan_lines(16);
  7518                              <1> 	; }
  7519                              <1> 
  7520 00003370 50                  <1> 	push	eax
  7521 00003371 E890FEFFFF          <1> 	call	get_font_access
  7522                              <1> 
  7523                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  7524                              <1> 	;mov	dl, bl
  7525                              <1> 	;and	dl, 3
  7526                              <1> 	;shl	dx, 14
  7527                              <1> 	;xchg	dx, bx
  7528                              <1> 	;and	dl, 4
  7529                              <1> 	;shl	dx, 11
  7530                              <1> 	;add	dx, bx 	
  7531                              <1>  
  7532                              <1> 	;xor	dx, dx  ; blockaddr = 0
  7533                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
  7534                              <1> 
  7535 00003376 28DB                <1> 	sub	bl, bl ; i = 0
  7536 00003378 B710                <1> 	mov	bh, 16
  7537                              <1> 	;mov	esi, vgafont16
  7538 0000337A BF00000A00          <1> 	mov	edi, 0A0000h
  7539                              <1> 	;movzx	eax, bh
  7540                              <1> 	; 02/08/2022
  7541 0000337F 29C0                <1> 	sub	eax, eax
  7542 00003381 88F8                <1> 	mov	al, bh
  7543                              <1> 
  7544                              <1> 	; 05/01/2021
  7545 00003383 F605[32100300]80    <1> 	test	byte [ufont], 80h
  7546 0000338A 7410                <1> 	jz	short lt8_16_0
  7547                              <1> 		; user font permission (after set mode)
  7548 0000338C F605[32100300]10    <1>  	test	byte [ufont], 16
  7549 00003393 7407                <1> 	jz	short lt8_16_0
  7550 00003395 BE00400900          <1> 	mov	esi, VGAFONT16USER
  7551 0000339A EB05                <1> 	jmp	short lt8_16_1
  7552                              <1> lt8_16_0:
  7553 0000339C BE[1C640100]        <1> 	mov	esi, vgafont16
  7554                              <1> lt8_16_1:
  7555                              <1> 	;mov	al, bl
  7556                              <1> 	;mul	bh
  7557                              <1> 	;movzx	esi, ax
  7558                              <1> 	;add	esi, vgafont16
  7559                              <1> 	;mov	al, bl ; i
  7560                              <1> 	;sub	ah, ah
  7561                              <1> 	;shl	ax, 5 ; * 32
  7562                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  7563                              <1> 	;movzx	edi, ax ; dest
  7564                              <1> 	;add	edi, 0A0000h
  7565                              <1> 	;movzx	ecx, bh
  7566 000033A1 89C1                <1> 	mov	ecx, eax ; 16	
  7567 000033A3 F3A4                <1> 	rep	movsb
  7568 000033A5 01C7                <1> 	add	edi, eax ; add edi, 16
  7569 000033A7 FEC3                <1> 	inc	bl
  7570 000033A9 75F6                <1> 	jnz	short lt8_16_1
  7571                              <1> 	;
  7572 000033AB E889FEFFFF          <1> 	call	release_font_access
  7573                              <1> 	;
  7574 000033B0 58                  <1> 	pop	eax
  7575                              <1> 	; if(AL>=0x10)
  7576 000033B1 3C10                <1> 	cmp	al, 10h
  7577 000033B3 7205                <1> 	jb	short lt8_16_2
  7578                              <1> 	; BH = 16
  7579                              <1>    	; set_scan_lines(16);
  7580 000033B5 E8BAFEFFFF          <1> 	call	set_scan_lines
  7581                              <1> lt8_16_2:
  7582 000033BA C3                  <1> 	retn
  7583                              <1> 
  7584                              <1> load_gfx_user_chars:
  7585                              <1> 	; 08/01/2021
  7586                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  7587                              <1> 	; 08/08/2016
  7588                              <1> 	; 10/07/2016
  7589                              <1> 	; Setup User-Defined Font for Graphics Mode (VGA)
  7590                              <1> 	;
  7591                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7592                              <1> 	; vgabios-0.7a (2011)
  7593                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7594                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_user_chars'
  7595                              <1> 
  7596                              <1> 	; biosfn_load_gfx_user_chars (ES,BP,CX,BL,DL)
  7597                              <1> 	; /* set 0x43 INT pointer */
  7598                              <1>     	; write_word(0x0, 0x43*4, BP);
  7599                              <1>     	; write_word(0x0, 0x43*4+2, ES);
  7600                              <1> 	
  7601                              <1> 	; 08/01/2021
  7602                              <1> 		
  7603                              <1> 	; BL   screen rows code: 00H = user-specified (in DL)
  7604                              <1>         ;                        01H = 14 rows
  7605                              <1>         ;                        02H = 25 rows
  7606                              <1>         ;                        03H = 43 rows
  7607                              <1>         ; CX   bytes per character definition
  7608                              <1>         ; DL   (when BL=0) custom number of character rows on screen
  7609                              <1>         ; EBP  address of font-definition information (user's mem space)
  7610                              <1> 
  7611                              <1> 	; 05/01/2021
  7612                              <1> 	;xor	eax, eax
  7613                              <1> 	;dec	eax ; 0FFFFFFFFh (user defined fonts)
  7614                              <1> 	;mov	[VGA_INT43H], eax
  7615                              <1> 
  7616                              <1> 	; 08/01/2021
  7617                              <1> 	; ebp = video font data (buffer) address
  7618 000033BB 892D[2E840100]      <1> 	mov	[VGA_INT43H], ebp
  7619                              <1> 
  7620                              <1> 	; switch (BL) {
  7621                              <1> 	; case 0:
  7622                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  7623                              <1> 	;    break;
  7624 000033C1 20DB                <1> 	and	bl, bl
  7625 000033C3 7508                <1> 	jnz	short l_gfx_uc_1
  7626 000033C5 8815[D6660000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  7627 000033CB EB23                <1> 	jmp	short l_gfx_uc_4
  7628                              <1> l_gfx_uc_1:
  7629                              <1> 	; case 1:
  7630                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  7631                              <1> 	;    break;
  7632 000033CD FECB                <1> 	dec	bl
  7633 000033CF 7509                <1> 	jnz	short l_gfx_uc_2
  7634                              <1> 	; bl = 1
  7635 000033D1 C605[D6660000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  7636 000033D8 EB16                <1> 	jmp	short l_gfx_uc_4
  7637                              <1> l_gfx_uc_2:
  7638 000033DA FECB                <1> 	dec	bl
  7639 000033DC 740B                <1> 	jz	short l_gfx_uc_3 ; bl = 2
  7640 000033DE FECB                <1> 	dec	bl
  7641 000033E0 750E                <1> 	jnz	short l_gfx_uc_4 ; bl > 3
  7642                              <1> 	; bl = 3
  7643                              <1> 	; case 3:
  7644                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  7645                              <1> 	;    break;
  7646 000033E2 C605[D6660000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  7647                              <1> l_gfx_uc_3:
  7648                              <1>     	; case 2:
  7649                              <1>     	; default:
  7650                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  7651                              <1> 	;    break;
  7652                              <1> 	; bl = 2 or bl > 3
  7653 000033E9 C605[D6660000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  7654                              <1>     	; }
  7655                              <1> l_gfx_uc_4:
  7656                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, CX);
  7657 000033F0 880D[D2660000]      <1> 	mov	[CHAR_HEIGHT], cl
  7658                              <1> 	; }
  7659 000033F6 C3                  <1> 	retn
  7660                              <1> 
  7661                              <1> load_gfx_8_14_chars:
  7662                              <1> 	; 08/08/2016
  7663                              <1> 	; 10/07/2016
  7664                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  7665                              <1> 	;
  7666                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7667                              <1> 	; vgabios-0.7a (2011)
  7668                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7669                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_14_chars'
  7670                              <1> 
  7671                              <1> 	; biosfn_load_gfx_8_14_chars (BL)
  7672                              <1> 	; /* set 0x43 INT pointer */
  7673                              <1>     	; write_word(0x0, 0x43*4, &vgafont14);
  7674                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  7675 000033F7 C705[2E840100]-     <1> 	mov	dword [VGA_INT43H], vgafont14
  7675 000033FD [1C560100]          <1>
  7676                              <1> 		
  7677                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  7678                              <1>         ;                         01H = 14 rows
  7679                              <1>         ;                         02H = 25 rows
  7680                              <1>         ;                         03H = 43 rows
  7681                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  7682                              <1> 
  7683                              <1> 	; switch (BL) {
  7684                              <1> 	; case 0:
  7685                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  7686                              <1> 	;    break;
  7687 00003401 20DB                <1> 	and	bl, bl
  7688 00003403 7508                <1> 	jnz	short l_gfx_8_14c_1
  7689 00003405 8815[D6660000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  7690 0000340B EB23                <1> 	jmp	short l_gfx_8_14c_4
  7691                              <1> l_gfx_8_14c_1:
  7692                              <1> 	; case 1:
  7693                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  7694                              <1> 	;    break;
  7695 0000340D FECB                <1> 	dec	bl
  7696 0000340F 7509                <1> 	jnz	short l_gfx_8_14c_2
  7697                              <1> 	; bl = 1
  7698 00003411 C605[D6660000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  7699 00003418 EB16                <1> 	jmp	short l_gfx_8_14c_4
  7700                              <1> l_gfx_8_14c_2:
  7701 0000341A FECB                <1> 	dec	bl
  7702 0000341C 740B                <1> 	jz	short l_gfx_8_14c_3 ; bl = 2
  7703 0000341E FECB                <1> 	dec	bl
  7704 00003420 750E                <1> 	jnz	short l_gfx_8_14c_4 ; bl > 3
  7705                              <1> 	; bl = 3
  7706                              <1> 	; case 3:
  7707                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  7708                              <1> 	;    break;
  7709 00003422 C605[D6660000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  7710                              <1> l_gfx_8_14c_3:
  7711                              <1>     	; case 2:
  7712                              <1>     	; default:
  7713                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  7714                              <1> 	;    break;
  7715                              <1> 	; bl = 2 or bl > 3
  7716 00003429 C605[D6660000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !
  7717                              <1>     	; }
  7718                              <1> l_gfx_8_14c_4:
  7719                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 14);
  7720 00003430 C605[D2660000]0E    <1>         mov     byte [CHAR_HEIGHT], 14
  7721                              <1> 	; }
  7722 00003437 C3                  <1> 	retn	
  7723                              <1> 
  7724                              <1> load_gfx_8_8_chars:
  7725                              <1> 	; 08/08/2016
  7726                              <1> 	; 10/07/2016
  7727                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  7728                              <1> 	;
  7729                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7730                              <1> 	; vgabios-0.7a (2011)
  7731                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7732                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_8_dd_chars'
  7733                              <1> 
  7734                              <1> 	; biosfn_load_gfx_8_8_dd_chars (BL)
  7735                              <1> 	; /* set 0x43 INT pointer */
  7736                              <1>     	; write_word(0x0, 0x43*4, &vgafont8);
  7737                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  7738 00003438 C705[2E840100]-     <1> 	mov	dword [VGA_INT43H], vgafont8
  7738 0000343E [1C4E0100]          <1>
  7739                              <1> 		
  7740                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  7741                              <1>         ;                         01H = 14 rows
  7742                              <1>         ;                         02H = 25 rows
  7743                              <1>         ;                         03H = 43 rows
  7744                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  7745                              <1> 
  7746                              <1> 	; switch (BL) {
  7747                              <1> 	; case 0:
  7748                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  7749                              <1> 	;    break;
  7750 00003442 20DB                <1> 	and	bl, bl
  7751 00003444 7508                <1> 	jnz	short l_gfx_8_8c_1
  7752 00003446 8815[D6660000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  7753 0000344C EB23                <1> 	jmp	short l_gfx_8_8c_4 	
  7754                              <1> l_gfx_8_8c_1:
  7755                              <1> 	; case 1:
  7756                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  7757                              <1> 	;    break;
  7758 0000344E FECB                <1> 	dec	bl
  7759 00003450 7509                <1> 	jnz	short l_gfx_8_8c_2
  7760                              <1> 	; bl = 1
  7761 00003452 C605[D6660000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  7762 00003459 EB16                <1> 	jmp	short l_gfx_8_8c_4 	
  7763                              <1> l_gfx_8_8c_2:
  7764 0000345B FECB                <1> 	dec	bl
  7765 0000345D 740B                <1> 	jz	short l_gfx_8_8c_3 ; bl = 2
  7766 0000345F FECB                <1> 	dec	bl
  7767 00003461 750E                <1> 	jnz	short l_gfx_8_8c_4 ; bl > 3
  7768                              <1> 	; bl = 3
  7769                              <1> 	; case 3:
  7770                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  7771                              <1> 	;    break;
  7772 00003463 C605[D6660000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  7773                              <1> l_gfx_8_8c_3:
  7774                              <1>     	; case 2:
  7775                              <1>     	; default:
  7776                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  7777                              <1> 	;    break;
  7778                              <1> 	; bl = 2 or bl > 3
  7779 0000346A C605[D6660000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  7780                              <1>     	; }
  7781                              <1> l_gfx_8_8c_4:
  7782                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 8);
  7783 00003471 C605[D2660000]08    <1>         mov     byte [CHAR_HEIGHT], 8
  7784                              <1> 	; }
  7785 00003478 C3                  <1> 	retn
  7786                              <1> 
  7787                              <1> load_gfx_8_16_chars:
  7788                              <1> 	; 08/08/2016
  7789                              <1> 	; 10/07/2016
  7790                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  7791                              <1> 	;
  7792                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7793                              <1> 	; vgabios-0.7a (2011)
  7794                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7795                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_16_chars'
  7796                              <1> 
  7797                              <1> 	; biosfn_load_gfx_8_16_chars (BL)
  7798                              <1> 	; /* set 0x43 INT pointer */
  7799                              <1>     	; write_word(0x0, 0x43*4, &vgafont16);
  7800                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  7801 00003479 C705[2E840100]-     <1> 	mov	dword [VGA_INT43H], vgafont16
  7801 0000347F [1C640100]          <1>
  7802                              <1> 		
  7803                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  7804                              <1>         ;                         01H = 14 rows
  7805                              <1>         ;                         02H = 25 rows
  7806                              <1>         ;                         03H = 43 rows
  7807                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  7808                              <1> 
  7809                              <1> 	; switch (BL) {
  7810                              <1> 	; case 0:
  7811                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  7812                              <1> 	;    break;
  7813 00003483 20DB                <1> 	and	bl, bl
  7814 00003485 7508                <1> 	jnz	short l_gfx_8_16c_1
  7815 00003487 8815[D6660000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  7816 0000348D EB23                <1> 	jmp	short l_gfx_8_16c_4 	
  7817                              <1> l_gfx_8_16c_1:
  7818                              <1> 	; case 1:
  7819                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  7820                              <1> 	;    break;
  7821 0000348F FECB                <1> 	dec	bl
  7822 00003491 7509                <1> 	jnz	short l_gfx_8_16c_2
  7823                              <1> 	; bl = 1
  7824 00003493 C605[D6660000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  7825 0000349A EB16                <1> 	jmp	short l_gfx_8_16c_4
  7826                              <1> l_gfx_8_16c_2:
  7827 0000349C FECB                <1> 	dec	bl
  7828 0000349E 740B                <1> 	jz	short l_gfx_8_16c_3 ; bl = 2
  7829 000034A0 FECB                <1> 	dec	bl
  7830 000034A2 750E                <1> 	jnz	short l_gfx_8_16c_4 ; bl > 3
  7831                              <1> 	; bl = 3
  7832                              <1> 	; case 3:
  7833                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  7834                              <1> 	;    break;
  7835 000034A4 C605[D6660000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  7836                              <1> l_gfx_8_16c_3:
  7837                              <1>     	; case 2:
  7838                              <1>     	; default:
  7839                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  7840                              <1> 	;    break;
  7841                              <1> 	; bl = 2 or bl > 3
  7842 000034AB C605[D6660000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  7843                              <1>     	; }
  7844                              <1> l_gfx_8_16c_4:
  7845                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 16);
  7846 000034B2 C605[D2660000]10    <1>         mov     byte [CHAR_HEIGHT], 16
  7847                              <1> 	; }
  7848 000034B9 C3                  <1> 	retn
  7849                              <1> 			
  7850                              <1> get_font_info:
  7851                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
  7852                              <1> 	; 08/01/2021 (TRDOS 386 v2.0.3)
  7853                              <1> 	; 19/09/2016
  7854                              <1> 	; 08/08/2016
  7855                              <1> 	; 10/07/2016
  7856                              <1> 	; Get Current Character Generator Info (VGA)
  7857                              <1> 	;
  7858                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7859                              <1> 	; vgabios-0.7a (2011)
  7860                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7861                              <1> 	; 'vgabios.c', 'biosfn_get_font_info'
  7862                              <1> 
  7863                              <1> 	; Modified for TRDOS 386 !
  7864                              <1> 	;
  7865                              <1> 	; INPUT ->
  7866                              <1> 	;    AX = 1130h
  7867                              <1> 	;    BL = 0 -> Get info for current VGA font
  7868                              <1> 	;	       (BH = unused)
  7869                              <1> 	;    19/09/2016
  7870                              <1> 	;    BL > 0 -> Get requested character font data
  7871                              <1> 	;	 BL = 1 -> vgafont8
  7872                              <1> 	;        BL = 2 -> vgafont14
  7873                              <1> 	;	 BL = 3 -> vgafont16   
  7874                              <1> 	;	;08/01/2021
  7875                              <1> 	;	 BL = 4 -> user defined 8x8 font
  7876                              <1> 	;	 BL = 5 -> user defined 8x14 font
  7877                              <1> 	;	 BL = 6 -> user defined 8x16 font
  7878                              <1> 	;	 BL > 6 -> Invalid function (for now!)
  7879                              <1> 	;	 BH = ASCII code of the first character
  7880                              <1> 	;	 ECX = Number of characters from the 1st char
  7881                              <1> 	;	 ECX >= 256 -> All (256-BH) characters
  7882                              <1> 	;	 ECX = 0 -> All characters (BH = unused)
  7883                              <1> 	;        EDX = User's Buffer Address	
  7884                              <1> 	; OUTPUT ->
  7885                              <1> 	;    AL = height (scanlines), bytes per character
  7886                              <1> 	;    AH = screen rows
  7887                              <1> 	;    Byte 16-23 of EAX = number of columns
  7888                              <1> 	;    Byte 24-31 of EAX = 
  7889                              <1> 	;	  0 -> default font (not configured yet)
  7890                              <1> 	;	  0FFh -> user defined font
  7891                              <1> 	;	  14 = vgafont14
  7892                              <1> 	;	   8 = vgafont8
  7893                              <1> 	;	  16 = vgafont16
  7894                              <1> 	;   If BL input > 0 -> 
  7895                              <1> 	;       EAX = Actual transfer count
  7896                              <1> 	;
  7897 000034BA 20DB                <1> 	and	bl, bl
  7898 000034BC 740F                <1> 	jz	short gfi_1
  7899                              <1> 	; invalid function (input)
  7900                              <1> 	; 08/01/2021
  7901 000034BE 80FB04              <1> 	cmp	bl, 4
  7902 000034C1 7263                <1> 	jb	short gfi_5
  7903 000034C3 7441                <1> 	je	short gfi_3	
  7904 000034C5 80FB06              <1> 	cmp	bl, 6
  7905 000034C8 744C                <1> 	je	short gfi_4
  7906                              <1> 	; bh = 5 or bh > 6
  7907                              <1> gfi_0:
  7908 000034CA 31C0                <1> 	xor	eax, eax ; 0
  7909 000034CC C3                  <1> 	retn
  7910                              <1> gfi_1:
  7911 000034CD A0[D2660000]        <1> 	mov	al, [CHAR_HEIGHT]
  7912 000034D2 8A25[D6660000]      <1> 	mov	ah, [VGA_ROWS]
  7913 000034D8 C1E010              <1> 	shl	eax, 16
  7914 000034DB A0[D0660000]        <1> 	mov	al, [CRT_COLS]
  7915 000034E0 8B0D[2E840100]      <1> 	mov	ecx, [VGA_INT43H]
  7916 000034E6 21C9                <1> 	and	ecx, ecx
  7917 000034E8 7418                <1> 	jz	short gfi_2 ; 0 = default font
  7918                              <1> 	; 08/01/2021
  7919 000034EA FECC                <1> 	dec	ah ; 0FFh
  7920 000034EC 81F900400900        <1> 	cmp	ecx, VGAFONT16USER
  7921 000034F2 740E                <1> 	je	short gfi_2
  7922 000034F4 81F900500900        <1> 	cmp	ecx, VGAFONT8USER
  7923 000034FA 7406                <1> 	je	short gfi_2	
  7924 000034FC 8A25[D2660000]      <1> 	mov	ah, [CHAR_HEIGHT] ; font size = height
  7925                              <1> gfi_2:
  7926 00003502 C1C010              <1> 	rol	eax, 16
  7927 00003505 C3                  <1> 	retn
  7928                              <1> gfi_3:
  7929                              <1> 	; 08/01/2021
  7930 00003506 F605[32100300]08    <1> 	test	byte [ufont], 08h ; 8x8 user font
  7931 0000350D 74BB                <1> 	jz	short gfi_0 ; not loaded !
  7932 0000350F BE00500900          <1> 	mov	esi, VGAFONT8USER ; *
  7933                              <1> 	;mov	bl, 8
  7934                              <1> 	;jmp	short gfi_8
  7935 00003514 EB4A                <1> 	jmp	short gfi_10
  7936                              <1> gfi_4:
  7937                              <1> 	; 08/01/2021
  7938 00003516 F605[32100300]10    <1> 	test	byte [ufont], 10h ; 8x16 user font
  7939 0000351D 74AB                <1> 	jz	short gfi_0 ; not loaded !
  7940 0000351F BE00400900          <1> 	mov	esi, VGAFONT16USER ; *
  7941 00003524 EB15                <1> 	jmp	short gfi_7
  7942                              <1> gfi_5:
  7943 00003526 80FB02              <1> 	cmp	bl, 2
  7944 00003529 7230                <1> 	jb	short gfi_9
  7945 0000352B 7709                <1> 	ja	short gfi_6
  7946                              <1> 	; BL = 2 -> vgafont14
  7947 0000352D BE[1C560100]        <1> 	mov	esi, vgafont14 ; *
  7948 00003532 B30E                <1> 	mov	bl, 14
  7949 00003534 EB07                <1> 	jmp	short gfi_8 
  7950                              <1> gfi_6:
  7951                              <1> 	; BL = 3 -> vgafont16
  7952 00003536 BE[1C640100]        <1> 	mov	esi, vgafont16 ; *
  7953                              <1> gfi_7:
  7954 0000353B B310                <1> 	mov	bl, 16
  7955                              <1> gfi_8:
  7956 0000353D 89D7                <1> 	mov	edi, edx ; **
  7957 0000353F 09C9                <1> 	or	ecx, ecx
  7958 00003541 7421                <1> 	jz	short gfi_11 ; all chars from the 00h
  7959                              <1> 	;mov	al, bh ; character index
  7960                              <1> 	; 03/08/2022
  7961 00003543 0FB6C7              <1> 	movzx	eax, bh
  7962 00003546 F6E3                <1> 	mul	bl ; char index * char height/size
  7963                              <1> 	;movzx	edx, ax
  7964                              <1> 	; 03/08/2022
  7965                              <1> 	;add	esi, edx ; *
  7966 00003548 01C6                <1> 	add	esi, eax
  7967 0000354A 31D2                <1> 	xor	edx, edx
  7968 0000354C FECA                <1> 	dec	dl 
  7969                              <1> 	; edx = 0FFh = 255
  7970                              <1> 	;mov	dx, 255
  7971 0000354E 28FA                <1> 	sub	dl, bh
  7972                              <1> 	;inc	dx	
  7973                              <1> 	; 03/08/2022
  7974 00003550 42                  <1> 	inc	edx
  7975 00003551 39D1                <1> 	cmp	ecx, edx
  7976 00003553 770F                <1> 	ja	short gfi_11
  7977 00003555 7411                <1> 	je	short gfi_12
  7978 00003557 89D1                <1> 	mov	ecx, edx
  7979 00003559 EB0D                <1> 	jmp	short gfi_12
  7980                              <1> gfi_9:
  7981                              <1> 	;BL = 1 -> vgafont8
  7982 0000355B BE[1C4E0100]        <1> 	mov	esi, vgafont8 ; *
  7983                              <1> gfi_10:
  7984 00003560 B308                <1> 	mov	bl, 8
  7985 00003562 EBD9                <1> 	jmp	short gfi_8
  7986                              <1> gfi_11:
  7987                              <1> 	;mov	ecx, 256
  7988                              <1> 	; 03/08/2022
  7989 00003564 29C9                <1> 	sub	ecx, ecx
  7990 00003566 FEC5                <1> 	inc	ch
  7991                              <1> 	; ecx = 100h 
  7992                              <1> gfi_12:
  7993                              <1> 	; 08/01/2021
  7994 00003568 89C8                <1> 	mov	eax, ecx ; character count
  7995 0000356A 30FF                <1> 	xor	bh, bh
  7996 0000356C 66F7E3              <1> 	mul	bx ; char count * char height/size
  7997 0000356F 89C1                <1>  	mov	ecx, eax
  7998                              <1> 
  7999                              <1> 	; ESI = source address in system space
  8000                              <1> 	; EDI = user's buffer address
  8001                              <1> 	; ECX = transfer (byte) count
  8002 00003571 E8E3D70000          <1> 	call	transfer_to_user_buffer
  8003 00003576 89C8                <1> 	mov	eax, ecx ; actual transfer count
  8004 00003578 C3                  <1> 	retn
  8005                              <1> 
  8006                              <1> set_all_palette_reg:
  8007                              <1> 	; 03/08/2022
  8008                              <1> 	; 10/08/2016
  8009                              <1> 	; Set All Palette Registers and Overscan
  8010                              <1> 	; EDX = Address of 17 bytes; 
  8011                              <1> 	; an rgbRGB value for each of 16 palette
  8012                              <1> 	; registers plus one for the border.
  8013                              <1> 
  8014 00003579 89D6                <1> 	mov	esi, edx ; user buffer
  8015                              <1> 	;mov	ecx, 17
  8016                              <1> 	; 03/08/2022
  8017 0000357B 29C9                <1> 	sub	ecx, ecx
  8018 0000357D B111                <1> 	mov	cl, 17
  8019 0000357F 89E7                <1> 	mov	edi, esp
  8020 00003581 83EC14              <1> 	sub	esp, 20	 	 
  8021 00003584 E81AD80000          <1> 	call	transfer_from_user_buffer
  8022                              <1> 	;jc	VIDEO_RETURN
  8023                              <1> 
  8024 00003589 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8025 0000358D EC                  <1> 	in	al, dx
  8026                              <1> 	;mov	cl, 0
  8027                              <1> 	; 03/08/2022
  8028 0000358E 28C9                <1> 	sub	cl, cl
  8029                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8030                              <1> 	; 03/08/2022
  8031 00003590 B2C0                <1> 	mov	dl, 0C0h
  8032                              <1> set_palette_loop:
  8033 00003592 88C8                <1> 	mov	al, cl
  8034 00003594 EE                  <1> 	out	dx, al
  8035 00003595 8A07                <1> 	mov	al, [edi]
  8036 00003597 EE                  <1> 	out	dx, al
  8037 00003598 47                  <1> 	inc	edi
  8038 00003599 FEC1                <1> 	inc	cl
  8039 0000359B 80F910              <1> 	cmp	cl, 10h
  8040 0000359E 75F2                <1> 	jne	short set_palette_loop
  8041 000035A0 B011                <1> 	mov	al, 11h
  8042 000035A2 EE                  <1> 	out	dx, al
  8043 000035A3 8A07                <1> 	mov	al, [edi]
  8044 000035A5 EE                  <1> 	out	dx, al
  8045 000035A6 B020                <1> 	mov	al, 20h
  8046 000035A8 EE                  <1> 	out	dx, al
  8047                              <1> 	; ifdef VBOX
  8048                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8049                              <1> 	; 03/08/2022
  8050 000035A9 B2DA                <1> 	mov	dl, 0DAh
  8051 000035AB EC                  <1> 	in	al, dx
  8052                              <1> 	; endif ; VBOX
  8053 000035AC 83C414              <1> 	add	esp, 20
  8054 000035AF E941E5FFFF          <1> 	jmp	VIDEO_RETURN
  8055                              <1> 	
  8056                              <1> 	; 07/08/2022
  8057                              <1> toggle_intensity:
  8058                              <1> 	; 03/08/2022
  8059                              <1> 	; 10/08/2016
  8060                              <1> 	; Select Foreground Blink or Bold Background
  8061                              <1> 	; BL = 00h = enable bold backgrounds
  8062                              <1> 	;	    (16 background colors)
  8063                              <1>         ;      01h = enable blinking foreground
  8064                              <1> 	;	    (8 background colors)
  8065                              <1> 
  8066 000035B4 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8067 000035B8 EC                  <1> 	in	al, dx
  8068                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8069                              <1> 	; 03/08/2022
  8070 000035B9 B2C0                <1> 	mov	dl, 0C0h
  8071 000035BB B010                <1> 	mov	al, 10h
  8072 000035BD EE                  <1> 	out	dx, al
  8073                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  8074                              <1> 	; 03/08/2022
  8075 000035BE FEC2                <1> 	inc	dl ; dx = 3C1h
  8076 000035C0 EC                  <1> 	in	al, dx
  8077 000035C1 24F7                <1> 	and	al, 0F7h
  8078 000035C3 80E301              <1> 	and	bl, 01h
  8079 000035C6 C0E303              <1> 	shl	bl, 3
  8080 000035C9 08D8                <1> 	or	al, bl
  8081                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8082                              <1> 	; 03/08/2022
  8083 000035CB FECA                <1> 	dec	dl ; dx = 3C0h
  8084 000035CD EE                  <1> 	out	dx, al
  8085 000035CE B020                <1> 	mov	al, 20h
  8086 000035D0 EE                  <1> 	out	dx, al
  8087                              <1> 	; ifdef VBOX
  8088                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8089                              <1> 	; 03/08/2022
  8090 000035D1 B2DA                <1> 	mov	dl, 0DAh
  8091 000035D3 EC                  <1> 	in	al, dx
  8092                              <1> 	; endif ; VBOX
  8093 000035D4 E91CE5FFFF          <1> 	jmp	VIDEO_RETURN
  8094                              <1> 
  8095                              <1> 	; 07/08/2022
  8096                              <1> vga_palf_unknown:
  8097 000035D9 29C0                <1> 	sub	eax, eax ; 0 = invalid function
  8098 000035DB E91AE5FFFF          <1>         jmp     _video_return
  8099                              <1> 
  8100                              <1> 	; 07/08/2022
  8101                              <1> vga_palf_101B:
  8102 000035E0 3C1B                <1> 	cmp	al, 1Bh
  8103                              <1> 	;jne	short vga_palf_unknown
  8104 000035E2 77F5                <1> 	ja	short vga_palf_unknown
  8105                              <1>  
  8106 000035E4 E810F6FFFF          <1> 	call	gray_scale_summing
  8107 000035E9 E907E5FFFF          <1>         jmp     VIDEO_RETURN 
  8108                              <1> 	
  8109                              <1> vga_pal_funcs:
  8110                              <1> 	; 07/08/2022
  8111                              <1> 	; 10/08/2016
  8112                              <1> 	; VGA Palette functions
  8113                              <1> 	;
  8114                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  8115                              <1> 	; vgabios-0.7a (2011)
  8116                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  8117                              <1> 	; 'vgabios.c', 'vgarom.asm'
  8118                              <1> 
  8119 000035EE 3C00                <1> 	cmp	al, 0
  8120 000035F0 7467                <1>         je      short set_single_palette_reg
  8121                              <1> vga_palf_1002:
  8122 000035F2 3C02                <1> 	cmp	al, 2
  8123 000035F4 7483                <1>         je      short set_all_palette_reg
  8124                              <1> 	; 07/08/2022
  8125 000035F6 7702                <1> 	ja	short vga_palf_1003
  8126 000035F8 EB5D                <1> 	jmp	short set_overscan_border_color 
  8127                              <1> 	; 07/08/2022
  8128                              <1> ;vga_palf_1001:
  8129                              <1> ;	cmp	al, 1
  8130                              <1> ;	je	short set_overscan_border_color
  8131                              <1> vga_palf_1003:
  8132 000035FA 3C03                <1> 	cmp	al, 3
  8133 000035FC 74B6                <1> 	je	short toggle_intensity
  8134                              <1> vga_palf_1007:
  8135 000035FE 3C07                <1> 	cmp	al, 7
  8136 00003600 747F                <1>         je      short get_single_palette_reg
  8137 00003602 72D5                <1> 	jb	short vga_palf_unknown
  8138                              <1> vga_palf_1008:
  8139 00003604 3C08                <1> 	cmp	al, 8
  8140 00003606 7477                <1>         je      short read_overscan_border_color
  8141                              <1> vga_palf_1009:
  8142 00003608 3C09                <1> 	cmp	al, 9
  8143                              <1> 	;je	short get_all_palette_reg
  8144                              <1> 	; 07/08/2022
  8145 0000360A 7505                <1> 	jne	short vga_palf_1010
  8146 0000360C E966010000          <1> 	jmp	get_all_palette_reg
  8147                              <1> vga_palf_1010:
  8148 00003611 3C10                <1> 	cmp	al, 10h
  8149                              <1> 	;je 	short set_single_dac_reg
  8150                              <1> 	; 07/08/2022
  8151 00003613 7707                <1> 	ja	short vga_palf_1012
  8152 00003615 72C2                <1> 	jb	short vga_palf_unknown
  8153 00003617 E908010000          <1> 	jmp	set_single_dac_reg
  8154                              <1> vga_palf_1012:
  8155 0000361C 3C12                <1> 	cmp	al, 12h
  8156                              <1> 	;je	short set_all_dac_reg
  8157                              <1> 	; 07/08/2022
  8158 0000361E 7707                <1> 	ja	short vga_palf_1013
  8159 00003620 72B7                <1> 	jb	short vga_palf_unknown
  8160 00003622 E916010000          <1> 	jmp	set_all_dac_reg	
  8161                              <1> vga_palf_1013:
  8162 00003627 3C13                <1> 	cmp	al, 13h
  8163                              <1> 	;je	short select_video_dac_color_page
  8164                              <1> 	; 07/08/2022
  8165 00003629 7505                <1> 	jne	short vga_palf_1015
  8166 0000362B E992010000          <1> 	jmp	select_video_dac_color_page
  8167                              <1> vga_palf_1015:
  8168 00003630 3C15                <1> 	cmp	al, 15h
  8169                              <1> 	;je	short read_single_dac_reg
  8170                              <1> 	; 07/08/2022
  8171 00003632 7707                <1> 	ja	short vga_palf_1017
  8172 00003634 72A3                <1> 	jb	short vga_palf_unknown
  8173 00003636 E98D000000          <1> 	jmp	read_single_dac_reg
  8174                              <1> vga_palf_1017:
  8175 0000363B 3C17                <1> 	cmp	al, 17h
  8176                              <1> 	;je	short read_all_dac_reg
  8177                              <1> 	; 07/08/2022
  8178 0000363D 7707                <1> 	ja	short vga_palf_1018
  8179 0000363F 7298                <1> 	jb	short vga_palf_unknown
  8180 00003641 E9A0000000          <1> 	jmp	read_all_dac_reg
  8181                              <1> vga_palf_1018:
  8182 00003646 3C18                <1> 	cmp	al, 18h
  8183 00003648 7464                <1>         je	short set_pel_mask
  8184                              <1> vga_palf_1019:
  8185 0000364A 3C19                <1> 	cmp	al, 19h
  8186 0000364C 746C                <1>         je	short read_pel_mask
  8187                              <1> vga_palf_101A:
  8188 0000364E 3C1A                <1> 	cmp	al, 1Ah
  8189                              <1>         ;je	short read_video_dac_state
  8190                              <1> 	; 07/08/2022
  8191 00003650 758E                <1> 	jne	short vga_palf_101B
  8192 00003652 E9AD010000          <1> 	jmp	read_video_dac_state
  8193                              <1> 
  8194                              <1> 	; 07/08/2022
  8195                              <1> set_overscan_border_color:
  8196                              <1> 	; 10/08/2016
  8197                              <1> 	; Set Overscan/Border Color Register
  8198                              <1> 	; BH = 6-bit RGB color to display 
  8199                              <1> 	;      for that attribute
  8200                              <1> 	
  8201 00003657 B311                <1> 	mov	bl, 11h
  8202                              <1>   	; 07/08/2022
  8203                              <1> 	;jmp	short set_single_palette_reg
  8204                              <1> 
  8205                              <1> set_single_palette_reg:
  8206                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
  8207                              <1> 	; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop)
  8208                              <1> 	; 10/08/2016
  8209                              <1> 	; Set One Palette Register
  8210                              <1> 	; BL = register number to set
  8211                              <1> 	;     (a 4-bit attribute nibble: 00h-0Fh)
  8212                              <1> 	; BH = 6-bit RGB color to display 
  8213                              <1> 	;      for that attribute
  8214                              <1> 
  8215 00003659 80FB14              <1> 	cmp	bl, 14h
  8216                              <1> 	;;ja	short no_actl_reg1
  8217                              <1> 	;ja	VIDEO_RETURN
  8218                              <1> 	; 03/08/2022
  8219 0000365C 7605                <1> 	jna	short sspr_1
  8220 0000365E E992E4FFFF          <1> 	jmp	VIDEO_RETURN
  8221                              <1> sspr_1:
  8222                              <1> 	;push	ax
  8223                              <1> 	;push	dx
  8224                              <1> 	; 12/04/2021
  8225 00003663 50                  <1> 	push	eax
  8226 00003664 52                  <1> 	push	edx
  8227 00003665 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8228 00003669 EC                  <1> 	in	al, dx
  8229                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8230                              <1> 	; 03/08/2022
  8231 0000366A B2C0                <1> 	mov	dl, 0C0h
  8232 0000366C 88D8                <1> 	mov	al, bl
  8233 0000366E EE                  <1> 	out	dx, al
  8234 0000366F 88F8                <1> 	mov	al, bh
  8235 00003671 EE                  <1> 	out	dx, al
  8236 00003672 B020                <1> 	mov	al, 20h
  8237 00003674 EE                  <1> 	out	dx, al
  8238                              <1> 	; ifdef VBOX
  8239                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8240                              <1> 	; 03/08/2022
  8241 00003675 B2DA                <1> 	mov	dl, 0DAh
  8242 00003677 EC                  <1> 	in	al, dx
  8243                              <1> 	; endif ; VBOX
  8244                              <1> 	;pop	dx
  8245                              <1> 	;pop	ax
  8246                              <1> 	; 12/04/2021
  8247 00003678 5A                  <1> 	pop	edx
  8248 00003679 58                  <1> 	pop	eax
  8249                              <1> ;no_actl_reg1:
  8250 0000367A E976E4FFFF          <1> 	jmp	VIDEO_RETURN
  8251                              <1> 
  8252                              <1> 	; 07/08/2022
  8253                              <1> read_overscan_border_color:
  8254                              <1> 	; 10/08/2016
  8255                              <1> 	; Read Overscan Register
  8256                              <1> 	; OUTPUT:
  8257                              <1> 	; BH = current rgbRGB value 
  8258                              <1> 	;      of the overscan/border register
  8259                              <1> 
  8260 0000367F B311                <1> 	mov	bl, 11h
  8261                              <1> 	; 07/08/2022
  8262                              <1> 	;jmp	short get_single_palette_reg
  8263                              <1> 
  8264                              <1> get_single_palette_reg:
  8265                              <1> 	; 03/08/2022
  8266                              <1> 	; 10/08/2016
  8267                              <1> 	; Read One Palette Register
  8268                              <1>         ; INPUT:
  8269                              <1> 	; BL = Palette register to read (00h-0Fh)
  8270                              <1> 	; OUTPUT:
  8271                              <1> 	; BH = Current rgbRGB value of specified register
  8272                              <1> 	;      for that attribute
  8273                              <1> 
  8274 00003681 80FB14              <1> 	cmp	bl, 14h
  8275                              <1> 	;;ja	short no_actl_reg2
  8276                              <1> 	;ja	VIDEO_RETURN
  8277                              <1> 	; 03/08/2022
  8278 00003684 7605                <1> 	jna	short gspr_1
  8279 00003686 E96AE4FFFF          <1> 	jmp	VIDEO_RETURN
  8280                              <1> gspr_1:
  8281 0000368B 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8282                              <1> 	; 03/08/2022
  8283 0000368F B2DA                <1> 	mov	dl, 0DAh
  8284 00003691 EC                  <1> 	in	al, dx
  8285                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8286                              <1> 	; 03/08/2022
  8287 00003692 B2C0                <1> 	mov	dl, 0C0h
  8288 00003694 88D8                <1> 	mov	al, bl
  8289 00003696 EE                  <1> 	out	dx, al
  8290                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  8291                              <1> 	; 03/08/2022
  8292 00003697 FEC2                <1> 	inc	dl ; dx = 3C1h
  8293 00003699 EC                  <1> 	in	al, dx
  8294 0000369A 8844240D            <1> 	mov	[esp+13], al ; bh
  8295                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8296                              <1> 	; 03/08/2022
  8297 0000369E B2DA                <1> 	mov	dl, 0DAh
  8298 000036A0 EC                  <1> 	in	al, dx
  8299                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8300                              <1> 	; 03/08/2022
  8301 000036A1 B2C0                <1> 	mov	dl, 0C0h
  8302 000036A3 B020                <1> 	mov	al, 20h
  8303 000036A5 EE                  <1> 	out	dx, al
  8304                              <1> 	; ifdef VBOX
  8305                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8306                              <1> 	; 03/08/2022
  8307 000036A6 B2DA                <1> 	mov	dl, 0DAh
  8308 000036A8 EC                  <1> 	in	al, dx
  8309                              <1> 	; endif ; VBOX
  8310 000036A9 E947E4FFFF          <1> 	jmp	VIDEO_RETURN
  8311                              <1> 
  8312                              <1> set_pel_mask:
  8313                              <1> 	; 10/08/2016
  8314                              <1> 	; BL = mask value
  8315 000036AE 66BAC603            <1> 	mov	dx, 3C6h ; VGAREG_PEL_MASK
  8316 000036B2 88D8                <1> 	mov	al, bl
  8317 000036B4 EE                  <1> 	out	dx, al
  8318 000036B5 E93BE4FFFF          <1> 	jmp	VIDEO_RETURN
  8319                              <1> 
  8320                              <1> read_pel_mask:
  8321                              <1> 	; 10/08/2016
  8322                              <1> 	; Output: BL = mask value 
  8323 000036BA 66BAC603            <1> 	mov	dx, 3C6h ; VGAREG_PEL_MASK
  8324 000036BE EC                  <1> 	in	al, dx
  8325 000036BF 8844240C            <1> 	mov	[esp+12], al ; bl
  8326 000036C3 E92DE4FFFF          <1> 	jmp	VIDEO_RETURN
  8327                              <1> 
  8328                              <1> read_single_dac_reg:
  8329                              <1> 	; 02/08/2022
  8330                              <1> 	; 10/08/2016
  8331                              <1> 	; Read One DAC Color Register
  8332                              <1> 	; INPUT:
  8333                              <1> 	; BX = color register to read (0-255)
  8334                              <1> 	; OUTPUT:
  8335                              <1> 	; CH = green value (00h-3Fh)
  8336                              <1>         ; CL = blue value  (00h-3Fh)
  8337                              <1>         ; DH = red value   (00h-3Fh)
  8338                              <1> 
  8339 000036C8 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  8340 000036CC 88D8                <1> 	mov	al, bl
  8341 000036CE EE                  <1> 	out	dx, al
  8342                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
  8343                              <1> 	; 02/08/2022
  8344 000036CF B2C9                <1> 	mov	dl, 0C9h
  8345 000036D1 EC                  <1> 	in	al, dx
  8346 000036D2 88442415            <1> 	mov	[esp+21], al ; dh
  8347 000036D6 EC                  <1> 	in	al, dx
  8348 000036D7 88C5                <1> 	mov	ch, al
  8349 000036D9 EC                  <1> 	in	al, dx
  8350 000036DA 88C1                <1> 	mov	cl, al
  8351 000036DC 66894C2410          <1> 	mov	[esp+16], cx ; cx
  8352 000036E1 E90FE4FFFF          <1> 	jmp	VIDEO_RETURN
  8353                              <1> 
  8354                              <1> read_all_dac_reg:
  8355                              <1> 	; 02/08/2022
  8356                              <1> 	; 12/08/2016
  8357                              <1> 	; 11/08/2016
  8358                              <1> 	; 10/08/2016
  8359                              <1> 	; Read a Block of DAC Color Registers
  8360                              <1>         ; BX = first DAC register to read (0-00FFh)
  8361                              <1>         ; ECX = number of registers to read (0-00FFh)
  8362                              <1>         ; EDX = addr of a buffer to hold R,G,B values
  8363                              <1> 	;	(CX*3 bytes long)
  8364                              <1> 
  8365 000036E6 89D7                <1> 	mov	edi, edx ; user buffer
  8366 000036E8 89CA                <1> 	mov	edx, ecx
  8367                              <1> 	;shl	dx, 1 ; *2
  8368                              <1> 	; 02/08/2022
  8369 000036EA D1E2                <1> 	shl	edx, 1
  8370 000036EC 01CA                <1> 	add	edx, ecx ; edx = 3*ecx
  8371 000036EE 89E5                <1> 	mov	ebp, esp
  8372 000036F0 89EE                <1> 	mov	esi, ebp
  8373 000036F2 29D6                <1> 	sub	esi, edx
  8374 000036F4 6683E6FC            <1> 	and	si, 0FFFCh ; (dword alignment)
  8375 000036F8 89F4                <1> 	mov	esp, esi
  8376 000036FA 52                  <1> 	push	edx ; 3*ecx
  8377 000036FB 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  8378 000036FF 88D8                <1> 	mov	al, bl
  8379 00003701 EE                  <1> 	out	dx, al
  8380 00003702 66BAC903            <1> 	mov	dx, 3C9h ; VGAREG_DAC_DATA
  8381 00003706 89F3                <1> 	mov	ebx, esi
  8382                              <1> read_dac_loop:
  8383 00003708 EC                  <1> 	in	al, dx
  8384 00003709 8803                <1> 	mov	[ebx], al
  8385 0000370B 43                  <1> 	inc	ebx
  8386 0000370C EC                  <1> 	in	al, dx
  8387 0000370D 8803                <1> 	mov	[ebx], al
  8388 0000370F 43                  <1> 	inc	ebx
  8389 00003710 EC                  <1> 	in	al, dx
  8390 00003711 8803                <1> 	mov	[ebx], al
  8391 00003713 43                  <1> 	inc	ebx
  8392                              <1> 	;dec	cx
  8393                              <1> 	; 02/08/2022
  8394 00003714 49                  <1> 	dec	ecx
  8395 00003715 75F1                <1> 	jnz	short read_dac_loop
  8396 00003717 59                  <1> 	pop	ecx ; 3*ecx
  8397                              <1> 	; ECX = transfer (byte) count
  8398                              <1> 	; ESI = source address in system space
  8399                              <1> 	; EDI = user's buffer address
  8400 00003718 E83CD60000          <1> 	call	transfer_to_user_buffer
  8401 0000371D 89EC                <1> 	mov	esp, ebp
  8402 0000371F E9D1E3FFFF          <1> 	jmp	VIDEO_RETURN
  8403                              <1> 
  8404                              <1> set_single_dac_reg:
  8405                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
  8406                              <1> 	; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop)
  8407                              <1> 	; 10/08/2016
  8408                              <1> 	; Set One DAC Color Register
  8409                              <1> 	; BX = color register to set (0-255)
  8410                              <1>         ; CH = green value (00h-3Fh)
  8411                              <1>         ; CL = blue value  (00h-3Fh)
  8412                              <1>         ; DH = red value   (00h-3Fh)
  8413                              <1> 
  8414                              <1> 	;push	dx
  8415                              <1> 	; 12/04/2021
  8416 00003724 52                  <1> 	push	edx
  8417 00003725 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
  8418 00003729 88D8                <1> 	mov	al, bl
  8419 0000372B EE                  <1> 	out	dx, al
  8420                              <1> 	;;mov	dx, 3C9h ; VGAREG_DAC_DATA
  8421                              <1> 	;inc	dx
  8422                              <1> 	; 03/08/2022
  8423 0000372C FEC2                <1> 	inc	dl
  8424                              <1> 	;pop	ax
  8425                              <1> 	; 12/04/2021
  8426 0000372E 58                  <1> 	pop	eax
  8427 0000372F 88E0                <1> 	mov	al, ah
  8428 00003731 EE                  <1> 	out	dx, al
  8429 00003732 88E8                <1> 	mov	al, ch
  8430 00003734 EE                  <1> 	out	dx, al
  8431 00003735 88C8                <1> 	mov	al, cl
  8432 00003737 EE                  <1> 	out	dx, al
  8433 00003738 E9B8E3FFFF          <1> 	jmp	VIDEO_RETURN
  8434                              <1> 
  8435                              <1> set_all_dac_reg:
  8436                              <1> 	; 02/08/2022 
  8437                              <1> 	; 12/08/2016
  8438                              <1> 	; 11/08/2016
  8439                              <1> 	; 10/08/2016
  8440                              <1> 	; Set a Block of DAC Color Register
  8441                              <1> 	; BX = first DAC register to set (0-00FFh)
  8442                              <1> 	; ECX = number of registers to set (0-00FFh)
  8443                              <1> 	; EDX = addr of a table of R,G,B values 
  8444                              <1> 	;	(it will be CX*3 bytes long)
  8445                              <1> 
  8446 0000373D 89D6                <1> 	mov	esi, edx ; user buffer
  8447 0000373F 89CA                <1> 	mov	edx, ecx
  8448                              <1> 	;shl	cx, 1 ; *2
  8449                              <1> 	; 02/08/2022
  8450 00003741 D1E1                <1> 	shl	ecx, 1
  8451 00003743 01D1                <1> 	add	ecx, edx ; ecx = 3*ecx
  8452 00003745 89E5                <1> 	mov	ebp, esp
  8453 00003747 89EF                <1> 	mov	edi, ebp
  8454 00003749 29CF                <1> 	sub	edi, ecx
  8455 0000374B 6683E7FC            <1> 	and	di, 0FFFCh ; (dword alignment)
  8456 0000374F 89FC                <1> 	mov	esp, edi
  8457 00003751 E84DD60000          <1> 	call	transfer_from_user_buffer
  8458                              <1> 	;jc	VIDEO_RETURN
  8459                              <1> 
  8460 00003756 89D1                <1> 	mov	ecx, edx
  8461 00003758 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
  8462 0000375C 88D8                <1> 	mov	al, bl
  8463 0000375E EE                  <1> 	out	dx, al
  8464                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
  8465                              <1> 	; 02/08/2022
  8466 0000375F FEC2                <1> 	inc	dl
  8467                              <1> set_dac_loop:
  8468 00003761 8A07                <1> 	mov	al, [edi]
  8469 00003763 EE                  <1> 	out	dx, al
  8470 00003764 47                  <1> 	inc	edi
  8471 00003765 8A07                <1> 	mov	al, [edi]
  8472 00003767 EE                  <1> 	out	dx, al
  8473 00003768 47                  <1> 	inc	edi
  8474 00003769 8A07                <1> 	mov	al, [edi]
  8475 0000376B EE                  <1> 	out	dx, al
  8476 0000376C 47                  <1> 	inc	edi
  8477                              <1> 	;dec	cx
  8478                              <1> 	; 02/08/2022
  8479 0000376D 49                  <1> 	dec	ecx
  8480 0000376E 75F1                <1> 	jnz	short set_dac_loop
  8481 00003770 89EC                <1> 	mov	esp, ebp
  8482 00003772 E97EE3FFFF          <1> 	jmp	VIDEO_RETURN
  8483                              <1> 
  8484                              <1> get_all_palette_reg:
  8485                              <1> 	; 03/08/2022
  8486                              <1> 	; 10/08/2016
  8487                              <1> 	; Read All Palette Registers
  8488                              <1> 	; EDX = Address of 17-byte buffer 
  8489                              <1> 	;	to receive data
  8490                              <1> 	
  8491 00003777 89D7                <1> 	mov	edi, edx
  8492 00003779 89E3                <1> 	mov	ebx, esp
  8493 0000377B 89DE                <1> 	mov	esi, ebx
  8494 0000377D 83EC14              <1> 	sub	esp, 20	 
  8495                              <1> 
  8496 00003780 B100                <1> 	mov	cl, 0
  8497                              <1> get_palette_loop:
  8498 00003782 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8499 00003786 EC                  <1> 	in	al, dx
  8500                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8501                              <1> 	; 03/08/2022
  8502 00003787 B2C0                <1> 	mov	dl, 0C0h
  8503 00003789 88C8                <1> 	mov	al, cl
  8504 0000378B EE                  <1> 	out	dx, al
  8505                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  8506                              <1> 	; 03/08/2022
  8507                              <1> 	;mov	dl, 0C1h
  8508 0000378C FEC2                <1> 	inc	dl
  8509 0000378E EC                  <1> 	in	al, dx
  8510 0000378F 8803                <1> 	mov	[ebx], al
  8511 00003791 43                  <1> 	inc	ebx
  8512 00003792 FEC1                <1> 	inc	cl
  8513 00003794 80F910              <1> 	cmp	cl, 10h
  8514 00003797 75E9                <1> 	jne	short get_palette_loop
  8515                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8516                              <1> 	; 03/08/2022
  8517 00003799 B2DA                <1> 	mov	dl, 0DAh
  8518 0000379B EC                  <1> 	in	al, dx
  8519                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8520                              <1> 	; 03/08/2022
  8521 0000379C B2C0                <1> 	mov	dl, 0C0h
  8522 0000379E B011                <1> 	mov	al, 11h
  8523 000037A0 EE                  <1> 	out	dx, al
  8524                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  8525                              <1> 	; 03/08/2022
  8526 000037A1 FEC2                <1> 	inc	dl ; dx = 3C1h
  8527 000037A3 EC                  <1> 	in	al, dx
  8528 000037A4 8803                <1> 	mov	[ebx], al
  8529                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8530                              <1> 	; 03/08/2022
  8531 000037A6 B2DA                <1> 	mov	dl, 0DAh
  8532 000037A8 EC                  <1> 	in	al, dx
  8533                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8534                              <1> 	; 03/08/2022
  8535 000037A9 B2C0                <1> 	mov	dl, 0C0h
  8536 000037AB B020                <1> 	mov	al, 20h
  8537 000037AD EE                  <1> 	out	dx, al
  8538                              <1> 	; ifdef VBOX
  8539                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8540                              <1> 	; 03/08/2022
  8541 000037AE B2DA                <1> 	mov	dl, 0DAh
  8542 000037B0 EC                  <1> 	in	al, dx
  8543                              <1> 	; endif ; VBOX
  8544                              <1> 
  8545                              <1> 	;mov	ecx, 17 ; transfer (byte) count
  8546                              <1> 	; 03/08/2022
  8547 000037B1 29C9                <1> 	sub	ecx, ecx
  8548 000037B3 B111                <1> 	mov	cl, 17	
  8549                              <1> 
  8550                              <1> 	; ESI = source address in system space
  8551                              <1> 	; EDI = user's buffer address
  8552 000037B5 E89FD50000          <1> 	call	transfer_to_user_buffer
  8553                              <1> 
  8554 000037BA 83C414              <1> 	add	esp, 20
  8555 000037BD E933E3FFFF          <1> 	jmp	VIDEO_RETURN
  8556                              <1> 
  8557                              <1> select_video_dac_color_page:
  8558                              <1> 	; 02/08/2022 (TRDOS 386 v2.0.5, code optimization)
  8559                              <1> 	; 12/04/2021 (TRDOS 386 v2.0.3, 32 bit push/pop)
  8560                              <1> 	; 10/08/2016
  8561                              <1> 	; DAC Color Paging Functions
  8562                              <1> 	; BL = 00H = select color paging mode
  8563                              <1>         ;       BH = paging mode
  8564                              <1>         ;            00h = 4 blocks of 64 registers
  8565                              <1>         ;            01h = 16 blocks of 16 registers
  8566                              <1> 	; BL = 01H = activate color page
  8567                              <1>         ;       BH = DAC color page number
  8568                              <1>         ;            00h-03h (4-page/64-reg mode)
  8569                              <1>         ;            00h-0Fh (16-page/16-reg mode)
  8570                              <1> 
  8571 000037C2 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8572 000037C6 EC                  <1> 	in	al, dx
  8573                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8574                              <1> 	; 02/08/2022
  8575 000037C7 B240                <1> 	mov	dl, 40h
  8576 000037C9 B010                <1> 	mov	al, 10h
  8577 000037CB EE                  <1> 	out	dx, al
  8578                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  8579                              <1> 	; 02/08/2022
  8580 000037CC FEC2                <1> 	inc	dl ; mov dl, 0C1h
  8581 000037CE EC                  <1> 	in	al, dx
  8582 000037CF 80E301              <1> 	and	bl, 01h
  8583 000037D2 750C                <1> 	jnz	short set_dac_page
  8584 000037D4 247F                <1> 	and	al, 07Fh
  8585 000037D6 C0E707              <1> 	shl	bh, 7
  8586 000037D9 08F8                <1> 	or	al, bh
  8587                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8588                              <1> 	; 02/08/2022
  8589 000037DB FECA                <1> 	dec	dl ; mov dl, 0C0h
  8590 000037DD EE                  <1> 	out	dx, al
  8591 000037DE EB19                <1> 	jmp	short set_actl_normal
  8592                              <1> set_dac_page:
  8593                              <1> 	;push	ax
  8594                              <1> 	; 12/04/2021
  8595 000037E0 50                  <1> 	push	eax
  8596 000037E1 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8597 000037E5 EC                  <1> 	in	al, dx
  8598                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8599                              <1> 	; 02/08/2022
  8600 000037E6 B2C0                <1> 	mov	dl, 0C0h
  8601 000037E8 B014                <1> 	mov	al, 14h
  8602 000037EA EE                  <1> 	out	dx, al
  8603                              <1> 	;pop	ax
  8604                              <1> 	; 12/04/2021
  8605 000037EB 58                  <1> 	pop	eax
  8606 000037EC 2480                <1> 	and	al, 80h
  8607 000037EE 7503                <1> 	jnz	short set_dac_16_page
  8608 000037F0 C0E702              <1> 	shl	bh, 2
  8609                              <1> set_dac_16_page:
  8610 000037F3 80E70F              <1> 	and	bh, 0Fh
  8611 000037F6 88F8                <1> 	mov	al, bh
  8612 000037F8 EE                  <1> 	out	dx, al
  8613                              <1> set_actl_normal:
  8614 000037F9 B020                <1> 	mov	al, 20h
  8615 000037FB EE                  <1> 	out	dx, al
  8616                              <1> 	; ifdef VBOX
  8617                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8618                              <1> 	; 02/08/2022
  8619 000037FC B2DA                <1> 	mov	dl, 0DAh
  8620 000037FE EC                  <1> 	in	al, dx
  8621                              <1> 	; endif ; VBOX
  8622 000037FF E9F1E2FFFF          <1> 	jmp	VIDEO_RETURN
  8623                              <1> 
  8624                              <1> read_video_dac_state:
  8625                              <1> 	; 10/08/2016
  8626                              <1> 	; Query DAC Color Paging State
  8627                              <1> 	; Output:
  8628                              <1> 	; BH = current active DAC color page
  8629                              <1>         ; BL = current active DAC paging mode
  8630                              <1> 
  8631 00003804 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8632 00003808 EC                  <1> 	in	al, dx
  8633 00003809 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8634 0000380D B010                <1> 	mov	al, 10h
  8635 0000380F EE                  <1> 	out	dx, al
  8636 00003810 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  8637 00003814 EC                  <1> 	in	al, dx
  8638 00003815 88C3                <1> 	mov	bl, al
  8639 00003817 C0EB07              <1> 	shr	bl, 7
  8640 0000381A 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8641 0000381E EC                  <1> 	in	al, dx
  8642 0000381F 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8643 00003823 B014                <1> 	mov	al, 14h
  8644 00003825 EE                  <1> 	out	dx, al
  8645 00003826 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  8646 0000382A EC                  <1> 	in	al, dx
  8647 0000382B 88C7                <1> 	mov	bh, al
  8648 0000382D 80E70F              <1> 	and	bh, 0Fh
  8649 00003830 F6C301              <1> 	test	bl, 01
  8650 00003833 7503                <1> 	jnz	short get_dac_16_page
  8651 00003835 C0EF02              <1> 	shr	bh, 2
  8652                              <1> get_dac_16_page:
  8653 00003838 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8654 0000383C EC                  <1> 	in	al, dx
  8655 0000383D 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  8656 00003841 B020                <1> 	mov	al, 20h
  8657 00003843 EE                  <1> 	out	dx, al
  8658                              <1> 	; ifdef VBOX
  8659 00003844 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  8660 00003848 EC                  <1> 	in	al, dx
  8661                              <1> 	; endif ; VBOX 
  8662 00003849 66895C240C          <1> 	mov	[esp+12], bx ; bx
  8663 0000384E E9A2E2FFFF          <1> 	jmp	VIDEO_RETURN
  8664                              <1> 
  8665                              <1> ; 23/11/2020 - TRDOS 386 v2.0.3
  8666                              <1> ; VBE 2 BOCHS/QEMU emulator extensions 
  8667                              <1> ;	for TRDOS 386 v2 kernel (video bios)
  8668                              <1> 
  8669                              <1> ; BOCH/QEMU VBE2 VGA BIOS code 
  8670                              <1> ;	by Jeroen Janssen (2002)
  8671                              <1> ;	by Volker Rupper (2003-2020)
  8672                              <1> ; vbe.c (02/01/2020) 
  8673                              <1> 
  8674                              <1> ; vbe.h (02/01/2020)
  8675                              <1> 
  8676                              <1> VBE_DISPI_BANK_ADDRESS	equ	0A0000h
  8677                              <1> VBE_DISPI_BANK_SIZE_KB	equ	64
  8678                              <1> 
  8679                              <1> VBE_DISPI_MAX_XRES	equ	2560
  8680                              <1> VBE_DISPI_MAX_YRES	equ	1600
  8681                              <1> 
  8682                              <1> VBE_DISPI_IOPORT_INDEX	equ	01CEh
  8683                              <1> VBE_DISPI_IOPORT_DATA	equ	01CFh
  8684                              <1> 
  8685                              <1> VBE_DISPI_INDEX_ID	equ	00h
  8686                              <1> VBE_DISPI_INDEX_XRES	equ	01h
  8687                              <1> VBE_DISPI_INDEX_YRES	equ	02h
  8688                              <1> VBE_DISPI_INDEX_BPP	equ	03h
  8689                              <1> VBE_DISPI_INDEX_ENABLE	equ	04h
  8690                              <1> VBE_DISPI_INDEX_BANK	equ	05h
  8691                              <1> VBE_DISPI_INDEX_VIRT_WIDTH equ	06h
  8692                              <1> VBE_DISPI_INDEX_VIRT_HEIGHT equ	07h
  8693                              <1> VBE_DISPI_INDEX_X_OFFSET equ	08h
  8694                              <1> VBE_DISPI_INDEX_Y_OFFSET equ	09h
  8695                              <1> VBE_DISPI_INDEX_VIDEO_MEMORY_64K equ 0Ah
  8696                              <1> VBE_DISPI_INDEX_DDC	equ	0Bh
  8697                              <1> 
  8698                              <1> VBE_DISPI_ID0		equ	0B0C0h
  8699                              <1> VBE_DISPI_ID1		equ	0B0C1h
  8700                              <1> VBE_DISPI_ID2		equ	0B0C2h
  8701                              <1> VBE_DISPI_ID3		equ	0B0C3h
  8702                              <1> VBE_DISPI_ID4		equ	0B0C4h
  8703                              <1> VBE_DISPI_ID5		equ	0B0C5h
  8704                              <1> 
  8705                              <1> VBE_DISPI_DISABLED	equ	00h
  8706                              <1> VBE_DISPI_ENABLED	equ	01h
  8707                              <1> VBE_DISPI_GETCAPS	equ	02h
  8708                              <1> VBE_DISPI_8BIT_DAC	equ	20h
  8709                              <1> VBE_DISPI_LFB_ENABLED	equ	40h
  8710                              <1> VBE_DISPI_NOCLEARMEM	equ	80h
  8711                              <1> 
  8712                              <1> VBE_DISPI_LFB_PHYSICAL_ADDRESS equ 0E0000000h
  8713                              <1> 
  8714                              <1> ; ***
  8715                              <1> 
  8716                              <1> ;// VBE Return Status Info
  8717                              <1> ;// AL
  8718                              <1> VBE_RETURN_STATUS_SUPPORTED	equ	4Fh
  8719                              <1> VBE_RETURN_STATUS_UNSUPPORTED	equ	00h
  8720                              <1> ;// AH
  8721                              <1> VBE_RETURN_STATUS_SUCCESSFULL	equ	00h
  8722                              <1> VBE_RETURN_STATUS_FAILED	equ	01h
  8723                              <1> VBE_RETURN_STATUS_NOT_SUPPORTED	equ	02h
  8724                              <1> VBE_RETURN_STATUS_INVALID	equ	03h
  8725                              <1> 
  8726                              <1> ;// VBE Mode Numbers
  8727                              <1> 
  8728                              <1> VBE_MODE_VESA_DEFINED		equ	0100h
  8729                              <1> VBE_MODE_REFRESH_RATE_USE_CRTC	equ	0800h
  8730                              <1> VBE_MODE_LINEAR_FRAME_BUFFER	equ	4000h
  8731                              <1> VBE_MODE_PRESERVE_DISPLAY_MEMORY equ	8000h
  8732                              <1> 
  8733                              <1> ;// Mode Attributes
  8734                              <1> 
  8735                              <1> VBE_MODE_ATTRIBUTE_SUPPORTED		   equ	0001h
  8736                              <1> VBE_MODE_ATTRIBUTE_EXTENDED_INFO_AVAILABLE equ	0002h
  8737                              <1> VBE_MODE_ATTRIBUTE_COLOR_MODE		   equ	0008h
  8738                              <1> VBE_MODE_ATTRIBUTE_GRAPHICS_MODE	   equ	0010h
  8739                              <1> VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE equ	0080h
  8740                              <1> VBE_MODE_ATTRIBUTE_DOUBLE_SCAN_MODE	   equ	0100h
  8741                              <1> VBE_MODE_ATTRIBUTE_INTERLACE_MODE	   equ	0200h
  8742                              <1> 
  8743                              <1> ;// Window attributes
  8744                              <1> 
  8745                              <1> VBE_WINDOW_ATTRIBUTE_RELOCATABLE equ	01h
  8746                              <1> VBE_WINDOW_ATTRIBUTE_READABLE	 equ	02h
  8747                              <1> VBE_WINDOW_ATTRIBUTE_WRITEABLE	 equ	04h
  8748                              <1> 
  8749                              <1> ;/* Video memory */
  8750                              <1> VGAMEM_GRAPH equ 0A000h
  8751                              <1> VGAMEM_CTEXT equ 0B800h
  8752                              <1> ;VGAMEM_MTEXT equ 0B000h
  8753                              <1> 
  8754                              <1> ;// Memory model
  8755                              <1> 
  8756                              <1> ;VBE_MEMORYMODEL_TEXT_MODE	equ	00h
  8757                              <1> ;VBE_MEMORYMODEL_CGA_GRAPHICS	equ	01h
  8758                              <1> ;VBE_MEMORYMODEL_PLANAR		equ	03h
  8759                              <1> VBE_MEMORYMODEL_PACKED_PIXEL	equ	04h
  8760                              <1> ;VBE_MEMORYMODEL_NON_CHAIN_4_256 equ	05h
  8761                              <1> VBE_MEMORYMODEL_DIRECT_COLOR	equ	06h
  8762                              <1> ;VBE_MEMORYMODEL_YUV		equ	07h
  8763                              <1> 
  8764                              <1> ;// DirectColorModeInfo
  8765                              <1> 
  8766                              <1> ;VBE_DIRECTCOLOR_COLOR_RAMP_PROGRAMMABLE equ 01h
  8767                              <1> VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE equ 02h
  8768                              <1> 
  8769                              <1> VBE_DISPI_TOTAL_VIDEO_MEMORY_MB	equ 16
  8770                              <1> 
  8771                              <1> ; 24/11/2020
  8772                              <1> ; vbe.c
  8773                              <1> 
  8774                              <1> %if 1
  8775                              <1> 
  8776                              <1> _vbe_biosfn_return_mode_info:
  8777                              <1> 	; 15/12/2020
  8778                              <1> 	; 12/12/2020
  8779                              <1> 	; Return VBE Mode Information	
  8780                              <1> 	; (call from 'sysvideo')
  8781                              <1> 	;
  8782                              <1> 	; Input:
  8783                              <1> 	;	cx = video (bios) mode
  8784                              <1> 	; Output:
  8785                              <1> 	;	cf = 0 -> (successful)
  8786                              <1> 	;	   MODE_INFO_LIST addr contains MODEINFO
  8787                              <1> 	;	cf = 1 -> error
  8788                              <1> 	;
  8789                              <1> 	; Modified registers: eax, edx, edi
  8790                              <1> 	;
  8791                              <1> 
  8792                              <1> 	; pushes for subroutine stack pops compatibility
  8793                              <1> 	
  8794                              <1> 	;push	ds  ; *
  8795                              <1> 	;push	es  ; **
  8796                              <1> 
  8797 00003853 55                  <1> 	push	ebp ; ***
  8798 00003854 56                  <1> 	push	esi ; **** 
  8799                              <1> 	
  8800 00003855 31FF                <1> 	xor	edi, edi  ; mov edi, 0
  8801                              <1> 
  8802 00003857 803D[79090000]03    <1> 	cmp	byte [vbe3], 3
  8803 0000385E 7221                <1> 	jb	short _vbe_rmi_1
  8804                              <1> 
  8805                              <1> 	;sub	edi, edi  ; 0 = kernel call (sign)
  8806                              <1> 	;	; no transfer to user's buffer
  8807                              <1> 	
  8808                              <1> 	; cx = Video mode (for 4F01h, with LFB flag)
  8809                              <1> 
  8810 00003860 66B8014F            <1> 	mov	ax, 4F01h
  8811                              <1> 
  8812 00003864 E83EE0FFFF          <1> 	call	_vbe3_pmfn_return_mode_info
  8813                              <1> 
  8814 00003869 6683F84F            <1> 	cmp	ax, 004Fh
  8815 0000386D 7533                <1> 	jne	short _vbe_rmi_2 ; fail
  8816                              <1> 
  8817                              <1> 	; 15/12/2020
  8818                              <1> 	; cx = vbe video mode
  8819 0000386F 80E501              <1> 	and	ch, 01h ; clear LFB flag
  8820 00003872 BEFE7B0900          <1> 	mov	esi, VBE3MODEINFOBLOCK - 2
  8821 00003877 66890E              <1> 	mov	[esi], cx ; MODEINFO.mode
  8822 0000387A E8A5000000          <1> 	call	set_lfbinfo_table
  8823 0000387F EB22                <1> 	jmp	short _vbe_rmi_3  ; cf = 0 
  8824                              <1> _vbe_rmi_1:
  8825 00003881 803D[79090000]02    <1> 	cmp	byte [vbe3], 2
  8826 00003888 7219                <1> 	jb	short _vbe_rmi_3 ; cf = 1
  8827 0000388A A0[7A090000]        <1> 	mov	al, [vbe2bios] ; 0C0h-0C5h for emu (*)
  8828 0000388F 3CC0                <1> 	cmp	al, 0C0h ; BOCHS/QEMU/VIRTUALBOX (*) ? 
  8829 00003891 7210                <1> 	jb	short _vbe_rmi_3  ; cf = 1
  8830 00003893 3CC5                <1> 	cmp	al, 0C5h ; (*)
  8831 00003895 770B                <1> 	ja	short _vbe_rmi_2 ; unknown vbios !? 
  8832                              <1> 	
  8833                              <1> 	;xor	edi, edi  ; 0 = kernel call (sign)
  8834                              <1> 	;	; no transfer to user's buffer
  8835                              <1> 
  8836                              <1> 	;mov	ax, 4F01h
  8837                              <1> 
  8838                              <1> 	; cx = Video mode (for 4F01h, with LFB flag)
  8839                              <1> 
  8840 00003897 E80A000000          <1> 	call	vbe_biosfn_return_mode_info
  8841 0000389C 6683F84F            <1> 	cmp	ax, 004Fh ; successful ?
  8842 000038A0 7401                <1> 	je	short _vbe_rmi_3  ; cf = 0
  8843                              <1> _vbe_rmi_2:
  8844 000038A2 F9                  <1> 	stc
  8845                              <1> 	; cf = 1	
  8846                              <1> _vbe_rmi_3:
  8847 000038A3 5E                  <1> 	pop	esi ; ****
  8848 000038A4 5D                  <1> 	pop	ebp ; ***
  8849                              <1> 	
  8850                              <1> 	;pop	es  ; **
  8851                              <1> 	;pop	ss  ; *
  8852                              <1> 	
  8853 000038A5 C3                  <1> 	retn
  8854                              <1> 
  8855                              <1> 
  8856                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
  8857                              <1> ; * ---------------------------------------------------------
  8858                              <1> ; * Function 01h - Return VBE Mode Information
  8859                              <1> ; * ---------------------------------------------------------
  8860                              <1> ; * Input:
  8861                              <1> ; *		AX = 4F01h
  8862                              <1> ; *		CX = Mode number
  8863                              <1> ; *    (ES:DI) EDI = Pointer to ModeInfoBlock structure	
  8864                              <1> ; * Output:
  8865                              <1> ; *		AX = VBE Return Status
  8866                              <1> ; * 
  8867                              <1> ; *----------------------------------------------------------
  8868                              <1> ; *
  8869                              <1> 
  8870                              <1> vbe_biosfn_return_mode_info:
  8871                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
  8872                              <1> 	; 15/12/2020 
  8873                              <1> 	; 14/12/2020
  8874                              <1> 	; 12/12/2020
  8875                              <1> 	; 11/12/2020 (TRDOS 386 v2.0.3)
  8876                              <1> 	;
  8877                              <1> 	; Input:
  8878                              <1> 	;	cx = video (bios) mode
  8879                              <1> 	;      edi = ModeInfoBlock buffer address
  8880                              <1> 	;	     (in user's memory space)
  8881                              <1> 	;      (ax = 4F01h)
  8882                              <1> 	; Output:
  8883                              <1> 	;	ax = 004Fh (successful)
  8884                              <1> 	;	ah > 0 -> error
  8885                              <1> 	;
  8886                              <1> 	; Modified registers: esi
  8887                              <1> 
  8888                              <1> 	;;push	ds  ; *
  8889                              <1> 	;;push	es  ; **
  8890                              <1> 	;;push	ebp ; ***
  8891                              <1> 	;;push	esi ; **** 
  8892                              <1> 
  8893 000038A6 F6C501              <1> 	test	ch, 1
  8894 000038A9 7505                <1> 	jnz	short vbe_rmi_1
  8895                              <1> 
  8896                              <1> 	; mode number < 100h
  8897                              <1> 	; CGA/VGA mode is not proper this VBE function 
  8898                              <1> 
  8899 000038AB 29C0                <1> 	sub	eax, eax
  8900                              <1> vbe_rmi_0:	
  8901                              <1> 	;mov	ax, 0100h  ; Function is not supported
  8902 000038AD B401                <1> 	mov	ah, 1
  8903 000038AF C3                  <1> 	retn
  8904                              <1> vbe_rmi_1:
  8905 000038B0 52                  <1> 	push	edx ; *****
  8906 000038B1 51                  <1> 	push	ecx ; ******
  8907 000038B2 53                  <1> 	push	ebx ; *******	
  8908 000038B3 57                  <1> 	push	edi ; ********
  8909                              <1> 	
  8910                              <1> 	; 14/12/2020
  8911 000038B4 89CB                <1> 	mov	ebx, ecx
  8912                              <1>  			
  8913                              <1> 	;xor	eax, eax
  8914 000038B6 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
  8915 000038B9 883D[D10F0300]      <1> 	mov	[vbe_mode_x], bh
  8916                              <1> 	;and	bx, 1FFh
  8917 000038BF 80E701              <1> 	and	bh, 1
  8918                              <1> 	;mov	bh, 1
  8919                              <1> 
  8920                              <1> 	; Alternative 2 (instead of 'Mode_info_find_mode')
  8921 000038C2 E86A060000          <1> 	call	set_mode_info_list ; (alternative 2)
  8922                              <1> 
  8923                              <1> 	; eax = 0	
  8924                              <1> 
  8925                              <1> 	;mov	bx, [esi] ; mode
  8926                              <1> 
  8927                              <1> 	; Alternative 1 (instead of 'set_mode_info_list')
  8928                              <1> 	;call	mode_info_find_mode ; (alternative 1)
  8929                              <1> 
  8930 000038C7 09F6                <1> 	or	esi, esi
  8931                              <1> 	; 14/12/2020
  8932 000038C9 744C                <1> 	jz	short vbe_rmi_4	; VBE mode number is wrong
  8933                              <1> 				; or it is not supported
  8934                              <1> 
  8935                              <1> 	; 15/12/2020
  8936                              <1> 	;mov	bx, [esi] ; mode
  8937                              <1> 
  8938                              <1> 	; 12/12/2020
  8939                              <1> 	;call	set_lfbinfo_table
  8940                              <1> 
  8941 000038CB F605[D10F0300]40    <1> 	test	byte [vbe_mode_x], 40h ; LFB model ?
  8942 000038D2 7404                <1> 	jz	short vbe_rmi_2
  8943                              <1> 	
  8944 000038D4 C6461C01            <1> 	mov	byte [esi+MODEINFO.NumberOfBanks], 1
  8945                              <1> vbe_rmi_2:
  8946                              <1> 	; (vbe.c, 02/01/2020, vruppert)
  8947                              <1> 	; 11/12/2020 (Erdogan Tan, video.s) 
  8948                              <1> 	; Bochs Graphics Adapter
  8949                              <1> 	; vendor_id: 1111h, device id: 1234h
  8950                              <1> 
  8951 000038D8 E835070000          <1> 	call	pci_get_lfb_addr
  8952                              <1> 	;or	eax, eax
  8953 000038DD 7404                <1> 	jz	short vbe_rmi_3
  8954                              <1> 	; zf = 0, ax > 0 (high word of LFB address)
  8955                              <1> 	; set/change LFB address in MODEINFO structure
  8956 000038DF 6689462C            <1> 	mov	[esi+MODEINFO.PhysBasePtr+2], ax
  8957                              <1> 	; 12/12/2020
  8958                              <1> 	;mov	[edi+LFBINFO.LFB_addr+2], ax
  8959                              <1> vbe_rmi_3:
  8960                              <1> 	;test	byte [esi+MODEINFO.WinAAttributes], 1 
  8961                              <1> 	;		; VBE_WINDOW_ATTRIBUTE_RELOCATABLE = 1
  8962                              <1>         ;jz	short vbe_rmi_4
  8963                              <1> 	;; 11/12/2020
  8964                              <1> 	;; In fact, this is far call address in (Bochs/BGA) Video Bios
  8965                              <1> 	;; Direct user access to kernel subroutines is not possible 
  8966                              <1> 	;; in TRDOS 386. Also, TRDOS 386 kernel will support only LFB.
  8967                              <1> 	;; Bank select may be a seperate sysvideo function in future
  8968                              <1> 	;; (if it will be required).
  8969                              <1> 	;mov	dword [esi+MODEINFO.WinFuncPtr], dispi_set_bank_farcall
  8970                              <1> ;vbe_rmi_4:
  8971                              <1> 	; 12/12/2020
  8972 000038E3 E83C000000          <1> 	call	set_lfbinfo_table
  8973                              <1> 
  8974                              <1> 	; 11/12/2020
  8975                              <1> 	; copy 68 bytes of MODE_INFO_LIST to user
  8976                              <1> 
  8977 000038E8 8B3C24              <1> 	mov	edi, [esp]  ; user's buffer address
  8978                              <1> 	; 12/12/2020
  8979 000038EB 09FF                <1> 	or	edi, edi ; 0 = kernel call 
  8980                              <1> 			 ; (call from '_vbe_biosfn_return_mode_info')
  8981 000038ED 7431                <1> 	jz	short vbe_rmi_6
  8982                              <1> 
  8983                              <1> 	; 15/12/2020
  8984                              <1> 	; prepare 256 bytes MODEINFO buffer at VBE3MODEINFOBLOCK
  8985                              <1> 	; and then, copy buffer conttent to user's buffer
  8986 000038EF 57                  <1> 	push	edi
  8987 000038F0 BE[F00F0300]        <1> 	mov	esi, MODE_INFO_LIST + 2	; MODEINFO.ModeAttributes
  8988 000038F5 BF007C0900          <1> 	mov	edi, VBE3MODEINFOBLOCK
  8989                              <1> 	;mov	ecx, 66/4  ; 66 bytes
  8990                              <1> 	; 03/08/2022
  8991 000038FA 29C9                <1> 	sub	ecx, ecx
  8992 000038FC B110                <1> 	mov	cl, 66/4
  8993 000038FE F3A5                <1> 	rep	movsd
  8994 00003900 31C0                <1> 	xor	eax, eax
  8995 00003902 B12F                <1> 	mov	cl, (256-68)/4 ; 188 bytes
  8996 00003904 F3AB                <1> 	rep	stosd
  8997 00003906 66AB                <1> 	stosw	; 2 bytes
  8998 00003908 5F                  <1> 	pop	edi
  8999 00003909 BE007C0900          <1> 	mov	esi, VBE3MODEINFOBLOCK
  9000                              <1> 	;mov	cx, 256 
  9001 0000390E FEC5                <1> 	inc	ch ; cx = 256
  9002 00003910 E844D40000          <1> 	call	transfer_to_user_buffer
  9003 00003915 7309                <1> 	jnc	short vbe_rmi_5
  9004                              <1> vbe_rmi_4:
  9005                              <1> 	;mov	eax, 014Fh ; fail/error
  9006 00003917 31C0                <1> 	xor	eax, eax
  9007 00003919 B401                <1> 	mov	ah, 01h
  9008                              <1> 	;jmp	short vbe_rmi_6
  9009 0000391B E981000000          <1> 	jmp	vbe_sm_ret1 ; 11/12/2020
  9010                              <1> vbe_rmi_5:
  9011                              <1> 	; 256 bytes of MODEINFO have been transferred to user
  9012                              <1> 	;mov	eax, 4Fh ; succesfull
  9013                              <1> vbe_rmi_6: ; 12/12/2020
  9014 00003920 31C0                <1> 	xor	eax, eax
  9015                              <1> ;vbe_rmi_6:
  9016 00003922 EB7D                <1> 	jmp	vbe_sm_ret1 ; 11/12/2020
  9017                              <1> 
  9018                              <1> 	;pop	edi ; ********
  9019                              <1> 	;pop	ebx ; *******
  9020                              <1> 	;pop	ecx ; ******
  9021                              <1> 	;pop	edx ; *****	
  9022                              <1> 	
  9023                              <1> 	;;pop	esi ; ****
  9024                              <1> 	;;pop	ebp ; ***
  9025                              <1> 	;;pop	es  ; **
  9026                              <1> 	;;pop	ds  ; * 
  9027                              <1> 
  9028                              <1> 	;retn
  9029                              <1> 
  9030                              <1> set_lfbinfo_table:
  9031                              <1> 	; 19/12/2020
  9032                              <1> 	; 11/12/2020
  9033                              <1> 	; Set/Fill LFBINFO structure/table
  9034                              <1> 	;
  9035                              <1> 	; Input:
  9036                              <1> 	;	esi = Mode info list address 
  9037                              <1> 	; Output:
  9038                              <1> 	;	LFB_Info address is filled with LFBINFO
  9039                              <1> 	;	edi = LFB_Info address
  9040                              <1> 	;
  9041                              <1> 	; Modified registers: eax, edx (=0), edi
  9042                              <1> 
  9043 00003924 BF[DE0F0300]        <1> 	mov	edi, LFB_Info
  9044 00003929 8B462A              <1> 	mov	eax, [esi+MODEINFO.PhysBasePtr]
  9045 0000392C 894702              <1> 	mov	[edi+LFBINFO.LFB_addr], eax ; LFB address
  9046                              <1> 	;mov	ax, [esi+MODEINFO.mode]
  9047 0000392F 668B06              <1> 	mov	ax, [esi]
  9048 00003932 668907              <1> 	mov	[edi+LFBINFO.mode],ax
  9049 00003935 8A461B              <1> 	mov	al, [esi+MODEINFO.BitsPerPixel]
  9050 00003938 88470E              <1> 	mov	[edi+LFBINFO.bpp], al
  9051 0000393B 29C0                <1> 	sub	eax, eax
  9052 0000393D 668B4614            <1> 	mov	ax, [esi+MODEINFO.XResolution]
  9053 00003941 6689470A            <1> 	mov	[edi+LFBINFO.X_res], ax
  9054 00003945 89C2                <1> 	mov	edx, eax ; 19/12/2020
  9055 00003947 668B4616            <1> 	mov	ax, [esi+MODEINFO.YResolution]
  9056 0000394B 6689470C            <1> 	mov	[edi+LFBINFO.Y_res], ax
  9057                              <1> 	; eax = Y_res ; screen height
  9058                              <1> 	; 19/12/2020	
  9059 0000394F F7E2                <1> 	mul	edx ; X_res*Y_res
  9060                              <1> 	; edx = 0
  9061 00003951 8A570E              <1> 	mov	dl, [edi+LFBINFO.bpp]
  9062                              <1> 	; Note:
  9063                              <1> 	; Bits per pixel may be 8,16,24,32 for TRDOS 386 v2.
  9064                              <1> 	; (4 bits for pixel is not used for VESA modes here)
  9065 00003954 C0EA03              <1> 	shr	dl, 3 ; convert bits to byte
  9066 00003957 F7E2                <1> 	mul	edx
  9067                              <1> 	; eax = screen/page/buffer size in bytes
  9068 00003959 894706              <1> 	mov	[edi+LFBINFO.LFB_size], eax
  9069                              <1> 	; edx = 0
  9070                              <1> 	; clear reserved byte in LFBINFO structure/table
  9071 0000395C 88570F              <1> 	mov	[edi+LFBINFO.reserved], dl ; not necessary
  9072 0000395F C3                  <1> 	retn
  9073                              <1> 
  9074                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
  9075                              <1> ; * ---------------------------------------------------------
  9076                              <1> ; * Function 02h - Set VBE Mode
  9077                              <1> ; * ---------------------------------------------------------
  9078                              <1> ; * Input:
  9079                              <1> ; *		AX = 4F02h
  9080                              <1> ; *		BX = Desired Mode to set
  9081                              <1> ; * Output:
  9082                              <1> ; *		AX = VBE Return Status
  9083                              <1> ; * 
  9084                              <1> ; *----------------------------------------------------------
  9085                              <1> ; *
  9086                              <1> 
  9087                              <1> vbe_biosfn_set_mode:
  9088                              <1> 	; 07/03/2021
  9089                              <1> 	; 12/12/2020
  9090                              <1> 	; 11/12/2020 (LFBINFO table for VESA VBE modes)
  9091                              <1> 	; 27/11/2020
  9092                              <1> 	; 25/11/2020
  9093                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
  9094                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
  9095                              <1> 	;
  9096                              <1> 	; Input:
  9097                              <1> 	;	bx = video (bios) mode
  9098                              <1> 	;	ax = 4F02h
  9099                              <1> 	; Output:
  9100                              <1> 	;	ax = 004Fh (successful)
  9101                              <1> 	;	ah > 0 -> error
  9102                              <1> 	;
  9103                              <1> 	; Modified registers: esi
  9104                              <1> 
  9105                              <1> 	; 27/11/2020
  9106                              <1> 
  9107                              <1> 	;;push	ds  ; *
  9108                              <1> 	;;push	es  ; **
  9109                              <1> 	;;push	ebp ; ***
  9110                              <1> 	;;push	esi ; **** 
  9111                              <1> 	
  9112                              <1> 	; 11/12/2020 			
  9113 00003960 52                  <1> 	push	edx ; *****
  9114 00003961 51                  <1> 	push	ecx ; ******
  9115 00003962 53                  <1> 	push	ebx ; *******	
  9116 00003963 57                  <1> 	push	edi ; ********
  9117                              <1> 
  9118                              <1> 	;xor	eax, eax
  9119 00003964 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
  9120 00003967 883D[D10F0300]      <1> 	mov	[vbe_mode_x], bh
  9121 0000396D 80E701              <1> 	and	bh, 1
  9122 00003970 753C                <1> 	jnz	short vbe_sm_3  ; VESA VBE mode
  9123                              <1> 
  9124                              <1>  	;;test	bx, 4000h ; VBE_MODE_LINEAR_FRAME_BUFFER
  9125                              <1> 	;test	bh, 40h
  9126                              <1> 	;jz	short vbe_sm_0
  9127                              <1> 	;; lfb_flag
  9128                              <1> 	;mov	al, 40h	; VBE_DISPI_LFB_ENABLED
  9129                              <1> vbe_sm_0:
  9130                              <1> 	; 27/11/2020
  9131 00003972 B080                <1> 	mov	al, 80h
  9132                              <1> 	;test	bh, 80h ; VBE_MODE_PRESERVE_DISPLAY_MEMORY 	
  9133                              <1> 	;jnz	short vbe_sm_1 ; no_clear
  9134                              <1> 	;; clear
  9135                              <1> 	;sub	al, al ; 0
  9136 00003974 8405[D10F0300]      <1> 	test	[vbe_mode_x], al ; 80h
  9137 0000397A 7402                <1> 	jz	short vbe_sm_1 ; clear display memory
  9138                              <1> 	; no_clear
  9139 0000397C 08C3                <1> 	or	bl, al ; VBE_MODE_PRESERVE_DISPLAY_MEMORY
  9140                              <1> vbe_sm_1:
  9141                              <1> 	; check non vesa mode
  9142                              <1> 	;;cmp	bx, 100h ; VBE_MODE_VESA_DEFINED
  9143                              <1> 	;;jna	short vbe_sm_2
  9144                              <1> 	;and	bh, 1
  9145                              <1> 	;jnz	short vbe_sm_3 
  9146                              <1> 
  9147                              <1> 	; BX <= 1FFh
  9148                              <1> 
  9149                              <1> 	; 27/11/2020
  9150                              <1> 	;or	bl, al	; al = 80h if no_clear option is set 
  9151                              <1> 	;		; al = 0 if no_clear option is not set 
  9152                              <1> 
  9153                              <1> 	; 25/11/2020
  9154                              <1> 	; VBE DISPI will be disabled in 'biosfn_set_video_mode'
  9155                              <1>  
  9156                              <1> 	;xor	al, al ; 0 ; VBE_DISPI_DISABLED
  9157                              <1> 	;call	dispi_set_enable
  9158                              <1> 
  9159                              <1> 	; call the vgabios in order to set the video mode
  9160                              <1> 	; this allows for going back to textmode with a VBE call
  9161                              <1> 	; (some applications expect that to work)
  9162                              <1> 
  9163                              <1> 	;and	bx, 0FFh
  9164                              <1> 	
  9165                              <1> 	; 27/11/2020
  9166                              <1> biosfn_set_video_mode:
  9167                              <1> 	; _call: call subroutine
  9168                              <1> 	; 26/11/2020 (TRDOS 386 v2.0.3)
  9169                              <1> 	; (ref: vgabios.c, 02/01/2020, vruppert)
  9170                              <1> 	; Input:
  9171                              <1> 	;	bl = VGA video (bios) mode
  9172                              <1> 	; Output:
  9173                              <1> 	;	cf = 1 -> error
  9174                              <1> 	;	cf = 0 -> ok
  9175                              <1> 	;
  9176                              <1> 	; Modified registers: esi
  9177                              <1> 
  9178                              <1> 	; 'dispi_set_enable(VBE_DISPI_DISABLED);'
  9179                              <1> 	
  9180                              <1> 	;mov	ax, 0 ; VBE_DISPI_DISABLED 
  9181 0000397E 31C0                <1> 	xor	eax, eax ; 0 
  9182 00003980 E89C040000          <1> 	call	dispi_set_enable
  9183                              <1> 	
  9184 00003985 88D8                <1> 	mov	al, bl
  9185                              <1> 	;jmp	_set_mode ; (in 'biosfn_set_video_mode' sub)
  9186 00003987 E87AE1FFFF          <1> 	call	_set_mode ; will return with cf=1 only if
  9187                              <1> 			; desired mode is not implemented
  9188                              <1> 	; _retn: return from subroutine
  9189 0000398C 721A                <1> 	jc	short vbe_sm_2 ; 25/11/2020
  9190                              <1> 
  9191                              <1> 	; 26/11/2020
  9192 0000398E 31C0                <1> 	xor	eax, eax 
  9193 00003990 A0[CE660000]        <1> 	mov	al, [CRT_MODE]
  9194                              <1> 	; 27/11/2020
  9195 00003995 8A25[1B840100]      <1> 	mov	ah, [noclearmem] ; 80h or 0
  9196                              <1> 	;and	ah 80h
  9197 0000399B 66A3[D20F0300]      <1> 	mov	[video_mode], ax ; bit 15 = no_clear flag
  9198                              <1> 				 ; bit 14 = 0 (not LFB model)
  9199                              <1> vbe_sm_ret1:
  9200                              <1> 	; 11/12/2020
  9201                              <1> 	; (vbe_rmi_4 and vbe_rmi_6 jump here)
  9202                              <1> 	; 27/11/2020
  9203 000039A1 B04F                <1> 	mov	al, 4Fh ; Function call successful
  9204                              <1> 	; eax = 004Fh
  9205                              <1> vbe_sm_ret2:
  9206                              <1> 	; 11/12/2020
  9207 000039A3 5F                  <1> 	pop	edi ; ********
  9208 000039A4 5B                  <1> 	pop	ebx ; *******
  9209 000039A5 59                  <1> 	pop	ecx ; ******
  9210 000039A6 5A                  <1> 	pop	edx ; *****
  9211                              <1> 
  9212                              <1> 	;;pop	esi ; ****
  9213                              <1> 	;;pop	ebp ; ***
  9214                              <1> 	;;pop	es  ; **
  9215                              <1> 	;;pop	ds  ; * 
  9216                              <1> 
  9217 000039A7 C3                  <1> 	retn
  9218                              <1> 
  9219                              <1> vbe_sm_2:
  9220                              <1> 	;mov	ax, 0100h ; Function is not supported
  9221                              <1> 	; 27/11/2020
  9222 000039A8 31C0                <1> 	xor	eax, eax
  9223 000039AA B401                <1> 	mov	ah, 01h
  9224                              <1> 	; eax = 0100h
  9225                              <1> 	;retn
  9226 000039AC EBF5                <1> 	jmp	short vbe_sm_ret2
  9227                              <1> 
  9228                              <1> vbe_sm_3:
  9229                              <1> 	; 12/12/2020
  9230                              <1> 	; check current mode, if it is 03h
  9231                              <1> 	; save page contents and cursor positions
  9232 000039AE 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 03h
  9233                              <1> 	;jne	short vbe_sm_0
  9234 000039B5 7505                <1> 	jne	short vbe_sm_4 ; 07/03/2021
  9235 000039B7 E8ECE3FFFF          <1> 	call	save_mode3_multiscreen
  9236                              <1> 	; set current mode to extended (SVGA) mode
  9237                              <1> 	;mov	byte [CRT_MODE], 0FFh ; VESA VBE mode
  9238                              <1> vbe_sm_4:
  9239                              <1> 	; 27/11/2020
  9240                              <1> 	; bx = mode (bit 0 to 8)
  9241                              <1> 
  9242                              <1> 	; 25/11/2020
  9243                              <1> 
  9244                              <1> 	; Alternative 2 (instead of 'Mode_info_find_mode')
  9245                              <1> 	;push	edi
  9246 000039BC E870050000          <1> 	call	set_mode_info_list ; (alternative 2)
  9247                              <1> 	;pop	edi
  9248                              <1> 
  9249                              <1> 	;mov	bx, [esi] ; mode
  9250                              <1> 
  9251                              <1> 	; Alternative 1 (instead of 'set_mode_info_list')
  9252                              <1> 	;call	mode_info_find_mode ; (alternative 1)
  9253                              <1> 
  9254 000039C1 09F6                <1> 	or	esi, esi
  9255 000039C3 74E3                <1> 	jz	short vbe_sm_2 ; VBE mode number is wrong
  9256                              <1> 			       ; or it is not supported
  9257                              <1> 
  9258                              <1> 	; 11/12/2020
  9259 000039C5 668B1E              <1> 	mov	bx, [esi] ; mode
  9260                              <1> 
  9261                              <1> 	; 27/11/2020
  9262 000039C8 0A3D[D10F0300]      <1> 	or	bh, [vbe_mode_x]
  9263                              <1> 
  9264                              <1> 	; save VESA VBE mode
  9265 000039CE 66891D[D20F0300]    <1> 	mov	[video_mode], bx
  9266                              <1> 		; 27/11/2020
  9267                              <1> 		; bit 0 to 8 = VESA VBE mode
  9268                              <1> 		; bit 9 to 13 = 0 (bit 0 to 13 = mode)
  9269                              <1> 		; bit 14 = Linear/Flat Frame Buffer flag
  9270                              <1> 		; bit 15 = 'memory not cleared
  9271                              <1> 		;	   at last mode set' flag
  9272                              <1> 
  9273                              <1> 	; first disable current mode
  9274                              <1> 	; (when switching between vesa modes)
  9275                              <1> 	; 'dispi_set_enable(VBE_DISPI_DISABLED);'
  9276                              <1> 
  9277                              <1> 	;mov	ax, VBE_DISPI_DISABLED ; 0
  9278 000039D5 29C0                <1> 	sub	eax, eax ; 0
  9279                              <1> 
  9280 000039D7 E845040000          <1> 	call	dispi_set_enable
  9281                              <1> 
  9282                              <1> 	; 11/12/2020
  9283 000039DC 8A461B              <1> 	mov	al, [esi+MODEINFO.BitsPerPixel]
  9284                              <1> 	; ah = 0
  9285                              <1> 
  9286                              <1> 	;cmp	byte [esi+MODEINFO.BitsPerPixel], 8
  9287 000039DF 3C08                <1> 	cmp	al, 8
  9288 000039E1 750B                <1> 	jne	short vbe_sm_5
  9289                              <1> 
  9290                              <1> 	; 11/12/2020
  9291                              <1> 	;push	edi
  9292 000039E3 50                  <1> 	push	eax
  9293                              <1> 	; 'load_dac_palette(3);'
  9294 000039E4 56                  <1> 	push	esi
  9295 000039E5 B403                <1> 	mov	ah, 3  ; palette3, 256 colors
  9296 000039E7 E8BBF1FFFF          <1> 	call	load_dac_palette
  9297 000039EC 5E                  <1> 	pop	esi
  9298                              <1> 	; 11/12/2020
  9299 000039ED 58                  <1> 	pop	eax
  9300                              <1> 	;pop	edi
  9301                              <1> vbe_sm_5:	
  9302                              <1>   	;'dispi_set_bpp(cur_info->info.BitsPerPixel);'
  9303                              <1> 	; 11/12/2020 (al = bits per pixel, ah = 0)
  9304                              <1> 	;xor	ah, ah
  9305                              <1> 	;mov	al, [esi+MODEINFO.BitsPerPixel]
  9306 000039EE E841040000          <1> 	call	dispi_set_bpp
  9307                              <1>         ;'dispi_set_xres(cur_info->info.XResolution);'
  9308 000039F3 668B4614            <1> 	mov	ax, [esi+MODEINFO.XResolution]
  9309 000039F7 E83E040000          <1> 	call	dispi_set_xres
  9310                              <1>         ;'dispi_set_yres(cur_info->info.YResolution);'
  9311 000039FC 668B4616            <1> 	mov	ax, [esi+MODEINFO.YResolution]
  9312 00003A00 E83B040000          <1> 	call	dispi_set_yres
  9313                              <1> 
  9314                              <1> 	;'dispi_set_bank(0);'
  9315                              <1> 	;xor	ax, ax
  9316 00003A05 31C0                <1> 	xor	eax, eax ; 0
  9317 00003A07 E83A040000          <1> 	call	dispi_set_bank
  9318                              <1>         ;'dispi_set_enable(VBE_DISPI_ENABLED|no_clear|lfb_flag);'
  9319                              <1> 	;mov	ax, di
  9320                              <1> 	; ah = 0 ; 27/11/2020
  9321 00003A0C A0[D10F0300]        <1> 	mov	al, [vbe_mode_x] ; restore VBE mode bit 14 & 15
  9322 00003A11 0C01                <1> 	or	al, 1 ; VBE_DISPI_ENABLED
  9323 00003A13 E809040000          <1> 	call	dispi_set_enable
  9324                              <1> 
  9325                              <1>         ; 'vga_compat_setup();'
  9326 00003A18 E83E040000          <1> 	call	vga_compat_setup
  9327                              <1> 
  9328                              <1> 	; 11/12/2020
  9329 00003A1D E802FFFFFF          <1> 	call	set_lfbinfo_table
  9330                              <1> 
  9331                              <1> 	; 26/11/2020
  9332 00003A22 31C0                <1> 	xor	eax, eax
  9333 00003A24 FEC8                <1> 	dec	al 
  9334 00003A26 A2[CE660000]        <1> 	mov	[CRT_MODE], al ; 0FFh = VESA VBE mode sign
  9335                              <1> 
  9336                              <1> 	; 27/11/2020
  9337 00003A2B E971FFFFFF          <1> 	jmp	vbe_sm_ret1 ; Function call successful
  9338                              <1> 	
  9339                              <1> 	; 27/11/2020
  9340                              <1> 	;mov	al, 4Fh
  9341                              <1> 	;	; eax = 004Fh = Function call successful
  9342                              <1> 	;jmp	short vbe_sm_ret2
  9343                              <1> 
  9344                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions)
  9345                              <1> ; * ---------------------------------------------------------
  9346                              <1> ; * Function 03h - Return Current VBE Mode
  9347                              <1> ; * ---------------------------------------------------------
  9348                              <1> ; * Input:
  9349                              <1> ; *		AX = 4F03h
  9350                              <1> ; * Output:
  9351                              <1> ; *		AX = VBE Return Status
  9352                              <1> ; *		BX = Current VBE Mode
  9353                              <1> ; * 
  9354                              <1> ; *----------------------------------------------------------
  9355                              <1> ; *
  9356                              <1> 
  9357                              <1> vbe_biosfn_return_current_mode:
  9358                              <1> 	; 11/12/2020
  9359                              <1> 	; 27/11/2020 (TRDOS 386 v2.0.3)
  9360                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
  9361                              <1> 	;
  9362                              <1> 	; Input:
  9363                              <1> 	;	none
  9364                              <1> 	; Output:
  9365                              <1> 	;	ax = 004Fh (successful)
  9366                              <1> 	;	ah > 0 -> error
  9367                              <1> 	;	bx = current video (bios) mode (if ah = 0)
  9368                              <1> 	;
  9369                              <1> 	; Modified registers: eax, ebx
  9370                              <1> 
  9371                              <1> 	; 27/11/2020
  9372                              <1> 
  9373                              <1> 	;;push	ds  ; *
  9374                              <1> 	;;push	es  ; **
  9375                              <1> 	;;push	ebp ; ***
  9376                              <1> 	;;push	esi ; **** 
  9377                              <1> 	 			
  9378                              <1> 	;push	edx ; *****
  9379                              <1> 
  9380                              <1> 	; (vbe.c)
  9381                              <1> 	;call	dispi_get_enable
  9382                              <1> 	;	; ax = vbe display interface status
  9383                              <1> 	;and	al, 1 ; VBE_DISPI_ENABLED
  9384                              <1> 	;jnz	short vbe_gm_1  ; VBE graphics mode
  9385                              <1> 
  9386 00003A30 A0[CE660000]        <1> 	mov	al, [CRT_MODE] ; current cga/vga mode
  9387 00003A35 3CFF                <1> 	cmp	al, 0FFh ; VBE extension signature
  9388 00003A37 720E                <1> 	jb	short vbe_gm_1 ; get CGA/VGA mode
  9389                              <1> 
  9390                              <1> 	; get VBE mode
  9391                              <1> vbe_gm_0:
  9392 00003A39 66A1[D20F0300]      <1> 	mov	ax, [video_mode]
  9393                              <1> 		; BX bits:
  9394                              <1> 		; bit 0 to 8 = VESA VBE video mode
  9395                              <1> 		; bit 9 to 13 = 0 
  9396                              <1> 		; bit 14 = last mode set LFB option
  9397                              <1> 		;	   1 - linear/flat frame buffer
  9398                              <1> 		;	   0 - windowed frame buffer
  9399                              <1> 		; bit 15 = last mode set no_clear option
  9400                              <1> 		;	   0 - video memory cleared
  9401                              <1> 		;	   1 - video memory not cleared
  9402                              <1> 	
  9403                              <1> vbe_gm_return:
  9404                              <1> 	;pop	edx ; ******
  9405 00003A3F 0FB7D8              <1> 	movzx	ebx, ax
  9406                              <1> ;vbe_srs_retn:
  9407 00003A42 31C0                <1> 	xor	eax, eax ; 0
  9408 00003A44 B04F                <1> 	mov	al, 4Fh ; ax = 004Fh (successful)
  9409 00003A46 C3                  <1> 	retn	
  9410                              <1> 
  9411                              <1> vbe_gm_1:
  9412                              <1> 	; legacy (old, standard) CGA/VGA bios video mode
  9413 00003A47 8A25[1B840100]      <1> 	mov	ah, [noclearmem] ; 80h or 0
  9414                              <1> 		; BX bits: 
  9415                              <1> 		; bit 0 to 7 = video mode
  9416                              <1> 		; bit 8 to 13 = 0 
  9417                              <1> 		; bit 14 = 0 (not LFB mode) CGA/VGA
  9418                              <1> 		; bit 15 = 1 if [noclearmem] = 80h
  9419                              <1> 		;	   0 if [noclearmem] = 0
  9420 00003A4D EBF0                <1> 	jmp	short vbe_gm_return
  9421                              <1> 
  9422                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
  9423                              <1> ; * ---------------------------------------------------------
  9424                              <1> ; * Function 04h - Save/Restore State
  9425                              <1> ; * ---------------------------------------------------------
  9426                              <1> ; * Input:
  9427                              <1> ; *		AX = 4F04h
  9428                              <1> ; *             DL = 00h Return Save/Restore State buff size
  9429                              <1> ; *                  01h Save State
  9430                              <1> ; *                  02h Restore State
  9431                              <1> ; *             CX = Requested states
  9432                              <1> ; *		     bit 0 - controller hardware state
  9433                              <1> ; *		     bit 1 - BIOS data state
  9434                              <1> ; *		     bit 2 - DAC state
  9435                              <1> ; *		     bit 3 - register state
  9436                              <1> ; *    (ES:BX) EBX = Pointer to buffer (if DL <> 00h)
  9437                              <1> ; * Output:
  9438                              <1> ; *		AX = VBE Return Status
  9439                              <1> ; *		BX = Number of 64-byte blocks 
  9440                              <1> ; *		     to hold the state buffer (if DL=00h)
  9441                              <1> ; * 
  9442                              <1> ; *----------------------------------------------------------
  9443                              <1> ; *
  9444                              <1> 
  9445                              <1> vbe_biosfn_save_restore_state:
  9446                              <1> 	; 23/01/2021
  9447                              <1> 	; 16/01/2021
  9448                              <1> 	; 14/01/2021
  9449                              <1> 	; 13/01/2021
  9450                              <1> 	; 12/01/2021
  9451                              <1> 	; 11/01/2021 (TRDOS 386 v2.0.3)
  9452                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
  9453                              <1> 	;
  9454                              <1> 	; Input:
  9455                              <1> 	;	dl = sub function
  9456                              <1> 	;	cl = requested state
  9457                              <1> 	;      ebx = pointer to buffer (if dl<>00h) 
  9458                              <1> 	; Output:
  9459                              <1> 	;	ax = 004Fh (successful)
  9460                              <1> 	;	ah > 0 -> error
  9461                              <1> 	;	bx = Number of 64-byte blocks 
  9462                              <1> 	;	     to hold the state buffer (if DL=00h)
  9463                              <1> 
  9464                              <1> 	; Modified registers: eax, ebx, edi
  9465                              <1> 	
  9466                              <1> 	; 14/01/2021
  9467 00003A4F 09DB                <1> 	or	ebx, ebx ; user's buffer address
  9468 00003A51 750A                <1> 	jnz	short _vbe_biosfn_save_restore_state
  9469                              <1> 
  9470 00003A53 20D2                <1> 	and	dl, dl
  9471 00003A55 7406                <1> 	jz	short _vbe_biosfn_save_restore_state
  9472                              <1> 
  9473                              <1> 	; function failed
  9474                              <1> 	;mov	eax, 0100h
  9475                              <1> 	;xor	eax, eax
  9476                              <1> 	;inc	ah  ; eax = 0100h
  9477                              <1> 	; 16/01/2021
  9478 00003A57 B84F010000          <1> 	mov	eax, 014Fh
  9479 00003A5C C3                  <1> 	retn
  9480                              <1> 
  9481                              <1> _vbe_biosfn_save_restore_state:
  9482                              <1> 	; 23/01/2021
  9483                              <1> 	; 14/01/2021
  9484                              <1> 	; ebx = 0 if the caller is kernel ('sysvideo')
  9485                              <1> 
  9486                              <1> 	; 13/01/2021
  9487 00003A5D 57                  <1> 	push	edi
  9488 00003A5E 52                  <1> 	push	edx
  9489 00003A5F 51                  <1> 	push	ecx
  9490                              <1> 
  9491                              <1> 	; 23/01/2021
  9492                              <1> 	; 12/01/2021
  9493 00003A60 80FA02              <1> 	cmp	dl, 2
  9494 00003A63 7757                <1> 	ja	short vbe_srs_7 ; 23/01/2021
  9495                              <1> 			; invalid sub function
  9496 00003A65 83F90F              <1> 	cmp	ecx, 0Fh
  9497 00003A68 7752                <1> 	ja	short vbe_srs_7 ; invalid !
  9498                              <1> 	
  9499 00003A6A 20D2                <1> 	and	dl, dl
  9500 00003A6C 7515                <1> 	jnz	short vbe_srs_4
  9501                              <1> 
  9502                              <1> 	; DL = 0
  9503                              <1> 	; Return Save/Restore State buffer size
  9504                              <1> 
  9505                              <1> 	;mov	ebx, ecx
  9506                              <1> 	;shl	bl, 1
  9507                              <1> 	;mov	bx, [ebx+vbestatebufsize]
  9508 00003A6E E881000000          <1> 	call	vbe_srs_gbs
  9509                              <1> 
  9510                              <1> ;	; 11/01/2021
  9511                              <1> ;	test	cl, 8
  9512                              <1> ;	jz	short vbe_srs_3
  9513                              <1> ;	; vbe_biosfn_read_video_state_size();
  9514                              <1> ;	; return 9 * 2;
  9515                              <1> ;	mov	bl, 18 ; register state size
  9516                              <1> ;vbe_srs_0:
  9517                              <1> ;	test	cl, 1
  9518                              <1> ;	jz	short vbe_srs_1
  9519                              <1> ;	; size += 0x46;
  9520                              <1> ;	add	bl, 70	; controller state size
  9521                              <1> ;vbe_srs_1:
  9522                              <1> ;	test	cl, 2
  9523                              <1> ;	jz	short vbe_srs_2
  9524                              <1> ;	; size += (5 + 8 + 5) * 2 + 6;
  9525                              <1> ;	;add	bl, 42 ; BIOS data state size ; Bochs/Plex86
  9526                              <1> ;	; 12/01/2021
  9527                              <1> ;	add	bl, 40 ; TRDOS 386 v2 VBIOS data state size
  9528                              <1> ;vbe_srs_2:
  9529                              <1> ;	test	cl, 4
  9530                              <1> ;	jz	short vbe_srs_3
  9531                              <1> ;	; size += 3 + 256 * 3 + 1;
  9532                              <1> ;	add	bx, 772 ; DAC state size
  9533                              <1> 
  9534                              <1> vbe_srs_3:
  9535 00003A73 6683C33F            <1> 	add	bx, 63
  9536 00003A77 66C1EB06            <1> 	shr	bx, 6 ; / 64
  9537                              <1> 
  9538                              <1> vbe_srs_retn:
  9539 00003A7B 31C0                <1> 	xor	eax, eax ; 0
  9540                              <1> vbe_srs_0:  ; 16/01/2021
  9541 00003A7D B04F                <1> 	mov	al, 4Fh ; ax = 004Fh (successful)
  9542                              <1> ;vbe_srs_0:
  9543                              <1> 	; 13/01/2021
  9544 00003A7F 59                  <1> 	pop	ecx
  9545 00003A80 5A                  <1> 	pop	edx
  9546 00003A81 5F                  <1> 	pop	edi	
  9547                              <1> 
  9548 00003A82 C3                  <1> 	retn
  9549                              <1> 
  9550                              <1> 	; 23/01/2021
  9551                              <1> ;vbe_srs_10:
  9552                              <1> 	;; 14/01/2021
  9553                              <1> 	; return to 'sysvideo'
  9554                              <1> 	;mov	ebx, ecx ; transfer count
  9555                              <1> 	;	; (byte count for saving current video state)
  9556                              <1> 	;jmp	short vbe_srs_retn 
  9557                              <1> 
  9558                              <1> vbe_srs_4:
  9559                              <1> 	; 23/01/2021
  9560 00003A83 80E10F              <1> 	and	cl, 0Fh ; 8, 4, 2, 1
  9561 00003A86 7434                <1> 	jz	short vbe_srs_7 ; cx = 0 -> invalid !
  9562                              <1> 
  9563 00003A88 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
  9564                              <1> 
  9565 00003A8D 80FA01              <1> 	cmp	dl, 1
  9566 00003A90 7730                <1> 	ja	short vbe_srs_8
  9567                              <1> 
  9568                              <1> 	; save video state
  9569                              <1> 
  9570 00003A92 F6C107              <1> 	test	cl, 07h ; 4, 2, 1
  9571 00003A95 740A                <1> 	jz	short vbe_srs_5  ; vbe dispi regs state
  9572                              <1> 
  9573 00003A97 E884000000          <1> 	call	biosfn_save_video_state
  9574                              <1> 	; edi = current position
  9575                              <1> 	;	in VBE3SAVERESTOREBLOCK
  9576                              <1> 	; 	(VGA save_state offset)
  9577                              <1> 	; modified regs: edi, eax, edx, ch
  9578 00003A9C F6C108              <1> 	test	cl, 8
  9579 00003A9F 7405                <1> 	jz	short vbe_srs_6
  9580                              <1> vbe_srs_5:
  9581 00003AA1 E8AB010000          <1> 	call	vbe_biosfn_save_video_state
  9582                              <1> 	; edi = end position
  9583                              <1> 	;	in VBE3SAVERESTOREBLOCK
  9584                              <1> 	; 	(VGA save_state offset)
  9585                              <1> 	; modified regs: edi, eax, edx, ch
  9586                              <1> vbe_srs_6:
  9587                              <1> 	; 23/01/2021
  9588 00003AA6 21DB                <1> 	and	ebx, ebx 
  9589 00003AA8 74D1                <1> 	jz	short vbe_srs_retn ; the caller is kernel
  9590                              <1> 	
  9591 00003AAA BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
  9592 00003AAF 29F7                <1> 	sub	edi, esi
  9593 00003AB1 89F9                <1> 	mov	ecx, edi ; transfer count in bytes
  9594                              <1> 
  9595                              <1> 	;; 14/01/2021
  9596                              <1> 	;and	ebx, ebx 
  9597                              <1> 	;jz	short vbe_srs_10 ; the caller is kernel
  9598                              <1> 
  9599 00003AB3 89DF                <1> 	mov	edi, ebx ; user's buffer address
  9600 00003AB5 E89FD20000          <1> 	call	transfer_to_user_buffer
  9601 00003ABA 73BF                <1> 	jnc	short vbe_srs_retn
  9602                              <1> vbe_srs_7:
  9603                              <1> 	; // function failed
  9604                              <1> 	;mov	eax, 0100h
  9605 00003ABC 31C0                <1> 	xor	eax, eax
  9606 00003ABE FEC4                <1> 	inc	ah  ; eax = 0100h
  9607                              <1> 	; 16/01/2021
  9608                              <1> 	; ax = 0014Fh
  9609                              <1> 	;retn
  9610                              <1> 	; 13/01/2021
  9611 00003AC0 EBBB                <1> 	jmp	short vbe_srs_0
  9612                              <1> vbe_srs_8:
  9613                              <1> 	;cmp	dl, 2
  9614                              <1> 	;jne	short vbe_srs_7
  9615                              <1> 	;		; invalid sub function
  9616                              <1> 
  9617                              <1> 	; 14/01/2021
  9618 00003AC2 09DB                <1> 	or	ebx, ebx ; user's buffer address
  9619                              <1> 	;jnz	short vbe_srs_11
  9620                              <1> 
  9621                              <1> 	; the caller is kernel ('sysvideo')
  9622                              <1> 	;jmp	short vbe_srs_12
  9623                              <1> 	; 23/01/2021
  9624 00003AC4 7414                <1> 	jz	short vbe_srs_12 ; 'sysvideo' call
  9625                              <1> vbe_srs_11:
  9626 00003AC6 89DE                <1> 	mov	esi, ebx ; user's buffer address
  9627                              <1> 	; 23/01/2021
  9628                              <1> 	;push	ebx
  9629                              <1> 	
  9630 00003AC8 E827000000          <1> 	call	vbe_srs_gbs
  9631                              <1> 	
  9632                              <1> 	; restore video state
  9633                              <1> 
  9634                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
  9635 00003ACD 51                  <1> 	push	ecx
  9636 00003ACE 89D9                <1> 	mov	ecx, ebx ; transfer count in bytes
  9637 00003AD0 E8CED20000          <1> 	call	transfer_from_user_buffer
  9638 00003AD5 59                  <1> 	pop	ecx
  9639                              <1> 	; 23/01/2021
  9640                              <1> 	;pop	ebx
  9641 00003AD6 89F3                <1> 	mov	ebx, esi
  9642 00003AD8 72E2                <1> 	jc	short vbe_srs_7
  9643                              <1> 
  9644                              <1> vbe_srs_12:
  9645                              <1> 	;mov	esi, VBE3SAVERESTOREBLOCK
  9646 00003ADA 89FE                <1> 	mov	esi, edi
  9647                              <1> 
  9648 00003ADC F6C107              <1> 	test	cl, 07h ; 4, 2, 1
  9649 00003ADF 740C                <1> 	jz	short vbe_srs_9	; vbe dispi regs state
  9650                              <1> 
  9651 00003AE1 E8A2010000          <1> 	call	biosfn_restore_video_state
  9652 00003AE6 72D4                <1> 	jc	short vbe_srs_7 ; invalid buffer content !
  9653                              <1> 	; esi = current position
  9654                              <1> 	;	in VBE3SAVERESTOREBLOCK
  9655                              <1> 	; 	(VGA save_state offset)
  9656                              <1> 	; modified regs: esi, eax, edx, ch
  9657 00003AE8 F6C108              <1> 	test	cl, 8
  9658                              <1> 	;jz	short vbe_srs_10
  9659                              <1> 	; 23/01/2020
  9660 00003AEB EB8E                <1> 	jmp	short vbe_srs_retn
  9661                              <1> vbe_srs_9:
  9662 00003AED E8F1020000          <1> 	call	vbe_biosfn_restore_video_state
  9663                              <1> 
  9664                              <1> 	; modified regs: esi, eax, edx, ch
  9665                              <1> 
  9666 00003AF2 EB87                <1> 	jmp	short vbe_srs_retn
  9667                              <1> 
  9668                              <1> ;vbe_srs_10:
  9669                              <1> ;	; successful
  9670                              <1> ;	xor	eax, eax ; 0
  9671                              <1> ;	mov	al, 4Fh ; ax = 004Fh (successful)
  9672                              <1> ;	retn
  9673                              <1> 
  9674                              <1> vbe_srs_gbs:
  9675                              <1> 	; return buffer size according to flags
  9676 00003AF4 89CB                <1> 	mov	ebx, ecx ; options/flags
  9677 00003AF6 D0E3                <1> 	shl	bl, 1
  9678 00003AF8 668B9B[003B0000]    <1> 	mov	bx, [ebx+vbestatebufsize]
  9679 00003AFF C3                  <1> 	retn
  9680                              <1> 
  9681                              <1> vbestatebufsize:
  9682                              <1> 	; ----------------------------------------
  9683                              <1> 	; CL =	0  1   2    3    4    5    6    7
  9684                              <1> 	; ----------------------------------------
  9685 00003B00 0000460028006E0004- <1> 	dw	0, 70, 40, 110, 772, 842, 812, 882
  9685 00003B09 034A032C037203      <1>
  9686                              <1> 	; ----------------------------------------
  9687                              <1> 	; CL =	8   9   10  11   12   13   14   15
  9688                              <1> 	; ----------------------------------------
  9689 00003B10 120058003A00800016- <1> 	dw	18, 88, 58, 128, 790, 860, 830, 900
  9689 00003B19 035C033E038403      <1>
  9690                              <1> 
  9691                              <1> ; 11/01/2021
  9692                              <1> VGAREG_ACTL_ADDRESS	equ 3C0h
  9693                              <1> VGAREG_ACTL_WRITE_DATA	equ 3C0h
  9694                              <1> VGAREG_ACTL_READ_DATA	equ 3C1h
  9695                              <1> 
  9696                              <1> VGAREG_INPUT_STATUS	equ 3C2h
  9697                              <1> VGAREG_WRITE_MISC_OUTPUT equ 3C2h
  9698                              <1> VGAREG_VIDEO_ENABLE	equ 3C3h
  9699                              <1> VGAREG_SEQU_ADDRESS	equ 3C4h
  9700                              <1> VGAREG_SEQU_DATA	equ 3C5h
  9701                              <1> 
  9702                              <1> VGAREG_PEL_MASK		equ 3C6h
  9703                              <1> VGAREG_DAC_STATE	equ 3C7h
  9704                              <1> VGAREG_DAC_READ_ADDRESS	equ 3C7h
  9705                              <1> VGAREG_DAC_WRITE_ADDRESS equ 3C8h
  9706                              <1> VGAREG_DAC_DATA		equ 3C9h
  9707                              <1> 
  9708                              <1> VGAREG_READ_FEATURE_CTL	equ 3CAh
  9709                              <1> VGAREG_READ_MISC_OUTPUT	equ 3CCh
  9710                              <1> 
  9711                              <1> VGAREG_GRDC_ADDRESS	equ 3CEh
  9712                              <1> VGAREG_GRDC_DATA	equ 3CFh
  9713                              <1> 
  9714                              <1> ;VGAREG_MDA_CRTC_ADDRESS equ 3B4h
  9715                              <1> ;VGAREG_MDA_CRTC_DATA	equ 3B5h
  9716                              <1> VGAREG_VGA_CRTC_ADDRESS	equ 3D4h
  9717                              <1> VGAREG_VGA_CRTC_DATA	equ 3D5h
  9718                              <1> 
  9719                              <1> ;VGAREG_MDA_WRITE_FEATURE_CTL equ 3BAh
  9720                              <1> VGAREG_VGA_WRITE_FEATURE_CTL equ 3DAh
  9721                              <1> VGAREG_ACTL_RESET	equ 3DAh
  9722                              <1> 
  9723                              <1> ;VGAREG_MDA_MODECTL	equ 3B8h
  9724                              <1> VGAREG_CGA_MODECTL	equ 3D8h
  9725                              <1> VGAREG_CGA_PALETTE	equ 3D9h
  9726                              <1> 
  9727                              <1> biosfn_save_video_state:
  9728                              <1> 	; 03/08/2022 (TRDOS 386 v2.0.5)
  9729                              <1> 	; 22/01/2021
  9730                              <1> 	; 12/01/2021
  9731                              <1> 	; 11/01/2021 (TRDOS 386 v2.0.3)
  9732                              <1> 	; (vgabios.c)
  9733                              <1> 
  9734                              <1> 	; modified registers: eax, edx, edi, ch
  9735                              <1> 
  9736                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
  9737                              <1> 
  9738                              <1> 	; input: edi = state buffer address
  9739                              <1> 
  9740 00003B20 F6C101              <1> 	test	cl, 1
  9741 00003B23 0F8485000000        <1> 	jz	bfn_svs_4
  9742                              <1> 
  9743 00003B29 66BAC403            <1> 	mov	dx, VGAREG_SEQU_ADDRESS ; 3C7h
  9744 00003B2D EC                  <1> 	in	al, dx
  9745 00003B2E AA                  <1> 	stosb
  9746                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9747 00003B2F B2D4                <1> 	mov	dl, 0D4h
  9748 00003B31 EC                  <1> 	in	al, dx
  9749 00003B32 AA                  <1> 	stosb
  9750                              <1>   	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh 
  9751 00003B33 B2CE                <1>         mov	dl, 0CEh
  9752 00003B35 EC                  <1> 	in	al, dx
  9753 00003B36 AA                  <1> 	stosb
  9754                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
  9755 00003B37 B2DA                <1> 	mov	dl, 0DAh
  9756 00003B39 EC                  <1> 	in	al, dx
  9757                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
  9758 00003B3A B2C0                <1> 	mov	dl, 0C0h
  9759 00003B3C EC                  <1> 	in	al, dx
  9760 00003B3D AA                  <1> 	stosb
  9761 00003B3E 88C4                <1> 	mov	ah, al ; ar_index
  9762                              <1> 	;mov	dx, VGAREG_READ_FEATURE_CTL ; 3CAh
  9763 00003B40 B2CA                <1> 	mov	dl, 0CAh
  9764 00003B42 EC                  <1> 	in	al, dx
  9765 00003B43 AA                  <1> 	stosb
  9766                              <1> 	; (5 bytes are writen above)
  9767                              <1> 
  9768                              <1> 	; for(i=1;i<=4;i++){
  9769 00003B44 B001                <1> 	mov	al, 1
  9770                              <1> 	;;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
  9771                              <1> 	;mov	dl, 0C4h
  9772 00003B46 B504                <1> 	mov	ch, 4
  9773                              <1> bfn_svs_0:
  9774                              <1> 	; outb(VGAREG_SEQU_ADDRESS, i);
  9775                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
  9776 00003B48 B2C4                <1> 	mov	dl, 0C4h
  9777 00003B4A EE                  <1> 	out	dx, al
  9778                              <1> 	;mov	dx, VGAREG_SEQU_DATA  ; 3C5h
  9779 00003B4B FEC2                <1> 	inc	dl  ; dx = 3C5h
  9780                              <1> 	; inb(VGAREG_SEQU_DATA)
  9781 00003B4D 50                  <1> 	push	eax
  9782 00003B4E EC                  <1> 	in	al, dx
  9783 00003B4F AA                  <1> 	stosb	; (4 bytes in loop)
  9784 00003B50 58                  <1> 	pop	eax
  9785                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
  9786                              <1> 	;dec	dl	
  9787 00003B51 FEC0                <1> 	inc	al  ; i++
  9788 00003B53 FECD                <1> 	dec	ch
  9789 00003B55 75F1                <1> 	jnz	short bfn_svs_0
  9790                              <1> 
  9791                              <1> 	; outb(VGAREG_SEQU_ADDRESS, 0);
  9792 00003B57 28C0                <1> 	sub	al, al ; 0
  9793 00003B59 EE                  <1> 	out	dx, al
  9794                              <1> 	; inb(VGAREG_SEQU_DATA)
  9795                              <1> 	;mov	dx, VGAREG_SEQU_DATA ; 3C5h
  9796 00003B5A FEC2                <1> 	inc	dl  ; dx = 3C5h
  9797 00003B5C EC                  <1> 	in	al, dx
  9798 00003B5D AA                  <1> 	stosb	; (+1 byte)
  9799                              <1> 
  9800                              <1>         ; for(i=0;i<=0x18;i++) {
  9801 00003B5E 28C0                <1> 	sub	al, al ; 0
  9802                              <1> 	;;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9803                              <1> 	;mov	dl, 0D4h
  9804 00003B60 B519                <1> 	mov	ch, 25
  9805                              <1> bfn_svs_1:
  9806                              <1>         ; outb(crtc_addr,i);
  9807                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9808 00003B62 B2D4                <1> 	mov	dl, 0D4h
  9809 00003B64 EE                  <1> 	out	dx, al
  9810                              <1> 	;mov	dx, VGAREG_VGA_CRTC_DATA ; 3D5h
  9811 00003B65 FEC2                <1> 	inc	dl  ; dx = 3D5h
  9812                              <1> 	; inb(crtc_addr+1)
  9813 00003B67 50                  <1> 	push	eax
  9814 00003B68 EC                  <1> 	in	al, dx
  9815 00003B69 AA                  <1> 	stosb	; (25 bytes in loop)
  9816 00003B6A 58                  <1> 	pop	eax
  9817                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9818                              <1> 	;dec	dl	
  9819 00003B6B FEC0                <1> 	inc	al  ; i++
  9820 00003B6D FECD                <1> 	dec	ch
  9821 00003B6F 75F1                <1> 	jnz	short bfn_svs_1
  9822                              <1> 
  9823 00003B71 80E420              <1> 	and	ah, 20h  ; (ar_index & 0x20)
  9824                              <1>         ; for(i=0;i<=0x13;i++) {
  9825 00003B74 28C0                <1> 	sub	al, al ; 0
  9826 00003B76 B514                <1> 	mov	ch, 20
  9827                              <1> bfn_svs_2:
  9828                              <1> 	; inb(VGAREG_ACTL_RESET);
  9829                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
  9830 00003B78 B2DA                <1> 	mov	dl, 0DAh
  9831 00003B7A 50                  <1> 	push	eax
  9832 00003B7B EC                  <1> 	in	al, dx
  9833 00003B7C 8A0424              <1> 	mov	al, [esp]
  9834                              <1>  	; outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20));
  9835 00003B7F 08E0                <1> 	or	al, ah
  9836                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
  9837 00003B81 B2C0                <1> 	mov	dl, 0C0h
  9838 00003B83 EE                  <1> 	out	dx, al
  9839                              <1> 	;mov	dx, VGAREG_ACTL_READ_DATA ; 3C1h
  9840                              <1> 	;mov	dl, 0C1h
  9841 00003B84 FEC2                <1> 	inc	dl
  9842 00003B86 EC                  <1> 	in	al, dx
  9843 00003B87 AA                  <1> 	stosb	; (20 bytes in loop)
  9844 00003B88 58                  <1> 	pop	eax
  9845 00003B89 FEC0                <1> 	inc	al  ; i++
  9846 00003B8B FECD                <1> 	dec	ch
  9847 00003B8D 75E9                <1> 	jnz	short bfn_svs_2
  9848                              <1> 
  9849                              <1> 	; inb(VGAREG_ACTL_RESET);
  9850                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
  9851 00003B8F B2DA                <1> 	mov	dl, 0DAh
  9852 00003B91 EC                  <1> 	in	al, dx
  9853                              <1> 
  9854                              <1>         ; for(i=0;i<=8;i++) {
  9855 00003B92 28C0                <1> 	sub	al, al ; 0
  9856                              <1> 	;;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
  9857                              <1> 	;mov	dl, 0CEh
  9858 00003B94 B509                <1> 	mov	ch, 9
  9859                              <1> bfn_svs_3:
  9860                              <1> 	; outb(VGAREG_GRDC_ADDRESS,i)
  9861                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
  9862 00003B96 B2CE                <1> 	mov	dl, 0CEh
  9863 00003B98 EE                  <1> 	out	dx, al
  9864                              <1> 	; inb(VGAREG_ACTL_READ_DATA)
  9865 00003B99 50                  <1> 	push	eax
  9866                              <1> 	;mov	dx, VGAREG_GRDC_DATA ; 3CFh
  9867                              <1> 	;mov	dl, 0CFh
  9868 00003B9A FEC2                <1> 	inc	dl
  9869 00003B9C EC                  <1> 	in	al, dx
  9870 00003B9D AA                  <1> 	stosb	; (9 bytes in loop)
  9871 00003B9E 58                  <1> 	pop	eax
  9872                              <1> 	;dec	dl
  9873 00003B9F FEC0                <1> 	inc	al  ; i++
  9874 00003BA1 FECD                <1> 	dec	ch
  9875 00003BA3 75F1                <1> 	jnz	short bfn_svs_3
  9876                              <1> 
  9877                              <1> 	; write_word(ES, BX, crtc_addr); BX+= 2;
  9878                              <1> 	; (offset 64)
  9879 00003BA5 66B8D403            <1> 	mov	ax, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
  9880 00003BA9 66AB                <1> 	stosw	; (2 bytes (1 word))
  9881                              <1> 
  9882                              <1>         ; /* XXX: read plane latches */
  9883 00003BAB 31C0                <1> 	xor	eax, eax  ; 0
  9884 00003BAD AB                  <1>        	stosd	; (4 bytes)
  9885                              <1> 
  9886                              <1> 	; (total 70 bytes are written above as controller hardware state)
  9887                              <1> 
  9888                              <1> bfn_svs_4:		
  9889                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
  9890 00003BAE F6C102              <1> 	test	cl, 2
  9891 00003BB1 7476                <1> 	jz	short bfn_svs_6
  9892                              <1> 
  9893                              <1> 	; VIDEO BIOS DATA
  9894                              <1> 	; !!! this data is valid for TRDOS 386 v2 kernel only !!!
  9895                              <1> 	; (this is not same with BOCHS/PLEX86 video bios, BIOS data)  
  9896                              <1>   
  9897                              <1>     	; if (CX & 2) {
  9898                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE)); BX++;
  9899                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)); BX += 2;
  9900                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE)); BX += 2;
  9901                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS)); BX += 2;
  9902                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS)); BX++;
  9903                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT)); BX += 2;
  9904                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL)); BX++;
  9905                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES)); BX++;
  9906                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL)); BX++;
  9907                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE)); BX += 2;
  9908                              <1>         ;for(i=0;i<8;i++) {
  9909                              <1>         ;   write_word(ES, BX, read_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i));
  9910                              <1>         ;   BX += 2;
  9911                              <1>         ;}
  9912                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START)); BX += 2;
  9913                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE)); BX++;
  9914                              <1>         ;/* current font */
  9915                              <1>         ;write_word(ES, BX, read_word(0, 0x1f * 4)); BX += 2;
  9916                              <1>         ;write_word(ES, BX, read_word(0, 0x1f * 4 + 2)); BX += 2;
  9917                              <1>         ;write_word(ES, BX, read_word(0, 0x43 * 4)); BX += 2;
  9918                              <1>         ;write_word(ES, BX, read_word(0, 0x43 * 4 + 2)); BX += 2;
  9919                              <1> 
  9920                              <1> 	; !!! save TRDOS 386 v2 kernel spesific video bios data !!!
  9921                              <1> 	; (which is/are used by 'SET_MODE' function and/or it's sub functions)
  9922                              <1> 
  9923 00003BB3 66B8D403            <1> 	mov	ax, 3D4h ; CRTC_ADDR, always 3D4h (color VGA) for TRDOS 386 v2
  9924 00003BB7 66AB                <1> 	stosw
  9925 00003BB9 A0[CE660000]        <1> 	mov	al, [CRT_MODE] ; Current video mode (0FFh for VESA VBE modes) 
  9926 00003BBE AA                  <1> 	stosb
  9927 00003BBF A0[CF660000]        <1> 	mov	al, [CRT_MODE_SET] ; 29h for mode 03h ; TRDOS 386 feature only !
  9928 00003BC4 AA                  <1> 	stosb	
  9929 00003BC5 66A1[D20F0300]      <1>  	mov	ax, [video_mode] ; Current VESA VBE (SVGA, extended VGA) mode 
  9930 00003BCB 66AB                <1> 	stosw			 ; (valid if [CRT_MODE] = 0FFh)	
  9931 00003BCD 66A1[1C840100]      <1> 	mov	ax, [CRT_LEN] ; page size (in bytes)
  9932 00003BD3 66AB                <1> 	stosw
  9933 00003BD5 66A1[A4770100]      <1> 	mov	ax, [CRT_START] ; video page start offset
  9934 00003BDB 66AB                <1>  	stosw
  9935 00003BDD A0[D0660000]        <1> 	mov	al, [CRT_COLS] ; nbcols, characters per row	
  9936 00003BE2 AA                  <1> 	stosb
  9937 00003BE3 A0[D6660000]        <1> 	mov	al, [VGA_ROWS] ; nbrows, (character) rows per page (not rows-1)
  9938 00003BE8 AA                  <1> 	stosb
  9939 00003BE9 A0[D2660000]        <1> 	mov	al, [CHAR_HEIGHT] ; character font height (8 or 16 or 14)
  9940 00003BEE AA                  <1> 	stosb
  9941 00003BEF A0[D3660000]        <1> 	mov	al, [VGA_VIDEO_CTL] ; ROM BIOS DATA AREA Offset 87h
  9942 00003BF4 AA                  <1> 	stosb
  9943 00003BF5 A0[D4660000]        <1> 	mov	al, [VGA_SWITCHES] ; feature bit switches
  9944 00003BFA AA                  <1> 	stosb
  9945 00003BFB A0[D5660000]        <1> 	mov	al, [VGA_MODESET_CTL] ; basic mode set options
  9946 00003C00 AA                  <1> 	stosb
  9947                              <1> 	; followings are only used by TRDOS 386 v2 (IBM PC/AT ROMBIOS) code 
  9948                              <1> 	; (bochs/plex86 does not use and return those)
  9949 00003C01 A0[D1660000]        <1> 	mov	al, [CRT_PALETTE] ; current color palette ; TRDOS 386 feature only !
  9950 00003C06 AA                  <1> 	stosb
  9951 00003C07 A0[B6770100]        <1> 	mov	al, [ACTIVE_PAGE] ; current video page 
  9952 00003C0C AA                  <1> 	stosb
  9953 00003C0D 66A1[E7660000]      <1> 	mov	ax, [CURSOR_MODE] ; cursor type
  9954 00003C13 66AB                <1> 	stosw
  9955                              <1> 	;mov	eax, [CURSOR_POSN] ; cursor position for video page 0 and 1 
  9956                              <1> 	;stosd
  9957                              <1> 	;mov	eax, [CURSOR_POSN+4] ; cursor position for video page 2 and 3 
  9958                              <1> 	;stosd
  9959                              <1> 	;mov	eax, [CURSOR_POSN+8] ; cursor position for video page 4 and 5 
  9960                              <1> 	;stosd
  9961                              <1> 	;mov	eax, [CURSOR_POSN+12] ; cursor position for video page 6 and 7 
  9962                              <1> 	;stosd
  9963 00003C15 56                  <1> 	push	esi
  9964 00003C16 B504                <1> 	mov	ch, 4
  9965 00003C18 BE[A6770100]        <1> 	mov	esi, CURSOR_POSN
  9966                              <1> bfn_svs_5:
  9967 00003C1D A5                  <1> 	movsd
  9968 00003C1E FECD                <1> 	dec	ch
  9969 00003C20 75FB                <1> 	jnz	short bfn_svs_5
  9970 00003C22 5E                  <1> 	pop	esi
  9971                              <1> 	; (font addr) protected mode address in kernel's/system memory space 
  9972                              <1> 	; (not accessable/meaningful address value by user)
  9973 00003C23 A1[2E840100]        <1> 	mov	eax, [VGA_INT43H] ; VGA current (default) font address
  9974 00003C28 AB                  <1> 	stosd
  9975                              <1> 	
  9976                              <1> 	; (total 40 bytes are written above as BIOS data state)
  9977                              <1> 
  9978                              <1> bfn_svs_6:
  9979                              <1> 	; 12/01/2021
  9980 00003C29 F6C104              <1> 	test	cl, 4
  9981 00003C2C 7422                <1> 	jz	short bfn_svs_8
  9982                              <1> 
  9983                              <1>   	;/* XXX: check this */
  9984                              <1> 		; /* read/write mode dac */
  9985                              <1>         ;write_byte(ES, BX, inb(VGAREG_DAC_STATE)); BX++;
  9986                              <1> 	;	; /* pix address */
  9987                              <1>         ;write_byte(ES, BX, inb(VGAREG_DAC_WRITE_ADDRESS)); BX++;
  9988                              <1>         ;write_byte(ES, BX, inb(VGAREG_PEL_MASK)); BX++;
  9989                              <1>         ;// Set the whole dac always, from 0
  9990                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS,0x00);
  9991                              <1>         ;for(i=0;i<256*3;i++) {
  9992                              <1>         ;   write_byte(ES, BX, inb(VGAREG_DAC_DATA)); BX++;
  9993                              <1>         ;}
  9994                              <1>         ;write_byte(ES, BX, 0); BX++; /* color select register */
  9995                              <1> 
  9996                              <1> 	; /* read/write mode dac */
  9997 00003C2E 66BAC703            <1>     	mov	dx, 3C7h ; VGAREG_DAC_STATE
  9998 00003C32 EC                  <1> 	in	al, dx
  9999 00003C33 AA                  <1> 	stosb
 10000                              <1> 	; /* pix address */
 10001                              <1>     	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 10002                              <1> 	;mov	dl, 0C8h
 10003 00003C34 FEC2                <1> 	inc	dl
 10004 00003C36 EC                  <1> 	in	al, dx
 10005 00003C37 AA                  <1> 	stosb
 10006                              <1>     	;mov	dx, VGAREG_PEL_MASK  ; 3C6h
 10007 00003C38 B2C6                <1> 	mov	dl, 0C6h
 10008 00003C3A EC                  <1> 	in	al, dx
 10009 00003C3B AA                  <1> 	stosb
 10010                              <1> 	;// Set the whole dac always, from 0
 10011 00003C3C 30C0                <1> 	xor	al, al ; 0
 10012                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 10013 00003C3E B2C8                <1> 	mov	dl, 0C8h
 10014 00003C40 EE                  <1> 	out	dx, al
 10015                              <1> 
 10016 00003C41 51                  <1> 	push	ecx ; 22/01/2021
 10017                              <1> 	;for(i=0;i<256*3;i++) {
 10018                              <1> 	;mov	ecx, 256*3 ; 768 bytes
 10019                              <1> 	; 03/08/2022
 10020 00003C42 29C9                <1> 	sub	ecx, ecx
 10021 00003C44 B503                <1> 	mov	ch, 3
 10022                              <1> 	; ecx = 300h = 768
 10023                              <1> 	;mov	dx, VGAREG_DAC_DATA ; 3C9h
 10024                              <1> 	;mov	dl, 0C9h
 10025 00003C46 FEC2                <1> 	inc	dl ; dx = 3C9h
 10026                              <1> bfn_svs_7:
 10027 00003C48 EC                  <1> 	in	al, dx
 10028 00003C49 AA                  <1> 	stosb
 10029 00003C4A E2FC                <1> 	loop	bfn_svs_7
 10030 00003C4C 59                  <1> 	pop	ecx ; 22/01/2021
 10031                              <1> 
 10032                              <1> 	; /* color select register */
 10033 00003C4D 28C0                <1> 	sub	al, al ; 0
 10034 00003C4F AA                  <1> 	stosb
 10035                              <1> 
 10036                              <1> 	; (total 772 bytes are written above as DAC state)
 10037                              <1> bfn_svs_8:
 10038 00003C50 C3                  <1> 	retn
 10039                              <1> 
 10040                              <1> vbe_biosfn_save_video_state:
 10041                              <1> 	; 23/01/2021
 10042                              <1> 	; 13/01/2021
 10043                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
 10044                              <1> 	; (vbe.c)
 10045                              <1> 
 10046                              <1> 	; modified registers: eax, edx, edi, ch
 10047                              <1> 	
 10048                              <1> 	; input: edi = state buffer address
 10049                              <1> 	; output: 
 10050                              <1> 	;	 VBE DISPI register contents will be saved
 10051                              <1> 	;	 (18 bytes, 9 words)
 10052                              <1> 
 10053                              <1> 	; outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 10054                              <1> 	; enable = inw(VBE_DISPI_IOPORT_DATA);
 10055                              <1>   	; write_word(ES, BX, enable);
 10056                              <1>  	; BX += 2;
 10057                              <1> 	; if (!(enable & VBE_DISPI_ENABLED)) 
 10058                              <1> 	;	return;
 10059                              <1> 	; for(i = VBE_DISPI_INDEX_XRES;
 10060                              <1> 	;		 i <= VBE_DISPI_INDEX_Y_OFFSET; i++) {
 10061                              <1> 	;    if (i != VBE_DISPI_INDEX_ENABLE) {
 10062                              <1> 	;        outw(VBE_DISPI_IOPORT_INDEX, i);
 10063                              <1> 	;        write_word(ES, BX, inw(VBE_DISPI_IOPORT_DATA));
 10064                              <1>         ;    BX += 2;
 10065                              <1> 	;        }
 10066                              <1> 	; }
 10067                              <1> 
 10068 00003C51 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10069                              <1> 	;mov	eax, 04h  ; VBE_DISPI_INDEX_ENABLE
 10070                              <1> 	 ;03/08/2022
 10071 00003C55 66EF                <1> 	out	dx, ax
 10072                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA	
 10073 00003C57 FEC2                <1> 	inc	dl
 10074 00003C59 66ED                <1> 	in	ax, dx ; enable (status)
 10075 00003C5B 66AB                <1> 	stosw 
 10076 00003C5D 6683E001            <1> 	and	ax, 1 ; VBE_DISPI_ENABLED
 10077 00003C61 7505                <1> 	jnz	short vbe_bfn_svs_0
 10078                              <1> 	; 23/01/2021
 10079                              <1> 	; ax = 0
 10080                              <1> 	; VBE_DISPI_DISABLED
 10081                              <1> 	; 13/01/2021
 10082                              <1> 	; clear remain 8 bytes 
 10083                              <1> 	;xor	eax, eax
 10084 00003C63 AB                  <1> 	stosd	; 2
 10085 00003C64 AB                  <1> 	stosd	; 2
 10086 00003C65 AB                  <1> 	stosd	; 2
 10087 00003C66 AB                  <1> 	stosd	; 2
 10088 00003C67 C3                  <1> 	retn
 10089                              <1> vbe_bfn_svs_0:
 10090                              <1> 	; VBE_DISPI_ENABLED
 10091                              <1> 
 10092                              <1> 	;sub	eax, eax
 10093 00003C68 28C0                <1> 	sub	al, al ; eax = 0
 10094                              <1> 	
 10095                              <1> 	; from VBE_DISPI_INDEX_XRES
 10096                              <1> 	;   to VBE_DISPI_INDEX_BPP	
 10097                              <1> 
 10098 00003C6A B503                <1>  	mov	ch, 3
 10099                              <1> 	; al = 0 ; VBE_DISPI_INDEX_XRES - 1
 10100                              <1> 
 10101 00003C6C E804000000          <1> 	call	vbe_bfn_svs_1
 10102                              <1> 
 10103                              <1> 	; from VBE_DISPI_INDEX_BANK
 10104                              <1> 	;   to VBE_DISPI_INDEX_Y_OFFSET
 10105                              <1> 
 10106 00003C71 FEC0                <1> 	inc	al 
 10107                              <1> 	; al = 4 ; VBE_DISPI_INDEX_BANK - 1
 10108                              <1> 
 10109 00003C73 B505                <1> 	mov	ch, 5
 10110                              <1> vbe_bfn_svs_1:
 10111 00003C75 FEC0                <1> 	inc	al ; from VBE_DISPI_INDEX_XRES
 10112                              <1> 		   ;   to VBE_DISPI_INDEX_BPP	
 10113                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10114 00003C77 FECA                <1> 	dec	dl ; 1CEh
 10115 00003C79 66EF                <1> 	out	dx, ax
 10116 00003C7B 50                  <1> 	push	eax
 10117                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10118 00003C7C FEC2                <1> 	inc	dl ; 1CFh
 10119 00003C7E 66ED                <1> 	in	ax, dx
 10120 00003C80 66AB                <1> 	stosw
 10121 00003C82 58                  <1> 	pop	eax
 10122 00003C83 FECD                <1> 	dec	ch
 10123 00003C85 75EE                <1> 	jnz	short vbe_bfn_svs_1		
 10124 00003C87 C3                  <1> 	retn
 10125                              <1> 
 10126                              <1> biosfn_restore_video_state:
 10127                              <1> 	; 22/01/2021
 10128                              <1> 	; 13/01/2021
 10129                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
 10130                              <1> 	; (vgabios.c)
 10131                              <1> 
 10132                              <1> 	; modified registers: eax, edx, esi, edi, ch
 10133                              <1> 
 10134                              <1> 	;mov	esi, VBE3SAVERESTOREBLOCK
 10135                              <1> 
 10136                              <1> 	; input: esi = state buffer address
 10137                              <1> 
 10138 00003C88 F6C101              <1> 	test	cl, 1
 10139 00003C8B 0F84A9000000        <1> 	jz	bfn_rvs_6
 10140                              <1> 
 10141 00003C91 66817E40D403        <1> 	cmp	word [esi+64], 3D4h ; must be 3D4h
 10142 00003C97 7402                <1> 	je	short bfn_rvs_0  
 10143                              <1> 			; it is seen as valid buffer
 10144 00003C99 F9                  <1> 	stc
 10145 00003C9A C3                  <1> 	retn
 10146                              <1> 
 10147                              <1> bfn_rvs_0:
 10148 00003C9B 89F7                <1> 	mov	edi, esi ; addr1
 10149 00003C9D 83C605              <1> 	add	esi, 5 ; skip 1st 5 bytes for now
 10150                              <1> 
 10151                              <1> 	; // Reset Attribute Ctl flip-flop
 10152                              <1>         ; inb(VGAREG_ACTL_RESET);
 10153 00003CA0 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10154 00003CA4 EC                  <1> 	in	al, dx
 10155                              <1> 
 10156                              <1> 	; for(i=1;i<=4;i++){
 10157 00003CA5 B001                <1> 	mov	al, 1
 10158                              <1> 	;;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 10159                              <1> 	;mov	dl, 0C4h
 10160 00003CA7 B504                <1> 	mov	ch, 4
 10161                              <1> bfn_rvs_1:
 10162                              <1> 	; outb(VGAREG_SEQU_ADDRESS, i);
 10163                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 10164 00003CA9 B2C4                <1> 	mov	dl, 0C4h
 10165 00003CAB EE                  <1> 	out	dx, al
 10166                              <1> 	;mov	dx, VGAREG_SEQU_DATA  ; 3C5h
 10167 00003CAC FEC2                <1> 	inc	dl  ; dx = 3C5h
 10168                              <1> 	; outb(VGAREG_SEQU_DATA)
 10169 00003CAE 50                  <1> 	push	eax
 10170 00003CAF AC                  <1> 	lodsb	; (4 bytes in loop)
 10171 00003CB0 EE                  <1> 	out	dx, al
 10172 00003CB1 58                  <1> 	pop	eax
 10173                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
 10174                              <1> 	;dec	dl	
 10175 00003CB2 FEC0                <1> 	inc	al  ; i++
 10176 00003CB4 FECD                <1> 	dec	ch
 10177 00003CB6 75F1                <1> 	jnz	short bfn_rvs_1
 10178                              <1> 
 10179                              <1> 	; outb(VGAREG_SEQU_ADDRESS, 0);
 10180 00003CB8 28C0                <1> 	sub	al, al ; 0
 10181 00003CBA EE                  <1> 	out	dx, al
 10182                              <1> 	; outb(VGAREG_SEQU_DATA)
 10183                              <1> 	;mov	dx, VGAREG_SEQU_DATA ; 3C5h
 10184 00003CBB FEC2                <1> 	inc	dl  ; dx = 3C5h
 10185 00003CBD AC                  <1> 	lodsb	; (+1 byte)
 10186 00003CBE EE                  <1> 	out	dx, al
 10187                              <1> 
 10188                              <1> 	; // Disable CRTC write protection
 10189                              <1> 	; outw(crtc_addr,0x0011);
 10190                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 10191 00003CBF B2D4                <1> 	mov	dl, 0D4h
 10192 00003CC1 66B81100            <1> 	mov	ax, 11h
 10193 00003CC5 66EF                <1> 	out	dx, ax
 10194                              <1> 
 10195                              <1> 	; // Set CRTC regs
 10196                              <1>        
 10197                              <1> 	; for(i=0;i<=0x18;i++) {
 10198                              <1>         ;   if (i != 0x11) {
 10199 00003CC7 28C0                <1> 	sub	al, al ; 0
 10200                              <1> 	;;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 10201                              <1> 	;mov	dl, 0D4h
 10202 00003CC9 B519                <1> 	mov	ch, 25
 10203                              <1> bfn_rvs_2:
 10204                              <1>         ; outb(crtc_addr,i);
 10205                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 10206 00003CCB B2D4                <1> 	mov	dl, 0D4h
 10207 00003CCD EE                  <1> 	out	dx, al
 10208                              <1> 	;mov	dx, VGAREG_VGA_CRTC_DATA ; 3D5h
 10209 00003CCE FEC2                <1> 	inc	dl  ; dx = 3D5h
 10210                              <1> 	; inb(crtc_addr+1)
 10211 00003CD0 50                  <1> 	push	eax
 10212 00003CD1 AC                  <1> 	lodsb	; (25 bytes in loop)
 10213 00003CD2 EE                  <1> 	out	dx, al
 10214 00003CD3 58                  <1> 	pop	eax
 10215                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 10216                              <1> 	;dec	dl
 10217 00003CD4 FEC0                <1> 	inc	al  ; i++
 10218 00003CD6 3C11                <1> 	cmp	al, 17 ; 11h
 10219 00003CD8 7505                <1> 	jne	short bfn_rvs_3
 10220 00003CDA AC                  <1> 	lodsb
 10221 00003CDB 88C4                <1> 	mov	ah, al ; *
 10222 00003CDD B012                <1> 	mov	al, 18 
 10223                              <1> bfn_rvs_3:
 10224 00003CDF FECD                <1> 	dec	ch
 10225 00003CE1 75E8                <1> 	jnz	short bfn_rvs_2
 10226                              <1> 
 10227                              <1> 	; // select crtc base address
 10228                              <1>         ; v = inb(VGAREG_READ_MISC_OUTPUT) & ~0x01;
 10229                              <1> 	;if (crtc_addr = 0x3d4)
 10230                              <1> 	;   v |= 0x01;
 10231                              <1> 	; outb(VGAREG_WRITE_MISC_OUTPUT, v);
 10232                              <1> 
 10233                              <1> 	;;mov	dx, VGAREG_READ_MISC_OUTPUT ; 3CCh
 10234                              <1> 	;mov	dl, 0CCh
 10235                              <1> 	;in	al, dl
 10236                              <1> 	;and	al, 1
 10237                              <1> 	;;mov	dx, VGAREG_WRITE_MISC_OUTPUT ; 3C2h
 10238                              <1> 	;mov	dl, 0C2h
 10239                              <1> 	;or	al, 1
 10240                              <1> 	;out	dx, al
 10241                              <1> 
 10242                              <1> 	; // enable write protection if needed
 10243                              <1> 	;outb(crtc_addr, 0x11);
 10244                              <1>         ;outb(crtc_addr+1, read_byte(ES, BX - 0x18 + 0x11));
 10245                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 10246 00003CE3 B2D4                <1> 	mov	dl, 0D4h
 10247 00003CE5 B011                <1> 	mov	al, 11h
 10248 00003CE7 EE                  <1> 	out	dx, al
 10249 00003CE8 88E0                <1> 	mov	al, ah ; *
 10250 00003CEA FEC2                <1> 	inc	dl ; dx = 3D5h
 10251 00003CEC EE                  <1> 	out	dx, al
 10252                              <1> 
 10253                              <1> 	; // Set Attribute Ctl
 10254 00003CED 8A6703              <1> 	mov	ah, [edi+3] ; addr1+3, ah = ar_index
 10255 00003CF0 80E420              <1> 	and	ah, 20h  ; (ar_index & 0x20)
 10256                              <1> 
 10257                              <1>         ; inb(VGAREG_ACTL_RESET);
 10258                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10259 00003CF3 B2DA                <1> 	mov	dl, 0DAh
 10260 00003CF5 EC                  <1> 	in	al, dx
 10261                              <1> 
 10262                              <1>         ; for(i=0;i<=0x13;i++) {
 10263 00003CF6 28C0                <1> 	sub	al, al ; 0
 10264 00003CF8 B514                <1> 	mov	ch, 20
 10265                              <1> bfn_rvs_4:
 10266                              <1>  	; outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20));
 10267 00003CFA 50                  <1> 	push	eax
 10268 00003CFB 08E0                <1> 	or	al, ah
 10269                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
 10270 00003CFD B2C0                <1> 	mov	dl, 0C0h
 10271 00003CFF EE                  <1> 	out	dx, al
 10272                              <1> 	;mov	dx, VGAREG_ACTL_WRITE_DATA ; 3C0h
 10273                              <1> 	;mov	dl, 0C0h
 10274 00003D00 AC                  <1> 	lodsb	; (20 bytes in loop)
 10275 00003D01 EE                  <1> 	out	dx, al
 10276 00003D02 58                  <1> 	pop	eax
 10277 00003D03 FEC0                <1> 	inc	al  ; i++
 10278 00003D05 FECD                <1> 	dec	ch
 10279 00003D07 75F1                <1> 	jnz	short bfn_rvs_4
 10280                              <1> 
 10281                              <1> 	; outb(VGAREG_ACTL_ADDRESS, ar_index);
 10282                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
 10283                              <1> 	;mov	dl, 0C0h
 10284 00003D09 88E0                <1> 	mov	al, ah ; ar_index
 10285 00003D0B EE                  <1> 	out	dx, al
 10286                              <1> 
 10287                              <1> 	; inb(VGAREG_ACTL_RESET);
 10288                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
 10289 00003D0C B2DA                <1> 	mov	dl, 0DAh
 10290 00003D0E EC                  <1> 	in	al, dx
 10291                              <1> 
 10292                              <1>         ; for(i=0;i<=8;i++) {
 10293 00003D0F 28C0                <1> 	sub	al, al ; 0
 10294                              <1> 	;;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
 10295                              <1> 	;mov	dl, 0CEh
 10296 00003D11 B509                <1> 	mov	ch, 9
 10297                              <1> bfn_rvs_5:
 10298                              <1> 	; outb(VGAREG_GRDC_ADDRESS,i)
 10299                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
 10300 00003D13 B2CE                <1> 	mov	dl, 0CEh
 10301 00003D15 EE                  <1> 	out	dx, al
 10302                              <1> 	; outb(VGAREG_ACTL_READ_DATA)
 10303 00003D16 50                  <1> 	push	eax
 10304                              <1> 	;mov	dx, VGAREG_GRDC_DATA ; 3CFh
 10305                              <1> 	;mov	dl, 0CFh
 10306 00003D17 FEC2                <1> 	inc	dl
 10307 00003D19 AC                  <1> 	lodsb	; (9 bytes in loop)
 10308 00003D1A EE                  <1> 	out	dx, al
 10309 00003D1B 58                  <1> 	pop	eax
 10310                              <1> 	;dec	dl
 10311 00003D1C FEC0                <1> 	inc	al  ; i++
 10312 00003D1E FECD                <1> 	dec	ch
 10313 00003D20 75F1                <1> 	jnz	short bfn_rvs_5
 10314                              <1> 
 10315                              <1> 	; BX += 2; /* crtc_addr */     ; 3D4h
 10316                              <1>         ; BX += 4; /* plane latches */ ; 0
 10317 00003D22 83C606              <1> 	add	esi, 6	      
 10318 00003D25 56                  <1> 	push	esi ; *	
 10319                              <1> 
 10320                              <1> 	;outb(VGAREG_SEQU_ADDRESS, read_byte(ES, addr1)); addr1++;
 10321                              <1>         ;outb(crtc_addr, read_byte(ES, addr1)); addr1++;
 10322                              <1>         ;outb(VGAREG_GRDC_ADDRESS, read_byte(ES, addr1)); addr1++;
 10323                              <1>         ;addr1++;
 10324                              <1>         ;outb(crtc_addr - 0x4 + 0xa, read_byte(ES, addr1)); addr1++;
 10325                              <1> 
 10326 00003D26 89FE                <1> 	mov	esi, edi ; start of state buffer
 10327                              <1> 
 10328                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C7h
 10329 00003D28 B2C7                <1> 	mov	dl, 0C7h 
 10330 00003D2A AC                  <1> 	lodsb
 10331 00003D2B EE                  <1> 	out	dx, al
 10332                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
 10333 00003D2C B2D4                <1> 	mov	dl, 0D4h
 10334 00003D2E AC                  <1> 	lodsb
 10335 00003D2F EE                  <1> 	out	dx, al
 10336                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh 
 10337 00003D30 B2CE                <1>         mov	dl, 0CEh
 10338 00003D32 AC                  <1> 	lodsb
 10339 00003D33 EE                  <1> 	out	dx, al
 10340 00003D34 AC                  <1> 	lodsb	; addr1++
 10341                              <1> 	;mov	dx, VGAREG_VGA_WRITE_FEATURE_CTL ; 3DAh
 10342 00003D35 B2DA                <1> 	mov	dl, 0DAh
 10343 00003D37 AC                  <1> 	lodsb
 10344 00003D38 EE                  <1> 	out	dx, al
 10345                              <1> 
 10346 00003D39 5E                  <1> 	pop	esi ; *
 10347                              <1> 
 10348                              <1> 	; (total 70 bytes are read above as controller hardware state)
 10349                              <1> 
 10350                              <1> bfn_rvs_6:		
 10351                              <1> 	; 13/01/2021
 10352 00003D3A F6C102              <1> 	test	cl, 2
 10353 00003D3D 747D                <1> 	jz	short bfn_rvs_9
 10354                              <1> 
 10355                              <1> 	; VIDEO BIOS DATA
 10356                              <1> 	; !!! this data is valid for TRDOS 386 v2 kernel only !!!
 10357                              <1> 	; (this is not same with BOCHS/PLEX86 video bios, BIOS data)  
 10358                              <1>   
 10359                              <1>     	; if (CX & 2) {
 10360                              <1> 	;write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE, read_byte(ES, BX)); BX++;
 10361                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_NB_COLS, read_word(ES, BX)); BX += 2;
 10362                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, read_word(ES, BX)); BX += 2;
 10363                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS, read_word(ES, BX)); BX += 2;
 10364                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, read_byte(ES, BX)); BX++;
 10365                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, read_word(ES, BX)); BX += 2;
 10366                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL, read_byte(ES, BX)); BX++;
 10367                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES, read_byte(ES, BX)); BX++;
 10368                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL, read_byte(ES, BX)); BX++;
 10369                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE, read_word(ES, BX)); BX += 2;
 10370                              <1>         ;for(i=0;i<8;i++) {
 10371                              <1>         ;   write_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i, read_word(ES, BX));
 10372                              <1>         ;   BX += 2;
 10373                              <1>         ;}
 10374                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START, read_word(ES, BX)); BX += 2;
 10375                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE, read_byte(ES, BX)); BX++;
 10376                              <1>         ;/* current font */
 10377                              <1>         ;write_word(0, 0x1f * 4, read_word(ES, BX)); BX += 2;
 10378                              <1>         ;write_word(0, 0x1f * 4 + 2, read_word(ES, BX)); BX += 2;
 10379                              <1>         ;write_word(0, 0x43 * 4, read_word(ES, BX)); BX += 2;
 10380                              <1>         ;write_word(0, 0x43 * 4 + 2, read_word(ES, BX)); BX += 2;
 10381                              <1> 
 10382                              <1> 	; !!! save TRDOS 386 v2 kernel spesific video bios data !!!
 10383                              <1> 	; (which is/are used by 'SET_MODE' function and/or it's sub functions)
 10384                              <1> 
 10385 00003D3F 66AD                <1> 	lodsw	 ; CRTC_ADDR, always 3D4h (color VGA) for TRDOS 386 v2
 10386                              <1> 	; skip 3D4h check if it is already checked
 10387 00003D41 F6C101              <1> 	test	cl, 1
 10388 00003D44 7508                <1> 	jnz	short bfn_rvs_7
 10389 00003D46 663DD403            <1> 	cmp	ax, 3D4h
 10390 00003D4A 7402                <1> 	je	short bfn_rvs_7
 10391 00003D4C F9                  <1> 	stc
 10392 00003D4D C3                  <1> 	retn
 10393                              <1> bfn_rvs_7:
 10394 00003D4E AC                  <1> 	lodsb
 10395 00003D4F A2[CE660000]        <1> 	mov	[CRT_MODE], al ; Current video mode (0FFh for VESA VBE modes) 
 10396 00003D54 AC                  <1> 	lodsb
 10397 00003D55 A2[CF660000]        <1> 	mov	[CRT_MODE_SET], al ; 29h for mode 03h ; TRDOS 386 feature only !
 10398 00003D5A 66AD                <1> 	lodsw	
 10399 00003D5C 66A3[D20F0300]      <1>  	mov	[video_mode], ax ; Current VESA VBE (SVGA, extended VGA) mode 
 10400 00003D62 66AD                <1> 	lodsw		 ; (valid if [CRT_MODE] = 0FFh)	
 10401 00003D64 66A3[1C840100]      <1> 	mov	[CRT_LEN], ax ; page size (in bytes)
 10402 00003D6A 66AD                <1> 	lodsw
 10403 00003D6C 66A3[A4770100]      <1> 	mov	[CRT_START], ax ; video page start offset
 10404 00003D72 AC                  <1>  	lodsb
 10405 00003D73 A2[D0660000]        <1> 	mov	[CRT_COLS], al ; nbcols, characters per row
 10406 00003D78 AC                  <1> 	lodsb
 10407 00003D79 A2[D6660000]        <1> 	mov	[VGA_ROWS], al ; nbrows, (character) rows per page (not rows-1)
 10408 00003D7E AC                  <1> 	lodsb
 10409 00003D7F A2[D2660000]        <1> 	mov	[CHAR_HEIGHT], al ; character font height (8 or 16 or 14)
 10410 00003D84 AC                  <1> 	lodsb
 10411 00003D85 A2[D3660000]        <1> 	mov	[VGA_VIDEO_CTL], al ; ROM BIOS DATA AREA Offset 87h
 10412 00003D8A AC                  <1> 	lodsb
 10413 00003D8B A2[D4660000]        <1> 	mov	[VGA_SWITCHES], al ; feature bit switches
 10414 00003D90 AC                  <1> 	lodsb
 10415 00003D91 A2[D5660000]        <1> 	mov	[VGA_MODESET_CTL], al ; basic mode set options
 10416                              <1> 	; followings are only used by TRDOS 386 v2 (IBM PC/AT ROMBIOS) code 
 10417                              <1> 	; (bochs/plex86 does not use and return those)
 10418 00003D96 AC                  <1> 	lodsb
 10419 00003D97 A2[D1660000]        <1> 	mov	[CRT_PALETTE], al ; current color palette ; TRDOS 386 feature only !
 10420 00003D9C AC                  <1> 	lodsb
 10421 00003D9D A2[B6770100]        <1> 	mov	[ACTIVE_PAGE], al ; current video page 
 10422 00003DA2 66AD                <1> 	lodsw
 10423 00003DA4 66A3[E7660000]      <1> 	mov	[CURSOR_MODE], ax ; cursor type
 10424                              <1> 	;lodsd
 10425                              <1> 	;mov	[CURSOR_POSN], eax ; cursor position for video page 0 and 1 
 10426                              <1> 	;lodsd
 10427                              <1> 	;mov	[CURSOR_POSN+4], eax ; cursor position for video page 2 and 3 
 10428                              <1> 	;lodsd
 10429                              <1> 	;mov	[CURSOR_POSN+8], eax ; cursor position for video page 4 and 5 
 10430                              <1> 	;lodsd
 10431                              <1> 	;mov	[CURSOR_POSN+12], eax ; cursor position for video page 6 and 7 
 10432 00003DAA B504                <1> 	mov	ch, 4
 10433 00003DAC BF[A6770100]        <1> 	mov	edi, CURSOR_POSN
 10434                              <1> bfn_rvs_8:
 10435 00003DB1 A5                  <1> 	movsd
 10436 00003DB2 FECD                <1> 	dec	ch
 10437 00003DB4 75FB                <1> 	jnz	short bfn_rvs_8
 10438                              <1> 	; (font addr) protected mode address in kernel's/system memory space 
 10439                              <1> 	; (not accessable/meaningful address value by user)
 10440 00003DB6 AD                  <1> 	lodsd
 10441 00003DB7 A3[2E840100]        <1> 	mov	[VGA_INT43H], eax ; VGA current (default) font address
 10442                              <1> 
 10443                              <1> 	; (total 40 bytes are read&written above as BIOS data state)
 10444                              <1> bfn_rvs_9:
 10445                              <1> 	; 13/01/2021
 10446 00003DBC F6C104              <1> 	test	cl, 4
 10447 00003DBF 7421                <1> 	jz	short bfn_rvs_11
 10448                              <1> 
 10449                              <1> 	;BX++;
 10450                              <1>         ;v = read_byte(ES, BX); BX++;
 10451                              <1>         ;outb(VGAREG_PEL_MASK, read_byte(ES, BX)); BX++;
 10452                              <1>         ;// Set the whole dac always, from 0
 10453                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS,0x00);
 10454                              <1>         ;for(i=0;i<256*3;i++) {
 10455                              <1>         ;   outb(VGAREG_DAC_DATA, read_byte(ES, BX)); BX++;
 10456                              <1>         ;}
 10457                              <1>         ;BX++;
 10458                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS, v);
 10459                              <1> 
 10460                              <1> 	; /* read/write mode dac */
 10461 00003DC1 AC                  <1> 	lodsb	; skip ; VGAREG_DAC_STATE
 10462 00003DC2 AC                  <1> 	lodsb
 10463 00003DC3 88C4                <1> 	mov	ah, al ; * ; v
 10464 00003DC5 AC                  <1> 	lodsb
 10465 00003DC6 66BAC603            <1> 	mov	dx, VGAREG_PEL_MASK  ; 3C6h
 10466 00003DCA EE                  <1> 	out	dx, al
 10467                              <1> 	;// Set the whole dac always, from 0
 10468 00003DCB 30C0                <1> 	xor	al, al ; 0
 10469                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 10470 00003DCD B2C8                <1> 	mov	dl, 0C8h
 10471 00003DCF EE                  <1> 	out	dx, al
 10472                              <1> 
 10473 00003DD0 51                  <1> 	push	ecx ; 22/01/2021
 10474                              <1> 	;for(i=0;i<256*3;i++) {
 10475                              <1> 	;mov	ecx, 256*3 ; 768 bytes
 10476                              <1> 	; 03/08/2022
 10477 00003DD1 29C9                <1> 	sub	ecx, ecx
 10478 00003DD3 B503                <1> 	mov	ch, 3
 10479                              <1> 	; ecx = 300h = 768
 10480                              <1> 	;mov	dx, VGAREG_DAC_DATA ; 3C9h
 10481                              <1> 	;mov	dl, 0C9h
 10482 00003DD5 FEC2                <1> 	inc	dl ; dx = 3C9h
 10483                              <1> bfn_rvs_10:
 10484 00003DD7 AC                  <1> 	lodsb
 10485 00003DD8 EE                  <1> 	out	dx, al
 10486 00003DD9 E2FC                <1> 	loop	bfn_rvs_10
 10487 00003DDB 59                  <1> 	pop	ecx ; 22/01/2021
 10488                              <1> 
 10489                              <1> 	; /* color select register */
 10490 00003DDC AC                  <1> 	lodsb	 ; skip 
 10491                              <1> 	
 10492 00003DDD 88E0                <1> 	mov	al, ah ; * ; v
 10493                              <1> 
 10494                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
 10495                              <1> 	;mov	dl, 0C8h
 10496 00003DDF FECA                <1> 	dec	dl ; dx  = 3C8h
 10497 00003DE1 EE                  <1> 	out	dx, al ; * ; v
 10498                              <1> 	
 10499                              <1> 	; (total 772 bytes are read above as DAC state)
 10500                              <1> bfn_rvs_11:
 10501 00003DE2 C3                  <1> 	retn
 10502                              <1> 
 10503                              <1> vbe_biosfn_restore_video_state:
 10504                              <1> 	; 23/01/2021
 10505                              <1> 	; 13/01/2021 (TRDOS 386 v2.0.3)
 10506                              <1> 	; (vbe.c)
 10507                              <1> 
 10508                              <1> 	; modified registers: eax, edx, esi, ch
 10509                              <1> 	
 10510                              <1> 	; input: esi = state buffer address
 10511                              <1> 	; output: 
 10512                              <1> 	;	 VBE DISPI register contents will be restored
 10513                              <1> 	;	 (18 bytes, 9 words)
 10514                              <1> 
 10515                              <1>  	; enable = read_word(ES, BX);
 10516                              <1> 	; BX += 2;
 10517                              <1> 	;
 10518                              <1> 	; if (!(enable & VBE_DISPI_ENABLED)) {
 10519                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 10520                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, enable);
 10521                              <1> 	; } else {
 10522                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);
 10523                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 10524                              <1>         ;   BX += 2;
 10525                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);
 10526                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 10527                              <1>         ;   BX += 2;
 10528                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
 10529                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 10530                              <1>         ;   BX += 2;
 10531                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 10532                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, enable);
 10533                              <1> 	;
 10534                              <1>         ;  for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++)
 10535                              <1> 	;    {
 10536                              <1>         ;     outw(VBE_DISPI_IOPORT_INDEX, i);
 10537                              <1>         ;     outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
 10538                              <1>         ;     BX += 2;
 10539                              <1>         ;    }
 10540                              <1>         ; }
 10541                              <1> 
 10542 00003DE3 66AD                <1> 	lodsw	; enable (status, enabled=1, disabled=0)
 10543 00003DE5 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10544                              <1> 	; 23/01/2021
 10545 00003DE9 6683E001            <1> 	and	ax, 1 ; VBE_DISPI_ENABLED
 10546 00003DED 750B                <1> 	jnz	short vbe_bfn_rvs_1
 10547                              <1> 	; ax = 0
 10548                              <1> 	; VBE_DISPI_DISABLED
 10549                              <1> vbe_bfn_rvs_0:
 10550                              <1> 	; enable (disable) dispi
 10551                              <1> 	; dx = 01CEh ; VBE_DISPI_IOPORT_INDEX
 10552                              <1> 	; ah = 0
 10553 00003DEF 50                  <1> 	push	eax
 10554 00003DF0 B004                <1> 	mov	al, 04h	; VBE_DISPI_INDEX_ENABLE
 10555 00003DF2 66EF                <1> 	out	dx, ax
 10556                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10557 00003DF4 FEC2                <1> 	inc	dl
 10558 00003DF6 58                  <1> 	pop	eax
 10559 00003DF7 66EF                <1> 	out	dx, ax ; enable (or disable)
 10560 00003DF9 C3                  <1> 	retn
 10561                              <1> vbe_bfn_rvs_1:
 10562                              <1> 	; VBE_DISPI_ENABLED
 10563                              <1> 
 10564                              <1> 	; from VBE_DISPI_INDEX_XRES
 10565                              <1> 	;   to VBE_DISPI_INDEX_BPP	
 10566                              <1> 
 10567 00003DFA B503                <1>  	mov	ch, 3
 10568 00003DFC 28C0                <1> 	sub	al, al ; 0 ; VBE_DISPI_INDEX_XRES - 1
 10569                              <1> 	; ax = 0
 10570                              <1> 
 10571 00003DFE E80B000000          <1> 	call	vbe_bfn_rvs_2
 10572                              <1> 
 10573                              <1>         ;outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
 10574                              <1> 	;outw(VBE_DISPI_IOPORT_DATA, enable);
 10575                              <1> 
 10576                              <1> 	; 23/01/2021
 10577 00003E03 B001                <1> 	mov	al, 1 ; VBE_DISPI_ENABLED
 10578                              <1> 	; ax = 1
 10579 00003E05 E8E5FFFFFF          <1> 	call	vbe_bfn_rvs_0
 10580                              <1> 
 10581                              <1> 	; from VBE_DISPI_INDEX_BANK
 10582                              <1> 	;   to VBE_DISPI_INDEX_Y_OFFSET
 10583                              <1> 
 10584 00003E0A B505                <1> 	mov	ch, 5
 10585                              <1> 	; 23/01/2021
 10586 00003E0C B004                <1> 	mov	al, 4  ; VBE_DISPI_INDEX_BANK - 1
 10587                              <1> 	; ax = 4
 10588                              <1> vbe_bfn_rvs_2:
 10589 00003E0E FEC0                <1> 	inc	al ; from VBE_DISPI_INDEX_XRES
 10590                              <1> 		     ; to VBE_DISPI_INDEX_BPP	
 10591                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10592                              <1> 	;mov	dl, 0CEh
 10593 00003E10 66EF                <1> 	out	dx, ax
 10594 00003E12 50                  <1> 	push	eax
 10595                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10596 00003E13 FEC2                <1> 	inc	dl ; 1CFh
 10597 00003E15 66AD                <1> 	lodsw
 10598 00003E17 66EF                <1> 	out	dx, ax
 10599 00003E19 58                  <1> 	pop	eax
 10600 00003E1A FECA                <1> 	dec	dl ; 1CEh
 10601 00003E1C FECD                <1> 	dec	ch
 10602 00003E1E 75EE                <1> 	jnz	short vbe_bfn_rvs_2		
 10603 00003E20 C3                  <1> 	retn
 10604                              <1> 
 10605                              <1> ; ---------------------------------------------------------
 10606                              <1>  
 10607                              <1> dispi_set_enable:
 10608                              <1> 	; 03/08/2022
 10609                              <1> 	; 23/11/2020
 10610                              <1> 	; Input:
 10611                              <1> 	;	ax = VBE_DISPI_ENABLED = 1
 10612                              <1> 	;	     or VBE_DISPI_DISABLED = 0
 10613                              <1> 	;
 10614                              <1> 	; Modified registers: none
 10615                              <1> 	
 10616                              <1> 	;push	edx
 10617                              <1> 	;push	eax
 10618                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10619                              <1> 	;mov	ax, 04h	  ; VBE_DISPI_INDEX_ENABLE
 10620                              <1> 	;out	dx, ax
 10621                              <1> 	;pop	eax
 10622                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10623                              <1> 	;;mov	dl, 0CFh
 10624                              <1> 	;inc	dl
 10625                              <1> 	;out	dx, ax
 10626                              <1> 	;pop	edx
 10627                              <1> 	;retn
 10628                              <1> 
 10629                              <1> 	; 25/11/2020
 10630                              <1> 	; Modified registers: edx
 10631                              <1> 	;;push	edx
 10632                              <1> 	;mov	dx, 04h ; VBE_DISPI_INDEX_ENABLE
 10633                              <1> 	; 03/08/2022
 10634 00003E21 28F6                <1> 	sub	dh, dh
 10635 00003E23 B204                <1> 	mov	dl, 04h ; VBE_DISPI_INDEX_ENABLE
 10636                              <1> 
 10637                              <1> 	;;call	dispi_set_parms
 10638                              <1> 	;;pop	edx
 10639                              <1> 	;;retn
 10640                              <1> 	;jmp	short dispi_set_parms
 10641                              <1> 
 10642                              <1> dispi_set_parms:
 10643                              <1> 	; 03/08/2022
 10644                              <1> 	; 25/11/2020
 10645                              <1> 	; Input:
 10646                              <1> 	;	ax = data
 10647                              <1> 	;	dx = vbe dispi register index
 10648                              <1> 	;
 10649                              <1> 	; Modified registers: edx
 10650                              <1> 
 10651 00003E25 50                  <1> 	push	eax
 10652                              <1> 	;mov	ax, dx
 10653                              <1> 	; 03/08/2022
 10654 00003E26 89D0                <1> 	mov	eax, edx
 10655 00003E28 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10656 00003E2C 66EF                <1> 	out	dx, ax
 10657 00003E2E 58                  <1> 	pop	eax
 10658                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10659                              <1> 	;mov	dl, 0CFh
 10660 00003E2F FEC2                <1> 	inc	dl
 10661 00003E31 66EF                <1> 	out	dx, ax
 10662 00003E33 C3                  <1> 	retn
 10663                              <1> 
 10664                              <1> dispi_set_bpp:
 10665                              <1> 	; 03/08/2022
 10666                              <1> 	; 25/11/2020
 10667                              <1> 	; Input:
 10668                              <1> 	;	ax = Bits per pixel value
 10669                              <1> 	;	     (8,16,24,32)
 10670                              <1> 	;
 10671                              <1> 	; Modified registers: none
 10672                              <1> 
 10673                              <1> 	;push	edx
 10674                              <1> 	;push	eax
 10675                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10676                              <1> 	;mov	ax, 03h	  ; VBE_DISPI_INDEX_BPP
 10677                              <1> 	;out	dx, ax
 10678                              <1> 	;pop	eax
 10679                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10680                              <1> 	;;mov	dl, 0CFh
 10681                              <1> 	;inc	dl
 10682                              <1> 	;out	dx, ax
 10683                              <1> 	;pop	edx
 10684                              <1> 	;retn
 10685                              <1> 
 10686                              <1> 	; 25/11/2020
 10687                              <1> 	; Modified registers: edx
 10688                              <1> 	;;push	edx
 10689                              <1> 	;mov	dx, 03h ; VBE_DISPI_INDEX_BPP
 10690                              <1> 	; 03/08/2022
 10691 00003E34 28F6                <1> 	sub	dh, dh
 10692 00003E36 B203                <1> 	mov	dl, 03h ; VBE_DISPI_INDEX_BPP	
 10693                              <1> 
 10694                              <1> 	;;call	dispi_set_parms
 10695                              <1> 	;;pop	edx
 10696                              <1> 	;;retn
 10697 00003E38 EBEB                <1> 	jmp	short dispi_set_parms
 10698                              <1> 
 10699                              <1> dispi_set_xres:
 10700                              <1> 	; 03/08/2022
 10701                              <1> 	; 25/11/2020
 10702                              <1> 	; Input:
 10703                              <1> 	;	ax = X resolution (screen witdh)
 10704                              <1> 	;	     (320,640,800,1024,1280,1920)
 10705                              <1> 	;
 10706                              <1> 	; Modified registers: none
 10707                              <1> 
 10708                              <1> 	;push	edx
 10709                              <1> 	;push	eax
 10710                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10711                              <1> 	;mov	ax, 01h	  ; VBE_DISPI_INDEX_XRES
 10712                              <1> 	;out	dx, ax
 10713                              <1> 	;pop	eax
 10714                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10715                              <1> 	;;mov	dl, 0CFh
 10716                              <1> 	;inc	dl
 10717                              <1> 	;out	dx, ax
 10718                              <1> 	;pop	edx
 10719                              <1> 	;retn
 10720                              <1> 
 10721                              <1> 	; 25/11/2020
 10722                              <1> 	; Modified registers: edx
 10723                              <1> 	;;push	edx
 10724                              <1> 	;mov	dx, 01h ; VBE_DISPI_INDEX_XRES
 10725                              <1> 	; 03/08/2022
 10726 00003E3A 28F6                <1> 	sub	dh, dh
 10727 00003E3C B201                <1> 	mov	dl, 01h ; VBE_DISPI_INDEX_XRES
 10728                              <1> 	;;call	dispi_set_parms
 10729                              <1> 	;;pop	edx
 10730                              <1> 	;;retn
 10731 00003E3E EBE5                <1> 	jmp	short dispi_set_parms
 10732                              <1> 
 10733                              <1> dispi_set_yres:
 10734                              <1> 	; 03/08/2022
 10735                              <1> 	; 25/11/2020
 10736                              <1> 	; Input:
 10737                              <1> 	;	ax = Y resolution (screen height)
 10738                              <1> 	;	     (200,400,600,720,768,1080)
 10739                              <1> 	;
 10740                              <1> 	; Modified registers: none
 10741                              <1> 
 10742                              <1> 	;push	edx
 10743                              <1> 	;push	eax
 10744                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10745                              <1> 	;mov	ax, 02h	  ; VBE_DISPI_INDEX_YRES
 10746                              <1> 	;out	dx, ax
 10747                              <1> 	;pop	eax
 10748                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10749                              <1> 	;;mov	dl, 0CFh
 10750                              <1> 	;inc	dl
 10751                              <1> 	;out	dx, ax
 10752                              <1> 	;pop	edx
 10753                              <1> 	;retn
 10754                              <1> 
 10755                              <1> 	; 25/11/2020
 10756                              <1> 	; Modified registers: edx
 10757                              <1> 	;;push	edx
 10758                              <1> 	;mov	dx, 02h ; VBE_DISPI_INDEX_YRES
 10759                              <1> 	; 03/08/2022
 10760 00003E40 28F6                <1> 	sub	dh, dh
 10761 00003E42 B202                <1> 	mov	dl, 02h ; VBE_DISPI_INDEX_YRES
 10762                              <1> 	;;call	dispi_set_parms
 10763                              <1> 	;;pop	edx
 10764                              <1> 	;;retn
 10765 00003E44 EBDF                <1> 	jmp	short dispi_set_parms
 10766                              <1> 
 10767                              <1> dispi_set_bank:
 10768                              <1> 	; 03/08/2022
 10769                              <1> 	; 25/11/2020
 10770                              <1> 	; Input:
 10771                              <1> 	;	ax = video memory bank number
 10772                              <1> 	;
 10773                              <1> 	; Modified registers: none
 10774                              <1> 
 10775                              <1> 	;push	edx
 10776                              <1> 	;push	eax
 10777                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10778                              <1> 	;mov	ax, 05h	  ; VBE_DISPI_INDEX_BANK
 10779                              <1> 	;out	dx, ax
 10780                              <1> 	;pop	eax
 10781                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10782                              <1> 	;;mov	dl, 0CFh
 10783                              <1> 	;inc	dl
 10784                              <1> 	;out	dx, ax
 10785                              <1> 	;pop	edx
 10786                              <1> 	;retn
 10787                              <1> 	
 10788                              <1> 	; 25/11/2020
 10789                              <1> 	; Modified registers: edx
 10790                              <1> 	;;push	edx
 10791                              <1> 	;mov	dx, 05h	; VBE_DISPI_INDEX_BANK
 10792                              <1> 	; 03/08/2022
 10793 00003E46 28F6                <1> 	sub	dh, dh
 10794 00003E48 B205                <1> 	mov	dl, 05h	; VBE_DISPI_INDEX_BANK
 10795                              <1> 	;;call	dispi_set_parms
 10796                              <1> 	;;pop	edx
 10797                              <1> 	;;retn
 10798 00003E4A EBD9                <1> 	jmp	short dispi_set_parms
 10799                              <1> 
 10800                              <1> dispi_get_enable:
 10801                              <1> 	; 03/08/2022
 10802                              <1> 	; 27/11/2020
 10803                              <1> 	; Input:
 10804                              <1> 	;	none
 10805                              <1> 	; Output:
 10806                              <1> 	;	ax = vbe dispi status
 10807                              <1> 	;
 10808                              <1> 	; Modified registers: eax
 10809                              <1> 	
 10810                              <1> 	;push	edx
 10811                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10812                              <1> 	;mov	ax, 04h	  ; VBE_DISPI_INDEX_ENABLE
 10813                              <1> 	;out	dx, ax
 10814                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10815                              <1> 	;;mov	dl, 0CFh
 10816                              <1> 	;inc	dl
 10817                              <1> 	;in	ax, dx
 10818                              <1> 	;pop	edx
 10819                              <1> 	;retn
 10820                              <1> 
 10821                              <1> 	; 27/11/2020
 10822                              <1> 	; Modified registers: eax, edx
 10823                              <1> 	;;push	edx
 10824                              <1> 	;mov	ax, 04h ; VBE_DISPI_INDEX_ENABLE
 10825                              <1> 	; 03/08/2022
 10826 00003E4C 28E4                <1> 	sub	ah, ah
 10827 00003E4E B004                <1> 	mov	al, 04h ; VBE_DISPI_INDEX_ENABLE
 10828                              <1> 
 10829                              <1> 	;;call	dispi_get_parms
 10830                              <1> 	;;pop	edx
 10831                              <1> 	;;retn
 10832                              <1> 	;jmp	short dispi_get_parms
 10833                              <1> 
 10834                              <1> dispi_get_parms:
 10835                              <1> 	; 25/11/2020
 10836                              <1> 	; Input:
 10837                              <1> 	;	ax = vbe dispi register index
 10838                              <1> 	; output:
 10839                              <1> 	;	ax = data
 10840                              <1> 	;
 10841                              <1> 	; Modified registers: eax, edx
 10842                              <1> 
 10843 00003E50 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10844 00003E54 66EF                <1> 	out	dx, ax
 10845                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10846                              <1> 	;mov	dl, 0CFh
 10847 00003E56 FEC2                <1> 	inc	dl
 10848 00003E58 66ED                <1> 	in	ax, dx
 10849 00003E5A C3                  <1> 	retn
 10850                              <1> 
 10851                              <1> vga_compat_setup:
 10852                              <1> 	; 03/08/2022
 10853                              <1> 	; 26/11/2020
 10854                              <1> 	; 25/11/2020
 10855                              <1> 	; VGA compatibility setup
 10856                              <1> 	; (vbe.c, 02/01/2020, vruppert)
 10857                              <1> 	;
 10858                              <1> 	; Input:
 10859                              <1> 	;	none
 10860                              <1> 	;
 10861                              <1> 	; Modified registers: eax, edx
 10862                              <1> 	
 10863                              <1> 	; 26/11/2020
 10864                              <1>   	;push	eax
 10865                              <1>   	;push	edx
 10866                              <1> 
 10867                              <1>   	; set CRT X resolution
 10868 00003E5B 66BACE01            <1>   	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 10869                              <1>   	;mov	ax, 01h  ; VBE_DISPI_INDEX_XRES
 10870                              <1>   	; 03/08/2022
 10871 00003E5F 31C0                <1> 	xor	eax, eax
 10872 00003E61 FEC0                <1> 	inc	al
 10873                              <1> 	; eax = 1
 10874 00003E63 66EF                <1> 	out	dx, ax
 10875                              <1>   	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 10876 00003E65 FEC2                <1>   	inc	dl
 10877 00003E67 66ED                <1> 	in	ax, dx
 10878 00003E69 50                  <1> 	push	eax
 10879 00003E6A 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 10880 00003E6E 66B81100            <1> 	mov	ax, 0011h ; Vertical retrace end register
 10881 00003E72 66EF                <1>   	out	dx, ax
 10882                              <1>   	;pop	eax
 10883                              <1>   	;push	eax
 10884 00003E74 8B0424              <1>   	mov	eax, [esp]
 10885                              <1> 	;shr	ax, 3 ; / 8 for pixel to character
 10886                              <1> 	;dec	ax  ; - 1 (EGA or VGA?)
 10887                              <1>   	; 03/08/2022
 10888 00003E77 C1E803              <1> 	shr	eax, 3
 10889 00003E7A 48                  <1>   	dec	eax
 10890 00003E7B 88C4                <1> 	mov	ah, al
 10891 00003E7D B001                <1>   	mov	al, 01h ; Horizontal display end register
 10892 00003E7F 66EF                <1>   	out	dx, ax
 10893 00003E81 58                  <1>   	pop	eax
 10894                              <1> 
 10895 00003E82 E89C000000          <1> 	call	vga_set_virt_width
 10896                              <1> 
 10897                              <1>   	; set CRT Y resolution
 10898                              <1> 	; 03/08/2022
 10899 00003E87 66BACE01            <1>   	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 10900 00003E8B 66B80200            <1>   	mov	ax, 02h  ; VBE_DISPI_INDEX_YRES
 10901 00003E8F 66EF                <1>   	out	dx, ax
 10902                              <1>   	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 10903                              <1> 	; 03/08/2022
 10904 00003E91 FEC2                <1>   	inc	dl
 10905 00003E93 66ED                <1> 	in	ax, dx
 10906 00003E95 50                  <1> 	push	eax
 10907 00003E96 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 10908 00003E9A 88C4                <1>   	mov	ah, al
 10909 00003E9C B012                <1> 	mov	al, 12h ; Vertical display end register
 10910 00003E9E 66EF                <1>   	out	dx, ax
 10911 00003EA0 58                  <1>   	pop	eax
 10912 00003EA1 B007                <1>   	mov	al, 07h	; Overflow register
 10913 00003EA3 EE                  <1>   	out	dx, al
 10914                              <1>   	;inc	dx
 10915                              <1>   	; 03/08/2022
 10916 00003EA4 FEC2                <1> 	inc	dl
 10917 00003EA6 EC                  <1> 	in	al, dx ; read overflow register
 10918 00003EA7 24BD                <1>   	and	al, 0BDh ; clear VDE 9th and 10th bits	
 10919 00003EA9 F6C401              <1>   	test	ah, 01h
 10920 00003EAC 7402                <1>   	jz	short bit8_clear
 10921 00003EAE 0C02                <1>   	or	al, 02h ; VDE 9th bit (bit 8) in bit 1
 10922                              <1> bit8_clear:
 10923 00003EB0 F6C402              <1>   	test	ah, 02h
 10924 00003EB3 7402                <1>   	jz	short bit9_clear
 10925 00003EB5 0C40                <1>   	or	al, 40h ; VDE 10th bit (bit 9) in bit 6
 10926                              <1> bit9_clear:
 10927 00003EB7 EE                  <1>   	out	dx, al
 10928                              <1> 
 10929                              <1>   	; other settings
 10930                              <1>  	;mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 10931                              <1>   	; 03/08/2022
 10932 00003EB8 B2D4                <1> 	mov	dl, 0D4h
 10933 00003EBA 66B80900            <1> 	mov	ax, 0009h ; Maximum scan line register
 10934 00003EBE 66EF                <1>   	out	dx, ax	; Reset
 10935 00003EC0 B017                <1>   	mov	al, 17h ; Mode control register		
 10936 00003EC2 EE                  <1>   	out	dx, al
 10937                              <1>  	;mov	dx, 3D5h ; VGAREG_VGA_CRTC_DATA
 10938 00003EC3 FEC2                <1>   	inc	dl
 10939 00003EC5 EC                  <1> 	in	al, dx	; Read mode control register
 10940 00003EC6 0C03                <1>   	or	al, 03h ; Set SRS and CMS bits
 10941 00003EC8 EE                  <1>   	out	dx, al 
 10942                              <1>   	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10943                              <1>   	; 03/08/2022
 10944 00003EC9 B2DA                <1> 	mov	dl, 0DAh
 10945 00003ECB EC                  <1> 	in	al, dx	 ; clear flip-flop
 10946                              <1>   	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10947                              <1>   	; 03/08/2022
 10948 00003ECC B2C0                <1> 	mov	dl, 0C0h
 10949 00003ECE B010                <1> 	mov	al, 10h	; Mode control register
 10950 00003ED0 EE                  <1>   	out	dx, al
 10951                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 10952 00003ED1 FEC2                <1> 	inc	dl
 10953 00003ED3 EC                  <1> 	in	al, dx
 10954 00003ED4 0C01                <1> 	or	al, 01h ; select graphics mode
 10955                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10956 00003ED6 FECA                <1> 	dec	dl
 10957 00003ED8 EE                  <1> 	out	dx, al ; Write to mode control register
 10958 00003ED9 B020                <1> 	mov	al, 20h ; Palette RAM <-> display memory
 10959 00003EDB EE                  <1> 	out	dx, al ; Write to attribute addr register
 10960                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 10961                              <1> 	; 03/08/2022
 10962 00003EDC B2CE                <1> 	mov	dl, 0CEh 
 10963 00003EDE 66B80605            <1> 	mov	ax, 0506h ; Misc. register, graph, mm 1
 10964 00003EE2 66EF                <1> 	out	dx, ax
 10965                              <1> 	;mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 10966                              <1> 	; 03/08/2022
 10967 00003EE4 B2C4                <1> 	mov	dl, 0C4h 
 10968 00003EE6 66B8020F            <1> 	mov	ax, 0F02h ; Map mask register, all planes
 10969 00003EEA 66EF                <1> 	out	dx, ax
 10970                              <1> 
 10971                              <1>   	; settings for >= 8bpp
 10972                              <1> 
 10973                              <1> 	;mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 10974                              <1> 	;mov	ax, 03h ; VBE_DISPI_INDEX_BPP
 10975                              <1> 	;out	dx, ax
 10976                              <1> 	;;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 10977                              <1> 	;inc	dl
 10978                              <1> 	;in	ax, dx
 10979                              <1> 	;cmp	al, 08h  ; < 8 bits per pixel
 10980                              <1> 	;jb	short vga_compat_end
 10981                              <1> 
 10982                              <1> 	;mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 10983                              <1> 	; 03/08/2022
 10984 00003EEC B2D4                <1> 	mov	dl, 0D4h
 10985 00003EEE B014                <1> 	mov	al, 14h  ; Underline location register
 10986 00003EF0 EE                  <1> 	out	dx, al
 10987                              <1> 	;mov	dx, 3D5h ; VGAREG_VGA_CRTC_DATA
 10988 00003EF1 FEC2                <1> 	inc	dl
 10989 00003EF3 EC                  <1> 	in	al, dx	
 10990 00003EF4 0C40                <1> 	or	al, 40h	 ; enable double word mode
 10991 00003EF6 EE                  <1> 	out	dx, al
 10992                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10993                              <1> 	; 03/08/2022
 10994 00003EF7 B2DA                <1> 	mov	dl, 0DAh
 10995 00003EF9 EC                  <1> 	in	al, dx	 ; clear flip-flop
 10996                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10997                              <1> 	; 03/08/2022
 10998 00003EFA B2C0                <1> 	mov	dl, 0C0h
 10999 00003EFC B010                <1> 	mov	al, 10h	 ; Mode control register
 11000 00003EFE EE                  <1> 	out	dx, al
 11001                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 11002 00003EFF FEC2                <1> 	inc	dl
 11003 00003F01 EC                  <1> 	in	al, dx
 11004 00003F02 0C40                <1> 	or	al, 40h  ; Pixel clock select is 1
 11005                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 11006 00003F04 FECA                <1> 	dec	dl
 11007 00003F06 EE                  <1> 	out	dx, al	 ; update mode control reggister
 11008 00003F07 B020                <1> 	mov	al, 20h	 ; select display memory as PAS	
 11009 00003F09 EE                  <1> 	out	dx, al
 11010                              <1> 	;mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 11011                              <1> 	; 03/08/2022
 11012 00003F0A B2C4                <1> 	mov	dl, 0C4h
 11013 00003F0C B004                <1> 	mov	al, 04h	; Memory mode register
 11014 00003F0E EE                  <1> 	out	dx, al
 11015                              <1> 	;mov	dx, 3C5h ; VGAREG_SEQU_DATA
 11016 00003F0F FEC2                <1> 	inc	dl
 11017 00003F11 EC                  <1> 	in	al, dx
 11018 00003F12 0C08                <1> 	or	al, 08h	; enable chain four
 11019 00003F14 EE                  <1> 	out	dx, al
 11020                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 11021                              <1> 	; 03/08/2022
 11022 00003F15 B2CE                <1> 	mov	dl, 0CEh
 11023 00003F17 B005                <1> 	mov	al, 05h	 ; Mode register	
 11024 00003F19 EE                  <1> 	out	dx, al
 11025                              <1> 	;mov	dx, 3CFh ; VGAREG_GRDC_DATA
 11026 00003F1A FEC2                <1> 	inc	dl
 11027 00003F1C EC                  <1> 	in	al, dx	
 11028 00003F1D 249F                <1> 	and	al, 9Fh	 ; clear shift register 
 11029 00003F1F 0C40                <1> 	or	al, 40h  ; set shift register to 2
 11030 00003F21 EE                  <1> 	out	dx, al
 11031                              <1> 
 11032                              <1> vga_compat_end:
 11033                              <1>   	;pop	edx
 11034                              <1>   	;pop	eax
 11035 00003F22 C3                  <1> 	retn
 11036                              <1> 
 11037                              <1> vga_set_virt_width:
 11038                              <1> 	; 03/08/2022
 11039                              <1> 	; 27/11/2020
 11040                              <1> 	; 25/11/2020
 11041                              <1> 	; (vbe.c, 02/01/2020, vruppert)
 11042                              <1> 	;
 11043                              <1> 	; Input:
 11044                              <1> 	;	AX = resolution (screen width)
 11045                              <1> 	;
 11046                              <1> 	; Modified registers: eax, edx
 11047                              <1> 
 11048                              <1>   	;;push	ebx
 11049                              <1>   	;push	edx
 11050                              <1> 	;push	eax
 11051                              <1>   	;mov	ebx, eax
 11052                              <1>   	;call	dispi_get_bpp ; bits per pixel
 11053                              <1> 	;cmp	al, 4
 11054                              <1> 	;ja	short set_width_svga  ; 8, 16, 24, 32 
 11055                              <1> 	;shr	bx, 1
 11056                              <1> ;set_width_svga:
 11057                              <1> 	;shr	bx, 3
 11058                              <1> 	;mov	eax, [esp]
 11059                              <1> 	;shr	ax, 3	; / 8, bytes per row
 11060                              <1> 	; 03/08/2022
 11061 00003F23 C1E803              <1> 	shr	eax, 3
 11062 00003F26 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 11063                              <1> 	;mov	ah, bl	; 
 11064 00003F2A 88C4                <1> 	mov	ah, al	; width in bytes
 11065 00003F2C B013                <1> 	mov	al, 13h	; offset register
 11066 00003F2E 66EF                <1> 	out	dx, ax	; index (3D4h) and data (3D5h)
 11067                              <1> 	;pop	eax
 11068                              <1> 	;pop  	edx
 11069                              <1> 	;;pop	ebx
 11070 00003F30 C3                  <1> 	retn
 11071                              <1> 
 11072                              <1> ; 24/11/2020
 11073                              <1> 
 11074                              <1> struc bmi ; BOCHS/PLEX86 MODE INFO structure/table 
 11075 00000000 ????                <1>  .mode:	  resw 1
 11076 00000002 ????                <1>  .width:  resw 1
 11077 00000004 ????                <1>  .height: resw 1
 11078 00000006 ????                <1>  .depth:  resw 1
 11079                              <1>  .size:	
 11080                              <1> endstruc
 11081                              <1> 
 11082                              <1> ; 24/11/2020
 11083                              <1> struc MODEINFO
 11084 00000000 ????                <1>  .mode:			resw 1  ; 1XXh
 11085 00000002 ????                <1>  .ModeAttributes:	resw 1
 11086 00000004 ??                  <1>  .WinAAttributes:	resb 1
 11087 00000005 ??                  <1>  .WinBAttributes:	resb 1	; = 0
 11088 00000006 ????                <1>  .WinGranularity:	resw 1
 11089 00000008 ????                <1>  .WinSize:		resw 1
 11090 0000000A ????                <1>  .WinASegment:		resw 1
 11091 0000000C ????                <1>  .WinBSegment:		resw 1	; = 0
 11092 0000000E ????????            <1>  .WinFuncPtr:		resd 1	; = 0
 11093 00000012 ????                <1>  .BytesPerScanLine:	resw 1
 11094 00000014 ????                <1>  .XResolution:		resw 1
 11095 00000016 ????                <1>  .YResolution:		resw 1
 11096 00000018 ??                  <1>  .XCharSize:		resb 1
 11097 00000019 ??                  <1>  .YCharSize:		resb 1
 11098 0000001A ??                  <1>  .NumberOfPlanes: 	resb 1
 11099 0000001B ??                  <1>  .BitsPerPixel:		resb 1
 11100 0000001C ??                  <1>  .NumberOfBanks:	resb 1
 11101 0000001D ??                  <1>  .MemoryModel:		resb 1
 11102 0000001E ??                  <1>  .BankSize:		resb 1	; = 0
 11103 0000001F ??                  <1>  .NumberOfImagePages: 	resb 1
 11104 00000020 ??                  <1>  .Reserved_page:	resb 1	; = 0
 11105 00000021 ??                  <1>  .RedMaskSize:		resb 1
 11106 00000022 ??                  <1>  .RedFieldPosition: 	resb 1
 11107 00000023 ??                  <1>  .GreenMaskSize:	resb 1
 11108 00000024 ??                  <1>  .GreenFieldPosition: 	resb 1
 11109 00000025 ??                  <1>  .BlueMaskSize:		resb 1
 11110 00000026 ??                  <1>  .BlueFieldPosition: 	resb 1
 11111 00000027 ??                  <1>  .RsvdMaskSize:		resb 1
 11112 00000028 ??                  <1>  .RsvdFieldPosition: 	resb 1
 11113 00000029 ??                  <1>  .DirectColorModeInfo: 	resb 1
 11114 0000002A ????????            <1>  .PhysBasePtr:		resd 1
 11115 0000002E ????????            <1>  .OffScreenMemOffset: 	resd 1	; = 0
 11116 00000032 ????                <1>  .OffScreenMemSize: 	resw 1	; = 0
 11117 00000034 ????                <1>  .LinBytesPerScanLine: 	resw 1
 11118 00000036 ??                  <1>  .BnkNumberOfPages: 	resb 1
 11119 00000037 ??                  <1>  .LinNumberOfPages: 	resb 1
 11120 00000038 ??                  <1>  .LinRedMaskSize:	resb 1
 11121 00000039 ??                  <1>  .LinRedFieldPosition1: resb 1
 11122 0000003A ??                  <1>  .LinGreenMaskSize1: 	resb 1
 11123 0000003B ??                  <1>  .LinGreenFieldPosition:resb 1
 11124 0000003C ??                  <1>  .LinBlueMaskSize: 	resb 1
 11125 0000003D ??                  <1>  .LinBlueFieldPosition:	resb 1
 11126 0000003E ??                  <1>  .LinRsvdMaskSize: 	resb 1
 11127 0000003F ??                  <1>  .LinRsvdFieldPosition:	resb 1
 11128 00000040 ????????            <1>  .MaxPixelClock:	resd 1	; = 0
 11129                              <1> .size:
 11130                              <1> endstruc
 11131                              <1> 
 11132                              <1> ; 10/12/2020
 11133                              <1> struc LFBINFO
 11134 00000000 ????                <1>  .mode:			resw 1  ; 1XXh
 11135 00000002 ????????            <1>  .LFB_addr:		resd 1
 11136 00000006 ????????            <1>  .LFB_size:		resd 1
 11137 0000000A ????                <1>  .X_res:		resw 1
 11138 0000000C ????                <1>  .Y_res:		resw 1
 11139 0000000E ??                  <1>  .bpp:			resb 1
 11140 0000000F ??                  <1>  .reserved:		resb 1
 11141                              <1> .size:	; 16 bytes
 11142                              <1> endstruc
 11143                              <1> 
 11144                              <1> set_mode_info_list:
 11145                              <1> 	; 14/12/2020
 11146                              <1> 	; 11/12/2020
 11147                              <1> 	; 24/11/2020
 11148                              <1> 	; (vbetables-gen.c)
 11149                              <1> 	; Input:
 11150                              <1> 	;	BX = VBE mode (including bochs special modes) 
 11151                              <1> 	; Output:
 11152                              <1> 	;	;;EAX = MODE_INFO_LIST address
 11153                              <1> 	;	EAX = 0 ; 11/12/2020
 11154                              <1> 	;	ESI = MODE_INFO_LIST address ; 11/12/2020
 11155                              <1> 	;	(if mode is not found, ESI = 0)
 11156                              <1> 	;
 11157                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi 
 11158                              <1> 
 11159 00003F31 BE[5A6A0000]        <1> 	mov	esi, b_vbe_modes ; bochs mode info base table
 11160 00003F36 BF[EE0F0300]        <1> 	mov	edi, MODE_INFO_LIST ; mode info list (4F01h)
 11161                              <1> sml_0:
 11162 00003F3B 66AD                <1> 	lodsw	
 11163 00003F3D 6639D8              <1> 	cmp	ax, bx ; is mode number same ?
 11164 00003F40 7410                <1> 	je	short sml_1 ; yes
 11165 00003F42 AD                  <1> 	lodsd
 11166 00003F43 66AD                <1> 	lodsw	
 11167 00003F45 81FE[1A6B0000]      <1> 	cmp	esi, end_of_b_vbe_modes
 11168 00003F4B 72EE                <1> 	jb	short sml_0
 11169                              <1> 	; not found
 11170 00003F4D 31C0                <1> 	xor	eax, eax ; 0
 11171                              <1> 	; 11/12/2020
 11172 00003F4F 31F6                <1> 	xor	esi, esi
 11173 00003F51 C3                  <1> 	retn
 11174                              <1> sml_1:
 11175 00003F52 66AB                <1> 	stosw	; mode
 11176 00003F54 AD                  <1> 	lodsd	; width, height
 11177                              <1> 	; 14/12/2020
 11178 00003F55 89C1                <1> 	mov	ecx, eax
 11179 00003F57 50                  <1> 	push	eax ; ***
 11180 00003F58 29C0                <1> 	sub	eax, eax ; clear high word of eax
 11181 00003F5A 66AD                <1> 	lodsw	; depth
 11182 00003F5C 50                  <1> 	push	eax ; **
 11183                              <1> 
 11184                              <1> 	;add	al, 7 ; only for 15 bit colors (not used here)
 11185 00003F5D C0E803              <1> 	shr	al, 3 ; / 8
 11186                              <1> 	; 14/12/2020
 11187 00003F60 66F7E1              <1> 	mul	cx  ; pitch = width * ((depth+7)/8)
 11188                              <1> 		; ax = pitch
 11189 00003F63 50                  <1> 	push	eax ; * ; high word of eax = 0
 11190 00003F64 C1E910              <1> 	shr	ecx, 16
 11191                              <1> 	;mul	cx
 11192                              <1> 	;mov	cx, ax
 11193 00003F67 31D2                <1> 	xor	edx, edx  ; clear high word of edx
 11194 00003F69 F7E1                <1> 	mul	ecx ; height * pitch
 11195 00003F6B 89C1                <1> 	mov	ecx, eax
 11196 00003F6D B800000001          <1> 	mov	eax, VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024 * 1024
 11197 00003F72 F7F1                <1> 	div	ecx
 11198                              <1> 		; eax = pages = vram_size / (height*pitch)
 11199                              <1> 	
 11200                              <1> 	;mov	cx, ax
 11201 00003F74 89C1                <1> 	mov	ecx, eax ; pages 
 11202                              <1> 		
 11203 00003F76 66B89B00            <1> 	mov	ax, MODE_ATTRIBUTES
 11204 00003F7A 66AB                <1> 	stosw	; ModeAttributes
 11205 00003F7C B007                <1> 	mov	al, WINA_ATTRIBUTES
 11206 00003F7E AA                  <1> 	stosb	; WinAAttributes
 11207 00003F7F 30C0                <1> 	xor	al, al ; WinBAttributes = 0
 11208 00003F81 AA                  <1> 	stosb
 11209 00003F82 66B84000            <1> 	mov	ax, VBE_DISPI_BANK_SIZE_KB
 11210 00003F86 66AB                <1> 	stosw	; WinGranularity
 11211 00003F88 66AB                <1> 	stosw	; WinSize
 11212 00003F8A 66B800A0            <1> 	mov	ax, VGAMEM_GRAPH
 11213 00003F8E 66AB                <1> 	stosw	; WinASegment
 11214 00003F90 29C0                <1> 	sub	eax, eax
 11215 00003F92 66AB                <1> 	stosw	; WinBSegment = 0
 11216 00003F94 AB                  <1> 	stosd	; WinFuncPtr = 0
 11217                              <1> 
 11218 00003F95 58                  <1> 	pop	eax ; * ; pitch
 11219 00003F96 89C3                <1> 	mov	ebx, eax  ; high word of ebx = 0 ; 14/12/2020
 11220 00003F98 66AB                <1> 	stosw	; BytesPerScanLine
 11221                              <1> 
 11222 00003F9A 5A                  <1> 	pop	edx ; ** ; depth (bits per pixel)
 11223 00003F9B 58                  <1> 	pop	eax ; *** width, height
 11224                              <1> 
 11225                              <1>  	; // Mandatory information for VBE 1.2 and above
 11226                              <1> 
 11227 00003F9C 66AB                <1> 	stosw	; XResolution (width)
 11228 00003F9E C1E810              <1> 	shr	eax, 16
 11229 00003FA1 50                  <1> 	push	eax ; **** height
 11230 00003FA2 66AB                <1> 	stosw	; YResolution (height)
 11231 00003FA4 B008                <1> 	mov	al, 8
 11232 00003FA6 AA                  <1>  	stosb	; XCharSize  ; char width
 11233 00003FA7 B010                <1> 	mov	al, 16
 11234 00003FA9 AA                  <1> 	stosb	; YCharSize  ; char height
 11235 00003FAA B001                <1> 	mov	al, 1
 11236 00003FAC AA                  <1> 	stosb	; NumberOfPlanes
 11237                              <1> 	;movzx	eax, dl
 11238 00003FAD 88D0                <1> 	mov	al, dl ; eax <= 32
 11239 00003FAF AA                  <1> 	stosb	; BitsPerPixel
 11240                              <1> 	; Number of banks = (height * pitch + 65535) / 65536
 11241 00003FB0 58                  <1> 	pop	eax ; **** ; height
 11242                              <1> 	; 14/12/2020
 11243 00003FB1 52                  <1> 	push	edx ; ***** ; depth ; edx <= 32
 11244 00003FB2 F7E3                <1> 	mul	ebx  ; pitch (ebx) * height (eax)
 11245                              <1> 	;mov	edx, [esp] ; *****
 11246                              <1> 	;mov	dl, [esp] ; *****
 11247 00003FB4 05FFFF0000          <1> 	add	eax, 65535
 11248 00003FB9 C1E810              <1> 	shr	eax, 16 ; / 65536 ; <= 127 ; 14/12/2020
 11249 00003FBC AA                  <1> 	stosb	; NumberOfBanks
 11250                              <1> 	; 14/12/2020
 11251                              <1> 	;cmp	dl, 8 ; 8 bits per pixel
 11252 00003FBD 803C2408            <1> 	cmp	byte [esp], 8
 11253 00003FC1 7704                <1> 	ja	short sml_2
 11254 00003FC3 B004                <1> 	mov	al, VBE_MEMORYMODEL_PACKED_PIXEL
 11255 00003FC5 EB02                <1> 	jmp	short sml_3
 11256                              <1> sml_2:
 11257                              <1> 	; 16, 24, 32 bits per pixel
 11258 00003FC7 B006                <1> 	mov	al, VBE_MEMORYMODEL_DIRECT_COLOR
 11259                              <1> sml_3:
 11260 00003FC9 AA                  <1> 	stosb
 11261 00003FCA 30C0                <1> 	xor	al, al ; 0
 11262 00003FCC AA                  <1> 	stosb	; BankSize = 0
 11263 00003FCD 49                  <1> 	dec	ecx ; pages - 1
 11264                              <1> 	; NumberOfImagePages = 262 for 320x200x8 mode
 11265                              <1> 	;;mov	ax, 255
 11266                              <1> 	; 14/12/2020
 11267                              <1> 	;mov	al, 255
 11268 00003FCE FEC8                <1> 	dec	al ; 255
 11269 00003FD0 39C1                <1> 	cmp	ecx, eax ; ecx <= 261, eax = 255 
 11270                              <1> 	;cmp	cx, ax
 11271 00003FD2 7302                <1> 	jnb	short sml_4
 11272 00003FD4 88C8                <1> 	mov	al, cl	 
 11273                              <1> sml_4:
 11274 00003FD6 AA                  <1> 	stosb	; NumberOfImagePages (1 byte)
 11275 00003FD7 28C0                <1> 	sub	al, al
 11276 00003FD9 AA                  <1> 	stosb	; Reserved_page = 0
 11277 00003FDA 58                  <1> 	pop	eax ; ***** ; depth
 11278 00003FDB 88C1                <1> 	mov	cl, al
 11279                              <1> 	; eax < = 32
 11280 00003FDD 2C08                <1> 	sub	al, 8 ; 8->0, 16->8, 24->16, 32->24
 11281 00003FDF BE[1A6B0000]        <1> 	mov	esi, direct_color_fields
 11282 00003FE4 01C6                <1> 	add	esi, eax
 11283 00003FE6 56                  <1> 	push	esi ; ******
 11284 00003FE7 AD                  <1> 	lodsd	; RedMaskSize (AL), RedFieldPosition (AH)
 11285                              <1> 	     	; GreenMaskSize (16), GreenFieldPosition (24)
 11286 00003FE8 AB                  <1> 	stosd
 11287 00003FE9 AD                  <1> 	lodsd	; BlueMaskSize (AL), BlueFieldPosition (AH)
 11288                              <1> 	     	; RsvdMaskSize (16), RsvdFieldPosition (24)
 11289 00003FEA AB                  <1> 	stosd
 11290 00003FEB 5E                  <1> 	pop	esi ; ******
 11291                              <1> 
 11292 00003FEC 30C0                <1> 	xor	al, al ; 0
 11293 00003FEE 80F920              <1> 	cmp	cl, 32
 11294 00003FF1 7202                <1> 	jb	short sml_5
 11295 00003FF3 B002                <1> 	mov	al, VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
 11296                              <1> sml_5: 
 11297 00003FF5 AA                  <1> 	stosb	; DirectColorModeInfo
 11298                              <1> 
 11299                              <1> 	; // Mandatory information for VBE 2.0 and above
 11300                              <1> 
 11301 00003FF6 B8000000E0          <1> 	mov	eax, VBE_DISPI_LFB_PHYSICAL_ADDRESS
 11302 00003FFB AB                  <1> 	stosd	; PhysBasePtr
 11303 00003FFC 29C0                <1> 	sub	eax, eax
 11304 00003FFE AB                  <1> 	stosd	; OffScreenMemOffset = 0
 11305 00003FFF 66AB                <1> 	stosw	; OffScreenMemSize = 0
 11306                              <1> 
 11307                              <1> 	;// Mandatory information for VBE 3.0 and above
 11308                              <1> 
 11309                              <1> 	; ebx = pitch
 11310 00004001 6689D8              <1> 	mov	ax, bx
 11311                              <1> 	;stosw
 11312                              <1> 
 11313                              <1> 	;xor	al, al
 11314                              <1>      	;stosb	; BnkNumberOfPages = 0
 11315                              <1>      	;stosb	; LinNumberOfPages = 0
 11316                              <1> 
 11317 00004004 AB                  <1> 	stosd	; pitch (word), 0 (byte), 0 (byte)  
 11318                              <1> 
 11319 00004005 AD                  <1> 	lodsd	; LinRedMaskSize (AL), LinRedFieldPosition (AH)
 11320                              <1> 	     	; LinGreenMaskSize (16), LinGreenFieldPosition (24)
 11321 00004006 AB                  <1> 	stosd
 11322 00004007 AD                  <1> 	lodsd	; LinBlueMaskSize (AL), LinBlueFieldPosition (AH)
 11323                              <1> 	     	; LinRsvdMaskSize (16), LinRsvdFieldPosition (24)
 11324 00004008 AB                  <1> 	stosd
 11325                              <1> 
 11326 00004009 29C0                <1> 	sub	eax, eax
 11327 0000400B AB                  <1> 	stosd	; MaxPixelClock = 0
 11328                              <1> 
 11329                              <1> 	;mov	eax, MODE_INFO_LIST
 11330                              <1> 	; 11/12/2020
 11331 0000400C BE[EE0F0300]        <1> 	mov	esi, MODE_INFO_LIST
 11332                              <1> 	
 11333 00004011 C3                  <1> 	retn	
 11334                              <1> 
 11335                              <1> ; end of set_mode_info_list ; edi = set_mode_info_list + 68
 11336                              <1> 
 11337                              <1> pci_get_lfb_addr:
 11338                              <1> 	; 11/12/2020
 11339                              <1> 	; Get linear frame buffer base from PCI
 11340                              <1> 	; (vgabios.c, 02/01/2020, vruppert)
 11341                              <1> 	;
 11342                              <1> 	; Input:
 11343                              <1> 	;	ax = PCI device vendor id
 11344                              <1> 	; Output:
 11345                              <1> 	;	ax  = LFB address (high 16 bit) (zf=0)
 11346                              <1> 	;	eax = 0 -> not found (error) (zf=1)
 11347                              <1> 	;
 11348                              <1> 	; Modified registers: eax
 11349                              <1> 
 11350 00004012 53                  <1> 	push	ebx
 11351 00004013 51                  <1> 	push	ecx
 11352 00004014 52                  <1> 	push	edx
 11353                              <1> 	;
 11354 00004015 89C3                <1> 	mov	ebx, eax
 11355 00004017 31C9                <1> 	xor	ecx, ecx
 11356 00004019 28D2                <1> 	sub	dl, dl	; mov dl, 0
 11357 0000401B E842000000          <1> 	call	pci_read_reg
 11358 00004020 6683F8FF            <1> 	cmp	ax, 0FFFFh
 11359 00004024 7417                <1> 	je	short pci_get_lfb_addr_fail
 11360                              <1> pci_get_lfb_addr_next_dev:
 11361 00004026 28D2                <1> 	sub	dl, dl ; mov dl, 0
 11362 00004028 E835000000          <1> 	call	pci_read_reg
 11363 0000402D 6639D8              <1> 	cmp	ax, bx	; check vendor
 11364 00004030 740F                <1> 	je	short pci_get_lfb_addr_found
 11365 00004032 6683C108            <1> 	add	cx, 08h
 11366 00004036 6681F90002          <1> 	cmp	cx, 200h ; search bus 0 and 1
 11367 0000403B 72E9                <1> 	jb	short pci_get_lfb_addr_next_dev
 11368                              <1> pci_get_lfb_addr_fail:
 11369 0000403D 31C0                <1> 	xor	eax, eax ; no LFB
 11370                              <1> 	; zf = 1
 11371 0000403F EB1D                <1> 	jmp	short pci_get_lfb_addr_return
 11372                              <1> pci_get_lfb_addr_found:
 11373 00004041 B210                <1> 	mov	dl, 10h	; I/O space 0
 11374 00004043 E81A000000          <1> 	call	pci_read_reg
 11375 00004048 66A9F1FF            <1> 	test	ax, 0FFF1h
 11376 0000404C 740D                <1> 	jz	short pci_get_lfb_addr_success
 11377 0000404E B214                <1> 	mov	dl, 14h ; I/O space 1
 11378 00004050 E80D000000          <1> 	call	pci_read_reg
 11379 00004055 66A9F1FF            <1> 	test	ax, 0FFF1h
 11380 00004059 75E2                <1> 	jnz	short pci_get_lfb_addr_fail
 11381                              <1> pci_get_lfb_addr_success:
 11382 0000405B C1E810              <1> 	shr	eax, 16 ; LFB address (hw)
 11383                              <1> 	; zf = 0
 11384                              <1> pci_get_lfb_addr_return:
 11385 0000405E 5A                  <1> 	pop	edx
 11386 0000405F 59                  <1> 	pop	ecx
 11387 00004060 5B                  <1> 	pop	ebx
 11388 00004061 C3                  <1> 	retn
 11389                              <1> 
 11390                              <1> pci_read_reg:
 11391                              <1> 	; 11/12/2020
 11392                              <1> 	; Read PCI register
 11393                              <1> 	; (vgabios.c, 02/01/2020, vruppert)
 11394                              <1> 	;
 11395                              <1> 	; Input:
 11396                              <1> 	;	cx = device/function
 11397                              <1> 	;	dl = register
 11398                              <1> 	; Output:
 11399                              <1> 	;	eax = value
 11400                              <1> 	;
 11401                              <1> 	; Modified registers: eax, edx
 11402                              <1> 
 11403 00004062 B800008000          <1> 	mov	eax, 00800000h 
 11404 00004067 6689C8              <1> 	mov	ax, cx
 11405 0000406A C1E008              <1> 	shl	eax, 8
 11406 0000406D 88D0                <1> 	mov	al, dl
 11407 0000406F 66BAF80C            <1> 	mov	dx, 0CF8h
 11408 00004073 EF                  <1>  	out	dx, eax
 11409 00004074 80C204              <1> 	add	dl, 4 ; mov dx, 0CFCh
 11410 00004077 ED                  <1> 	in	eax, dx
 11411 00004078 C3                  <1> 	retn
 11412                              <1> 
 11413                              <1> %endif
 11414                              <1> 
 11415                              <1> ; -----------
 11416                              <1> 
 11417                              <1> %if 0
 11418                              <1> 
 11419                              <1> mode_info_find_mode:
 11420                              <1> 	; 25/11/2020
 11421                              <1> 	; Input:
 11422                              <1> 	;	bx = VESA VBE2 video mode (+ bochs extensions)
 11423                              <1> 	; Output:
 11424                              <1> 	;	esi = mode info address (for BX input)
 11425                              <1> 	;	esi = 0 -> not found
 11426                              <1> 	;
 11427                              <1> 	; Modified registers: eax, esi
 11428                              <1> 
 11429                              <1> 	xor	eax, eax
 11430                              <1> 	mov	esi, MODE_INFO_LIST
 11431                              <1> mifm_1:
 11432                              <1> 	mov	ax, [esi]
 11433                              <1> 	cmp	ax, bx
 11434                              <1> 	je	short mifm_2
 11435                              <1> 	add	esi, MODEINFO.size ; add esi, 68
 11436                              <1> 	cmp	esi, VBE_VESA_MODE_END_OF_LIST
 11437                              <1> 	jb	short mifm_1
 11438                              <1> 	; not found
 11439                              <1> 	sub	esi, esi ; 0
 11440                              <1> mifm_2
 11441                              <1> 	retn
 11442                              <1> 
 11443                              <1> dispi_get_bpp:
 11444                              <1> 	; 28/11/2020
 11445                              <1> 	; Input:
 11446                              <1> 	;	none
 11447                              <1> 	; Output:
 11448                              <1> 	;	al = Bits per pixel
 11449                              <1> 	;	     (8,16,24,32)
 11450                              <1> 	;	ah = Bytes per pixel
 11451                              <1> 	;	     (1,2,3,4)	
 11452                              <1> 	;
 11453                              <1> 	; Modified registers: none
 11454                              <1> 
 11455                              <1> 	;push	edx
 11456                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 11457                              <1> 	;mov	ax, 03h	  ; VBE_DISPI_INDEX_BPP
 11458                              <1> 	;out	dx, ax
 11459                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 11460                              <1> 	;;mov	dl, 0CFh
 11461                              <1> 	;inc	dl
 11462                              <1> 	;in	ax, dx
 11463                              <1> 	;mov	ah, al
 11464                              <1> 	;shr	ah, 3 ; / 8
 11465                              <1> 	;;test	al, 7 ; 15 bit graphics mode
 11466                              <1>  	;;jz	short get_bpp_noinc
 11467                              <1> 	;;inc	ah
 11468                              <1> ;;get_bpp_noinc:
 11469                              <1> 	;pop	edx
 11470                              <1> 	;retn
 11471                              <1> 
 11472                              <1> 	; 28/11/2020
 11473                              <1> 	; Modified registers: edx
 11474                              <1> 	;push	edx
 11475                              <1> 	mov	dx, 03h ; VBE_DISPI_INDEX_BPP
 11476                              <1> 	call	dispi_get_parms
 11477                              <1> 	;pop	edx
 11478                              <1> 	;retn
 11479                              <1> 	mov	ah, al
 11480                              <1> 	shr	ah, 3 ; / 8
 11481                              <1> 	;test	al, 7 ; 15 bit graphips mode
 11482                              <1>  	;jz	short get_bpp_noinc
 11483                              <1> 	;inc	ah
 11484                              <1> ;get_bpp_noinc:
 11485                              <1> 	;pop	edx
 11486                              <1> 	retn
 11487                              <1> 
 11488                              <1> restore_vesa_video_state:
 11489                              <1> 	; 02/08/2022 (TRDOS 386 v2.0.5)
 11490                              <1> 	; 14/01/2021
 11491                              <1> 	; 06/12/2020
 11492                              <1> 	; Input:
 11493                              <1> 	;	[vbe3stbufsize] <= 32 ; <= 32*64 bytes
 11494                              <1> 	; Output:
 11495                              <1> 	;	AX = 004Fh (successed)
 11496                              <1> 	;
 11497                              <1> 	;	eax = 0 -> buffer size problem
 11498                              <1> 	;	eax > 0 and ax <> 004Fh -> failed
 11499                              <1> 	;
 11500                              <1> 	; Modified regs: eax, ebx, ecx, edx, esi, edi 
 11501                              <1> 
 11502                              <1> 	;movzx	ecx, word [vbe3stbufsize]  
 11503                              <1> 	;cmp	cx, 32 ; 32 * 64 bytes
 11504                              <1> 	;ja	short r_v_b_s_fail
 11505                              <1> 
 11506                              <1> 	movzx	ecx, byte [vbe3stbufsize]; <=32	
 11507                              <1> 	;shl	cx, 4 ; dword count for movsd
 11508                              <1> 	; 02/08/2022
 11509                              <1> 	shl	ecx, 4 ; <= 32*16 dwords (32*64 bytes)
 11510                              <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; destination
 11511                              <1> 					; (vbe3 pmi buff)
 11512                              <1> 	mov	esi, VBE3VIDEOSTATE ; source (kernel buff)
 11513                              <1> 	rep	movsd
 11514                              <1> 
 11515                              <1> 	mov	ax, 4F04h
 11516                              <1> 	mov	dl, 02h ; restore
 11517                              <1> 	;mov	cx, 0Fh
 11518                              <1> 	mov	cl, 0Fh
 11519                              <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
 11520                              <1> 	jmp	short int10h_32bit_pmi
 11521                              <1> 
 11522                              <1> ;s_v_b_s_fail:
 11523                              <1> ;r_v_b_s_fail:
 11524                              <1> ;	xor	eax, eax
 11525                              <1> ;	retn
 11526                              <1> 
 11527                              <1> save_vesa_video_state:
 11528                              <1> 	; 02/08/2022 (TRDOS 386 v2.0.5)
 11529                              <1> 	; 14/01/2021
 11530                              <1> 	; 06/12/2020
 11531                              <1> 	; Input:
 11532                              <1> 	;	[vbe3stbufsize] <= 32 ; <= 32*64 bytes
 11533                              <1> 	; Output:
 11534                              <1> 	;	AX = 004Fh (successed)
 11535                              <1> 	;
 11536                              <1> 	;	eax = 0 -> buffer size problem
 11537                              <1> 	;	eax > 0 and ax <> 004Fh -> failed
 11538                              <1> 	;
 11539                              <1> 	; Modified regs: eax, ebx, ecx, edx, esi, edi 
 11540                              <1> 
 11541                              <1> 	;cmp	word [vbe33stbufsize], 32  
 11542                              <1> 	;			; 32 * 64 bytes
 11543                              <1> 	;ja	short s_v_b_s_fail
 11544                              <1> 
 11545                              <1> 	mov	ax, 4F04h
 11546                              <1> 	mov	dl, 01h ; save
 11547                              <1> 	;mov	cx, 0Fh
 11548                              <1> 	mov	cl, 0Fh
 11549                              <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
 11550                              <1> 
 11551                              <1> 	call	int10h_32bit_pmi
 11552                              <1> 
 11553                              <1> 	movzx	ecx, byte [vbe3stbufsize]; <=32	
 11554                              <1> 	;shl	cx, 4 ; dword count for movsd
 11555                              <1> 	; 02/08/2022
 11556                              <1> 	shl	ecx, 4 ; <= 32*16 dwords (32*64 bytes)
 11557                              <1> 	mov	esi, VBE3SAVERESTOREBLOCK ; destination
 11558                              <1> 					; (vbe3 pmi buff)
 11559                              <1> 	mov	edi, VBE3VIDEOSTATE ; source (kernel buff)
 11560                              <1> 	rep	movsd	
 11561                              <1> 	retn
 11562                              <1> 
 11563                              <1> dispi_set_bank_farcall:
 11564                              <1> 	; 03/08/2022
 11565                              <1> 	; 12/04/2021 (32 bit push/pop)
 11566                              <1> 	; 11/12/2020
 11567                              <1> 	; (This may be 'sysvideo' function, later)
 11568                              <1> 	;
 11569                              <1> 	; Input: 
 11570                              <1> 	;	bx = 0000h, set bank number
 11571                              <1> 	;	   = 0100h, get bank number
 11572                              <1> 	;	dx = bank number (if bx = 0)	
 11573                              <1> 	; Output:
 11574                              <1> 	;	dx = bank number
 11575                              <1> 		 	
 11576                              <1> 	cmp	bx, 0100h
 11577                              <1> 	je	short dispi_set_bank_farcall_get
 11578                              <1> 	or	bx, bx
 11579                              <1> 	;jnz	dispi_set_bank_farcall_error
 11580                              <1> 	; 03/08/2022
 11581                              <1> 	jz	short dsbfcall_1
 11582                              <1> 	jmp	dispi_set_bank_farcall_error
 11583                              <1> dsbfcall_1:
 11584                              <1> 	mov	ax, dx
 11585                              <1> 	;push	dx
 11586                              <1> 	;push	ax
 11587                              <1> 	; 12/04/2021
 11588                              <1> 	push	edx
 11589                              <1> 	push	eax
 11590                              <1> 	mov	ax, VBE_DISPI_INDEX_BANK
 11591                              <1> 	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 11592                              <1> 	out	dx, ax
 11593                              <1> 	;pop	ax
 11594                              <1> 	; 12/04/2021
 11595                              <1> 	pop	eax
 11596                              <1> 	;;mov	dx, VBE_DISPI_IOPORT_DATA
 11597                              <1> 	;mov	dl, 0CFh
 11598                              <1> 	inc	dl ; 1CFh = VBE_DISPI_IOPORT_DATA
 11599                              <1> 	out	dx, ax
 11600                              <1> 	in	ax, dx
 11601                              <1> 	;pop	dx
 11602                              <1> 	; 12/04/2021
 11603                              <1> 	pop	edx
 11604                              <1> 	cmp	dx, ax
 11605                              <1> 	jne	short dispi_set_bank_farcall_error
 11606                              <1> 	mov	ax, 004Fh
 11607                              <1> 	retn	; retf for real mode far call
 11608                              <1> dispi_set_bank_farcall_get:
 11609                              <1> 	mov	ax, VBE_DISPI_INDEX_BANK
 11610                              <1> 	; 03/08/2022
 11611                              <1> 	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 11612                              <1> 	out	dx, ax
 11613                              <1> 	;;mov	dx, VBE_DISPI_IOPORT_DATA
 11614                              <1> 	;mov	dl, 0CFh
 11615                              <1> 	; 03/08/2022
 11616                              <1> 	inc	dl ; 1CFh = VBE_DISPI_IOPORT_DATA
 11617                              <1> 	in	ax, dx
 11618                              <1> 	mov	dx, ax
 11619                              <1> 	retn	; retf for real mode far call
 11620                              <1> dispi_set_bank_farcall_error:
 11621                              <1> 	mov	ax, 014Fh
 11622                              <1> 	retn	; retf for real mode far call
 11623                              <1> 
 11624                              <1> %endif
 11625                              <1> 
 11626                              <1> ; % include 'vidata.s' ; VIDEO DATA
 11627                              <1> 
 11628                              <1> ; /// End Of VIDEO FUNCTIONS ///
  2804                                  
  2805                                  setup_rtc_int:
  2806                                  ; source: http://wiki.osdev.org/RTC
  2807 00004079 FA                      	cli		; disable interrupts
  2808                                  	; default int frequency is 1024 Hz (Lower 4 bits of register A is 0110b or 6)
  2809                                  	; in order to change this ...
  2810                                  	; frequency  = 32768 >> (rate-1) --> 32768 >> 5 = 1024
  2811                                  	; (rate must be above 2 and not over 15)
  2812                                  	; new rate = 15 --> 32768 >> (15-1) = 2 Hz
  2813 0000407A B08A                    	mov	al, 8Ah 
  2814 0000407C E670                    	out	70h, al ; set index to register A, disable NMI
  2815 0000407E 90                      	nop
  2816 0000407F E471                    	in	al, 71h ; get initial value of register A
  2817 00004081 88C4                    	mov 	ah, al
  2818 00004083 80E4F0                  	and	ah, 0F0h
  2819 00004086 B08A                    	mov	al, 8Ah 
  2820 00004088 E670                    	out	70h, al ; reset index to register A
  2821 0000408A 88E0                    	mov	al, ah
  2822 0000408C 0C0F                    	or	al, 0Fh	; new rate (0Fh -> 15)
  2823 0000408E E671                    	out	71h, al ; write only our rate to A. Note, rate is the bottom 4 bits. 
  2824                                  	; enable RTC interrupt
  2825 00004090 B08B                    	mov	al, 8Bh ;
  2826 00004092 E670                    	out	70h, al ; select register B and disable NMI
  2827 00004094 90                      	nop
  2828 00004095 E471                    	in	al, 71h ; read the current value of register B
  2829 00004097 88C4                    	mov	ah, al  ;
  2830 00004099 B08B                    	mov 	al, 8Bh ;
  2831 0000409B E670                    	out	70h, al ; set the index again (a read will reset the index to register B)	
  2832 0000409D 88E0                    	mov	al, ah  ;
  2833 0000409F 0C40                    	or	al, 40h ;
  2834 000040A1 E671                    	out	71h, al ; write the previous value ORed with 0x40. This turns on bit 6 of register B
  2835 000040A3 FB                      	sti
  2836 000040A4 C3                      	retn
  2837                                  
  2838                                  ; Write memory information
  2839                                  ; 29/01/2016
  2840                                  ; 06/11/2014
  2841                                  ; 14/08/2015 
  2842                                  memory_info:	
  2843 000040A5 A1[8C770100]            	mov	eax, [memory_size] ; in pages
  2844 000040AA 50                      	push	eax
  2845 000040AB C1E00C                  	shl	eax, 12		   ; in bytes
  2846 000040AE BB0A000000              	mov	ebx, 10
  2847 000040B3 89D9                    	mov	ecx, ebx	   ; 10
  2848 000040B5 BE[753A0100]            	mov	esi, mem_total_b_str	
  2849 000040BA E8D3000000              	call	bintdstr
  2850 000040BF 58                      	pop	eax
  2851 000040C0 B107                    	mov	cl, 7
  2852 000040C2 BE[993A0100]            	mov	esi, mem_total_p_str
  2853 000040C7 E8C6000000              	call	bintdstr	
  2854                                  	; 14/08/2015
  2855 000040CC E8DE000000              	call	calc_free_mem
  2856                                  	; edx = calculated free pages
  2857                                  	; ecx = 0
  2858 000040D1 A1[90770100]            	mov 	eax, [free_pages]
  2859 000040D6 39D0                    	cmp	eax, edx ; calculated free mem value 
  2860                                  		; and initial free mem value are same or not?
  2861 000040D8 751D                    	jne 	short pmim ; print mem info with '?' if not
  2862 000040DA 52                      	push 	edx ; free memory in pages	
  2863                                  	;mov 	eax, edx
  2864 000040DB C1E00C                  	shl	eax, 12 ; convert page count
  2865                                  			; to byte count
  2866 000040DE B10A                    	mov	cl, 10
  2867 000040E0 BE[B93A0100]            	mov	esi, free_mem_b_str
  2868 000040E5 E8A8000000              	call	bintdstr
  2869 000040EA 58                      	pop	eax
  2870 000040EB B107                    	mov	cl, 7
  2871 000040ED BE[DD3A0100]            	mov	esi, free_mem_p_str
  2872 000040F2 E89B000000              	call	bintdstr
  2873                                  pmim:
  2874 000040F7 BE[633A0100]            	mov	esi, msg_memory_info
  2875                                  	;
  2876 000040FC B407                    	mov	ah, 07h ; Black background, 
  2877                                  			; light gray forecolor
  2878                                  print_kmsg: ; 29/01/2016
  2879 000040FE 8825[B7770100]          	mov	[ccolor], ah
  2880                                  pkmsg_loop:
  2881 00004104 AC                      	lodsb
  2882 00004105 08C0                    	or	al, al
  2883 00004107 7410                    	jz	short pkmsg_ok
  2884 00004109 56                      	push	esi
  2885                                  	; 13/05/2016
  2886 0000410A 0FB61D[B7770100]        	movzx	ebx, byte [ccolor]
  2887                                  			; Video page 0 (bh=0)
  2888 00004111 E842E1FFFF              	call	_write_tty
  2889 00004116 5E                      	pop	esi
  2890 00004117 EBEB                    	jmp	short pkmsg_loop
  2891                                  pkmsg_ok:
  2892 00004119 C3                      	retn
  2893                                  
  2894                                  ; 19/12/2020
  2895                                  ; temporary
  2896                                  ; Write default liner frame buffer address
  2897                                  ;
  2898                                  default_lfb_info:	
  2899 0000411A 66A1[060F0000]          	mov	ax, [def_LFB_addr] ; high word
  2900 00004120 E829000000              	call	wordtohex
  2901 00004125 A3[353B0100]            	mov	dword [lfb_addr_str], eax
  2902 0000412A BE[1E3B0100]            	mov	esi, msg_lfb_addr
  2903 0000412F B40F                    	mov	ah, 0Fh ; Black background, 
  2904                                  			; white forecolor
  2905 00004131 EBCB                    	jmp	short print_kmsg
  2906                                  
  2907                                  ; Convert binary number to hexadecimal string
  2908                                  ; 10/05/2015  
  2909                                  ; dsectpm.s (28/02/2015)
  2910                                  ; Retro UNIX 386 v1 - Kernel v0.2.0.6  
  2911                                  ; 01/12/2014
  2912                                  ; 25/11/2014
  2913                                  ;
  2914                                  bytetohex:
  2915                                  	; INPUT ->
  2916                                  	; 	AL = byte (binary number)
  2917                                  	; OUTPUT ->
  2918                                  	;	AX = hexadecimal string
  2919                                  	;
  2920 00004133 53                      	push	ebx
  2921 00004134 31DB                    	xor	ebx, ebx
  2922 00004136 88C3                    	mov	bl, al
  2923 00004138 C0EB04                  	shr	bl, 4
  2924 0000413B 8A9B[81410000]          	mov	bl, [ebx+hexchrs] 	 	
  2925 00004141 86D8                    	xchg	bl, al
  2926 00004143 80E30F                  	and	bl, 0Fh
  2927 00004146 8AA3[81410000]          	mov	ah, [ebx+hexchrs] 
  2928 0000414C 5B                      	pop	ebx	
  2929 0000414D C3                      	retn
  2930                                  
  2931                                  wordtohex:
  2932                                  	; INPUT ->
  2933                                  	; 	AX = word (binary number)
  2934                                  	; OUTPUT ->
  2935                                  	;	EAX = hexadecimal string
  2936                                  	;
  2937 0000414E 53                      	push	ebx
  2938 0000414F 31DB                    	xor	ebx, ebx
  2939 00004151 86E0                    	xchg	ah, al
  2940 00004153 6650                    	push	ax ; * save ax
  2941 00004155 88E3                    	mov	bl, ah
  2942 00004157 C0EB04                  	shr	bl, 4
  2943 0000415A 8A83[81410000]          	mov	al, [ebx+hexchrs]
  2944 00004160 88E3                    	mov	bl, ah
  2945 00004162 80E30F                  	and	bl, 0Fh
  2946 00004165 8AA3[81410000]          	mov	ah, [ebx+hexchrs]
  2947 0000416B C1E010                  	shl	eax, 16 ; ax -> hw of eax
  2948 0000416E 6658                    	pop	ax ; * restore ax 
  2949 00004170 5B                      	pop	ebx
  2950 00004171 EBC0                    	jmp	short bytetohex
  2951                                  	;mov	bl, al
  2952                                  	;shr	bl, 4
  2953                                  	;mov	bl, [ebx+hexchrs]
  2954                                  	;xchg	bl, al	 	
  2955                                  	;and	bl, 0Fh
  2956                                  	;mov	ah, [ebx+hexchrs] 
  2957                                  	;pop	ebx	
  2958                                  	;retn
  2959                                  
  2960                                  dwordtohex:
  2961                                  	; INPUT ->
  2962                                  	; 	EAX = dword (binary number)
  2963                                  	; OUTPUT ->
  2964                                  	;	EDX:EAX = hexadecimal string
  2965                                  	;
  2966 00004173 50                      	push	eax
  2967 00004174 C1E810                  	shr	eax, 16
  2968 00004177 E8D2FFFFFF              	call	wordtohex
  2969 0000417C 89C2                    	mov	edx, eax
  2970 0000417E 58                      	pop	eax
  2971                                  	;call	wordtohex
  2972                                  	;retn
  2973                                  	; 18/04/2021
  2974 0000417F EBCD                    	jmp	short wordtohex
  2975                                  
  2976                                  ; 10/05/2015
  2977                                  hex_digits:
  2978                                  hexchrs:
  2979 00004181 303132333435363738-     	db '0123456789ABCDEF'
  2979 0000418A 39414243444546     
  2980                                  ; 19/01/2021 - VESA EDID ready flag (4Fh)
  2981 00004191 00                      edid:	db 0
  2982                                  
  2983                                  ; Convert binary number to decimal/numeric string
  2984                                  ; 06/11/2014
  2985                                  ; Temporary Code
  2986                                  ;
  2987                                  
  2988                                  bintdstr:
  2989                                  	; EAX = binary number
  2990                                  	; ESI = decimal/numeric string address
  2991                                  	; EBX = divisor (10)
  2992                                  	; ECX = string length (<=10)
  2993 00004192 01CE                    	add	esi, ecx
  2994                                  btdstr0:
  2995 00004194 4E                      	dec	esi
  2996 00004195 31D2                    	xor	edx, edx
  2997 00004197 F7F3                    	div	ebx
  2998 00004199 80C230                  	add	dl, 30h
  2999 0000419C 8816                    	mov	[esi], dl
  3000 0000419E FEC9                    	dec	cl
  3001 000041A0 740C                    	jz	short btdstr2 ; 08/09/2016
  3002 000041A2 09C0                    	or	eax, eax
  3003 000041A4 75EE                    	jnz	short btdstr0
  3004                                  btdstr1:
  3005 000041A6 4E                      	dec	esi
  3006 000041A7 C60620                          mov     byte [esi], 20h ; blank space
  3007 000041AA FEC9                    	dec	cl
  3008 000041AC 75F8                    	jnz	short btdstr1
  3009                                  btdstr2:
  3010 000041AE C3                      	retn
  3011                                  
  3012                                  ; Calculate free memory pages on M.A.T.
  3013                                  ; 06/11/2014
  3014                                  ; Temporary Code
  3015                                  ;
  3016                                  
  3017                                  calc_free_mem:
  3018 000041AF 31D2                    	xor	edx, edx
  3019                                  	;xor	ecx, ecx
  3020 000041B1 668B0D[A0770100]        	mov	cx, [mat_size] ; in pages
  3021 000041B8 C1E10A                  	shl	ecx, 10	; 1024 dwords per page
  3022 000041BB BE00001000              	mov	esi, MEM_ALLOC_TBL
  3023                                  cfm0:
  3024 000041C0 AD                      	lodsd
  3025 000041C1 51                      	push	ecx
  3026 000041C2 B920000000              	mov	ecx, 32
  3027                                  cfm1:
  3028 000041C7 D1E8                    	shr	eax, 1
  3029 000041C9 7301                    	jnc	short cfm2
  3030 000041CB 42                      	inc	edx
  3031                                  cfm2:
  3032 000041CC E2F9                    	loop	cfm1
  3033 000041CE 59                      	pop	ecx
  3034 000041CF E2EF                    	loop	cfm0
  3035 000041D1 C3                      	retn
  3036                                  
  3037                                  %include 'diskio.s'  ; 07/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - diskio.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 11/08/2022 (Previous: 18/04/2021 - Kernel v2.0.4)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; diskio.inc (22/08/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> ; Ref: Retro UNIX 386 v1.1 (Kernel v0.2.1.5) 'diskio' modification: 12/07/2022
    19                              <1> 
    20                              <1> ; Retro UNIX 386 v1 Kernel - DISKIO.INC
    21                              <1> ; Last Modification: 22/08/2015
    22                              <1> ; 	(Initialized Disk Parameters Data is in 'DISKDATA.INC') 
    23                              <1> ; 	(Uninitialized Disk Parameters Data is in 'DISKBSS.INC') 
    24                              <1> 
    25                              <1> ; DISK I/O SYSTEM - Erdogan Tan (Retro UNIX 386 v1 project)
    26                              <1> 
    27                              <1> ; ///////// DISK I/O SYSTEM ///////////////
    28                              <1> 
    29                              <1> ; 11/04/2021
    30                              <1> ;; 06/02/2015
    31                              <1> ;diskette_io:
    32                              <1> 	;clc ; 20/07/2020
    33                              <1> 	;pushfd
    34                              <1> 	;push 	cs
    35                              <1> 	;;call 	DISKETTE_IO_1
    36                              <1> 	;;retn
    37                              <1> 	
    38                              <1> ;;;;;; DISKETTE I/O ;;;;;;;;;;;;;;;;;;;; 06/02/2015 ;;;
    39                              <1> ;//////////////////////////////////////////////////////
    40                              <1> 
    41                              <1> ; DISKETTE I/O - Erdogan Tan (Retro UNIX 386 v1 project)
    42                              <1> ; 20/02/2015
    43                              <1> ; 06/02/2015 (unix386.s)
    44                              <1> ; 16/12/2014 - 02/01/2015 (dsectrm2.s)
    45                              <1> ;
    46                              <1> ; Code (DELAY) modifications - AWARD BIOS 1999 (ADISK.EQU, COMMON.MAC)
    47                              <1> ;
    48                              <1> ; ADISK.EQU
    49                              <1> 
    50                              <1> ;----- Wait control constants 
    51                              <1> 
    52                              <1> ;amount of time to wait while RESET is active.
    53                              <1> 
    54                              <1> WAITCPU_RESET_ON	EQU	21		;Reset on must last at least 14us
    55                              <1> 						;at 250 KBS xfer rate.
    56                              <1> 						;see INTEL MCS, 1985, pg. 5-456
    57                              <1> 
    58                              <1> WAITCPU_FOR_STATUS	EQU	100		;allow 30 microseconds for
    59                              <1> 						;status register to become valid
    60                              <1> 						;before re-reading.
    61                              <1> 
    62                              <1> ;After sending a byte to NEC, status register may remain
    63                              <1> ;incorrectly set for 24 us.
    64                              <1> 
    65                              <1> WAITCPU_RQM_LOW		EQU	24		;number of loops to check for
    66                              <1> 						;RQM low.
    67                              <1> 
    68                              <1> ; COMMON.MAC
    69                              <1> ;
    70                              <1> ;	Timing macros
    71                              <1> ;
    72                              <1> 
    73                              <1> %macro 		SIODELAY 0 			; SHORT IODELAY
    74                              <1> 		jmp short $+2
    75                              <1> %endmacro		
    76                              <1> 
    77                              <1> %macro		IODELAY  0			; NORMAL IODELAY
    78                              <1> 		jmp short $+2
    79                              <1> 		jmp short $+2
    80                              <1> %endmacro
    81                              <1> 
    82                              <1> %macro		NEWIODELAY 0
    83                              <1> 		out 0EBh, al
    84                              <1> %endmacro 
    85                              <1> 
    86                              <1> ; (According to) AWARD BIOS 1999 - ATORGS.ASM (dw -> equ, db -> equ)
    87                              <1> ;;; WAIT_FOR_MEM
    88                              <1> ;WAIT_FDU_INT_LO	equ	017798		; 2.5 secs in 30 micro units.
    89                              <1> ;WAIT_FDU_INT_HI	equ	1
    90                              <1> WAIT_FDU_INT_LH		equ	83334		; 27/02/2015 (2.5 seconds waiting)
    91                              <1> ;;; WAIT_FOR_PORT
    92                              <1> ;WAIT_FDU_SEND_LO	equ	16667		; .5 secons in 30 us units.
    93                              <1> ;WAIT_FDU_SEND_HI	equ	0
    94                              <1> WAIT_FDU_SEND_LH	equ 	16667		; 27/02/2015	
    95                              <1> ;Time to wait while waiting for each byte of NEC results = .5
    96                              <1> ;seconds.  .5 seconds = 500,000 micros.  500,000/30 = 16,667.
    97                              <1> ;WAIT_FDU_RESULTS_LO	equ	16667		; .5 seconds in 30 micro units.
    98                              <1> ;WAIT_FDU_RESULTS_HI	equ	0
    99                              <1> WAIT_FDU_RESULTS_LH	equ	16667  ; 27/02/2015
   100                              <1> ;;; WAIT_REFRESH
   101                              <1> ;amount of time to wait for head settle, per unit in parameter
   102                              <1> ;table = 1 ms.
   103                              <1> WAIT_FDU_HEAD_SETTLE	equ	33		; 1 ms in 30 micro units.
   104                              <1> 
   105                              <1> 
   106                              <1> ; //////////////// DISKETTE I/O ////////////////
   107                              <1> 
   108                              <1> ; 11/12/2014 (copy from IBM PC-XT Model 286 BIOS - POSTEQU.INC)
   109                              <1> 
   110                              <1> ;----------------------------------------
   111                              <1> ;	EQUATES USED BY POST AND BIOS	:
   112                              <1> ;----------------------------------------
   113                              <1> 
   114                              <1> ;--------- 8042 KEYBOARD INTERFACE AND DIAGNOSTIC CONTROL REGISTERS ------------
   115                              <1> ;PORT_A		EQU	060H		; 8042 KEYBOARD SCAN CODE/CONTROL PORT
   116                              <1> ;PORT_B		EQU	061H		; PORT B READ/WRITE DIAGNOSTIC REGISTER
   117                              <1> ;REFRESH_BIT	EQU	00010000B	; REFRESH TEST BIT
   118                              <1> 
   119                              <1> ;----------------------------------------
   120                              <1> ;	CMOS EQUATES FOR THIS SYSTEM	:
   121                              <1> ;-------------------------------------------------------------------------------
   122                              <1> ;CMOS_PORT	EQU	070H		; I/O ADDRESS OF CMOS ADDRESS PORT
   123                              <1> ;CMOS_DATA	EQU	071H		; I/O ADDRESS OF CMOS DATA PORT
   124                              <1> ;NMI		EQU	10000000B	; DISABLE NMI INTERRUPTS MASK -
   125                              <1> 					;  HIGH BIT OF CMOS LOCATION ADDRESS
   126                              <1> 
   127                              <1> ;---------- CMOS TABLE LOCATION ADDRESS'S ## -----------------------------------
   128                              <1> CMOS_DISKETTE	EQU	010H		; DISKETTE DRIVE TYPE BYTE	      ;
   129                              <1> ;		EQU	011H		; - RESERVED			      ;C
   130                              <1> CMOS_DISK	EQU	012H		; FIXED DISK TYPE BYTE		      ;H
   131                              <1> ;		EQU	013H		; - RESERVED			      ;E
   132                              <1> CMOS_EQUIP	EQU	014H		; EQUIPMENT WORD LOW BYTE	      ;C
   133                              <1> 
   134                              <1> ;---------- DISKETTE EQUATES ---------------------------------------------------
   135                              <1> INT_FLAG	EQU	10000000B	; INTERRUPT OCCURRENCE FLAG
   136                              <1> DSK_CHG 	EQU	10000000B	; DISKETTE CHANGE FLAG MASK BIT
   137                              <1> DETERMINED	EQU	00010000B	; SET STATE DETERMINED IN STATE BITS
   138                              <1> HOME		EQU	00010000B	; TRACK 0 MASK
   139                              <1> SENSE_DRV_ST	EQU	00000100B	; SENSE DRIVE STATUS COMMAND
   140                              <1> TRK_SLAP	EQU	030H		; CRASH STOP (48 TPI DRIVES)
   141                              <1> QUIET_SEEK	EQU	00AH		; SEEK TO TRACK 10
   142                              <1> ;MAX_DRV 	EQU	2		; MAX NUMBER OF DRIVES
   143                              <1> HD12_SETTLE	EQU	15		; 1.2 M HEAD SETTLE TIME
   144                              <1> HD320_SETTLE	EQU	20		; 320 K HEAD SETTLE TIME
   145                              <1> MOTOR_WAIT	EQU	37		; 2 SECONDS OF COUNTS FOR MOTOR TURN OFF
   146                              <1> 
   147                              <1> ;---------- DISKETTE ERRORS ----------------------------------------------------
   148                              <1> ;TIME_OUT	EQU	080H		; ATTACHMENT FAILED TO RESPOND
   149                              <1> ;BAD_SEEK	EQU	040H		; SEEK OPERATION FAILED
   150                              <1> BAD_NEC 	EQU	020H		; DISKETTE CONTROLLER HAS FAILED
   151                              <1> BAD_CRC 	EQU	010H		; BAD CRC ON DISKETTE READ
   152                              <1> MED_NOT_FND	EQU	00CH		; MEDIA TYPE NOT FOUND
   153                              <1> DMA_BOUNDARY	EQU	009H		; ATTEMPT TO DMA ACROSS 64K BOUNDARY
   154                              <1> BAD_DMA 	EQU	008H		; DMA OVERRUN ON OPERATION
   155                              <1> MEDIA_CHANGE	EQU	006H		; MEDIA REMOVED ON DUAL ATTACH CARD
   156                              <1> RECORD_NOT_FND	EQU	004H		; REQUESTED SECTOR NOT FOUND
   157                              <1> WRITE_PROTECT	EQU	003H		; WRITE ATTEMPTED ON WRITE PROTECT DISK
   158                              <1> BAD_ADDR_MARK	EQU	002H		; ADDRESS MARK NOT FOUND
   159                              <1> BAD_CMD 	EQU	001H		; BAD COMMAND PASSED TO DISKETTE I/O
   160                              <1> 
   161                              <1> ;---------- DISK CHANGE LINE EQUATES -------------------------------------------
   162                              <1> NOCHGLN 	EQU	001H		; NO DISK CHANGE LINE AVAILABLE
   163                              <1> CHGLN		EQU	002H		; DISK CHANGE LINE AVAILABLE
   164                              <1> 
   165                              <1> ;---------- MEDIA/DRIVE STATE INDICATORS ---------------------------------------
   166                              <1> TRK_CAPA	EQU	00000001B	; 80 TRACK CAPABILITY
   167                              <1> FMT_CAPA	EQU	00000010B	; MULTIPLE FORMAT CAPABILITY (1.2M)
   168                              <1> DRV_DET 	EQU	00000100B	; DRIVE DETERMINED
   169                              <1> MED_DET 	EQU	00010000B	; MEDIA DETERMINED BIT
   170                              <1> DBL_STEP	EQU	00100000B	; DOUBLE STEP BIT
   171                              <1> RATE_MSK	EQU	11000000B	; MASK FOR CLEARING ALL BUT RATE
   172                              <1> RATE_500	EQU	00000000B	; 500 KBS DATA RATE
   173                              <1> RATE_300	EQU	01000000B	; 300 KBS DATA RATE
   174                              <1> RATE_250	EQU	10000000B	; 250 KBS DATA RATE
   175                              <1> STRT_MSK	EQU	00001100B	; OPERATION START RATE MASK
   176                              <1> SEND_MSK	EQU	11000000B	; MASK FOR SEND RATE BITS
   177                              <1> 
   178                              <1> ;---------- MEDIA/DRIVE STATE INDICATORS COMPATIBILITY -------------------------
   179                              <1> M3D3U		EQU	00000000B	; 360 MEDIA/DRIVE NOT ESTABLISHED
   180                              <1> M3D1U		EQU	00000001B	; 360 MEDIA,1.2DRIVE NOT ESTABLISHED
   181                              <1> M1D1U		EQU	00000010B	; 1.2 MEDIA/DRIVE NOT ESTABLISHED
   182                              <1> MED_UNK 	EQU	00000111B	; NONE OF THE ABOVE
   183                              <1> 
   184                              <1> ;---------- INTERRUPT EQUATES --------------------------------------------------
   185                              <1> ;EOI		EQU	020H		; END OF INTERRUPT COMMAND TO 8259
   186                              <1> ;INTA00		EQU	020H		; 8259 PORT
   187                              <1> INTA01		EQU	021H		; 8259 PORT
   188                              <1> INTB00		EQU	0A0H		; 2ND 8259
   189                              <1> INTB01		EQU	0A1H		;
   190                              <1> 
   191                              <1> ;-------------------------------------------------------------------------------
   192                              <1> DMA08		EQU	008H		; DMA STATUS REGISTER PORT ADDRESS
   193                              <1> DMA		EQU	000H		; DMA CH.0 ADDRESS REGISTER PORT ADDRESS
   194                              <1> DMA18		EQU	0D0H		; 2ND DMA STATUS PORT ADDRESS
   195                              <1> DMA1		EQU	0C0H		; 2ND DMA CH.0 ADDRESS REGISTER ADDRESS
   196                              <1> ;-------------------------------------------------------------------------------
   197                              <1> ;TIMER		EQU	040H		; 8254 TIMER - BASE ADDRESS
   198                              <1> 
   199                              <1> ;-------------------------------------------------------------------------------
   200                              <1> DMA_PAGE	EQU	081H		; START OF DMA PAGE REGISTERS
   201                              <1> 
   202                              <1> ; 06/02/2015 (unix386.s, protected mode modifications)
   203                              <1> ; (unix386.s <-- dsectrm2.s)
   204                              <1> ; 11/12/2014 (copy from IBM PC-XT Model 286 BIOS - DSEG.INC)
   205                              <1> 
   206                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
   207                              <1> ; 10/12/2014
   208                              <1> ;
   209                              <1> ;int40h:
   210                              <1> ;	pushf
   211                              <1> ;	push 	cs
   212                              <1> ;	;cli
   213                              <1> ;	call 	DISKETTE_IO_1
   214                              <1> ;	retn
   215                              <1> 
   216                              <1> ; DSKETTE ----- 04/21/86 DISKETTE BIOS
   217                              <1> ; (IBM PC XT Model 286 System BIOS Source Code, 04-21-86)
   218                              <1> ;
   219                              <1> 
   220                              <1> ;-- INT13H ---------------------------------------------------------------------
   221                              <1> ; DISKETTE I/O
   222                              <1> ;	THIS INTERFACE PROVIDES ACCESS TO THE 5 1/4 INCH 360 KB,
   223                              <1> ;	1.2 MB, 720 KB AND 1.44 MB DISKETTE DRIVES.
   224                              <1> ; INPUT
   225                              <1> ;	(AH) =  00H RESET DISKETTE SYSTEM
   226                              <1> ;		HARD RESET TO NEC, PREPARE COMMAND, RECALIBRATE REQUIRED
   227                              <1> ;		ON ALL DRIVES
   228                              <1> ;------------------------------------------------------------------------------- 
   229                              <1> ;	(AH)= 01H  READ THE STATUS OF THE SYSTEM INTO (AH)
   230                              <1> ;		@DISKETTE_STATUS FROM LAST OPERATION IS USED
   231                              <1> ;-------------------------------------------------------------------------------
   232                              <1> ;	REGISTERS FOR READ/WRITE/VERIFY/FORMAT
   233                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   234                              <1> ;	(DH) - HEAD NUMBER (0-1 ALLOWED, NOT VALUE CHECKED)
   235                              <1> ;	(CH) - TRACK NUMBER (NOT VALUE CHECKED)
   236                              <1> ;		MEDIA	DRIVE	TRACK NUMBER
   237                              <1> ;		320/360	320/360	    0-39
   238                              <1> ;		320/360	1.2M	    0-39
   239                              <1> ;		1.2M	1.2M	    0-79
   240                              <1> ;		720K	720K	    0-79
   241                              <1> ;		1.44M	1.44M	    0-79	
   242                              <1> ;	(CL) - 	SECTOR NUMBER (NOT VALUE CHECKED, NOT USED FOR FORMAT)
   243                              <1> ;		MEDIA	DRIVE	SECTOR NUMBER
   244                              <1> ;		320/360	320/360	     1-8/9
   245                              <1> ;		320/360	1.2M	     1-8/9
   246                              <1> ;		1.2M	1.2M	     1-15
   247                              <1> ;		720K	720K	     1-9
   248                              <1> ;		1.44M	1.44M	     1-18		
   249                              <1> ;	(AL)	NUMBER OF SECTORS (NOT VALUE CHECKED)
   250                              <1> ;		MEDIA	DRIVE	MAX NUMBER OF SECTORS
   251                              <1> ;		320/360	320/360	     8/9
   252                              <1> ;		320/360	1.2M	     8/9
   253                              <1> ;		1.2M	1.2M	     15
   254                              <1> ;		720K	720K	      9
   255                              <1> ;		1.44M	1.44M	     18
   256                              <1> ;
   257                              <1> ;	(ES:BX) - ADDRESS OF BUFFER (NOT REQUIRED FOR VERIFY)
   258                              <1> ;
   259                              <1> ;-------------------------------------------------------------------------------
   260                              <1> ;	(AH)= 02H  READ THE DESIRED SECTORS INTO MEMORY
   261                              <1> ;-------------------------------------------------------------------------------
   262                              <1> ;	(AH)= 03H  WRITE THE DESIRED SECTORS FROM MEMORY
   263                              <1> ;-------------------------------------------------------------------------------
   264                              <1> ;	(AH)= 04H  VERIFY THE DESIRED SECTORS
   265                              <1> ;-------------------------------------------------------------------------------
   266                              <1> ;	(AH)= 05H  FORMAT THE DESIRED TRACK
   267                              <1> ;		(ES,BX) MUST POINT TO THE COLLECTION OF DESIRED ADDRESS FIELDS
   268                              <1> ;		FOR THE	TRACK. EACH FIELD IS COMPOSED OF 4 BYTES, (C,H,R,N),
   269                              <1> ;		WHERE C = TRACK NUMBER, H=HEAD NUMBER, R = SECTOR NUMBER, 
   270                              <1> ;		N= NUMBER OF BYTES PER SECTOR (00=128,01=256,02=512,03=1024),
   271                              <1> ;		THERE MUST BE ONE ENTRY FOR EVERY SECTOR ON THE TRACK.
   272                              <1> ;		THIS INFORMATION IS USED TO FIND THE REQUESTED SECTOR DURING 
   273                              <1> ;		READ/WRITE ACCESS.
   274                              <1> ;		PRIOR TO FORMATTING A DISKETTE, IF THERE EXISTS MORE THAN
   275                              <1> ;		ONE SUPPORTED MEDIA FORMAT TYPE WITHIN THE DRIVE IN QUESTION,
   276                              <1> ;		THEN "SET DASD TYPE" (INT 13H, AH = 17H) OR 'SET MEDIA TYPE'
   277                              <1> ;		(INT 13H, AH =  18H) MUST BE CALLED TO SET THE DISKETTE TYPE
   278                              <1> ;		THAT IS TO BE FORMATTED. IF "SET DASD TYPE" OR "SET MEDIA TYPE"
   279                              <1> ;		IS NOT CALLED, THE FORMAT ROUTINE WILL ASSUME THE 
   280                              <1> ;		MEDIA FORMAT TO BE THE MAXIMUM CAPACITY OF THE DRIVE.
   281                              <1> ;
   282                              <1> ;		THESE PARAMETERS OF DISK BASE MUST BE CHANGED IN ORDER TO
   283                              <1> ;		FORMAT THE FOLLOWING MEDIAS:
   284                              <1> ;		---------------------------------------------
   285                              <1> ;		: MEDIA  :     DRIVE      : PARM 1 : PARM 2 :
   286                              <1> ;		---------------------------------------------
   287                              <1> ;		: 320K	 : 320K/360K/1.2M :  50H   :   8    :
   288                              <1> ;		: 360K	 : 320K/360K/1.2M :  50H   :   9    :
   289                              <1> ;		: 1.2M	 : 1.2M           :  54H   :  15    :
   290                              <1> ;		: 720K	 : 720K/1.44M     :  50H   :   9    :
   291                              <1> ;		: 1.44M	 : 1.44M          :  6CH   :  18    :		  	
   292                              <1> ;		---------------------------------------------
   293                              <1> ;		NOTES: - PARM 1 = GAP LENGTH FOR FORMAT
   294                              <1> ;		       - PARM 2 = EOT (LAST SECTOR ON TRACK)
   295                              <1> ;		       - DISK BASE IS POINTED BY DISK POINTER LOCATED
   296                              <1> ;			 AT ABSOLUTE ADDRESS 0:78.
   297                              <1> ;		       - WHEN FORMAT OPERATIONS ARE COMPLETE, THE PARAMETERS
   298                              <1> ;			 SHOULD BE RESTORED TO THEIR RESPECTIVE INITIAL VALUES.			
   299                              <1> ;-------------------------------------------------------------------------------
   300                              <1> ;	(AH) = 08H READ DRIVE PARAMETERS
   301                              <1> ;	REGISTERS
   302                              <1> ;	  INPUT
   303                              <1> ;	    (DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   304                              <1> ;	     ** 27/05/2016 - TRDOS 386 (TRDOS v2.0) **	
   305                              <1> ;            ** EBX = Buffer address for floppy disk parameters table **
   306                              <1> ;	  OUTPUT
   307                              <1> ;	    (ES:DI) POINTS TO DRIVE PARAMETER TABLE
   308                              <1> ; 	    *** TRDOS 386 note: floppy disk parameter table (16 bytes)
   309                              <1> ;	    will be returned to user in EBX, buffer address *** 27/05/2016 ***		
   310                              <1> ;					
   311                              <1> ;	    (CH) - LOW ORDER 8 OF 10 BITS MAXIMUM NUMBER OF TRACKS
   312                              <1> ;	    (CL) - BITS 7 & 6 - HIGH ORDER TWO BITS OF MAXIMUM TRACKS
   313                              <1> ;	           BITS 5 THRU 0 - MAXIMUM SECTORS PER TRACK
   314                              <1> ;	    (DH) - MAXIMUM HEAD NUMBER
   315                              <1> ;	    (DL) - NUMBER OF DISKETTE DRIVES INSTALLED
   316                              <1> ;	    (BH) - 0
   317                              <1> ;	    (BL) - BITS 7 THRU 4 - 0
   318                              <1> ;	           BITS 3 THRU 0 - VALID DRIVE TYPE VALUE IN CMOS
   319                              <1> ;	    (AX) - 0
   320                              <1> ;	 UNDER THE FOLLOWING CIRCUMSTANCES:
   321                              <1> ;	    (1) THE DRIVE NUMBER IS INVALID,
   322                              <1> ;	    (2) THE DRIVE TYPE IS UNKNOWN AND CMOS IS NOT PRESENT, 
   323                              <1> ;	    (3) THE DRIVE TYPE IS UNKNOWN AND CMOS IS BAD,
   324                              <1> ;	    (4) OR THE DRIVE TYPE IS UNKNOWN AND THE CMOS DRIVE TYPE IS INVALID
   325                              <1> ;	    THEN ES,AX,BX,CX,DH,DI=0 ; DL=NUMBER OF DRIVES. 
   326                              <1> ;	    IF NO DRIVES ARE PRESENT THEN: ES,AX,BX,CX,DX,DI=0.
   327                              <1> ;	    @DISKETTE_STATUS = 0 AND CY IS RESET.
   328                              <1> ;-------------------------------------------------------------------------------
   329                              <1> ;	(AH)= 15H  READ DASD TYPE
   330                              <1> ;	OUTPUT REGISTERS
   331                              <1> ;	(AH) - ON RETURN IF CARRY FLAG NOT SET, OTHERWISE ERROR	
   332                              <1> ;		00 - DRIVE NOT PRESENT	
   333                              <1> ;		01 - DISKETTE, NO CHANGE LINE AVAILABLE
   334                              <1> ;		02 - DISKETTE, CHANGE LINE AVAILABLE	
   335                              <1> ;		03 - RESERVED (FIXED DISK)
   336                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   337                              <1> ;-------------------------------------------------------------------------------
   338                              <1> ;	(AH)= 16H  DISK CHANGE LINE STATUS
   339                              <1> ;	OUTPUT REGISTERS
   340                              <1> ;	(AH) - 00 - DISK CHANGE LINE NOT ACTIVE	
   341                              <1> ;	       06 - DISK CHANGE LINE ACTIVE & CARRY BIT ON
   342                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   343                              <1> ;-------------------------------------------------------------------------------
   344                              <1> ;	(AH)= 17H  SET DASD TYPE FOR FORMAT
   345                              <1> ;	INPUT REGISTERS
   346                              <1> ;	(AL) -	00 - NOT USED	
   347                              <1> ;		01 - DISKETTE 320/360K IN 360K DRIVE	
   348                              <1> ;		02 - DISKETTE 360K IN 1.2M DRIVE
   349                              <1> ;		03 - DISKETTE 1.2M IN 1.2M DRIVE
   350                              <1> ;		04 - DISKETTE 720K IN 720K DRIVE
   351                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED:
   352                              <1> ;	       (DO NOT USE WHEN DISKETTE ATTACH CARD USED)
   353                              <1> ;-------------------------------------------------------------------------------
   354                              <1> ;	(AH)= 18H  SET MEDIA TYPE FOR FORMAT
   355                              <1> ;	INPUT REGISTERS
   356                              <1> ;	(CH) - LOW ORDER 8 OF 10 BITS MAXIMUM TRACKS
   357                              <1> ;	(CL) - BITS 7 & 6 - HIGH ORDER TWO BITS OF MAXIMUM TRACKS
   358                              <1> ;	       BITS 5 THRU 0 - MAXIMUM SECTORS PER TRACK
   359                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHACKED)
   360                              <1> ;	OUTPUT REGISTERS:
   361                              <1> ;	(ES:DI) - POINTER TO DRIVE PARAMETERS TABLE FOR THIS MEDIA TYPE,
   362                              <1> ;		  UNCHANGED IF (AH) IS NON-ZERO
   363                              <1> ;	(AH) - 00H, CY = 0, TRACK AND SECTORS/TRACK COMBINATION IS SUPPORTED
   364                              <1> ;	     - 01H, CY = 1, FUNCTION IS NOT AVAILABLE
   365                              <1> ;	     - 0CH, CY = 1, TRACK AND SECTORS/TRACK COMBINATION IS NOT SUPPORTED
   366                              <1> ;	     - 80H, CY = 1, TIME OUT (DISKETTE NOT PRESENT)		
   367                              <1> ;-------------------------------------------------------------------------------
   368                              <1> ;	DISK CHANGE STATUS IS ONLY CHECKED WHEN A MEDIA SPECIFIED IS OTHER
   369                              <1> ;	THAN 360 KB DRIVE. IF THE DISK CHANGE LINE IS FOUND TO BE
   370                              <1> ;	ACTIVE THE FOLLOWING ACTIONS TAKE PLACE:
   371                              <1> ;		ATTEMPT TO RESET DISK CHANGE LINE TO INACTIVE STATE. 
   372                              <1> ;		IF ATTEMPT SUCCEEDS SET DASD TYPE FOR FORMAT AND RETURN DISK 
   373                              <1> ;		CHANGE ERROR CODE
   374                              <1> ;		IF ATTEMPT FAILS RETURN TIMEOUT ERROR CODE AND SET DASD TYPE 
   375                              <1> ;		TO A PREDETERMINED STATE INDICATING MEDIA TYPE UNKNOWN.
   376                              <1> ;	IF THE DISK CHANGE LINE IN INACTIVE PERFORM SET DASD TYPE FOR FORMAT.
   377                              <1> ;
   378                              <1> ; DATA VARIABLE -- @DISK_POINTER
   379                              <1> ;	DOUBLE WORD POINTER TO THE CURRENT SET OF DISKETTE PARAMETERS
   380                              <1> ;-------------------------------------------------------------------------------
   381                              <1> ; OUTPUT FOR ALL FUNCTIONS
   382                              <1> ;	AH = STATUS OF OPERATION
   383                              <1> ;		STATUS BITS ARE DEFINED IN THE EQUATES FOR @DISKETTE_STATUS
   384                              <1> ;		VARIABLE IN THE DATA SEGMENT OF THIS MODULE
   385                              <1> ;	CY = 0	SUCCESSFUL OPERATION (AH=0 ON RETURN, EXCEPT FOR READ DASD
   386                              <1> ;		TYPE AH=(15)).
   387                              <1> ;	CY = 1	FAILED OPERATION (AH HAS ERROR REASON)
   388                              <1> ;	FOR READ/WRITE/VERIFY
   389                              <1> ;		DS,BX,DX,CX PRESERVED
   390                              <1> ;	NOTE: IF AN ERROR IS REPORTED BY THE DISKETTE CODE, THE APPROPRIATE 
   391                              <1> ;		ACTION IS TO RESET THE DISKETTE, THEN RETRY THE OPERATION.
   392                              <1> ;		ON READ ACCESSES, NO MOTOR START DELAY IS TAKEN, SO THAT 
   393                              <1> ;		THREE RETRIES ARE REQUIRED ON READS TO ENSURE THAT THE 
   394                              <1> ;		PROBLEM IS NOT DUE TO MOTOR START-UP.
   395                              <1> ;-------------------------------------------------------------------------------
   396                              <1> ;
   397                              <1> ; DISKETTE STATE MACHINE - ABSOLUTE ADDRESS 40:90 (DRIVE A) & 91 (DRIVE B)
   398                              <1> ;
   399                              <1> ;   -----------------------------------------------------------------
   400                              <1> ;   |       |       |       |       |       |       |       |       |
   401                              <1> ;   |   7   |   6   |   5   |   4   |   3   |   2   |   1   |   0   |
   402                              <1> ;   |       |       |       |       |       |       |       |       |
   403                              <1> ;   -----------------------------------------------------------------
   404                              <1> ;	|	|	|	|	|	|	|	|
   405                              <1> ;	|	|	|	|	|	-----------------
   406                              <1> ;	|	|	|	|	|		|
   407                              <1> ;	|	|	|	|    RESERVED		|
   408                              <1> ;	|	|	|	|		  PRESENT STATE
   409                              <1> ;	|	|	|	|	000: 360K IN 360K DRIVE UNESTABLISHED
   410                              <1> ;	|	|	|	|	001: 360K IN 1.2M DRIVE UNESTABLISHED
   411                              <1> ;	|	|	|	|	010: 1.2M IN 1.2M DRIVE UNESTABLISHED
   412                              <1> ;	|	|	|	|	011: 360K IN 360K DRIVE ESTABLISHED
   413                              <1> ;	|	|	|	|	100: 360K IN 1.2M DRIVE ESTABLISHED
   414                              <1> ;	|	|	|	|	101: 1.2M IN 1.2M DRIVE ESTABLISHED
   415                              <1> ;	|	|	|	|	110: RESERVED
   416                              <1> ;	|	|	|	|	111: NONE OF THE ABOVE
   417                              <1> ;	|	|	|	|
   418                              <1> ;	|	|	|	------>	MEDIA/DRIVE ESTABLISHED
   419                              <1> ;	|	|	|
   420                              <1> ;	|	|	-------------->	DOUBLE STEPPING REQUIRED (360K IN 1.2M
   421                              <1> ;	|	|			DRIVE)
   422                              <1> ;	|	|
   423                              <1> ;	------------------------------>	DATA TRANSFER RATE FOR THIS DRIVE:
   424                              <1> ;
   425                              <1> ;						00: 500 KBS
   426                              <1> ;						01: 300 KBS
   427                              <1> ;						10: 250 KBS
   428                              <1> ;						11: RESERVED
   429                              <1> ;
   430                              <1> ;
   431                              <1> ;-------------------------------------------------------------------------------
   432                              <1> ; STATE OPERATION STARTED - ABSOLUTE ADDRESS 40:92 (DRIVE A) & 93 (DRIVE B)
   433                              <1> ;-------------------------------------------------------------------------------
   434                              <1> ; PRESENT CYLINDER NUMBER - ABSOLUTE ADDRESS 40:94 (DRIVE A) & 95 (DRIVE B)
   435                              <1> ;-------------------------------------------------------------------------------
   436                              <1> 
   437                              <1> struc MD
   438 00000000 ??                  <1> 	.SPEC1		resb	1	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   439 00000001 ??                  <1> 	.SPEC2		resb	1	; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   440 00000002 ??                  <1> 	.OFF_TIM	resb	1	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   441 00000003 ??                  <1> 	.BYT_SEC	resb	1	; 512 BYTES/SECTOR
   442 00000004 ??                  <1> 	.SEC_TRK	resb	1	; EOT (LAST SECTOR ON TRACK)
   443 00000005 ??                  <1> 	.GAP		resb	1	; GAP LENGTH
   444 00000006 ??                  <1> 	.DTL		resb	1	; DTL
   445 00000007 ??                  <1> 	.GAP3		resb	1	; GAP LENGTH FOR FORMAT
   446 00000008 ??                  <1> 	.FIL_BYT	resb	1	; FILL BYTE FOR FORMAT
   447 00000009 ??                  <1> 	.HD_TIM		resb	1	; HEAD SETTLE TIME (MILLISECONDS)
   448 0000000A ??                  <1> 	.STR_TIM	resb	1	; MOTOR START TIME (1/8 SECONDS)
   449 0000000B ??                  <1> 	.MAX_TRK	resb	1	; MAX. TRACK NUMBER
   450 0000000C ??                  <1> 	.RATE		resb	1	; DATA TRANSFER RATE
   451                              <1> endstruc
   452                              <1> 
   453                              <1> BIT7OFF	EQU	7FH
   454                              <1> BIT7ON	EQU	80H
   455                              <1> 
   456                              <1> ; 30/08/2020 - TRDOS 386 v2
   457                              <1> 
   458                              <1> ;;int13h: ; 16/02/2015
   459                              <1> ;; 16/02/2015 - 21/02/2015
   460                              <1> ; 17/07/2022 - TRDOS 386 v2.0.5
   461                              <1> ;int40h:
   462                              <1> ;; 11/04/2021
   463                              <1> ;diskette_io:
   464                              <1> ;	clc ; 20/07/2020
   465                              <1> ;	pushfd
   466                              <1> ;	push 	cs
   467                              <1> ;	call 	DISKETTE_IO_1
   468                              <1> ;	retn
   469                              <1> 
   470                              <1> 	; 09/08/2022
   471                              <1> 	; 06/08/2022
   472                              <1> 	; 17/07/2022 - TRDOS 386 v2.0.5
   473                              <1> 	; (jump from DISK_IO)
   474                              <1> DISKETTE_IO_1:
   475                              <1> 	;sti ; 17/07/2022		; INTERRUPTS BACK ON
   476                              <1> 	
   477                              <1> 	;push	ebp			; USER REGISTER
   478                              <1> 	;push	edi			; USER REGISTER
   479                              <1> 	;push	edx			; HEAD #, DRIVE # OR USER REGISTER
   480                              <1> 	;push	ebx			; BUFFER OFFSET PARAMETER OR REGISTER
   481                              <1> 	;push	ecx			; TRACK #-SECTOR # OR USER REGISTER
   482                              <1> 	;mov	ebp, esp		; BP     => PARAMETER LIST DEP. ON AH
   483                              <1> 					; [BP]   = SECTOR #
   484                              <1> 					; [BP+1] = TRACK #
   485                              <1> 					; [BP+2] = BUFFER OFFSET
   486                              <1> 					; FOR RETURN OF DRIVE PARAMETERS:
   487                              <1> 					; CL/[BP] = BITS 7&6 HI BITS OF MAX CYL
   488                              <1> 					; 	    BITS 0-5 MAX SECTORS/TRACK
   489                              <1> 					; CH/[BP+1] = LOW 8 BITS OF MAX CYL.
   490                              <1> 					; BL/[BP+2] = BITS 7-4 = 0
   491                              <1> 					;	      BITS 3-0 = VALID CMOS TYPE
   492                              <1> 					; BH/[BP+3] = 0
   493                              <1> 					; DL/[BP+4] = # DRIVES INSTALLED
   494                              <1> 					; DH/[BP+5] = MAX HEAD #
   495                              <1> 					; DI/[BP+6] = OFFSET TO DISK BASE
   496                              <1> 	;push	es ; 06/02/2015	
   497                              <1> 	;push	ds			; BUFFER SEGMENT PARM OR USER REGISTER
   498                              <1> 	;push	esi			; USER REGISTERS
   499                              <1> 	;;call	DDS			; SEGMENT OF BIOS DATA AREA TO DS
   500                              <1> 	;;mov	cx, cs
   501                              <1> 	;;mov	ds, cx
   502                              <1> 	;mov	cx, KDATA
   503                              <1> 	;mov	ds, cx
   504                              <1> 	;mov	es, cx
   505                              <1> 
   506                              <1> 	; 17/07/2022
   507                              <1> 	; Registers are also on stack 
   508                              <1> 	; (with same contents) 
   509                              <1> 	; in following order:
   510                              <1> 	;
   511                              <1> 	;    ebx = esp+20
   512                              <1> 	;    ecx = esp+16
   513                              <1> 	;    edx = esp+12
   514                              <1> 	;    esi = esp+8
   515                              <1> 	;    edi = esp+4
   516                              <1> 	;
   517                              <1> 	; [esp] = caller's return address (from 'DISK_IO')	
   518                              <1> 	;
   519                              <1> 	; cs = KCODE == KDATA
   520                              <1> 	; ds = es = ss = KDATA
   521                              <1> 
   522                              <1> 	; 17/07/2022
   523 000041D2 55                  <1> 	push	ebp
   524 000041D3 89DD                <1> 	mov	ebp, ebx
   525                              <1> 
   526                              <1> 	;cmp	ah, (FNC_TAE-FNC_TAB)/2	; CHECK FOR > LARGEST FUNCTION
   527 000041D5 80FC19              <1> 	cmp	ah, (FNC_TAE-FNC_TAB)/4	; 18/02/2015
   528                              <1> 	;jb	short OK_FUNC		; FUNCTION OK
   529                              <1> 	;mov	ah, 14h			; REPLACE WITH KNOWN INVALID FUNCTION
   530                              <1> 	; 09/08/2022
   531 000041D8 730F                <1> 	jnb	short INV_FUNC
   532                              <1> OK_FUNC:
   533 000041DA 80FC01              <1> 	cmp	ah, 1			; RESET OR STATUS ?
   534 000041DD 760C                <1> 	jbe	short OK_DRV		; IF RESET OR STATUS DRIVE ALWAYS OK
   535 000041DF 80FC08              <1> 	cmp	ah, 8			; READ DRIVE PARMS ?
   536 000041E2 7407                <1> 	je	short OK_DRV		; IF SO DRIVE CHECKED LATER
   537 000041E4 80FA01              <1> 	cmp	dl, 1			; DRIVES 0 AND 1 OK
   538 000041E7 7602                <1> 	jbe	short OK_DRV		; IF 0 OR 1 THEN JUMP
   539                              <1> INV_FUNC:
   540 000041E9 B414                <1> 	mov	ah, 14h			; REPLACE WITH KNOWN INVALID FUNCTION
   541                              <1> OK_DRV:
   542                              <1> 	; 17/07/2022
   543                              <1> 	;xor	ecx, ecx
   544                              <1> 	;;mov	esi, ecx ; 08/02/2015
   545                              <1> 	;mov	edi, ecx ; 08/02/2015
   546                              <1> 	;mov	cl, ah			; CL = FUNCTION
   547                              <1> 	;;xor	ch, ch			; CX = FUNCTION
   548                              <1> 	;;shl	cl, 1			; FUNCTION TIMES 2
   549                              <1> 	;shl	cl, 2 ; 20/02/2015	; FUNCTION TIMES 4 (for 32 bit offset)
   550                              <1> 	;mov	ebx, FNC_TAB		; LOAD START OF FUNCTION TABLE
   551                              <1> 	;add	ebx, ecx		; ADD OFFSET INTO TABLE => ROUTINE
   552                              <1> 
   553                              <1> 	; 17/07/2022	
   554 000041EB 29DB                <1> 	sub	ebx, ebx
   555 000041ED 88E3                <1> 	mov	bl, ah			; BL = FUNCTION	
   556 000041EF C0E302              <1> 	shl	bl, 2 ; * 4
   557 000041F2 81C3[11420000]      <1> 	add	ebx, FNC_TAB		; [EBX] = FUNCTION ADDRESS
   558                              <1> 	
   559 000041F8 88F4                <1> 	mov	ah, dh			; AX = HEAD #,# OF SECTORS OR DASD TYPE
   560                              <1> 	;xor	dh, dh			; DX = DRIVE #
   561                              <1> 	;mov	si, ax			; SI = HEAD #,# OF SECTORS OR DASD TYPE
   562                              <1> 	;mov	di, dx			; DI = DRIVE #
   563                              <1> 	
   564 000041FA 0FB7F0              <1> 	movzx	esi, ax			; ESI = HEAD #,# OF SECTORS OR DASD TYPE
   565 000041FD 0FB6FA              <1> 	movzx	edi, dl			; EDI = DRIVE # 
   566                              <1> 
   567                              <1> 	; CH = cylinder number (low 8 bit)
   568                              <1> 	; CL = sector number (and high 2 bits of cylinder number)
   569                              <1> 
   570                              <1> 	; 06/08/2022
   571                              <1> 	; 11/12/2014
   572                              <1>         ;mov	[cfd], dl               ; current floppy drive (for 'GET_PARM')        
   573                              <1> 	; 06/08/2022
   574                              <1> 	; EDI = (current) DRIVE #
   575                              <1> 	;
   576 00004200 8A25[10780100]      <1> 	mov	ah, [DSKETTE_STATUS]	; LOAD STATUS TO AH FOR STATUS FUNCTION
   577 00004206 C605[10780100]00    <1> 	mov	byte [DSKETTE_STATUS], 0 ; INITIALIZE FOR ALL OTHERS
   578                              <1> 
   579                              <1> ;	THROUGHOUT THE DISKETTE BIOS, THE FOLLOWING INFORMATION IS CONTAINED IN
   580                              <1> ;	THE FOLLOWING MEMORY LOCATIONS AND REGISTERS. NOT ALL DISKETTE BIOS
   581                              <1> ;	FUNCTIONS REQUIRE ALL OF THESE PARAMETERS.
   582                              <1> ;
   583                              <1> ;		DI	: DRIVE #
   584                              <1> ;		SI-HI	: HEAD #
   585                              <1> ;		SI-LOW	: # OF SECTORS OR DASD TYPE FOR FORMAT
   586                              <1> ;		ES	: BUFFER SEGMENT
   587                              <1> ;		[BP]	: SECTOR #
   588                              <1> ;		[BP+1]	: TRACK #
   589                              <1> ;		[BP+2]	: BUFFER OFFSET
   590                              <1> ;
   591                              <1> ;	ACROSS CALLS TO SUBROUTINES THE CARRY FLAG (CY=1), WHERE INDICATED IN 
   592                              <1> ;	SUBROUTINE PROLOGUES, REPRESENTS AN EXCEPTION RETURN (NORMALLY AN ERROR 
   593                              <1> ;	CONDITION). IN MOST CASES, WHEN CY = 1, @DSKETTE_STATUS CONTAINS THE 
   594                              <1> ;	SPECIFIC ERROR CODE.
   595                              <1> 
   596                              <1> 	; 17/07/2022
   597                              <1> 	; EBX = pointer to function address
   598                              <1> 	; EBP = buffer address
   599                              <1> 	; EDI = drive number (0 or 1)
   600                              <1> 	; ESI = head number (byte 1) and sector count or disk type (byte 0)
   601                              <1> 	; CH = cylinder number (low 8 bit)
   602                              <1> 	; CL = sector number (and high 2 bits of cylinder number)
   603                              <1> 
   604                              <1> 					; (AH) = @DSKETTE_STATUS
   605 0000420D FF13                <1> 	call	dword [ebx]		; CALL THE REQUESTED FUNCTION
   606                              <1> 	
   607                              <1> 	;pop	esi			; RESTORE ALL REGISTERS
   608                              <1> 	;pop	ds
   609                              <1> 	;pop	es	; 06/02/2015
   610                              <1> 	;pop	ecx
   611                              <1> 	;pop	ebx
   612                              <1> 	;pop	edx
   613                              <1> 	;pop	edi
   614                              <1> 	;mov	ebp, esp
   615                              <1> 	;push	eax
   616                              <1> 	;pushfd
   617                              <1> 	;pop	eax
   618                              <1> 	;;mov	[bp+6], ax
   619                              <1> 	;mov	[ebp+12], eax  ; 18/02/2015, flags
   620                              <1> 	;pop	eax
   621                              <1> 	;pop	ebp
   622                              <1> 	;iretd
   623                              <1> 
   624                              <1> 	; 17/07/2022
   625 0000420F 5D                  <1> 	pop	ebp
   626                              <1> 
   627                              <1> 	; 17/07/2022
   628                              <1> 	; Stack order:
   629                              <1> 	;    ebx = esp+20
   630                              <1> 	;    ecx = esp+16
   631                              <1> 	;    edx = esp+12
   632                              <1> 	;    esi = esp+8
   633                              <1> 	;    edi = esp+4
   634                              <1> 	;
   635                              <1> 	; [esp] = caller's return address (from 'DISK_IO')
   636                              <1> 
   637                              <1> 	; CF = disk i/o status (1 = error)
   638                              <1> 	; AH = error code (if > 0 and cf = 1)
   639                              <1> 
   640                              <1> 	; 17/07/2022
   641 00004210 C3                  <1> 	retn	; return to the caller of 'DISK_IO' 
   642                              <1> 
   643                              <1> ;-------------------------------------------------------------------------------
   644                              <1> ; DW --> dd (06/02/2015)
   645 00004211 [75420000]          <1> FNC_TAB	dd	DSK_RESET		; AH = 00H; RESET
   646 00004215 [E0420000]          <1> 	dd	DSK_STATUS		; AH = 01H; STATUS
   647 00004219 [F0420000]          <1> 	dd	DSK_READ		; AH = 02H; READ
   648 0000421D [FD420000]          <1> 	dd	DSK_WRITE		; AH = 03H; WRITE
   649 00004221 [05440000]          <1> 	dd	DSK_VERF		; AH = 04H; VERIFY
   650 00004225 [15440000]          <1> 	dd	DSK_FORMAT		; AH = 05H; FORMAT
   651 00004229 [93440000]          <1> 	dd	FNC_ERR			; AH = 06H; INVALID
   652 0000422D [93440000]          <1> 	dd	FNC_ERR			; AH = 07H; INVALID
   653 00004231 [9F440000]          <1> 	dd	DSK_PARMS		; AH = 08H; READ DRIVE PARAMETERS
   654 00004235 [93440000]          <1> 	dd	FNC_ERR			; AH = 09H; INVALID
   655 00004239 [93440000]          <1> 	dd	FNC_ERR			; AH = 0AH; INVALID
   656 0000423D [93440000]          <1> 	dd	FNC_ERR			; AH = 0BH; INVALID
   657 00004241 [93440000]          <1> 	dd	FNC_ERR			; AH = 0CH; INVALID
   658 00004245 [93440000]          <1> 	dd	FNC_ERR			; AH = 0DH; INVALID
   659 00004249 [93440000]          <1> 	dd	FNC_ERR			; AH = 0EH; INVALID
   660 0000424D [93440000]          <1> 	dd	FNC_ERR			; AH = 0FH; INVALID
   661 00004251 [93440000]          <1> 	dd	FNC_ERR			; AH = 10H; INVALID
   662 00004255 [93440000]          <1> 	dd	FNC_ERR			; AH = 11H; INVALID
   663 00004259 [93440000]          <1> 	dd	FNC_ERR			; AH = 12H; INVALID
   664 0000425D [93440000]          <1> 	dd	FNC_ERR			; AH = 13H; INVALID
   665 00004261 [93440000]          <1> 	dd	FNC_ERR			; AH = 14H; INVALID
   666 00004265 [5C450000]          <1> 	dd	DSK_TYPE		; AH = 15H; READ DASD TYPE
   667 00004269 [7C450000]          <1> 	dd	DSK_CHANGE		; AH = 16H; CHANGE STATUS
   668 0000426D [AB450000]          <1> 	dd	FORMAT_SET		; AH = 17H; SET DASD TYPE
   669 00004271 [20460000]          <1> 	dd	SET_MEDIA		; AH = 18H; SET MEDIA TYPE	
   670                              <1> FNC_TAE EQU     $                       ; END
   671                              <1> 
   672                              <1> 	; 17/07/2022 - TRDOS 386 v2.0.5
   673                              <1> ;-------------------------------------------------------------------------------
   674                              <1> ; DISK_RESET	(AH = 00H)	
   675                              <1> ;		RESET THE DISKETTE SYSTEM.
   676                              <1> ;
   677                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   678                              <1> ;-------------------------------------------------------------------------------
   679                              <1> DSK_RESET:
   680                              <1> 	; 17/07/2022
   681 00004275 66BAF203            <1> 	mov	dx, 03F2h		; ADAPTER CONTROL PORT
   682 00004279 FA                  <1> 	cli				; NO INTERRUPTS
   683 0000427A A0[0E780100]        <1> 	mov	al, [MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
   684 0000427F 243F                <1> 	and	al, 00111111b		; KEEP SELECTED AND MOTOR ON BITS
   685 00004281 C0C004              <1> 	rol	al, 4			; MOTOR VALUE TO HIGH NIBBLE
   686                              <1> 					; DRIVE SELECT TO LOW NIBBLE
   687 00004284 0C08                <1> 	or	al, 00001000b		; TURN ON INTERRUPT ENABLE
   688 00004286 EE                  <1> 	out	dx, al			; RESET THE ADAPTER
   689 00004287 C605[0D780100]00    <1> 	mov	byte [SEEK_STATUS], 0	; SET RECALIBRATE REQUIRED ON ALL DRIVES
   690                              <1> 	;jmp	$+2			; WAIT FOR I/O
   691                              <1> 	;jmp	$+2			; WAIT FOR I/O (TO INSURE MINIMUM
   692                              <1> 					;      PULSE WIDTH)
   693                              <1> 	; 19/12/2014
   694                              <1> 	NEWIODELAY
    83 0000428E E6EB                <2>  out 0EBh, al
   695                              <1> 
   696                              <1> 	; 17/12/2014 
   697                              <1> 	; AWARD BIOS 1999 - RESETDRIVES (ADISK.ASM)
   698 00004290 B915000000          <1> 	mov	ecx, WAITCPU_RESET_ON	; cx = 21 -- Min. 14 micro seconds !?
   699                              <1> wdw1:
   700                              <1> 	NEWIODELAY   ; 27/02/2015
    83 00004295 E6EB                <2>  out 0EBh, al
   701 00004297 E2FC                <1> 	loop	wdw1
   702                              <1> 	;
   703 00004299 0C04                <1> 	or	al, 00000100b		; TURN OFF RESET BIT
   704 0000429B EE                  <1> 	out	dx, al			; RESET THE ADAPTER
   705                              <1> 	; 16/12/2014
   706                              <1> 	IODELAY
    78 0000429C EB00                <2>  jmp short $+2
    79 0000429E EB00                <2>  jmp short $+2
   707                              <1> 	;
   708                              <1> 	;sti				; ENABLE THE INTERRUPTS
   709 000042A0 E8D10A0000          <1> 	call	WAIT_INT		; WAIT FOR THE INTERRUPT
   710 000042A5 7230                <1> 	jc	short DR_ERR		; IF ERROR, RETURN IT
   711                              <1> 	;mov	cx, 11000000b		; CL = EXPECTED @NEC_STATUS
   712                              <1> 	; 17/07/2022
   713                              <1> 	;xor	ch, ch
   714 000042A7 B1C0                <1> 	mov	cl, 11000000b
   715                              <1> NXT_DRV:
   716                              <1> 	;push	cx			; SAVE FOR CALL
   717                              <1> 	; 11/04/2021
   718 000042A9 51                  <1> 	push	ecx
   719 000042AA B8[D6420000]        <1> 	mov	eax, DR_POP_ERR 	; LOAD NEC_OUTPUT ERROR ADDRESS
   720 000042AF 50                  <1> 	push	eax			; "
   721 000042B0 B408                <1> 	mov	ah, 08h			; SENSE INTERRUPT STATUS COMMAND
   722 000042B2 E8B7090000          <1> 	call	NEC_OUTPUT
   723 000042B7 58                  <1> 	pop	eax			; THROW AWAY ERROR RETURN
   724 000042B8 E8E80A0000          <1> 	call	RESULTS			; READ IN THE RESULTS
   725                              <1> 	;pop	cx			; RESTORE AFTER CALL
   726                              <1> 	; 11/04/2021
   727 000042BD 59                  <1> 	pop	ecx
   728 000042BE 7217                <1> 	jc	short DR_ERR		; ERROR RETURN
   729 000042C0 3A0D[11780100]      <1> 	cmp	cl, [NEC_STATUS]	; TEST FOR DRIVE READY TRANSITION
   730 000042C6 750F                <1> 	jnz	short DR_ERR		; EVERYTHING OK
   731 000042C8 FEC1                <1> 	inc	cl			; NEXT EXPECTED @NEC_STATUS
   732 000042CA 80F9C3              <1> 	cmp	cl, 11000011b		; ALL POSSIBLE DRIVES CLEARED
   733 000042CD 76DA                <1> 	jbe	short NXT_DRV		; FALL THRU IF 11000100B OR >
   734                              <1> 	;
   735 000042CF E8F4030000          <1> 	call	SEND_SPEC		; SEND SPECIFY COMMAND TO NEC
   736                              <1> RESBAC:
   737                              <1> 	; 06/08/2022
   738 000042D4 EB10                <1> 	jmp	short SETUP_END_X
   739                              <1> 	;call	SETUP_END		; VARIOUS CLEANUPS
   740                              <1> 	;;mov	bx, si			; GET SAVED AL TO BL
   741                              <1> 	;; 17/07/2022
   742                              <1> 	;mov	ebx, esi		
   743                              <1> 	;mov	al, bl			; PUT BACK FOR RETURN
   744                              <1> 	;retn		
   745                              <1> 
   746                              <1> DR_POP_ERR:
   747                              <1> 	;pop	cx			; CLEAR STACK
   748                              <1> 	; 11/04/2021
   749 000042D6 59                  <1> 	pop	ecx
   750                              <1> DR_ERR:
   751 000042D7 800D[10780100]20    <1> 	or	byte [DSKETTE_STATUS], BAD_NEC ; SET ERROR CODE
   752                              <1> 	;jmp	short RESBAC		; RETURN FROM RESET
   753                              <1> 	; 06/08/2022
   754 000042DE EB06                <1> 	jmp	short SETUP_END_X
   755                              <1> 
   756                              <1> ;-------------------------------------------------------------------------------
   757                              <1> ; DISK_STATUS	(AH = 01H)
   758                              <1> ;	DISKETTE STATUS.
   759                              <1> ;
   760                              <1> ; ON ENTRY:	AH : STATUS OF PREVIOUS OPERATION
   761                              <1> ;
   762                              <1> ; ON EXIT:	AH, @DSKETTE_STATUS, CY REFLECT STATUS OF PREVIOUS OPERATION.
   763                              <1> ;-------------------------------------------------------------------------------
   764                              <1> DSK_STATUS:
   765 000042E0 8825[10780100]      <1> 	mov	[DSKETTE_STATUS], ah	; PUT BACK FOR SETUP END
   766                              <1> SETUP_END_X:	; 06/08/2022
   767 000042E6 E8FD000000          <1> 	call	SETUP_END		; VARIOUS CLEANUPS
   768                              <1> 	;mov	bx, si			; GET SAVED AL TO BL
   769                              <1> 	;mov	al, bl			; PUT BACK FOR RETURN
   770                              <1> 	; 06/08/2022
   771 000042EB 89F3                <1> 	mov	ebx, esi
   772 000042ED 88D8                <1> 	mov	al, bl
   773 000042EF C3                  <1> 	retn		
   774                              <1> 
   775                              <1> ;-------------------------------------------------------------------------------
   776                              <1> ; DISK_READ	(AH = 02H)	
   777                              <1> ;	DISKETTE READ.
   778                              <1> ;
   779                              <1> ; ON ENTRY:	DI	: DRIVE #
   780                              <1> ;		SI-HI	: HEAD #
   781                              <1> ;		SI-LOW	: # OF SECTORS
   782                              <1> ;		ES	: BUFFER SEGMENT
   783                              <1> ;		[BP]	: SECTOR #
   784                              <1> ;		[BP+1]	: TRACK #
   785                              <1> ;		[BP+2]	: BUFFER OFFSET
   786                              <1> ;
   787                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   788                              <1> ;-------------------------------------------------------------------------------
   789                              <1> 
   790                              <1> ; 06/02/2015, ES:BX -> EBX (unix386.s)
   791                              <1> 
   792                              <1> DSK_READ:
   793 000042F0 8025[0E780100]7F    <1> 	and	byte [MOTOR_STATUS], 01111111b ; INDICATE A READ OPERATION
   794 000042F7 66B846E6            <1> 	mov	ax, 0E646h		; AX = NEC COMMAND, DMA COMMAND
   795                              <1> 	;call	RD_WR_VF		; COMMON READ/WRITE/VERIFY
   796                              <1> 	;retn
   797                              <1> 	; 06/08/2022
   798 000042FB EB0B                <1> 	jmp	short RD_WR_VF
   799                              <1> 
   800                              <1> ;-------------------------------------------------------------------------------
   801                              <1> ; DISK_WRITE	(AH = 03H)
   802                              <1> ;	DISKETTE WRITE.
   803                              <1> ;
   804                              <1> ; ON ENTRY:	DI	: DRIVE #
   805                              <1> ;		SI-HI	: HEAD #
   806                              <1> ;		SI-LOW	: # OF SECTORS
   807                              <1> ;		ES	: BUFFER SEGMENT
   808                              <1> ;		[BP]	: SECTOR #
   809                              <1> ;		[BP+1]	: TRACK #
   810                              <1> ;		[BP+2]	: BUFFER OFFSET
   811                              <1> ;
   812                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   813                              <1> ;-------------------------------------------------------------------------------
   814                              <1> 
   815                              <1> ; 06/02/2015, ES:BX -> EBX (unix386.s)
   816                              <1> 
   817                              <1> DSK_WRITE:
   818 000042FD 66B84AC5            <1> 	mov	ax, 0C54Ah		; AX = NEC COMMAND, DMA COMMAND
   819 00004301 800D[0E780100]80    <1> 	or	byte [MOTOR_STATUS], 10000000b ; INDICATE WRITE OPERATION
   820                              <1> 	;call	RD_WR_VF		; COMMON READ/WRITE/VERIFY
   821                              <1> 	;retn
   822                              <1> 	; 06/08/2022
   823                              <1> 	;jmp	short RD_WR_VF
   824                              <1> 
   825                              <1> 	; 09/08/2022
   826                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
   827                              <1> ;-------------------------------------------------------------------------------
   828                              <1> ; RD_WR_VF
   829                              <1> ;	COMMON READ, WRITE AND VERIFY: 
   830                              <1> ;	MAIN LOOP FOR STATE RETRIES.
   831                              <1> ;
   832                              <1> ; ON ENTRY:	AH = READ/WRITE/VERIFY NEC PARAMETER
   833                              <1> ;		AL = READ/WRITE/VERIFY DMA PARAMETER
   834                              <1> ;
   835                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   836                              <1> ;-------------------------------------------------------------------------------
   837                              <1> RD_WR_VF:
   838                              <1> 	; 11/08/2022
   839                              <1> 	; 09/08/2022
   840                              <1> 	; 07/08/2022
   841                              <1> 	; 06/08/2022
   842                              <1> 	; 11/04/2021 (32 bit push/pop, AX -> EAX)
   843 00004308 50                  <1> 	push	eax			; SAVE DMA, NEC PARAMETERS
   844 00004309 E803040000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
   845 0000430E E86A040000          <1> 	call	SETUP_STATE		; INITIALIZE START AND END RATE
   846 00004313 58                  <1> 	pop	eax			; RESTORE READ/WRITE/VERIFY
   847                              <1> DO_AGAIN:
   848 00004314 50                  <1> 	push	eax			; SAVE READ/WRITE/VERIFY PARAMETER
   849 00004315 E8F8040000          <1> 	call	MED_CHANGE		; MEDIA CHANGE AND RESET IF CHANGED
   850 0000431A 58                  <1> 	pop	eax			; RESTORE READ/WRITE/VERIFY
   851                              <1> 	;jc	short RWV_END		; MEDIA CHANGE ERROR OR TIME-OUT
   852                              <1> 	; 07/08/2022
   853 0000431B 7305                <1> 	jnc	short RWV
   854 0000431D E9BC000000          <1> 	jmp	RWV_END
   855                              <1> RWV:
   856 00004322 50                  <1> 	push	eax			; SAVE READ/WRITE/VERIFY PARAMETER
   857 00004323 8AB7[1B780100]      <1> 	mov	dh, [DSK_STATE+edi]	; GET RATE STATE OF THIS DRIVE
   858 00004329 80E6C0              <1> 	and	dh, RATE_MSK		; KEEP ONLY RATE
   859 0000432C E83E080000          <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN AL (AL)
   860                              <1> 	;;20/02/2015
   861                              <1> 	;;jc	short RWV_ASSUME	; ERROR IN CMOS
   862 00004331 7447                <1> 	jz	short RWV_ASSUME ; 20/02/2015
   863 00004333 3C01                <1> 	cmp	al, 1			; 40 TRACK DRIVE?
   864 00004335 750D                <1> 	jne	short RWV_1		; NO, BYPASS CMOS VALIDITY CHECK
   865 00004337 F687[1B780100]01    <1> 	test	byte [DSK_STATE+edi], TRK_CAPA ; CHECK FOR 40 TRACK DRIVE
   866 0000433E 7411                <1> 	jz	short RWV_2		; YES, CMOS IS CORRECT
   867                              <1> 	;mov	al, 2			; CHANGE TO 1.2M
   868                              <1> 	; 06/08/2022
   869 00004340 FEC0                <1> 	inc	al ; al = 2
   870 00004342 EB0D                <1> 	jmp	short RWV_2
   871                              <1> RWV_1:
   872                              <1> 	; 09/08/2022
   873                              <1> 	;jb	short RWV_2		; NO DRIVE SPECIFIED, CONTINUE
   874 00004344 F687[1B780100]01    <1> 	test    byte [DSK_STATE+edi], TRK_CAPA ; IS IT REALLY 40 TRACK?
   875 0000434B 7504                <1> 	jnz	short RWV_2		; NO, 80 TRACK
   876 0000434D B001                <1> 	mov	al, 1			; IT IS 40 TRACK, FIX CMOS VALUE
   877 0000434F EB00                <1> 	jmp	short rwv_3
   878                              <1> RWV_2:
   879                              <1> 	; 09/08/2022
   880                              <1> 	;or	al, al			; TEST FOR NO DRIVE
   881                              <1> 	;jz	short RWV_ASSUME	; ASSUME TYPE, USE MAX TRACK
   882                              <1> rwv_3:
   883 00004351 E855030000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL.
   884 00004356 7222                <1> 	jc	short RWV_ASSUME	; TYPE NOT IN TABLE (BAD CMOS)
   885                              <1> 
   886                              <1> ;-----	SEARCH FOR MEDIA/DRIVE PARAMETER TABLE
   887                              <1> 
   888 00004358 57                  <1> 	push	edi			; SAVE DRIVE #
   889                              <1> 	; 09/08/2022
   890                              <1> 	;xor	ebx, ebx		; EBX = INDEX TO DR_TYPE TABLE
   891 00004359 BB[A8640000]        <1> 	mov	ebx, DR_TYPE
   892                              <1> 	;mov	ecx, DR_CNT		; ECX = LOOP COUNT
   893 0000435E B106                <1> 	mov	cl, DR_CNT
   894                              <1> RWV_DR_SEARCH:
   895                              <1> 	;mov	ah, [DR_TYPE+ebx]	; GET DRIVE TYPE
   896 00004360 8A23                <1> 	mov	ah, [ebx]
   897 00004362 80E47F              <1> 	and	ah, BIT7OFF		; MASK OUT MSB
   898 00004365 38E0                <1> 	cmp	al, ah			; DRIVE TYPE MATCH?
   899                              <1> 	; 09/08/2022
   900                              <1> 	;cmp	dl, ah
   901 00004367 7509                <1> 	jne	short RWV_NXT_MD	; NO, CHECK NEXT DRIVE TYPE
   902                              <1> RWV_DR_FND:
   903                              <1> 	;mov	edi, [DR_TYPE+ebx+1] 	; EDI = MEDIA/DRIVE PARAMETER TABLE
   904 00004369 43                  <1> 	inc	ebx
   905 0000436A 8B3B                <1> 	mov	edi, [ebx]
   906 0000436C 4B                  <1> 	dec	ebx
   907                              <1> RWV_MD_SEARH:
   908 0000436D 3A770C              <1>         cmp	dh, [edi+MD.RATE]       ; MATCH?
   909 00004370 741D                <1> 	je	short RWV_MD_FND	; YES, GO GET 1ST SPECIFY BYTE
   910                              <1> RWV_NXT_MD:
   911 00004372 83C305              <1> 	add	ebx, 5			; CHECK NEXT DRIVE TYPE
   912                              <1> 	;loop	RWV_DR_SEARCH
   913 00004375 FEC9                <1> 	dec	cl
   914 00004377 75E7                <1> 	jnz	short RWV_DR_SEARCH 
   915 00004379 5F                  <1> 	pop	edi			; RESTORE DRIVE #
   916                              <1> 
   917                              <1> ;-----	ASSUME PRIMARY DRIVE IS INSTALLED AS SHIPPED
   918                              <1> 
   919                              <1> RWV_ASSUME:
   920 0000437A BB[C6640000]        <1> 	mov	ebx, MD_TBL1		; POINT TO 40 TRACK 250 KBS
   921 0000437F F687[1B780100]01    <1> 	test 	byte [DSK_STATE+edi], TRK_CAPA ; TEST FOR 80 TRACK
   922 00004386 740A                <1> 	jz	short RWV_MD_FND1	; MUST BE 40 TRACK
   923 00004388 BB[E0640000]        <1> 	mov	ebx, MD_TBL3		; POINT TO 80 TRACK 500 KBS
   924 0000438D EB03                <1> 	jmp	short RWV_MD_FND1	; GO SPECIFY PARAMTERS
   925                              <1> 
   926                              <1> ;-----	CS:BX POINTS TO MEDIA/DRIVE PARAMETER TABLE
   927                              <1> 	 			
   928                              <1> RWV_MD_FND:
   929 0000438F 89FB                <1> 	mov	ebx, edi		; BX = MEDIA/DRIVE PARAMETER TABLE
   930 00004391 5F                  <1> 	pop	edi			; RESTORE DRIVE #
   931                              <1> 	
   932                              <1> ;-----	SEND THE SPECIFY COMMAND TO THE CONTROLLER
   933                              <1> 
   934                              <1> RWV_MD_FND1:
   935 00004392 E85A030000          <1> 	call	SEND_SPEC_MD
   936 00004397 E8E3040000          <1> 	call	CHK_LASTRATE		; ZF=1 ATTEMP RATE IS SAME AS LAST RATE
   937 0000439C 7405                <1> 	jz	short RWV_DBL		; YES,SKIP SEND RATE COMMAND
   938 0000439E E8BC040000          <1> 	call	SEND_RATE		; SEND DATA RATE TO NEC
   939                              <1> RWV_DBL:
   940 000043A3 53                  <1> 	push	ebx			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
   941 000043A4 E825070000          <1> 	call	SETUP_DBL		; CHECK FOR DOUBLE STEP
   942 000043A9 5B                  <1> 	pop	ebx			; RESTORE ADDRESS
   943 000043AA 7225                <1> 	jc	short CHK_RET		; ERROR FROM READ ID, POSSIBLE RETRY
   944                              <1> 	;pop	eax			; RESTORE NEC COMMAND
   945                              <1> 	;push	eax			; SAVE NEC COMMAND
   946                              <1> 	; 09/08/2022
   947 000043AC 8B0424              <1> 	mov	eax, [esp]
   948                              <1> 	;push	ebx			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
   949 000043AF E8E0040000          <1> 	call	DMA_SETUP		; SET UP THE DMA
   950                              <1> 	;pop	ebx
   951 000043B4 58                  <1> 	pop	eax			; RESTORE NEC COMMAND
   952 000043B5 7231                <1> 	jc	short RWV_BAC		; CHECK FOR DMA BOUNDARY ERROR
   953 000043B7 50                  <1> 	push	eax			; SAVE NEC COMMAND
   954 000043B8 53                  <1> 	push	ebx			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
   955                              <1> 	; 11/08/2022
   956 000043B9 8B5C2420            <1> 	mov	ebx, [esp+32] ; ECX
   957 000043BD E866050000          <1> 	call	NEC_INIT		; INITIALIZE NEC
   958 000043C2 5B                  <1> 	pop	ebx			; RESTORE ADDRESS
   959 000043C3 720C                <1> 	jc	short CHK_RET		; ERROR - EXIT
   960 000043C5 E88C050000          <1> 	call	RWV_COM			; OP CODE COMMON TO READ/WRITE
   961 000043CA 7205                <1> 	jc	short CHK_RET		; ERROR - EXIT
   962 000043CC E8D2050000          <1> 	call	NEC_TERM		; TERMINATE, GET STATUS, ETC.
   963                              <1> CHK_RET:
   964 000043D1 E871060000          <1> 	call	RETRY			; CHECK FOR, SETUP RETRY
   965 000043D6 58                  <1> 	pop	eax			; RESTORE READ/WRITE PARAMETER
   966 000043D7 7305                <1> 	jnc	short RWV_END		; CY = 0 NO RETRY
   967 000043D9 E936FFFFFF          <1>         jmp	DO_AGAIN                ; CY = 1 MEANS RETRY
   968                              <1> RWV_END:
   969 000043DE E81C060000          <1> 	call	DSTATE			; ESTABLISH STATE IF SUCCESSFUL
   970 000043E3 E8AE060000          <1> 	call	NUM_TRANS		; AL = NUMBER TRANSFERRED
   971                              <1> RWV_BAC:				; BAD DMA ERROR ENTRY
   972                              <1> 	; 06/08/2022
   973                              <1> 	;push	eax			; SAVE NUMBER TRANSFERRED
   974                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
   975                              <1> 	;pop	eax			; RESTORE NUMBER TRANSFERRED
   976                              <1> 	;call	SETUP_END		; VARIOUS CLEANUPS
   977                              <1> 	;retn
   978                              <1> 
   979                              <1> ;-------------------------------------------------------------------------------
   980                              <1> ; SETUP_END
   981                              <1> ;	RESTORES @MOTOR_COUNT TO PARAMETER PROVIDED IN TABLE 
   982                              <1> ;	AND LOADS @DSKETTE_STATUS TO AH, AND SETS CY.
   983                              <1> ;
   984                              <1> ; ON EXIT:
   985                              <1> ;	AH, @DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   986                              <1> ;-------------------------------------------------------------------------------
   987                              <1> SETUP_END:
   988                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
   989                              <1> 	;mov	dl, 2			; GET THE MOTOR WAIT PARAMETER
   990                              <1> 	;push	ax			; SAVE NUMBER TRANSFERRED
   991                              <1> 	; 11/04/2021
   992 000043E8 50                  <1> 	push	eax
   993                              <1> 	; 06/08/2022
   994 000043E9 B002                <1> 	mov	al, 2			; GET THE MOTOR WAIT PARAMETER		
   995 000043EB E888070000          <1> 	call	GET_PARM
   996 000043F0 8825[0F780100]      <1> 	mov	[MOTOR_COUNT], ah	; STORE UPON RETURN
   997                              <1> 	;pop	ax			; RESTORE NUMBER TRANSFERRED
   998                              <1> 	; 11/04/2021
   999 000043F6 58                  <1> 	pop	eax
  1000 000043F7 8A25[10780100]      <1> 	mov	ah, [DSKETTE_STATUS]	; GET STATUS OF OPERATION
  1001 000043FD 08E4                <1> 	or	ah, ah			; CHECK FOR ERROR
  1002 000043FF 7403                <1> 	jz	short NUN_ERR		; NO ERROR
  1003 00004401 30C0                <1> 	xor	al, al			; CLEAR NUMBER RETURNED
  1004                              <1> 	; 06/08/2022
  1005 00004403 F9                  <1> 	stc
  1006                              <1> NUN_ERR: 
  1007                              <1> 	;cmp	ah, 1			; SET THE CARRY FLAG TO INDICATE
  1008                              <1> 	;cmc				; SUCCESS OR FAILURE
  1009 00004404 C3                  <1> 	retn
  1010                              <1> 
  1011                              <1> ;-------------------------------------------------------------------------------
  1012                              <1> ; DISK_VERF	(AH = 04H)
  1013                              <1> ;	DISKETTE VERIFY.
  1014                              <1> ;
  1015                              <1> ; ON ENTRY:	DI	: DRIVE #
  1016                              <1> ;		SI-HI	: HEAD #
  1017                              <1> ;		SI-LOW	: # OF SECTORS
  1018                              <1> ;		ES	: BUFFER SEGMENT
  1019                              <1> ;		[BP]	: SECTOR #
  1020                              <1> ;		[BP+1]	: TRACK #
  1021                              <1> ;		[BP+2]	: BUFFER OFFSET
  1022                              <1> ;
  1023                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1024                              <1> ;-------------------------------------------------------------------------------
  1025                              <1> DSK_VERF:
  1026 00004405 8025[0E780100]7F    <1> 	and	byte [MOTOR_STATUS], 01111111b ; INDICATE A READ OPERATION
  1027 0000440C 66B842E6            <1> 	mov	ax, 0E642h		; AX = NEC COMMAND, DMA COMMAND
  1028                              <1> 	;call	RD_WR_VF		; COMMON READ/WRITE/VERIFY
  1029                              <1> 	;retn
  1030                              <1> 	; 06/08/2022
  1031 00004410 E9F3FEFFFF          <1> 	jmp	RD_WR_VF
  1032                              <1> 
  1033                              <1> ;-------------------------------------------------------------------------------
  1034                              <1> ; DISK_FORMAT	(AH = 05H)
  1035                              <1> ;	DISKETTE FORMAT.
  1036                              <1> ;
  1037                              <1> ; ON ENTRY:	DI	: DRIVE #
  1038                              <1> ;		SI-HI	: HEAD #
  1039                              <1> ;		SI-LOW	: # OF SECTORS
  1040                              <1> ;		ES	: BUFFER SEGMENT
  1041                              <1> ;		[BP]	: SECTOR #
  1042                              <1> ;		[BP+1]	: TRACK #
  1043                              <1> ;		[BP+2]	: BUFFER OFFSET
  1044                              <1> ;		@DISK_POINTER POINTS TO THE PARAMETER TABLE OF THIS DRIVE
  1045                              <1> ;
  1046                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1047                              <1> ;-------------------------------------------------------------------------------
  1048                              <1> DSK_FORMAT:
  1049                              <1> 	; 11/08/2022
  1050                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  1051 00004415 E8F7020000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1052 0000441A E89F030000          <1> 	call	FMT_INIT		; ESTABLISH STATE IF UNESTABLISHED
  1053 0000441F 800D[0E780100]80    <1> 	or	byte [MOTOR_STATUS], 10000000b ; INDICATE WRITE OPERATION
  1054 00004426 E8E7030000          <1> 	call	MED_CHANGE		; CHECK MEDIA CHANGE AND RESET IF SO
  1055 0000442B 7261                <1>         jc      short FM_DON            ; MEDIA CHANGED, SKIP
  1056 0000442D E896020000          <1> 	call	SEND_SPEC		; SEND SPECIFY COMMAND TO NEC
  1057 00004432 E848040000          <1> 	call	CHK_LASTRATE		; ZF=1 ATTEMPT RATE IS SAME AS LAST RATE
  1058 00004437 7405                <1>         jz      short FM_WR             ; YES, SKIP SPECIFY COMMAND
  1059 00004439 E821040000          <1> 	call	SEND_RATE		; SEND DATA RATE TO CONTROLLER
  1060                              <1> FM_WR:
  1061 0000443E E8C8040000          <1> 	call	FMTDMA_SET		; SET UP THE DMA FOR FORMAT
  1062 00004443 7249                <1>         jc      short FM_DON            ; RETURN WITH ERROR
  1063 00004445 B44D                <1> 	mov	ah, 04Dh		; ESTABLISH THE FORMAT COMMAND
  1064                              <1> 	; 11/08/2022
  1065 00004447 8B5C2418            <1> 	mov	ebx, [esp+24] ; ECX
  1066 0000444B E8D8040000          <1> 	call	NEC_INIT		; INITIALIZE THE NEC
  1067 00004450 723C                <1> 	jc	short FM_DON            ; ERROR - EXIT
  1068 00004452 B8[8E440000]        <1>         mov     eax, FM_DON             ; LOAD ERROR ADDRESS
  1069 00004457 50                  <1> 	push	eax			; PUSH NEC_OUT ERROR RETURN
  1070                              <1> 	;mov	dl, 3			; BYTES/SECTOR VALUE TO NEC
  1071                              <1> 	; 06/08/2022
  1072 00004458 B003                <1> 	mov	al, 3
  1073 0000445A E819070000          <1> 	call	GET_PARM
  1074 0000445F E80A080000          <1> 	call	NEC_OUTPUT
  1075                              <1> 	;mov	dl, 4			; SECTORS/TRACK VALUE TO NEC
  1076                              <1> 	; 06/08/2022
  1077 00004464 B004                <1> 	mov	al, 4
  1078 00004466 E80D070000          <1> 	call	GET_PARM
  1079 0000446B E8FE070000          <1> 	call	NEC_OUTPUT
  1080                              <1> 	;mov	dl, 7			; GAP LENGTH VALUE TO NEC
  1081                              <1> 	; 06/08/2022
  1082 00004470 B007                <1> 	mov	al, 7
  1083 00004472 E801070000          <1> 	call	GET_PARM
  1084 00004477 E8F2070000          <1> 	call	NEC_OUTPUT
  1085                              <1> 	;mov	dl, 8			; FILLER BYTE TO NEC
  1086                              <1> 	; 06/08/2022
  1087 0000447C B008                <1> 	mov	al, 8
  1088 0000447E E8F5060000          <1> 	call	GET_PARM
  1089 00004483 E8E6070000          <1> 	call	NEC_OUTPUT
  1090 00004488 58                  <1> 	pop	eax			; THROW AWAY ERROR
  1091 00004489 E815050000          <1> 	call	NEC_TERM		; TERMINATE, RECEIVE STATUS, ETC,
  1092                              <1> FM_DON:
  1093                              <1> 	; 06/08/2022
  1094                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1095                              <1> 	; 06/08/2022
  1096 0000448E E953FEFFFF          <1> 	jmp	SETUP_END_X
  1097                              <1> 	;call	SETUP_END		; VARIOUS CLEANUPS
  1098                              <1> 	;; 06/08/2022
  1099                              <1> 	;mov	ebx, esi		; GET SAVED AL TO BL
  1100                              <1> 	;mov	al, bl			; PUT BACK FOR RETURN
  1101                              <1> 	;retn
  1102                              <1> 
  1103                              <1> ;-------------------------------------------------------------------------------
  1104                              <1> ; FNC_ERR
  1105                              <1> ;	INVALID FUNCTION REQUESTED OR INVALID DRIVE: 
  1106                              <1> ;	SET BAD COMMAND IN STATUS.
  1107                              <1> ;
  1108                              <1> ; ON EXIT: 	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1109                              <1> ;-------------------------------------------------------------------------------
  1110                              <1> FNC_ERR:				; INVALID FUNCTION REQUEST
  1111                              <1> 	;mov	ax, si
  1112                              <1> 	; 06/08/2022
  1113 00004493 89F0                <1> 	mov	eax, esi		; RESTORE AL
  1114 00004495 B401                <1> 	mov	ah, BAD_CMD		; SET BAD COMMAND ERROR
  1115 00004497 8825[10780100]      <1> 	mov	[DSKETTE_STATUS], ah	; STORE IN DATA AREA
  1116 0000449D F9                  <1> 	stc				; SET CARRY INDICATING ERROR
  1117 0000449E C3                  <1> 	retn
  1118                              <1> 
  1119                              <1> ; 06/08/2022 - TRDOS 386 Kernel v2.0.5
  1120                              <1> ; 30/08/2020
  1121                              <1> ; 29/08/2020
  1122                              <1> ; 01/06/2016
  1123                              <1> ; 28/05/2016
  1124                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v.2.0)
  1125                              <1> ;-------------------------------------------------------------------------------
  1126                              <1> ; DISK_PARMS	(AH = 08H)	
  1127                              <1> ;	READ DRIVE PARAMETERS.
  1128                              <1> ;
  1129                              <1> ; ON ENTRY:	DI : DRIVE #
  1130                              <1> ;		; 27/05/2016
  1131                              <1> ;		EBX = Buffer Address for floppy disk parameters table (16 bytes)
  1132                              <1> ;
  1133                              <1> ; ON EXIT:	CL/[BP]   = BITS 7 & 6 HI 2 BITS OF MAX CYLINDER
  1134                              <1> ;		            BITS 0-5 MAX SECTORS/TRACK
  1135                              <1> ;		CH/[BP+1] = LOW 8 BITS OF MAX CYLINDER
  1136                              <1> ;		BL/[BP+2] = BITS 7-4 = 0
  1137                              <1> ;		            BITS 3-0 = VALID CMOS DRIVE TYPE
  1138                              <1> ;		BH/[BP+3] = 0
  1139                              <1> ;		DL/[BP+4] = # DRIVES INSTALLED (VALUE CHECKED)
  1140                              <1> ;		DH/[BP+5] = MAX HEAD #
  1141                              <1> ;	     ** 27/05/2016 - TRDOS 386 (TRDOS v2.0) **	
  1142                              <1> ;            ** EBX = Buffer address for floppy disk parameters table **
  1143                              <1> ;		;DI/[BP+6] = OFFSET TO DISK_BASE
  1144                              <1> ;		;ES        = SEGMENT OF DISK_BASE
  1145                              <1> ;
  1146                              <1> ;		AX        = 0
  1147                              <1> ;
  1148                              <1> ;		NOTE : THE ABOVE INFORMATION IS STORED IN THE USERS STACK AT
  1149                              <1> ;		       THE LOCATIONS WHERE THE MAIN ROUTINE WILL POP THEM
  1150                              <1> ;		       INTO THE APPROPRIATE REGISTERS BEFORE RETURNING TO THE
  1151                              <1> ;		       CALLER.
  1152                              <1> ;-------------------------------------------------------------------------------
  1153                              <1> DSK_PARMS:
  1154                              <1> 	; 09/08/2022
  1155                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  1156                              <1> 	;
  1157                              <1> 	; Registers on stack:
  1158                              <1> 	;    ebx = esp+28
  1159                              <1> 	;    ecx = esp+24
  1160                              <1> 	;    edx = esp+20
  1161                              <1> 	;    esi = esp+16
  1162                              <1> 	;    edi = esp+12
  1163                              <1> 	;    return address from DSKETTE_IO_1 = esp+8
  1164                              <1> 	;    ebp = esp+4
  1165                              <1> 	;    return address from DSK_PARMS = esp
  1166                              <1> 	;
  1167                              <1> 	; INPUT:
  1168                              <1> 	;   ebp = buffer address
  1169                              <1> 	;   edi = drive number (0 or 1)
  1170                              <1> 	
  1171                              <1> 	; OUTPUT:
  1172                              <1> 	;   ebx = [esp+28] ((BL = cmos type, BH = 0))
  1173                              <1> 	;   ecx = [esp+24] ((CL = sectors per track, CH = tracks - 1))
  1174                              <1> 	;   edx = [esp+20] ((DL = floppy drive count, DH = heads - 1))
  1175                              <1> 	;   user's buffer = FDPT table
  1176                              <1> 			 
  1177 0000449F E86D020000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH,
  1178                              <1>      	
  1179                              <1> 	;;mov	word [bp+2], 0		; DRIVE TYPE = 0
  1180                              <1>      	;;mov	ax, [EQUIP_FLAG]	; LOAD EQUIPMENT FLAG FOR # DISKETTES
  1181                              <1>      	;;and	al, 11000001b		; KEEP DISKETTE DRIVE BITS
  1182                              <1>      	;;mov	dl, 2			; DISKETTE DRIVES = 2
  1183                              <1>      	;;cmp	al, 01000001b		; 2 DRIVES INSTALLED ?
  1184                              <1>      	;;jz	short STO_DL		; IF YES JUMP
  1185                              <1>      	;;dec	dl			; DISKETTE DRIVES = 1
  1186                              <1>      	;;cmp	al, 00000001b		; 1 DRIVE INSTALLED ?
  1187                              <1>      	;;jnz	short NON_DRV		; IF NO JUMP
  1188                              <1> 	
  1189 000044A4 29D2                <1> 	sub	edx, edx
  1190 000044A6 66A1[2C650000]      <1> 	mov     ax, [fd0_type]
  1191 000044AC 6621C0              <1> 	and     ax, ax
  1192 000044AF 747C                <1>         jz      short NON_DRV
  1193 000044B1 FEC2                <1> 	inc     dl
  1194 000044B3 20E4                <1> 	and     ah, ah
  1195 000044B5 7402                <1> 	jz      short STO_DL
  1196 000044B7 FEC2                <1> 	inc     dl
  1197                              <1> STO_DL:
  1198                              <1> 	; 30/08/2020
  1199                              <1> 	;cmp	dx, di
  1200                              <1> 	; 06/08/2022
  1201 000044B9 39FA                <1> 	cmp	edx, edi
  1202 000044BB 7670                <1> 	jna	short NON_DRV
  1203                              <1> 	;
  1204                              <1> 	;;mov	[bp+4], dl		; STORE NUMBER OF DRIVES
  1205                              <1> 	;mov	[ebp+8], edx ; 20/02/2015	 	
  1206                              <1> 
  1207                              <1> 	; 06/08/2022
  1208 000044BD FEC6                <1> 	inc	dh ; number of heads - 1 
  1209                              <1> 	; dh = 1
  1210                              <1> 	; dl = number of floppy/diskette drives (DL)
  1211 000044BF 89542414            <1> 	mov	[esp+20], edx
  1212                              <1> 
  1213                              <1> 	; 11/04/2021
  1214                              <1> 	;cmp	di, 1			; CHECK FOR VALID DRIVE
  1215                              <1> 	;;ja	short NON_DRV1		; DRIVE INVALID
  1216                              <1> 	;ja	NON_DRV1 ; 29/08/2020
  1217                              <1> 	;	
  1218                              <1> 	;;mov	byte [bp+5], 1		; MAXIMUM HEAD NUMBER =	1
  1219                              <1> 	; 06/08/2022
  1220                              <1> 	;mov	byte [ebp+9], 1 ; 20/02/2015	
  1221                              <1> 	
  1222 000044C3 E8A7060000          <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN AL
  1223                              <1> 	;;20/02/2015
  1224                              <1> 	;;jc	short CHK_EST		; IF CMOS BAD CHECKSUM ESTABLISHED
  1225                              <1> 	;;or	al, al			; TEST FOR NO DRIVE TYPE
  1226 000044C8 740F                <1> 	jz	short CHK_EST		; JUMP IF SO
  1227 000044CA E8DC010000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  1228 000044CF 7208                <1> 	jc	short CHK_EST		; TYPE NOT IN TABLE (POSSIBLE BAD CMOS)
  1229                              <1> 	;mov	[bp+2], al		; STORE VALID CMOS DRIVE TYPE
  1230                              <1>         ;mov	[ebp+4], al ; 06/02/2015
  1231 000044D1 8A4B04              <1> 	mov	cl, [ebx+MD.SEC_TRK]	; GET SECTOR/TRACK
  1232 000044D4 8A6B0B              <1>         mov	ch, [ebx+MD.MAX_TRK]	; GET MAX. TRACK NUMBER
  1233 000044D7 EB36                <1> 	jmp	short STO_CX		; CMOS GOOD, USE CMOS
  1234                              <1> CHK_EST:
  1235 000044D9 8AA7[1B780100]      <1> 	mov	ah, [DSK_STATE+edi]	; LOAD STATE FOR THIS DRIVE
  1236 000044DF F6C410              <1> 	test	ah, MED_DET		; CHECK FOR ESTABLISHED STATE
  1237 000044E2 744D                <1> 	jz	short NON_DRV1		; CMOS BAD/INVALID OR UNESTABLISHED
  1238                              <1> USE_EST:
  1239 000044E4 80E4C0              <1> 	and	ah, RATE_MSK		; ISOLATE STATE
  1240 000044E7 80FC80              <1> 	cmp	ah, RATE_250		; RATE 250 ?
  1241 000044EA 755C                <1> 	jne	short USE_EST2		; NO, GO CHECK OTHER RATE
  1242                              <1> 
  1243                              <1> ;-----	DATA RATE IS 250 KBS, TRY 360 KB TABLE FIRST
  1244                              <1> 
  1245 000044EC B001                <1> 	mov	al, 1			; DRIVE TYPE 1 (360KB)
  1246 000044EE E8B8010000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  1247 000044F3 8A4B04              <1>         mov	cl, [ebx+MD.SEC_TRK]	; GET SECTOR/TRACK
  1248 000044F6 8A6B0B              <1>         mov	ch, [ebx+MD.MAX_TRK]	; GET MAX. TRACK NUMBER
  1249 000044F9 F687[1B780100]01    <1> 	test	byte [DSK_STATE+edi], TRK_CAPA ; 80 TRACK ?
  1250 00004500 740D                <1> 	jz	short STO_CX		; MUST BE 360KB DRIVE 
  1251                              <1> 
  1252                              <1> ;-----	IT IS 1.44 MB DRIVE
  1253                              <1> 
  1254                              <1> PARM144:
  1255 00004502 B004                <1> 	mov	al, 4			; DRIVE TYPE 4 (1.44MB)
  1256 00004504 E8A2010000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  1257 00004509 8A4B04              <1> 	mov	cl, [ebx+MD.SEC_TRK]	; GET SECTOR/TRACK
  1258 0000450C 8A6B0B              <1> 	mov	ch, [ebx+MD.MAX_TRK]	; GET MAX. TRACK NUMBER
  1259                              <1> STO_CX:
  1260                              <1> 	;mov	[ebp], ecx		; SAVE POINTER IN STACK FOR RETURN
  1261                              <1> 	; 06/08/2022
  1262 0000450F 894C2418            <1> 	mov	[esp+24], ecx ; spt (cl), tracks - 1 (ch)
  1263                              <1> ES_DI:
  1264                              <1> 	;mov	[bp+6], bx		; ADDRESS OF MEDIA/DRIVE PARM TABLE 
  1265                              <1> 	;mov	[ebp+12], ebx ; 06/02/2015
  1266                              <1> 	;mov	ax, cs			; SEGMENT MEDIA/DRIVE PARAMETER TABLE
  1267                              <1> 	;mov	es, ax			; ES IS SEGMENT OF TABLE
  1268                              <1> 	;
  1269                              <1> 	; 28/05/2016
  1270                              <1> 	; 27/05/2016
  1271                              <1> 	; return floppy disk parameters table to user
  1272                              <1> 	; in user's buffer, which is pointed by EBX
  1273                              <1> 	
  1274                              <1> 	; 09/08/2022
  1275                              <1> 	;movzx	eax, al
  1276 00004513 29C9                <1> 	sub	ecx, ecx
  1277 00004515 88C1                <1> 	mov	cl, al
  1278                              <1> 	;;mov	[ebp+4], eax  ; ebx	; drive type (for floppy drives)
  1279                              <1> 	; 06/08/2022
  1280                              <1> 	;mov	[esp+28], eax ; drive type	
  1281                              <1> 	; 09/08/2022
  1282 00004517 894C241C            <1> 	mov	[esp+28], ecx ; drive type
  1283                              <1> 
  1284                              <1> 	; 06/08/2022
  1285                              <1> 	;push	edi
  1286                              <1> 	
  1287                              <1> 	;mov	edi, [ebp+4]  		; ebx (input), user's buffer address
  1288                              <1> 	; 06/08/2022
  1289                              <1> 	;mov	edi, ebp ; [esp+28] ; user's buffer address
  1290                              <1> 	;
  1291                              <1> 	;; 29/08/2020
  1292                              <1> 	;or	edi, edi
  1293                              <1> 	;jz	short no_copy_fdpt
  1294                              <1> 	; 06/08/2022
  1295 0000451B 09ED                <1> 	or	ebp, ebp ; [esp+28] = ebx ; user's buffer address if > 0
  1296 0000451D 740B                <1> 	jz	short DP_OUT
  1297                              <1> 	; 06/08/2022
  1298                              <1> 	;push	edi
  1299 0000451F 89EF                <1> 	mov	edi, ebp
  1300                              <1> 	;
  1301                              <1> 	; 06/08/2022
  1302                              <1> 	; 01/06/2016 (Int 33h, disk type return for floppy disks, in BL)
  1303                              <1> 	;mov	[user_buffer], eax	; 01/06/2016 (overwrite ebx return value)
  1304                              <1> 	
  1305                              <1> 	;(Int 33h, Function 08h will replace user's buffer addr with disk type!)
  1306                              <1> 	;
  1307 00004521 89DE                <1> 	mov	esi, ebx 		; floppy disk parameter table (16 bytes)
  1308                              <1> 	;mov	ecx, 16 ; 16 bytes
  1309                              <1>         ; 09/08/2022
  1310                              <1> 	; ecx < 256
  1311                              <1> 	; 06/08/2022
  1312                              <1> 	;sub	ecx, ecx
  1313 00004523 B110                <1> 	mov	cl, 16
  1314 00004525 E82FC80000          <1> 	call    transfer_to_user_buffer ; trdosk6.s (16/05/2016)
  1315                              <1> no_copy_fdpt:
  1316                              <1> 	; 06/08/2022
  1317                              <1> 	;pop	edi	
  1318                              <1> DP_OUT:
  1319                              <1> 	; 06/08/2022
  1320                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1321                              <1> 	;xor	ax, ax			; CLEAR
  1322                              <1> 	; 06/08/2022
  1323 0000452A 31C0                <1> 	xor	eax, eax
  1324                              <1> 	;clc
  1325 0000452C C3                  <1> 	retn
  1326                              <1> 
  1327                              <1> ;-----	NO DRIVE PRESENT HANDLER
  1328                              <1> 
  1329                              <1> NON_DRV:
  1330                              <1> 	;;mov	byte [bp+4], 0		; CLEAR NUMBER OF DRIVES
  1331                              <1> 	;mov	[ebp+8], edx ; 0 ; 20/02/2015
  1332                              <1> 	; 06/08/2022
  1333 0000452D 89542414            <1> 	mov	[esp+20], edx ; 0 ; number of floppy drives and heads are 0
  1334                              <1> NON_DRV1:
  1335 00004531 6681FF8000          <1> 	cmp	di, 80h			; CHECK FOR FIXED MEDIA TYPE REQUEST
  1336 00004536 7206                <1> 	jb	short NON_DRV2		; CONTINUE IF NOT REQUEST FALL THROUGH
  1337                              <1> 
  1338                              <1> ;-----	FIXED DISK REQUEST FALL THROUGH ERROR
  1339                              <1> 	
  1340                              <1> 	; 06/08/2022
  1341                              <1> 	;call	XLAT_OLD		; ELSE TRANSLATE TO COMPATIBLE MODE
  1342                              <1> 	;mov	ax, si			; RESTORE AL
  1343                              <1> 	; 06/08/2022
  1344 00004538 89F0                <1> 	mov	eax, esi
  1345 0000453A B401                <1> 	mov	ah, BAD_CMD		; SET BAD COMMAND ERROR
  1346 0000453C F9                  <1> 	stc
  1347 0000453D C3                  <1> 	retn
  1348                              <1> 
  1349                              <1> NON_DRV2:
  1350                              <1> 	;xor	ax, ax			; CLEAR PARMS IF NO DRIVES OR CMOS BAD
  1351 0000453E 31C0                <1> 	xor	eax, eax	
  1352                              <1> 	;mov	[ebp], ax		; TRACKS, SECTORS/TRACK = 0
  1353                              <1> 	; 06/08/2022
  1354 00004540 89442418            <1> 	mov	[esp+24], eax ; spt and max. track number is 0
  1355                              <1> 
  1356                              <1> 	;;mov	[bp+5], ah		; HEAD = 0
  1357                              <1> 	; 06/08/2022
  1358                              <1> 	;mov	[ebp+9], ah ; 06/02/2015
  1359                              <1> 	; 06/08/2022
  1360                              <1> 	;mov	[esp+21], ah ; 0	
  1361                              <1> 
  1362                              <1> 	;;mov	[bp+6], ax		; OFFSET TO DISK_BASE = 0
  1363                              <1> 	; 06/08/2022
  1364                              <1> 	;mov	[ebp+12], eax
  1365                              <1> 	
  1366                              <1> 	;;mov	es, ax			; ES IS SEGMENT OF TABLE
  1367                              <1> 	;jmp	short DP_OUT
  1368                              <1> 
  1369                              <1> 	; 06/08/2022
  1370                              <1> 	; 30/08/2020
  1371                              <1> 	;call	XLAT_OLD
  1372                              <1> 	;;mov	ah, NOT_RDY ; drive not ready
  1373 00004544 B407                <1> 	mov	ah, INIT_FAIL ; DRIVE PARAMETER ACTIVITY FAILED 
  1374 00004546 F9                  <1> 	stc	; cf -> 1, ah = 'drive not ready' error code
  1375 00004547 C3                  <1> 	retn		
  1376                              <1> 
  1377                              <1> ;-----	DATA RATE IS EITHER 300 KBS OR 500 KBS, TRY 1.2 MB TABLE FIRST
  1378                              <1> 
  1379                              <1> USE_EST2:
  1380 00004548 B002                <1> 	mov	al, 2			; DRIVE TYPE 2 (1.2MB)
  1381 0000454A E85C010000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  1382 0000454F 8A4B04              <1>         mov     cl, [ebx+MD.SEC_TRK]    ; GET SECTOR/TRACK
  1383 00004552 8A6B0B              <1>         mov     ch, [ebx+MD.MAX_TRK]    ; GET MAX. TRACK NUMBER
  1384 00004555 80FC40              <1> 	cmp	ah, RATE_300		; RATE 300 ?
  1385 00004558 74B5                <1> 	jz	short STO_CX		; MUST BE 1.2MB DRIVE
  1386 0000455A EBA6                <1> 	jmp	short PARM144		; ELSE, IT IS 1.44MB DRIVE 
  1387                              <1> 
  1388                              <1> ; 30/08/2020
  1389                              <1> 
  1390                              <1> ;-------------------------------------------------------------------------------
  1391                              <1> ; DISK_TYPE (AH = 15H)	
  1392                              <1> ;	THIS ROUTINE RETURNS THE TYPE OF MEDIA INSTALLED.
  1393                              <1> ;
  1394                              <1> ;  ON ENTRY:	DI = DRIVE #
  1395                              <1> ;
  1396                              <1> ;  ON EXIT:	AH = DRIVE TYPE, CY=0
  1397                              <1> ;-------------------------------------------------------------------------------
  1398                              <1> DSK_TYPE:
  1399                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  1400 0000455C E8B0010000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1401 00004561 8A87[1B780100]      <1> 	mov	al, [DSK_STATE+edi]	; GET PRESENT STATE INFORMATION
  1402 00004567 08C0                <1> 	or	al, al			; CHECK FOR NO DRIVE
  1403 00004569 740D                <1> 	jz	short NO_DRV
  1404 0000456B B401                <1> 	mov	ah, NOCHGLN		; NO CHANGE LINE FOR 40 TRACK DRIVE
  1405 0000456D A801                <1> 	test	al, TRK_CAPA		; IS THIS DRIVE AN 80 TRACK DRIVE?
  1406 0000456F 7402                <1> 	jz	short DT_BACK		; IF NO JUMP
  1407 00004571 B402                <1> 	mov	ah, CHGLN		; CHANGE LINE FOR 80 TRACK DRIVE
  1408                              <1> DT_BACK:
  1409                              <1> 	; 06/08/2022
  1410                              <1> 	;;push	ax			; SAVE RETURN VALUE
  1411                              <1> 	; 11/04/2021
  1412                              <1> 	;push	eax
  1413                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1414                              <1> 	;; 11/04/2021
  1415                              <1> 	;pop	eax
  1416                              <1> 	;; pop	ax
  1417                              <1> 	;clc				; NO ERROR
  1418                              <1> 	;mov	bx, si			; GET SAVED AL TO BL
  1419                              <1> 	; 06/08/2022
  1420 00004573 89F3                <1> 	mov	ebx, esi
  1421 00004575 88D8                <1> 	mov	al, bl			; PUT BACK FOR RETURN
  1422 00004577 C3                  <1> 	retn
  1423                              <1> NO_DRV:	
  1424                              <1> 	;xor	ah, ah			; NO DRIVE PRESENT OR UNKNOWN
  1425                              <1> 	;jmp	short DT_BACK
  1426                              <1> 	
  1427                              <1> 	; 06/08/2022
  1428                              <1> 	; 30/08/2020
  1429                              <1> 	;call	XLAT_OLD
  1430 00004578 29C0                <1> 	sub	eax, eax
  1431 0000457A F9                  <1> 	stc	; cf = 1 -> drive not ready, ah = 0 (disk type = 0)
  1432 0000457B C3                  <1> 	retn
  1433                              <1> 
  1434                              <1> ;-------------------------------------------------------------------------------
  1435                              <1> ; DISK_CHANGE	(AH = 16H)
  1436                              <1> ;	THIS ROUTINE RETURNS THE STATE OF THE DISK CHANGE LINE.
  1437                              <1> ;
  1438                              <1> ; ON ENTRY:	DI = DRIVE #
  1439                              <1> ;
  1440                              <1> ; ON EXIT:	AH = @DSKETTE_STATUS
  1441                              <1> ;		     00 - DISK CHANGE LINE INACTIVE, CY = 0
  1442                              <1> ;		     06 - DISK CHANGE LINE ACTIVE, CY = 1
  1443                              <1> ;-------------------------------------------------------------------------------
  1444                              <1> DSK_CHANGE:
  1445                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  1446 0000457C E890010000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1447 00004581 8A87[1B780100]      <1> 	mov	al, [DSK_STATE+edi]	; GET MEDIA STATE INFORMATION
  1448 00004587 08C0                <1> 	or	al, al			; DRIVE PRESENT ?
  1449 00004589 7417                <1> 	jz	short DC_NON		; JUMP IF NO DRIVE
  1450 0000458B A801                <1> 	test	al, TRK_CAPA		; 80 TRACK DRIVE ?
  1451 0000458D 7407                <1> 	jz	short SETIT		; IF SO , CHECK CHANGE LINE
  1452                              <1> DC0:
  1453 0000458F E86B080000          <1>         call    READ_DSKCHNG            ; GO CHECK STATE OF DISK CHANGE LINE
  1454 00004594 7407                <1> 	jz	short FINIS		; CHANGE LINE NOT ACTIVE
  1455                              <1> SETIT:	
  1456 00004596 C605[10780100]06    <1> 	mov	byte [DSKETTE_STATUS], MEDIA_CHANGE ; INDICATE MEDIA REMOVED
  1457                              <1> 
  1458                              <1> FINIS:	; 06/08/2022
  1459                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1460                              <1> 	; 06/08/2022
  1461 0000459D E944FDFFFF          <1> 	jmp	SETUP_END_X
  1462                              <1> 	;call	SETUP_END		; VARIOUS CLEANUPS
  1463                              <1> 	;; 06/08/2022
  1464                              <1> 	;mov	ebx, esi		; GET SAVED AL TO BL
  1465                              <1> 	;mov	al, bl			; PUT BACK FOR RETURN
  1466                              <1> 	;retn
  1467                              <1> DC_NON:
  1468 000045A2 800D[10780100]80    <1> 	or	byte [DSKETTE_STATUS], TIME_OUT ; SET TIMEOUT, NO DRIVE
  1469 000045A9 EBF2                <1> 	jmp	short FINIS
  1470                              <1> 
  1471                              <1> ;-------------------------------------------------------------------------------
  1472                              <1> ; FORMAT_SET	(AH = 17H)
  1473                              <1> ;	THIS ROUTINE IS USED TO ESTABLISH THE TYPE OF MEDIA TO BE USED
  1474                              <1> ;	FOR THE FOLLOWING FORMAT OPERATION.
  1475                              <1> ;
  1476                              <1> ; ON ENTRY:	SI LOW = DASD TYPE FOR FORMAT
  1477                              <1> ;		DI     = DRIVE #
  1478                              <1> ;
  1479                              <1> ; ON EXIT:	@DSKETTE_STATUS REFLECTS STATUS
  1480                              <1> ;		AH = @DSKETTE_STATUS
  1481                              <1> ;		CY = 1 IF ERROR
  1482                              <1> ;-------------------------------------------------------------------------------
  1483                              <1> FORMAT_SET:
  1484 000045AB E861010000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1485                              <1> 	;push	si			; SAVE DASD TYPE
  1486                              <1> 	; 11/04/2021
  1487 000045B0 56                  <1> 	push	esi
  1488                              <1> 	;mov	ax, si			; AH = ? , AL = DASD TYPE
  1489                              <1> 	;xor	ah, ah			; AH = 0 , AL = DASD TYPE
  1490                              <1> 	;mov	si, ax			; SI = DASD TYPE
  1491                              <1> 	; 11/04/2021
  1492 000045B1 89F0                <1> 	mov	eax, esi
  1493 000045B3 0FB6F0              <1> 	movzx	esi, al	
  1494 000045B6 80A7[1B780100]0F    <1> 	and	byte [DSK_STATE+edi], ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR STATE
  1495                              <1> 	;dec	si			; CHECK FOR 320/360K MEDIA & DRIVE
  1496                              <1> 	; 11/04/2021
  1497 000045BD 4E                  <1> 	dec	esi
  1498 000045BE 7509                <1> 	jnz	short NOT_320		; BYPASS IF NOT
  1499 000045C0 808F[1B780100]90    <1> 	or	byte [DSK_STATE+edi], MED_DET+RATE_250 ; SET TO 320/360
  1500 000045C7 EB45                <1> 	jmp	short S0
  1501                              <1> 
  1502                              <1> NOT_320:
  1503 000045C9 E844020000          <1> 	call	MED_CHANGE		; CHECK FOR TIME_OUT
  1504 000045CE 803D[10780100]80    <1> 	cmp	byte [DSKETTE_STATUS], TIME_OUT
  1505 000045D5 7437                <1> 	jz	short S0		; IF TIME OUT TELL CALLER
  1506                              <1> S3:
  1507                              <1> 	;dec	si			; CHECK FOR 320/360K IN 1.2M DRIVE
  1508                              <1> 	; 11/04/2021
  1509 000045D7 4E                  <1> 	dec	esi
  1510 000045D8 7509                <1> 	jnz	short NOT_320_12	; BYPASS IF NOT
  1511 000045DA 808F[1B780100]70    <1> 	OR	byte [DSK_STATE+edi], MED_DET+DBL_STEP+RATE_300 ; SET STATE
  1512 000045E1 EB2B                <1> 	jmp	short S0
  1513                              <1> 
  1514                              <1> NOT_320_12:
  1515                              <1> 	;dec	si			; CHECK FOR 1.2M MEDIA IN 1.2M DRIVE
  1516                              <1> 	; 11/04/2021
  1517 000045E3 4E                  <1> 	dec	esi
  1518 000045E4 7509                <1> 	jnz	short NOT_12		; BYPASS IF NOT
  1519 000045E6 808F[1B780100]10    <1> 	or	byte [DSK_STATE+edi], MED_DET+RATE_500 ; SET STATE VARIABLE
  1520 000045ED EB1F                <1> 	jmp	short S0		; RETURN TO CALLER
  1521                              <1> 
  1522                              <1> NOT_12:	
  1523                              <1> 	;dec	si			; CHECK FOR SET DASD TYPE 04
  1524                              <1> 	; 11/04/2021
  1525 000045EF 4E                  <1> 	dec	esi
  1526 000045F0 7525                <1> 	jnz	short FS_ERR		; BAD COMMAND EXIT IF NOT VALID TYPE
  1527                              <1> 
  1528 000045F2 F687[1B780100]04    <1> 	test	byte [DSK_STATE+edi], DRV_DET ; DRIVE DETERMINED ?
  1529 000045F9 740B                <1> 	jz	short ASSUME		; IF STILL NOT DETERMINED ASSUME
  1530 000045FB B050                <1> 	mov	al, MED_DET+RATE_300
  1531 000045FD F687[1B780100]02    <1>         test    byte [DSK_STATE+edi], FMT_CAPA ; MULTIPLE FORMAT CAPABILITY ?
  1532 00004604 7502                <1> 	jnz	short OR_IT_IN		; IF 1.2 M THEN DATA RATE 300
  1533                              <1> 
  1534                              <1> ASSUME:
  1535 00004606 B090                <1> 	mov	al, MED_DET+RATE_250	; SET UP
  1536                              <1> 
  1537                              <1> OR_IT_IN:
  1538 00004608 0887[1B780100]      <1> 	or	[DSK_STATE+edi], al	; OR IN THE CORRECT STATE
  1539                              <1> S0:
  1540                              <1> 	; 06/08/2022
  1541                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1542 0000460E E8D5FDFFFF          <1> 	call	SETUP_END		; VARIOUS CLEANUPS
  1543                              <1> 	;pop	BX			; GET SAVED AL TO BL
  1544                              <1> 	; 11/04/2021
  1545 00004613 5B                  <1> 	pop	ebx
  1546 00004614 88D8                <1> 	mov	al, bl			; PUT BACK FOR RETURN
  1547 00004616 C3                  <1> 	retn
  1548                              <1> 
  1549                              <1> FS_ERR:
  1550 00004617 C605[10780100]01    <1> 	mov	byte [DSKETTE_STATUS], BAD_CMD ; UNKNOWN STATE,BAD COMMAND
  1551 0000461E EBEE                <1> 	jmp	short S0
  1552                              <1> 
  1553                              <1> ;-------------------------------------------------------------------------------
  1554                              <1> ; SET_MEDIA	(AH = 18H)
  1555                              <1> ;	THIS ROUTINE SETS THE TYPE OF MEDIA AND DATA RATE 
  1556                              <1> ;	TO BE USED FOR THE FOLLOWING FORMAT OPERATION.
  1557                              <1> ;
  1558                              <1> ; ON ENTRY:
  1559                              <1> ;	[BP]	= SECTOR PER TRACK
  1560                              <1> ;	[BP+1]	= TRACK #
  1561                              <1> ;	DI	= DRIVE #
  1562                              <1> ;
  1563                              <1> ; ON EXIT:
  1564                              <1> ;	@DSKETTE_STATUS REFLECTS STATUS
  1565                              <1> ;	IF NO ERROR:
  1566                              <1> ;		AH = 0
  1567                              <1> ;		CY = 0
  1568                              <1> ;		ES = SEGMENT OF MEDIA/DRIVE PARAMETER TABLE
  1569                              <1> ;		DI/[BP+6] = OFFSET OF MEDIA/DRIVE PARAMETER TABLE
  1570                              <1> ;	IF ERROR:	
  1571                              <1> ;		AH = @DSKETTE_STATUS
  1572                              <1> ;		CY = 1
  1573                              <1> ;-------------------------------------------------------------------------------
  1574                              <1> SET_MEDIA:
  1575                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  1576 00004620 E8EC000000          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1577 00004625 F687[1B780100]01    <1>         test    byte [DSK_STATE+edi], TRK_CAPA ; CHECK FOR CHANGE LINE AVAILABLE
  1578 0000462C 7415                <1> 	jz	short SM_CMOS		; JUMP IF 40 TRACK DRIVE
  1579 0000462E E8DF010000          <1> 	call	MED_CHANGE		; RESET CHANGE LINE
  1580 00004633 803D[10780100]80    <1> 	cmp	byte [DSKETTE_STATUS], TIME_OUT ; IF TIME OUT TELL CALLER
  1581 0000463A 746A                <1> 	je	short SM_RTN
  1582 0000463C C605[10780100]00    <1> 	mov	byte [DSKETTE_STATUS], 0 ; CLEAR STATUS
  1583                              <1> SM_CMOS:
  1584 00004643 E827050000          <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  1585                              <1> 	;;20/02/2015
  1586                              <1> 	;;jc	short MD_NOT_FND	; ERROR IN CMOS
  1587                              <1> 	;;or	al, al			; TEST FOR NO DRIVE
  1588 00004648 745C                <1> 	jz	short SM_RTN		; RETURN IF SO
  1589 0000464A E85C000000          <1> 	call	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  1590 0000464F 7233                <1> 	jc	short MD_NOT_FND	; TYPE NOT IN TABLE (BAD CMOS)
  1591 00004651 57                  <1> 	push	edi			; SAVE REG.
  1592 00004652 31DB                <1> 	xor	ebx, ebx		; BX = INDEX TO DR. TYPE TABLE
  1593 00004654 B906000000          <1> 	mov	ecx, DR_CNT		; CX = LOOP COUNT
  1594                              <1> DR_SEARCH:
  1595 00004659 8AA3[A8640000]      <1> 	mov	ah, [DR_TYPE+ebx]	; GET DRIVE TYPE
  1596 0000465F 80E47F              <1> 	and	ah, BIT7OFF		; MASK OUT MSB
  1597 00004662 38E0                <1> 	cmp	al, ah			; DRIVE TYPE MATCH ?
  1598 00004664 7518                <1> 	jne	short NXT_MD		; NO, CHECK NEXT DRIVE TYPE
  1599                              <1> DR_FND:
  1600 00004666 8BBB[A9640000]      <1> 	mov	edi, [DR_TYPE+ebx+1] 	; DI = MEDIA/DRIVE PARAM TABLE
  1601                              <1> MD_SEARCH:
  1602 0000466C 8A6704              <1>         mov	ah, [edi+MD.SEC_TRK]    ; GET SECTOR/TRACK
  1603                              <1> 	;cmp	[ebp], ah		; MATCH?
  1604                              <1> 	; 06/08/2022
  1605 0000466F 38642418            <1> 	cmp	[esp+24], ah  ; CL ; spt	
  1606 00004673 7509                <1> 	jne	short NXT_MD		; NO, CHECK NEXT MEDIA
  1607 00004675 8A670B              <1>         mov     ah, [edi+MD.MAX_TRK]    ; GET MAX. TRACK #
  1608                              <1> 	;cmp 	[ebp+1], ah		; MATCH?
  1609                              <1> 	; 06/08/2022
  1610 00004678 38642419            <1> 	cmp	[esp+25], ah  ; CH ; heads - 1
  1611 0000467C 740F                <1> 	je	short MD_FND		; YES, GO GET RATE
  1612                              <1> NXT_MD:
  1613                              <1> 	;add	bx, 3			; CHECK NEXT DRIVE TYPE
  1614 0000467E 83C305              <1>         add	ebx, 5 ; 18/02/2015
  1615 00004681 E2D6                <1> 	loop	DR_SEARCH
  1616 00004683 5F                  <1> 	pop	edi			; RESTORE REG.
  1617                              <1> MD_NOT_FND:
  1618 00004684 C605[10780100]0C    <1> 	mov	byte [DSKETTE_STATUS], MED_NOT_FND ; ERROR, MEDIA TYPE NOT FOUND
  1619 0000468B EB19                <1> 	jmp	short SM_RTN		; RETURN
  1620                              <1> MD_FND:
  1621 0000468D 8A470C              <1>         mov	al, [edi+MD.RATE]       ; GET RATE
  1622 00004690 3C40                <1> 	cmp	al, RATE_300		; DOUBLE STEP REQUIRED FOR RATE 300
  1623 00004692 7502                <1> 	jne	short MD_SET
  1624 00004694 0C20                <1> 	or	al, DBL_STEP
  1625                              <1> MD_SET:
  1626                              <1> 	;;mov	[bp+6], di		; SAVE TABLE POINTER IN STACK
  1627                              <1> 	; 06/08/2022
  1628                              <1> 	;mov	[ebp+12], edi ; 18/02/2015
  1629                              <1> 	
  1630 00004696 0C10                <1> 	or	al, MED_DET		; SET MEDIA ESTABLISHED
  1631 00004698 5F                  <1> 	pop	edi
  1632 00004699 80A7[1B780100]0F    <1> 	and	byte [DSK_STATE+edi], ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR STATE
  1633 000046A0 0887[1B780100]      <1> 	or	[DSK_STATE+edi], al
  1634                              <1> 	;mov	ax, cs			; SEGMENT OF MEDIA/DRIVE PARAMETER TABLE
  1635                              <1> 	;mov	es, ax			; ES IS SEGMENT OF TABLE
  1636                              <1> SM_RTN:
  1637                              <1> 	; 06/08/2022
  1638                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1639                              <1> 	;call	SETUP_END		; VARIOUS CLEANUPS
  1640                              <1> 	;retn
  1641                              <1> 	; 06/08/2022
  1642 000046A6 E93DFDFFFF          <1> 	jmp	SETUP_END
  1643                              <1> 
  1644                              <1> ;----------------------------------------------------------------
  1645                              <1> ; DR_TYPE_CHECK							:
  1646                              <1> ;	CHECK IF THE GIVEN DRIVE TYPE IN REGISTER (AL)		:
  1647                              <1> ;	IS SUPPORTED IN BIOS DRIVE TYPE TABLE			:
  1648                              <1> ; ON ENTRY:							:
  1649                              <1> ;	AL = DRIVE TYPE						:
  1650                              <1> ; ON EXIT:							:
  1651                              <1> ;	CY = 0 	DRIVE TYPE SUPPORTED				:
  1652                              <1> ;	     EBX = OFFSET TO MEDIA/DRIVE PARAMETER TABLE	:
  1653                              <1> ;	CY = 1	DRIVE TYPE NOT SUPPORTED 			:
  1654                              <1> ; REGISTERS ALTERED: EBX, AH ; 11/07/2022 			:
  1655                              <1> ;----------------------------------------------------------------
  1656                              <1> DR_TYPE_CHECK:
  1657                              <1> 	; 09/08/2022 - TRDOS 386 Kernel v2.0.5 
  1658                              <1> 	; 12/07/2022
  1659                              <1> 	; 11/07/2022
  1660                              <1> 	; 08/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
  1661                              <1> 	; 24/12/2021
  1662                              <1> 	;push	eax ; 11/07/2022
  1663                              <1> 	;push	ecx ; 08/07/2022
  1664                              <1> 	;xor	ebx,ebx			; EBX = INDEX TO DR_TYPE TABLE
  1665 000046AB BB[A8640000]        <1> 	mov	ebx, DR_TYPE
  1666                              <1> 	;;mov	ecx, DR_CNT		; ECX = LOOP COUNT
  1667                              <1> 	;mov	cl, DR_CNT
  1668 000046B0 B406                <1> 	mov	ah, DR_CNT ; 11/07/2022
  1669                              <1> TYPE_CHK:	
  1670                              <1> 	;;mov	ah, [DR_TYPE+ebx]	; GET DRIVE TYPE
  1671                              <1> 	;mov	ah, [ebx]
  1672                              <1> 	;cmp	al, ah			; DRIVE TYPE MATCH?
  1673 000046B2 3A03                <1> 	cmp	al, [ebx] ; 11/07/2022
  1674 000046B4 740E                <1> 	je	short DR_TYPE_VALID	; YES, RETURN WITH CARRY RESET
  1675                              <1> 	; 16/02/2015 (32 bit address modification)
  1676 000046B6 83C305              <1> 	add	ebx, 5			; CHECK NEXT DRIVE TYPE
  1677                              <1> 	;loop	TYPE_CHK
  1678                              <1> 	;dec	cl
  1679 000046B9 FECC                <1> 	dec	ah ; 11/07/2022
  1680 000046BB 75F5                <1> 	jnz	short TYPE_CHK
  1681                              <1> 	;
  1682 000046BD BB[07650000]        <1> 	mov	ebx, MD_TBL6		; 1.44MB fd parameter table
  1683                              <1> 					; Default for GET_PARM (11/12/2014)
  1684                              <1> 	;
  1685 000046C2 F9                  <1> 	stc				; DRIVE TYPE NOT FOUND IN TABLE
  1686                              <1> 	;jmp	short TYPE_RTN
  1687                              <1> 	; 12/07/2022
  1688 000046C3 C3                  <1> 	retn
  1689                              <1> DR_TYPE_VALID:
  1690                              <1> 	;mov	ebx, [DR_TYPE+ebx+1] 	; EBX = MEDIA TABLE
  1691 000046C4 43                  <1> 	inc	ebx
  1692 000046C5 8B1B                <1> 	mov	ebx, [ebx]
  1693                              <1> TYPE_RTN:
  1694                              <1> 	;pop	ecx ; 08/07/2022
  1695                              <1> 	; 24/12/2021
  1696                              <1> 	;pop	eax ; 11/07/2022
  1697 000046C7 C3                  <1> 	retn	
  1698                              <1> 		
  1699                              <1> ;----------------------------------------------------------------
  1700                              <1> ; SEND_SPEC							:
  1701                              <1> ;	SEND THE SPECIFY COMMAND TO CONTROLLER USING DATA FROM	:
  1702                              <1> ;	THE DRIVE PARAMETER TABLE POINTED BY @DISK_POINTER	:
  1703                              <1> ; ON ENTRY:	@DISK_POINTER = DRIVE PARAMETER TABLE		:
  1704                              <1> ; ON EXIT:	NONE						:	
  1705                              <1> ; REGISTERS ALTERED: CX, DX					:
  1706                              <1> ;----------------------------------------------------------------		
  1707                              <1> SEND_SPEC:
  1708                              <1> 	; 06/08/2022
  1709 000046C8 50                  <1> 	push	eax			; SAVE AX
  1710 000046C9 B8[EF460000]        <1> 	mov	eax, SPECBAC		; LOAD ERROR ADDRESS
  1711 000046CE 50                  <1> 	push	eax			; PUSH NEC_OUT ERROR RETURN
  1712 000046CF B403                <1> 	mov	ah, 03h			; SPECIFY COMMAND
  1713 000046D1 E898050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
  1714                              <1> 	;sub	dl, dl			; FIRST SPECIFY BYTE
  1715                              <1> 	; 06/08/2022
  1716 000046D6 28C0                <1> 	sub	al, al ; 0 
  1717 000046D8 E89B040000          <1> 	call	GET_PARM		; GET PARAMETER TO AH
  1718 000046DD E88C050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
  1719                              <1> 	;mov	dl, 1			; SECOND SPECIFY BYTE
  1720                              <1> 	; 06/08/2022
  1721 000046E2 B001                <1> 	mov	al, 1
  1722 000046E4 E88F040000          <1> 	call	GET_PARM		; GET PARAMETER TO AH
  1723 000046E9 E880050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
  1724 000046EE 58                  <1> 	pop	eax			; POP ERROR RETURN
  1725                              <1> SPECBAC:
  1726 000046EF 58                  <1> 	pop	eax			; RESTORE ORIGINAL AX VALUE
  1727 000046F0 C3                  <1> 	retn
  1728                              <1> 
  1729                              <1> ;----------------------------------------------------------------
  1730                              <1> ; SEND_SPEC_MD							:
  1731                              <1> ;	SEND THE SPECIFY COMMAND TO CONTROLLER USING DATA FROM	:
  1732                              <1> ;	THE MEDIA/DRIVE PARAMETER TABLE POINTED BY (CS:BX)	:
  1733                              <1> ; ON ENTRY:	CS:BX = MEDIA/DRIVE PARAMETER TABLE		:
  1734                              <1> ; ON EXIT:	NONE						:	
  1735                              <1> ; REGISTERS ALTERED: AX						:
  1736                              <1> ;----------------------------------------------------------------		
  1737                              <1> SEND_SPEC_MD:
  1738 000046F1 50                  <1> 	push	eax			; SAVE RATE DATA
  1739 000046F2 B8[0F470000]        <1> 	mov	eax, SPEC_ESBAC		; LOAD ERROR ADDRESS
  1740 000046F7 50                  <1> 	push	eax			; PUSH NEC_OUT ERROR RETURN
  1741 000046F8 B403                <1> 	mov	ah, 03h			; SPECIFY COMMAND
  1742 000046FA E86F050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
  1743 000046FF 8A23                <1>         mov     ah, [ebx+MD.SPEC1]      ; GET 1ST SPECIFY BYTE
  1744 00004701 E868050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
  1745 00004706 8A6301              <1>         mov     ah, [ebx+MD.SPEC2]      ; GET SECOND SPECIFY BYTE
  1746 00004709 E860050000          <1> 	call	NEC_OUTPUT		; OUTPUT THE COMMAND
  1747 0000470E 58                  <1> 	pop	eax			; POP ERROR RETURN
  1748                              <1> SPEC_ESBAC:
  1749 0000470F 58                  <1> 	pop	eax			; RESTORE ORIGINAL AX VALUE
  1750 00004710 C3                  <1> 	retn
  1751                              <1> 
  1752                              <1> ;-------------------------------------------------------------------------------
  1753                              <1> ; XLAT_NEW  
  1754                              <1> ;	TRANSLATES DISKETTE STATE LOCATIONS FROM COMPATIBLE
  1755                              <1> ;	MODE TO NEW ARCHITECTURE.
  1756                              <1> ;
  1757                              <1> ; ON ENTRY:	DI = DRIVE #
  1758                              <1> ;-------------------------------------------------------------------------------
  1759                              <1> XLAT_NEW:
  1760                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
  1761                              <1> 	; 11/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
  1762 00004711 83FF01              <1> 	cmp	edi, 1			; VALID DRIVE
  1763 00004714 7709                <1> 	ja	short XN_OUT		; IF INVALID BACK
  1764 00004716 80BF[1B780100]00    <1> 	cmp	byte [DSK_STATE+edi], 0	; NO DRIVE ?
  1765 0000471D 7401                <1> 	jz	short DO_DET		; IF NO DRIVE ATTEMPT DETERMINE
  1766                              <1> 	
  1767                              <1> 	;;mov	cx, di			; CX = DRIVE NUMBER
  1768                              <1> 	;mov	ecx, edi
  1769                              <1> 	;or	cl, cl
  1770                              <1> 	;jz	short XN_0
  1771                              <1> 	;shl	cl, 2			; CL = SHIFT COUNT, A=0, B=4
  1772                              <1> 	;mov	al, [HF_CNTRL]		; DRIVE INFORMATION
  1773                              <1> 	;ror	al, cl			; TO LOW NIBBLE
  1774                              <1> ;XN_0:	
  1775                              <1> 	;and	al, DRV_DET+FMT_CAPA+TRK_CAPA ; KEEP DRIVE BITS
  1776                              <1>         ;and	byte [DSK_STATE+edi], ~(DRV_DET+FMT_CAPA+TRK_CAPA)
  1777                              <1> 	;or	[DSK_STATE+edi], al	; UPDATE DRIVE STATE
  1778                              <1> XN_OUT:
  1779 0000471F C3                  <1> 	retn
  1780                              <1> 
  1781                              <1> DO_DET:
  1782                              <1> 	;call	DRIVE_DET		; TRY TO DETERMINE
  1783                              <1> 	;retn
  1784                              <1> 	;jmp	DRIVE_DET
  1785                              <1> 
  1786                              <1> ;-------------------------------------------------------------------------------
  1787                              <1> ; DRIVE_DET
  1788                              <1> ;	DETERMINES WHETHER DRIVE IS 80 OR 40 TRACKS AND
  1789                              <1> ;	UPDATES STATE INFORMATION ACCORDINGLY.
  1790                              <1> ; ON ENTRY:	DI = DRIVE #
  1791                              <1> ;-------------------------------------------------------------------------------
  1792                              <1> DRIVE_DET:
  1793                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
  1794                              <1> 	; 08/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
  1795 00004720 E88E040000          <1> 	call	MOTOR_ON		; TURN ON MOTOR IF NOT ALREADY ON
  1796 00004725 E8FA050000          <1> 	call	RECAL			; RECALIBRATE DRIVE
  1797 0000472A 724E                <1> 	jc	short DD_BAC		; ASSUME NO DRIVE PRESENT
  1798 0000472C B530                <1> 	mov	ch, TRK_SLAP		; SEEK TO TRACK 48
  1799 0000472E E872050000          <1> 	call	SEEK
  1800 00004733 7245                <1> 	jc	short DD_BAC		; ERROR NO DRIVE
  1801 00004735 B50B                <1> 	mov	ch, QUIET_SEEK+1	; SEEK TO TRACK 10
  1802                              <1> SK_GIN:
  1803 00004737 FECD                <1> 	dec	ch			; DECREMENT TO NEXT TRACK
  1804                              <1> 	;push	cx			; SAVE TRACK
  1805                              <1> 	; 11/04/2021
  1806 00004739 51                  <1> 	push	ecx
  1807 0000473A E866050000          <1> 	call	SEEK
  1808 0000473F 723A                <1> 	jc	short POP_BAC		; POP AND RETURN
  1809 00004741 B8[7B470000]        <1> 	mov	eax, POP_BAC		; LOAD NEC OUTPUT ERROR ADDRESS
  1810 00004746 50                  <1> 	push	eax
  1811 00004747 B404                <1> 	mov	ah, SENSE_DRV_ST	; SENSE DRIVE STATUS COMMAND BYTE
  1812 00004749 E820050000          <1> 	call	NEC_OUTPUT		; OUTPUT TO NEC
  1813                              <1> 	;mov	ax, di			; AL = DRIVE
  1814                              <1> 	; 06/08/2022
  1815 0000474E 89F8                <1> 	mov	eax, edi
  1816 00004750 88C4                <1> 	mov	ah, al			; AH = DRIVE
  1817 00004752 E817050000          <1> 	call	NEC_OUTPUT		; OUTPUT TO NEC
  1818 00004757 E849060000          <1> 	call	RESULTS			; GO GET STATUS
  1819 0000475C 58                  <1> 	pop	eax			; THROW AWAY ERROR ADDRESS
  1820                              <1> 	;pop	cx			; RESTORE TRACK
  1821                              <1> 	; 11/04/2021
  1822 0000475D 59                  <1> 	pop	ecx
  1823 0000475E F605[11780100]10    <1> 	test	byte [NEC_STATUS], HOME	; TRACK 0 ?
  1824 00004765 74D0                <1> 	jz	short SK_GIN		; GO TILL TRACK 0
  1825 00004767 08ED                <1> 	or	ch, ch			; IS HOME AT TRACK 0
  1826 00004769 7408                <1> 	jz	short IS_80		; MUST BE 80 TRACK DRIVE
  1827                              <1> 
  1828                              <1> ;	DRIVE IS A 360; SET DRIVE TO DETERMINED;
  1829                              <1> ;	SET MEDIA TO DETERMINED AT RATE 250.
  1830                              <1> 
  1831 0000476B 808F[1B780100]94    <1> 	or	byte [DSK_STATE+edi], DRV_DET+MED_DET+RATE_250
  1832 00004772 C3                  <1> 	retn				; ALL INFORMATION SET
  1833                              <1> IS_80:
  1834 00004773 808F[1B780100]01    <1> 	or	byte [DSK_STATE+edi], TRK_CAPA ; SETUP 80 TRACK CAPABILITY
  1835                              <1> DD_BAC:
  1836 0000477A C3                  <1> 	retn
  1837                              <1> POP_BAC:
  1838                              <1> 	;pop	cx			; THROW AWAY
  1839                              <1> 	; 11/04/2021
  1840 0000477B 59                  <1> 	pop	ecx
  1841 0000477C C3                  <1> 	retn
  1842                              <1> 
  1843                              <1> 
  1844                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
  1845                              <1> 
  1846                              <1> %if 0
  1847                              <1> 
  1848                              <1> ;-------------------------------------------------------------------------------
  1849                              <1> ; XLAT_OLD 
  1850                              <1> ;	TRANSLATES DISKETTE STATE LOCATIONS FROM NEW
  1851                              <1> ;	ARCHITECTURE TO COMPATIBLE MODE.
  1852                              <1> ;
  1853                              <1> ; ON ENTRY:	DI = DRIVE
  1854                              <1> ;-------------------------------------------------------------------------------
  1855                              <1> XLAT_OLD:
  1856                              <1> 	cmp	edi, 1			; VALID DRIVE ?
  1857                              <1> 	ja	short XO_OUT            ; IF INVALID BACK
  1858                              <1>         cmp	byte [DSK_STATE+edi], 0	; NO DRIVE ?
  1859                              <1> 	jz	short XO_OUT		; IF NO DRIVE TRANSLATE DONE
  1860                              <1> 
  1861                              <1> ;-----	TEST FOR SAVED DRIVE INFORMATION ALREADY SET
  1862                              <1> 
  1863                              <1> 	;mov	cx, di			; CX = DRIVE NUMBER
  1864                              <1> 	; 06/08/2022
  1865                              <1> 	mov	ecx, edi
  1866                              <1> 	shl	cl, 2			; CL = SHIFT COUNT, A=0, B=4
  1867                              <1> 	mov	ah, FMT_CAPA		; LOAD MULTIPLE DATA RATE BIT MASK
  1868                              <1> 	ror	ah, cl			; ROTATE BY MASK
  1869                              <1> 	test	[HF_CNTRL], ah		; MULTIPLE-DATA RATE DETERMINED ?
  1870                              <1> 	jnz	short SAVE_SET		; IF SO, NO NEED TO RE-SAVE
  1871                              <1> 
  1872                              <1> ;-----	ERASE DRIVE BITS IN @HF_CNTRL FOR THIS DRIVE
  1873                              <1> 
  1874                              <1> 	mov	ah, DRV_DET+FMT_CAPA+TRK_CAPA ; MASK TO KEEP
  1875                              <1> 	ror	ah, cl			; FIX MASK TO KEEP
  1876                              <1> 	not	ah			; TRANSLATE MASK
  1877                              <1> 	and	[HF_CNTRL], ah		; KEEP BITS FROM OTHER DRIVE INTACT
  1878                              <1> 
  1879                              <1> ;-----	ACCESS CURRENT DRIVE BITS AND STORE IN @HF_CNTRL
  1880                              <1> 
  1881                              <1> 	mov	al, [DSK_STATE+edi]	; ACCESS STATE
  1882                              <1> 	and	al, DRV_DET+FMT_CAPA+TRK_CAPA ; KEEP DRIVE BITS
  1883                              <1> 	ror	al, cl			; FIX FOR THIS DRIVE
  1884                              <1> 	or	[HF_CNTRL], al		; UPDATE SAVED DRIVE STATE
  1885                              <1> 
  1886                              <1> ;-----	TRANSLATE TO COMPATIBILITY MODE
  1887                              <1> 
  1888                              <1> SAVE_SET:
  1889                              <1> 	mov	ah, [DSK_STATE+edi]	; ACCESS STATE
  1890                              <1> 	mov	bh, ah			; TO BH FOR LATER
  1891                              <1> 	and	ah, RATE_MSK		; KEEP ONLY RATE
  1892                              <1> 	cmp	ah, RATE_500		; RATE 500 ?
  1893                              <1> 	jz	short CHK_144		; YES 1.2/1.2 OR 1.44/1.44
  1894                              <1> 	mov	al, M3D1U		; AL = 360 IN 1.2 UNESTABLISHED
  1895                              <1> 	cmp	ah, RATE_300		; RATE 300 ?
  1896                              <1> 	jnz	short CHK_250		; NO, 360/360, 720/720 OR 720/1.44
  1897                              <1> 	test	bh, DBL_STEP		; CHECK FOR DOUBLE STEP
  1898                              <1> 	jnz	short TST_DET		; MUST BE 360 IN 1.2
  1899                              <1> UNKNO:
  1900                              <1> 	mov	al, MED_UNK		; NONE OF THE ABOVE
  1901                              <1> 	jmp	short AL_SET		; PROCESS COMPLETE
  1902                              <1> CHK_144:
  1903                              <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  1904                              <1> 	;;20/02/2015
  1905                              <1> 	;;jc	short UNKNO		; ERROR, SET 'NONE OF ABOVE'
  1906                              <1> 	jz	short UNKNO ;; 20/02/2015
  1907                              <1> 	cmp	al, 2			; 1.2MB DRIVE ?
  1908                              <1> 	jne	short UNKNO		; NO, GO SET 'NONE OF ABOVE'
  1909                              <1> 	mov	al, M1D1U		; AL = 1.2 IN 1.2 UNESTABLISHED
  1910                              <1> 	jmp	short TST_DET
  1911                              <1> CHK_250:
  1912                              <1> 	mov	al, M3D3U		; AL = 360 IN 360 UNESTABLISHED
  1913                              <1> 	cmp	ah, RATE_250		; RATE 250 ?
  1914                              <1> 	jnz	short UNKNO		; IF SO FALL IHRU
  1915                              <1> 	test	bh, TRK_CAPA		; 80 TRACK CAPABILITY ?
  1916                              <1> 	jnz	short UNKNO		; IF SO JUMP, FALL THRU TEST DET
  1917                              <1> TST_DET:
  1918                              <1> 	test	bh, MED_DET		; DETERMINED ?
  1919                              <1> 	jz	short AL_SET		; IF NOT THEN SET
  1920                              <1> 	add	al, 3			; MAKE DETERMINED/ESTABLISHED
  1921                              <1> AL_SET:
  1922                              <1> 	and	byte [DSK_STATE+edi], ~(DRV_DET+FMT_CAPA+TRK_CAPA) ; CLEAR DRIVE
  1923                              <1> 	or	[DSK_STATE+edi], al	; REPLACE WITH COMPATIBLE MODE
  1924                              <1> XO_OUT:
  1925                              <1> 	retn
  1926                              <1> 
  1927                              <1> %endif
  1928                              <1> 
  1929                              <1> ;-------------------------------------------------------------------------------
  1930                              <1> ; SETUP_STATE:	INITIALIZES START AND END RATES.
  1931                              <1> ;-------------------------------------------------------------------------------
  1932                              <1> SETUP_STATE:
  1933 0000477D F687[1B780100]10    <1> 	test	byte [DSK_STATE+edi], MED_DET ; MEDIA DETERMINED ?
  1934 00004784 7537                <1> 	jnz	short J1C		; NO STATES IF DETERMINED
  1935 00004786 66B84000            <1>         mov     ax, (RATE_500*256)+RATE_300 ; AH = START RATE, AL = END RATE
  1936 0000478A F687[1B780100]04    <1> 	test	byte [DSK_STATE+edi], DRV_DET ; DRIVE ?
  1937 00004791 740D                <1> 	jz	short AX_SET		; DO NOT KNOW DRIVE
  1938 00004793 F687[1B780100]02    <1> 	test	byte [DSK_STATE+edi], FMT_CAPA ; MULTI-RATE?
  1939 0000479A 7504                <1> 	jnz	short AX_SET		; JUMP IF YES
  1940 0000479C 66B88080            <1>         mov     ax, RATE_250*257	; START A END RATE 250 FOR 360 DRIVE
  1941                              <1> AX_SET:	
  1942 000047A0 80A7[1B780100]1F    <1> 	and	byte [DSK_STATE+edi], ~(RATE_MSK+DBL_STEP) ; TURN OFF THE RATE
  1943 000047A7 08A7[1B780100]      <1> 	or	[DSK_STATE+edi], ah	; RATE FIRST TO TRY
  1944 000047AD 8025[18780100]F3    <1> 	and	byte [LASTRATE], ~STRT_MSK ; ERASE LAST TO TRY RATE BITS
  1945 000047B4 C0C804              <1> 	ror	al, 4			; TO OPERATION LAST RATE LOCATION
  1946 000047B7 0805[18780100]      <1> 	or	[LASTRATE], al		; LAST RATE
  1947                              <1> J1C:	
  1948 000047BD C3                  <1> 	retn
  1949                              <1> 
  1950                              <1> ;-------------------------------------------------------------------------------
  1951                              <1> ;  FMT_INIT: ESTABLISH STATE IF UNESTABLISHED AT FORMAT TIME.
  1952                              <1> ;-------------------------------------------------------------------------------
  1953                              <1> FMT_INIT:
  1954 000047BE F687[1B780100]10    <1> 	test	byte [DSK_STATE+edi], MED_DET ; IS MEDIA ESTABLISHED
  1955 000047C5 7546                <1> 	jnz	short F1_OUT		; IF SO RETURN
  1956 000047C7 E8A3030000          <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN AL
  1957                              <1> 	;; 20/02/2015
  1958                              <1> 	;;jc	short CL_DRV		; ERROR IN CMOS ASSUME NO DRIVE
  1959 000047CC 7440                <1> 	jz	short CL_DRV ;; 20/02/2015
  1960 000047CE FEC8                <1> 	dec	al			; MAKE ZERO ORIGIN
  1961                              <1> 	;;JS	short CL_DRV		; NO DRIVE IF AL 0
  1962 000047D0 8AA7[1B780100]      <1> 	mov	ah, [DSK_STATE+edi]	; AH = CURRENT STATE
  1963 000047D6 80E40F              <1> 	and	ah, ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR
  1964 000047D9 08C0                <1> 	or	al, al			; CHECK FOR 360
  1965 000047DB 7505                <1> 	jnz	short N_360		; IF 360 WILL BE 0
  1966 000047DD 80CC90              <1> 	or	ah, MED_DET+RATE_250	; ESTABLISH MEDIA
  1967 000047E0 EB25                <1> 	jmp	short SKP_STATE		; SKIP OTHER STATE PROCESSING
  1968                              <1> N_360:	
  1969 000047E2 FEC8                <1> 	dec	al			; 1.2 M DRIVE
  1970 000047E4 7505                <1> 	jnz	short N_12		; JUMP IF NOT
  1971                              <1> F1_RATE:
  1972 000047E6 80CC10              <1> 	or	ah, MED_DET+RATE_500	; SET FORMAT RATE
  1973 000047E9 EB1C                <1> 	jmp	short SKP_STATE		; SKIP OTHER STATE PROCESSING
  1974                              <1> N_12:	
  1975 000047EB FEC8                <1> 	dec	al			; CHECK FOR TYPE 3
  1976 000047ED 750F                <1> 	jnz	short N_720		; JUMP IF NOT
  1977 000047EF F6C404              <1> 	test	ah, DRV_DET		; IS DRIVE DETERMINED
  1978 000047F2 7410                <1> 	jz	short ISNT_12		; TREAT AS NON 1.2 DRIVE
  1979 000047F4 F6C402              <1> 	test	ah, FMT_CAPA		; IS 1.2M
  1980 000047F7 740B                <1> 	jz	short ISNT_12		; JUMP IF NOT
  1981 000047F9 80CC50              <1> 	or	ah, MED_DET+RATE_300	; RATE 300
  1982 000047FC EB09                <1> 	jmp	short SKP_STATE		; CONTINUE
  1983                              <1> N_720:
  1984 000047FE FEC8                <1> 	dec	al			; CHECK FOR TYPE 4
  1985 00004800 750C                <1> 	jnz	short CL_DRV		; NO DRIVE, CMOS BAD
  1986 00004802 EBE2                <1> 	jmp	SHORT F1_RATE
  1987                              <1> ISNT_12: 
  1988 00004804 80CC90              <1> 	or	ah, MED_DET+RATE_250	; MUST BE RATE 250
  1989                              <1> SKP_STATE:
  1990 00004807 88A7[1B780100]      <1> 	mov	[DSK_STATE+edi], ah	; STORE AWAY
  1991                              <1> F1_OUT:
  1992 0000480D C3                  <1> 	retn
  1993                              <1> CL_DRV:	
  1994 0000480E 30E4                <1> 	xor	ah, ah			; CLEAR STATE
  1995 00004810 EBF5                <1> 	jmp	short SKP_STATE		; SAVE IT
  1996                              <1> 
  1997                              <1> ;-------------------------------------------------------------------------------
  1998                              <1> ; MED_CHANGE	
  1999                              <1> ;	CHECKS FOR MEDIA CHANGE, RESETS MEDIA CHANGE, 
  2000                              <1> ;	CHECKS MEDIA CHANGE AGAIN.
  2001                              <1> ;
  2002                              <1> ; ON EXIT:	CY = 1 MEANS MEDIA CHANGE OR TIMEOUT
  2003                              <1> ;		@DSKETTE_STATUS = ERROR CODE
  2004                              <1> ;-------------------------------------------------------------------------------
  2005                              <1> MED_CHANGE:
  2006                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2007 00004812 E8E8050000          <1> 	call	READ_DSKCHNG		; READ DISK CHANCE LINE STATE
  2008 00004817 7445                <1> 	jz	short MC_OUT		; BYPASS HANDLING DISK CHANGE LINE
  2009 00004819 80A7[1B780100]EF    <1> 	and	byte [DSK_STATE+edi], ~MED_DET ; CLEAR STATE FOR THIS DRIVE
  2010                              <1> 
  2011                              <1> ;	THIS SEQUENCE ENSURES WHENEVER A DISKETTE IS CHANGED THAT
  2012                              <1> ;	ON THE NEXT OPERATION THE REQUIRED MOTOR START UP TIME WILL
  2013                              <1> ;	BE WAITED. (DRIVE MOTOR MAY GO OFF UPON DOOR OPENING).
  2014                              <1> 
  2015                              <1> 	;mov	cx, di			; CL = DRIVE 0
  2016                              <1> 	; 06/08/2022
  2017 00004820 89F9                <1> 	mov	ecx, edi
  2018 00004822 B001                <1> 	mov	al, 1			; MOTOR ON BIT MASK
  2019 00004824 D2E0                <1> 	shl	al, cl			; TO APPROPRIATE POSITION
  2020 00004826 F6D0                <1> 	not	al			; KEEP ALL BUT MOTOR ON
  2021 00004828 FA                  <1> 	cli				; NO INTERRUPTS
  2022 00004829 2005[0E780100]      <1> 	and	[MOTOR_STATUS], al	; TURN MOTOR OFF INDICATOR
  2023 0000482F FB                  <1> 	sti				; INTERRUPTS ENABLED
  2024 00004830 E87E030000          <1> 	call	MOTOR_ON		; TURN MOTOR ON
  2025                              <1> 
  2026                              <1> ;-----	THIS SEQUENCE OF SEEKS IS USED TO RESET DISKETTE CHANGE SIGNAL
  2027                              <1> 
  2028 00004835 E83BFAFFFF          <1> 	call	DSK_RESET		; RESET NEC
  2029 0000483A B501                <1> 	mov	ch, 1			; MOVE TO CYLINDER 1
  2030 0000483C E864040000          <1> 	call	SEEK			; ISSUE SEEK
  2031 00004841 30ED                <1> 	xor	ch, ch			; MOVE TO CYLINDER 0
  2032 00004843 E85D040000          <1> 	call	SEEK			; ISSUE SEEK
  2033 00004848 C605[10780100]06    <1> 	mov	byte [DSKETTE_STATUS], MEDIA_CHANGE ; STORE IN STATUS
  2034                              <1> OK1:
  2035 0000484F E8AB050000          <1> 	call	READ_DSKCHNG		; CHECK MEDIA CHANGED AGAIN
  2036 00004854 7407                <1> 	jz	short OK2		; IF ACTIVE, NO DISKETTE, TIMEOUT
  2037                              <1> OK4:
  2038 00004856 C605[10780100]80    <1> 	mov	byte [DSKETTE_STATUS], TIME_OUT ; TIMEOUT IF DRIVE EMPTY
  2039                              <1> OK2:		
  2040 0000485D F9                  <1> 	stc				; MEDIA CHANGED, SET CY
  2041                              <1> MC_OUT:	; 06/08/2022 (cf = 0)
  2042 0000485E C3                  <1> 	retn
  2043                              <1> ;MC_OUT:
  2044                              <1> 	;clc				; NO MEDIA CHANGED, CLEAR CY
  2045                              <1> 	;retn
  2046                              <1> 
  2047                              <1> ;-------------------------------------------------------------------------------
  2048                              <1> ; SEND_RATE
  2049                              <1> ;	SENDS DATA RATE COMMAND TO NEC
  2050                              <1> ; ON ENTRY:	DI = DRIVE #
  2051                              <1> ; ON EXIT:	NONE
  2052                              <1> ; REGISTERS ALTERED: DX
  2053                              <1> ;-------------------------------------------------------------------------------
  2054                              <1> SEND_RATE:
  2055                              <1> 	;push	ax			; SAVE REG.
  2056                              <1> 	; 11/04/2021
  2057 0000485F 50                  <1> 	push	eax
  2058 00004860 8025[18780100]3F    <1> 	and	byte [LASTRATE], ~SEND_MSK ; ELSE CLEAR LAST RATE ATTEMPTED
  2059 00004867 8A87[1B780100]      <1> 	mov	al, [DSK_STATE+edi]	; GET RATE STATE OF THIS DRIVE
  2060 0000486D 24C0                <1> 	and	al, SEND_MSK		; KEEP ONLY RATE BITS
  2061 0000486F 0805[18780100]      <1> 	or	[LASTRATE], al		; SAVE NEW RATE FOR NEXT CHECK
  2062 00004875 C0C002              <1> 	rol	al, 2			; MOVE TO BIT OUTPUT POSITIONS
  2063 00004878 66BAF703            <1> 	mov	dx, 03F7h		; OUTPUT NEW DATA RATE
  2064 0000487C EE                  <1> 	out	dx, al
  2065                              <1> 	;pop	ax			; RESTORE REG.
  2066                              <1> 	; 11/04/2021
  2067 0000487D 58                  <1> 	pop	eax
  2068 0000487E C3                  <1> 	retn
  2069                              <1> 
  2070                              <1> ;-------------------------------------------------------------------------------
  2071                              <1> ; CHK_LASTRATE
  2072                              <1> ;	CHECK PREVIOUS DATE RATE SNT TO THE CONTROLLER.
  2073                              <1> ; ON ENTRY:
  2074                              <1> ;	DI = DRIVE #
  2075                              <1> ; ON EXIT:
  2076                              <1> ;	ZF =  1 DATA RATE IS THE SAME AS THE LAST RATE SENT TO NEC
  2077                              <1> ;	ZF =  0 DATA RATE IS DIFFERENT FROM LAST RATE
  2078                              <1> ; REGISTERS ALTERED: DX
  2079                              <1> ;-------------------------------------------------------------------------------
  2080                              <1> CHK_LASTRATE:
  2081                              <1> 	; 13/07/2022 - TRDOS 386 v2.0.5
  2082                              <1> 	;push	ax			; SAVE REG.
  2083                              <1> 	; 11/04/2021
  2084 0000487F 50                  <1> 	push	eax
  2085                              <1> 	; 13/07/2022 (BugFix)
  2086 00004880 8A25[18780100]      <1> 	mov	ah, [LASTRATE] 		; GET LAST DATA RATE SELECTED
  2087 00004886 8A87[1B780100]      <1> 	mov	al, [DSK_STATE+edi]	; GET RATE STATE OF THIS DRIVE
  2088 0000488C 6625C0C0            <1>         and	ax, SEND_MSK*257        ; KEEP ONLY RATE BITS OF BOTH
  2089 00004890 38E0                <1> 	cmp	al, ah			; COMPARE TO PREVIOUSLY TRIED
  2090                              <1> 					; ZF = 1 RATE IS THE SAME
  2091                              <1> 	;pop	ax			; RESTORE REG.
  2092                              <1> 	; 11/04/2021
  2093 00004892 58                  <1> 	pop	eax
  2094 00004893 C3                  <1> 	retn
  2095                              <1> 
  2096                              <1> ;-------------------------------------------------------------------------------
  2097                              <1> ; DMA_SETUP
  2098                              <1> ;	THIS ROUTINE SETS UP THE DMA FOR READ/WRITE/VERIFY OPERATIONS.
  2099                              <1> ;
  2100                              <1> ; ON ENTRY:	AL = DMA COMMAND
  2101                              <1> ;
  2102                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  2103                              <1> ;-------------------------------------------------------------------------------
  2104                              <1> 
  2105                              <1> ; SI = Head #, # of Sectors or DASD Type
  2106                              <1> 
  2107                              <1> ; 22/08/2015
  2108                              <1> ; 08/02/2015 - Protected Mode Modification
  2109                              <1> ; 06/02/2015 - 07/02/2015
  2110                              <1> ; NOTE: Buffer address must be in 1st 16MB of Physical Memory (24 bit limit).
  2111                              <1> ; (DMA Addres = Physical Address)
  2112                              <1> ; (Retro UNIX 386 v1 Kernel/System Mode Virtual Address = Physical Address)
  2113                              <1> ;
  2114                              <1> ; 09/08/2022
  2115                              <1> ; 06/08/2022
  2116                              <1> ; 04/02/2016 (clc)
  2117                              <1> ; 20/02/2015 modification (source: AWARD BIOS 1999, DMA_SETUP)
  2118                              <1> ; 16/12/2014 (IODELAY)
  2119                              <1> 
  2120                              <1> DMA_SETUP:
  2121                              <1> 	; 09/08/2022
  2122                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
  2123                              <1> 	;; 20/02/2015
  2124                              <1> 	;;mov	edx, [ebp+4] 		; Buffer address
  2125                              <1> 	; 06/08/2022
  2126                              <1> 	;mov	edx, ebp ; buffer address
  2127                              <1> 	;test	edx, 0FF000000h		; 16 MB limit (22/08/2015, bugfix)
  2128 00004894 F7C5000000FF        <1> 	test	ebp, 0FF000000h
  2129 0000489A 7566                <1> 	jnz	short dma_bnd_err_stc
  2130                              <1> 	; 09/08/2022
  2131 0000489C 89EA                <1> 	mov	edx, ebp
  2132                              <1> 	;
  2133                              <1> 	;;push	ax			; DMA command
  2134                              <1> 	; 11/04/2021
  2135 0000489E 50                  <1> 	push	eax
  2136                              <1> 	; 06/08/2022
  2137                              <1> 	;push	edx			; *
  2138                              <1> 	;mov	dl, 3			; GET BYTES/SECTOR PARAMETER
  2139                              <1> 	; 06/08/2022
  2140 0000489F B003                <1> 	mov	al, 3			; GET BYTES/SECTOR PARAMETER
  2141 000048A1 E8D2020000          <1> 	call	GET_PARM		; 
  2142 000048A6 88E1                <1> 	mov	cl, ah 			; SHIFT COUNT (0=128, 1=256, 2=512 ETC)
  2143                              <1> 	;mov	ax, si			; Sector count
  2144                              <1> 	; 06/08/2022
  2145 000048A8 89F0                <1> 	mov	eax, esi
  2146 000048AA 88C4                <1> 	mov	ah, al			; AH = # OF SECTORS
  2147 000048AC 28C0                <1> 	sub	al, al			; AL = 0, AX = # SECTORS * 256
  2148                              <1> 	;shr	ax, 1			; AX = # SECTORS * 128
  2149                              <1> 	; 06/08/2022
  2150 000048AE D1E8                <1> 	shr	eax, 1
  2151                              <1> 	;shl	ax, cl			; SHIFT BY PARAMETER VALUE
  2152                              <1> 	;dec	ax			; -1 FOR DMA VALUE
  2153                              <1> 	;mov	cx, ax
  2154 000048B0 D3E0                <1> 	shl	eax, cl
  2155 000048B2 48                  <1> 	dec	eax
  2156 000048B3 89C1                <1> 	mov	ecx, eax
  2157                              <1> 	; 06/08/2022
  2158                              <1> 	;pop	edx			; *
  2159                              <1> 	;;pop	ax
  2160                              <1> 	; 11/04/2021
  2161 000048B5 58                  <1> 	pop	eax
  2162 000048B6 3C42                <1> 	cmp	al, 42h
  2163 000048B8 7507                <1>         jne     short NOT_VERF
  2164                              <1> 	; 09/08/2022
  2165 000048BA BA0000FF00          <1> 	mov	edx, 0FF0000h
  2166                              <1> 	; 06/08/2022
  2167                              <1> 	;mov	ebp, 0FF0000h
  2168 000048BF EB08                <1> 	jmp	short J33
  2169                              <1> NOT_VERF:
  2170 000048C1 6601CA              <1> 	add	dx, cx			; check for overflow
  2171 000048C4 723D                <1> 	jc	short dma_bnd_err
  2172                              <1> 	;
  2173 000048C6 6629CA              <1> 	sub	dx, cx			; Restore start address
  2174                              <1> J33:
  2175 000048C9 FA                  <1> 	cli				; DISABLE INTERRUPTS DURING DMA SET-UP
  2176 000048CA E60C                <1> 	out	DMA+12, al		; SET THE FIRST/LA5T F/F
  2177                              <1> 	IODELAY				; WAIT FOR I/O
    78 000048CC EB00                <2>  jmp short $+2
    79 000048CE EB00                <2>  jmp short $+2
  2178 000048D0 E60B                <1> 	out	DMA+11, al		; OUTPUT THE MODE BYTE
  2179                              <1> 	;mov	eax, edx		; Buffer address
  2180                              <1> 	; 06/08/2022
  2181                              <1> 	;mov	eax, ebp
  2182                              <1> 	; 09/08/2022
  2183 000048D2 89D0                <1> 	mov	eax, edx
  2184 000048D4 E604                <1> 	out	DMA+4, al		; OUTPUT LOW ADDRESS
  2185                              <1> 	IODELAY				; WAIT FOR I/O
    78 000048D6 EB00                <2>  jmp short $+2
    79 000048D8 EB00                <2>  jmp short $+2
  2186 000048DA 88E0                <1> 	mov	al, ah
  2187 000048DC E604                <1> 	out	DMA+4, al		; OUTPUT HIGH ADDRESS
  2188 000048DE C1E810              <1> 	shr	eax, 16
  2189                              <1> 	IODELAY				; I/O WAIT STATE
    78 000048E1 EB00                <2>  jmp short $+2
    79 000048E3 EB00                <2>  jmp short $+2
  2190 000048E5 E681                <1> 	out	081h, al		; OUTPUT HIGHEST BITS TO PAGE REGISTER
  2191                              <1> 	IODELAY
    78 000048E7 EB00                <2>  jmp short $+2
    79 000048E9 EB00                <2>  jmp short $+2
  2192                              <1> 	;mov	ax, cx			; Byte count - 1
  2193                              <1> 	; 06/08/2022
  2194 000048EB 89C8                <1> 	mov	eax, ecx
  2195 000048ED E605                <1> 	out	DMA+5, al		; LOW BYTE OF COUNT
  2196                              <1> 	IODELAY				; WAIT FOR I/O
    78 000048EF EB00                <2>  jmp short $+2
    79 000048F1 EB00                <2>  jmp short $+2
  2197 000048F3 88E0                <1> 	mov	al, ah
  2198 000048F5 E605                <1> 	out	DMA+5, al		; HIGH BYTE OF COUNT
  2199                              <1> 	IODELAY
    78 000048F7 EB00                <2>  jmp short $+2
    79 000048F9 EB00                <2>  jmp short $+2
  2200 000048FB FB                  <1> 	sti				; RE-ENABLE INTERRUPTS
  2201 000048FC B002                <1> 	mov	al, 2			; MODE FOR 8237
  2202 000048FE E60A                <1> 	out	DMA+10, al		; INITIALIZE THE DISKETTE CHANNEL
  2203                              <1> 
  2204 00004900 F8                  <1> 	clc	; 04/02/2016
  2205 00004901 C3                  <1> 	retn
  2206                              <1> 
  2207                              <1> dma_bnd_err_stc:
  2208 00004902 F9                  <1> 	stc
  2209                              <1> dma_bnd_err:
  2210 00004903 C605[10780100]09    <1> 	mov	byte [DSKETTE_STATUS], DMA_BOUNDARY ; SET ERROR
  2211 0000490A C3                  <1> 	retn				; CY SET BY ABOVE IF ERROR
  2212                              <1> 
  2213                              <1> ;; 16/12/2014
  2214                              <1> ;;	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  2215                              <1> ;;	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  2216                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
  2217                              <1> ;;	IODELAY
  2218                              <1> ;; 	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  2219                              <1> ;;	;SIODELAY
  2220                              <1> ;;      ;cmp	AL,42H			; DMA VERIFY COMMAND
  2221                              <1> ;;      ;JNE	short NOT_VERF		; NO
  2222                              <1> ;;      ;xor	AX,AX			; START ADDRESS
  2223                              <1> ;;      ;jmp	SHORT J33
  2224                              <1> ;;;NOT_VERF:	
  2225                              <1> ;;	;mov	AX,ES			; GET THE ES VALUE
  2226                              <1> ;;	;ROL	AX,4			; ROTATE LEFT
  2227                              <1> ;;	;mov	CH,AL			; GET HIGHEST NIBBLE OF ES TO CH
  2228                              <1> ;;	;and	AL,11110000B		; ZERO THE LOW NIBBLE FROM SEGMENT
  2229                              <1> ;;	;add	AX,[BP+2]		; TEST FOR CARRY FROM ADDITION
  2230                              <1> ;;	mov	eax,[ebp+4] ; 06/02/2015	
  2231                              <1> ;;	;jnc	short J33
  2232                              <1> ;;	;inc	CH			; CARRY MEANS HIGH 4 BITS MUST BE INC
  2233                              <1> ;;;J33:
  2234                              <1> ;;	push	eax			; SAVE START ADDRESS
  2235                              <1> ;;	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  2236                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
  2237                              <1> ;;	IODELAY
  2238                              <1> ;;	mov	AL,AH
  2239                              <1> ;;	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  2240                              <1> ;;	shr	eax, 16	     ; 07/02/2015
  2241                              <1> ;;	;mov	AL,CH			; GET HIGH 4 BITS
  2242                              <1> ;;	;jmp	$+2			; I/O WAIT STATE
  2243                              <1> ;;	IODELAY
  2244                              <1> ;;	;and	AL,00001111B
  2245                              <1> ;;	OUT	081H,AL			; OUTPUT HIGH 4 BITS TO PAGE REGISTER
  2246                              <1> ;;	;SIODELAY
  2247                              <1> ;;
  2248                              <1> ;;;----- DETERMINE COUNT
  2249                              <1> ;;	sub	eax, eax ; 08/02/2015
  2250                              <1> ;;	mov	AX,SI			; AL =  # OF SECTORS
  2251                              <1> ;;	xchg	AL,AH			; AH =  # OF SECTORS
  2252                              <1> ;;	sub	AL,AL			; AL = 0, AX = # SECTORS * 256
  2253                              <1> ;;	SHR	AX,1			; AX = # SECTORS * 128
  2254                              <1> ;;	push	AX			; SAVE # OF SECTORS * 128
  2255                              <1> ;;	mov	DL,3			; GET BYTES/SECTOR PARAMETER
  2256                              <1> ;;	call	GET_PARM		; "
  2257                              <1> ;;	mov	CL,AH			; SHIFT COUNT (0=128, 1=256, 2=512 ETC)
  2258                              <1> ;;	pop	AX			; AX = # SECTORS * 128
  2259                              <1> ;;	SHL	AX,CL			; SHIFT BY PARAMETER VALUE
  2260                              <1> ;;	dec	AX			; -1 FOR DMA VALUE
  2261                              <1> ;;	push	eax  ; 08/02/2015	; SAVE COUNT VALUE
  2262                              <1> ;;	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  2263                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
  2264                              <1> ;;	IODELAY
  2265                              <1> ;;	mov	AL,AH
  2266                              <1> ;;	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  2267                              <1> ;;	;IODELAY
  2268                              <1> ;;	STI				; RE-ENABLE INTERRUPTS
  2269                              <1> ;;	pop	ecx  ; 08/02/2015 	; RECOVER COUNT VALUE
  2270                              <1> ;;	pop	eax  ; 08/02/2015	; RECOVER ADDRESS VALUE
  2271                              <1> ;;	;add	AX, CX			; ADD, TEST FOR 64K OVERFLOW
  2272                              <1> ;;	add	ecx,eax ; 08/02/2015
  2273                              <1> ;;	mov	AL, 2			; MODE FOR 8237
  2274                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
  2275                              <1> ;;	SIODELAY
  2276                              <1> ;;	OUT	DMA+10,AL		; INITIALIZE THE DISKETTE CHANNEL
  2277                              <1> ;;	;jnc	short NO_BAD		; CHECK FOR ERROR
  2278                              <1> ;;	jc	short dma_bnd_err ; 08/02/2015
  2279                              <1> ;;	and	ecx,0FFF00000h	; 16 MB limit
  2280                              <1> ;;	jz	short NO_BAD
  2281                              <1> ;;dma_bnd_err:
  2282                              <1> ;;	mov	byte [DSKETTE_STATUS],DMA_BOUNDARY ; SET ERROR
  2283                              <1> ;;NO_BAD:
  2284                              <1> ;;	retn				; CY SET BY ABOVE IF ERROR
  2285                              <1> 
  2286                              <1> ;-------------------------------------------------------------------------------
  2287                              <1> ; FMTDMA_SET
  2288                              <1> ;	THIS ROUTINE SETS UP THE DMA CONTROLLER FOR A FORMAT OPERATION.
  2289                              <1> ;
  2290                              <1> ; ON ENTRY:	NOTHING REQUIRED
  2291                              <1> ;
  2292                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  2293                              <1> ;-------------------------------------------------------------------------------
  2294                              <1> 
  2295                              <1> FMTDMA_SET:
  2296                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2297                              <1> 	;; 20/02/2015 modification	
  2298                              <1> 	;;mov	edx, [ebp+4] 		; Buffer address
  2299                              <1> 	; 06/08/2022
  2300                              <1> 	;mov	edx, ebp ; buffer address
  2301                              <1> 	; 06/08/2022
  2302                              <1> 	;test	edx, 0FF000000h		; 16 MB limit
  2303 0000490B F7C5000000FF        <1> 	test	ebp, 0FF000000h
  2304 00004911 75EF                <1> 	jnz	short dma_bnd_err_stc
  2305                              <1> 	;
  2306                              <1> 	;;push	dx			; *
  2307                              <1> 	;; 11/04/2021
  2308                              <1> 	; 06/08/2022
  2309                              <1> 	;push	edx
  2310                              <1> 	;mov	dl, 4			; SECTORS/TRACK VALUE IN PARM TABLE
  2311                              <1> 	; 06/08/2022
  2312 00004913 B004                <1> 	mov	al, 4			; SECTORS/TRACK VALUE IN PARM TABLE				
  2313 00004915 E85E020000          <1> 	call	GET_PARM		; "
  2314 0000491A 88E0                <1> 	mov	al, ah			; AL = SECTORS/TRACK VALUE
  2315 0000491C 28E4                <1> 	sub	ah, ah			; AX = SECTORS/TRACK VALUE
  2316                              <1> 	;shl	ax, 2			; AX = SEC/TRK * 4 (OFFSET C,H,R,N)
  2317                              <1> 	; 06/08/2022
  2318 0000491E C1E002              <1> 	shl	eax, 2
  2319                              <1> 	;dec	ax			; -1 FOR DMA VALUE
  2320 00004921 48                  <1> 	dec	eax
  2321                              <1> 	;mov	cx, ax
  2322 00004922 89C1                <1> 	mov	ecx, eax
  2323                              <1> 	;;pop	dx			; *
  2324                              <1> 	;; 11/04/2021
  2325                              <1> 	; 06/08/2022
  2326                              <1> 	;pop	edx
  2327                              <1> 	; 06/08/2022
  2328 00004924 B04A                <1> 	mov	al, 04Ah
  2329                              <1> 	;
  2330 00004926 EB99                <1> 	jmp	short NOT_VERF ; 06/08/2022	
  2331                              <1> 
  2332                              <1> ;; 06/08/2022	
  2333                              <1> ;	add	dx, cx			; check for overflow
  2334                              <1> ;	jc	short dma_bnd_err
  2335                              <1> ;	;
  2336                              <1> ;	sub	dx, cx			; Restore start address
  2337                              <1> ;	;
  2338                              <1> ;	;mov	al, 04Ah		; WILL WRITE TO THE DISKETTE
  2339                              <1> ;	cli				; DISABLE INTERRUPTS DURING DMA SET-UP
  2340                              <1> ;	out	DMA+12, al		; SET THE FIRST/LA5T F/F
  2341                              <1> ;	IODELAY				; WAIT FOR I/O
  2342                              <1> ;	out	DMA+11, al		; OUTPUT THE MODE BYTE
  2343                              <1> ;	mov	eax, edx		; Buffer address
  2344                              <1> ;	out	DMA+4, al		; OUTPUT LOW ADDRESS
  2345                              <1> ;	IODELAY				; WAIT FOR I/O
  2346                              <1> ;	mov	al, ah
  2347                              <1> ;	out	DMA+4, al		; OUTPUT HIGH ADDRESS
  2348                              <1> ;	shr	eax, 16
  2349                              <1> ;	IODELAY				; I/O WAIT STATE
  2350                              <1> ;	out	081h, al		; OUTPUT HIGHEST BITS TO PAGE REGISTER
  2351                              <1> ;	IODELAY
  2352                              <1> ;	;mov	ax, cx			; Byte count - 1
  2353                              <1> ;	; 06/08/2022
  2354                              <1> ;	mov	eax, ecx
  2355                              <1> ;	out	DMA+5, al		; LOW BYTE OF COUNT
  2356                              <1> ;	IODELAY				; WAIT FOR I/O
  2357                              <1> ;	mov	al, ah
  2358                              <1> ;	out	DMA+5, al		; HIGH BYTE OF COUNT
  2359                              <1> ;	IODELAY
  2360                              <1> ;	sti				; RE-ENABLE INTERRUPTS
  2361                              <1> ;	mov	al, 2			; MODE FOR 8237
  2362                              <1> ;	out	DMA+10, al		; INITIALIZE THE DISKETTE CHANNEL
  2363                              <1> ;
  2364                              <1> ;	; 06/08/2022
  2365                              <1> ;	clc
  2366                              <1> ;	retn
  2367                              <1> 
  2368                              <1> ;; 08/02/2015 - Protected Mode Modification
  2369                              <1> ;;	mov	AL,04AH			; WILL WRITE TO THE DISKETTE
  2370                              <1> ;;	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  2371                              <1> ;;	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  2372                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
  2373                              <1> ;;	IODELAY
  2374                              <1> ;;	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  2375                              <1> ;;	;mov	AX,ES			; GET THE ES VALUE
  2376                              <1> ;;	;ROL	AX,4			; ROTATE LEFT
  2377                              <1> ;;	;mov	CH,AL			; GET HIGHEST NIBBLE OF ES TO CH
  2378                              <1> ;;	;and	AL,11110000B		; ZERO THE LOW NIBBLE FROM SEGMENT
  2379                              <1> ;;	;add	AX,[BP+2]		; TEST FOR CARRY FROM ADDITION
  2380                              <1> ;;	;jnc	short J33A
  2381                              <1> ;;	;inc	CH			; CARRY MEANS HIGH 4 BITS MUST BE INC
  2382                              <1> ;;	mov	eax,[ebp+4] ; 08/02/2015
  2383                              <1> ;;;J33A:
  2384                              <1> ;;	push	eax ; 08/02/2015	; SAVE START ADDRESS
  2385                              <1> ;;	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  2386                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
  2387                              <1> ;;	IODELAY
  2388                              <1> ;;	mov	AL,AH
  2389                              <1> ;;	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  2390                              <1> ;;	shr 	eax,16 ; 08/02/2015
  2391                              <1> ;;	;mov	AL,CH			; GET HIGH 4 BITS
  2392                              <1> ;;	;jmp	$+2			; I/O WAIT STATE
  2393                              <1> ;;	IODELAY
  2394                              <1> ;;	;and	AL,00001111B
  2395                              <1> ;;	OUT	081H,AL			; OUTPUT HIGH 4 BITS TO PAGE REGISTER
  2396                              <1> ;;
  2397                              <1> ;;;----- DETERMINE COUNT
  2398                              <1> ;;	sub	eax,eax ; 08/02/2015
  2399                              <1> ;;	mov	DL,4			; SECTORS/TRACK VALUE IN PARM TABLE
  2400                              <1> ;;	call	GET_PARM		; "
  2401                              <1> ;;	xchg	AL,AH			; AL = SECTORS/TRACK VALUE
  2402                              <1> ;;	sub	AH,AH			; AX = SECTORS/TRACK VALUE
  2403                              <1> ;;	SHL	AX,2			; AX = SEC/TRK * 4 (OFFSET C,H,R,N)
  2404                              <1> ;;	dec	AX			; -1 FOR DMA VALUE
  2405                              <1> ;;	push	eax 	; 08/02/2015	; SAVE # OF BYTES TO BE TRANSFERED
  2406                              <1> ;;	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  2407                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
  2408                              <1> ;;	IODELAY
  2409                              <1> ;;	mov	AL,AH
  2410                              <1> ;;	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  2411                              <1> ;;	STI				; RE-ENABLE INTERRUPTS
  2412                              <1> ;;	pop	ecx	; 08/02/2015	; RECOVER COUNT VALUE
  2413                              <1> ;;	pop	eax	; 08/02/2015	; RECOVER ADDRESS VALUE
  2414                              <1> ;;	;add	AX,CX			; ADD, TEST FOR 64K OVERFLOW
  2415                              <1> ;;	add	ecx,eax ; 08/02/2015
  2416                              <1> ;;	mov	AL,2			; MODE FOR 8237
  2417                              <1> ;;	;jmp	$+2			; WAIT FOR I/O
  2418                              <1> ;;	SIODELAY
  2419                              <1> ;;	OUT	DMA+10,AL		; INITIALIZE THE DISKETTE CHANNEL
  2420                              <1> ;;	;jnc	short FMTDMA_OK		; CHECK FOR ERROR
  2421                              <1> ;;	jc	short fmtdma_bnd_err ; 08/02/2015
  2422                              <1> ;;	and	ecx,0FFF00000h	; 16 MB limit
  2423                              <1> ;;	jz	short FMTDMA_OK
  2424                              <1> ;;	stc	; 20/02/2015
  2425                              <1> ;;fmtdma_bnd_err:
  2426                              <1> ;;	mov	byte [DSKETTE_STATUS],DMA_BOUNDARY ; SET ERROR
  2427                              <1> ;;FMTDMA_OK:
  2428                              <1> ;;	retn				; CY SET BY ABOVE IF ERROR
  2429                              <1> 
  2430                              <1> ;-------------------------------------------------------------------------------
  2431                              <1> ; NEC_INIT	
  2432                              <1> ;	THIS ROUTINE SEEKS TO THE REQUESTED TRACK AND INITIALIZES
  2433                              <1> ;	THE NEC FOR THE READ/WRITE/VERIFY/FORMAT OPERATION.
  2434                              <1> ;
  2435                              <1> ; ON ENTRY:	AH = NEC COMMAND TO BE PERFORMED
  2436                              <1> ;
  2437                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  2438                              <1> ;-------------------------------------------------------------------------------
  2439                              <1> NEC_INIT:
  2440                              <1> 	; 11/08/2022
  2441                              <1> 	; EBX = user's ECX register content (on stack)
  2442                              <1> 	; 10/08/2022
  2443                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2444                              <1> 	;push	ax			; SAVE NEC COMMAND
  2445                              <1> 	; 11/04/2021
  2446 00004928 50                  <1> 	push	eax
  2447 00004929 E885020000          <1> 	call	MOTOR_ON		; TURN MOTOR ON FOR SPECIFIC DRIVE
  2448                              <1> 
  2449                              <1> ;-----	DO THE SEEK OPERATION
  2450                              <1> 
  2451                              <1> 	;mov	ch, [ebp+1]		; CH = TRACK #
  2452                              <1> 	; 10/08/2022
  2453 0000492E 88FD                <1> 	mov	ch, bh ; CH = TRACK #
  2454 00004930 E870030000          <1> 	call	SEEK			; MOVE TO CORRECT TRACK
  2455                              <1> 	;pop	ax			; RECOVER COMMAND
  2456                              <1> 	; 11/04/2021
  2457 00004935 58                  <1> 	pop	eax
  2458 00004936 721D                <1> 	jc	short ER_1		; ERROR ON SEEK
  2459 00004938 BB[55490000]        <1> 	mov	ebx, ER_1		; LOAD ERROR ADDRESS
  2460 0000493D 53                  <1> 	push	ebx			; PUSH NEC_OUT ERROR RETURN
  2461                              <1> 
  2462                              <1> ;-----	SEND OUT THE PARAMETERS TO THE CONTROLLER
  2463                              <1> 
  2464 0000493E E82B030000          <1> 	call	NEC_OUTPUT		; OUTPUT THE OPERATION COMMAND
  2465                              <1> 	;mov	ax, si			; AH = HEAD #
  2466                              <1> 	; 06/08/2022
  2467 00004943 89F0                <1> 	mov	eax, esi
  2468 00004945 89FB                <1> 	mov	ebx, edi		; BL = DRIVE #
  2469 00004947 C0E402              <1> 	sal	ah, 2			; MOVE IT TO BIT 2
  2470 0000494A 80E404              <1> 	and	ah, 00000100b		; ISOLATE THAT BIT
  2471 0000494D 08DC                <1> 	or	ah, bl			; OR IN THE DRIVE NUMBER
  2472 0000494F E81A030000          <1> 	call	NEC_OUTPUT		; FALL THRU CY SET IF ERROR
  2473 00004954 5B                  <1> 	pop	ebx			; THROW AWAY ERROR RETURN
  2474                              <1> ER_1:
  2475 00004955 C3                  <1> 	retn
  2476                              <1> 
  2477                              <1> ;-------------------------------------------------------------------------------
  2478                              <1> ; RWV_COM
  2479                              <1> ;	THIS ROUTINE SENDS PARAMETERS TO THE NEC SPECIFIC TO THE 
  2480                              <1> ;	READ/WRITE/VERIFY OPERATIONS.
  2481                              <1> ;
  2482                              <1> ; ON ENTRY:	CS:BX = ADDRESS OF MEDIA/DRIVE PARAMETER TABLE
  2483                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  2484                              <1> ;-------------------------------------------------------------------------------
  2485                              <1> RWV_COM:
  2486                              <1> 	; 11/08/2022
  2487                              <1> 	; 10/08/2022
  2488                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2489 00004956 B8[A2490000]        <1> 	mov	eax, ER_2		; LOAD ERROR ADDRESS
  2490 0000495B 50                  <1> 	push	eax			; PUSH NEC_OUT ERROR RETURN
  2491                              <1> 	;mov	ah, [ebp+1]		; OUTPUT TRACK #
  2492                              <1> 	; 11/08/2022
  2493 0000495C 8A642425            <1> 	mov	ah, [esp+37] ; CH = OUTPUT TRACK #
  2494 00004960 E809030000          <1> 	call	NEC_OUTPUT
  2495                              <1> 	;mov	ax, si			; OUTPUT HEAD #
  2496                              <1> 	; 06/08/2022
  2497 00004965 89F0                <1> 	mov	eax, esi
  2498 00004967 E802030000          <1> 	call	NEC_OUTPUT
  2499                              <1> 	;mov	ah, [ebp]		; OUTPUT SECTOR #
  2500                              <1> 	; 11/08/2022
  2501 0000496C 8A642424            <1> 	mov	ah, [esp+36] ; CL = OUTPUT SECTOR #
  2502 00004970 E8F9020000          <1> 	call	NEC_OUTPUT
  2503                              <1> 	;mov	dl, 3			; BYTES/SECTOR PARAMETER FROM BLOCK
  2504                              <1> 	; 06/08/2022
  2505 00004975 B003                <1> 	mov	al, 3
  2506 00004977 E8FC010000          <1> 	call	GET_PARM 		; ... TO THE NEC
  2507 0000497C E8ED020000          <1> 	call	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  2508                              <1> 	;mov	dl, 4			; EOT PARAMETER FROM BLOCK
  2509                              <1> 	; 06/08/2022
  2510 00004981 B004                <1> 	mov	al, 4
  2511 00004983 E8F0010000          <1> 	call	GET_PARM 		; ... TO THE NEC
  2512 00004988 E8E1020000          <1> 	call	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  2513 0000498D 8A6305              <1> 	mov	ah, [ebx+MD.GAP]        ; GET GAP LENGTH
  2514                              <1> _R15:
  2515 00004990 E8D9020000          <1> 	call	NEC_OUTPUT
  2516                              <1> 	;mov	dl, 6			; DTL PARAMETER PROM BLOCK
  2517                              <1> 	; 06/08/2022
  2518 00004995 B006                <1> 	mov	al, 6
  2519 00004997 E8DC010000          <1> 	call	GET_PARM		; ... TO THE NEC
  2520 0000499C E8CD020000          <1> 	call	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  2521 000049A1 58                  <1> 	pop	eax			; THROW AWAY ERROR EXIT
  2522                              <1> ER_2:
  2523 000049A2 C3                  <1> 	retn
  2524                              <1> 
  2525                              <1> ;-------------------------------------------------------------------------------
  2526                              <1> ; NEC_TERM
  2527                              <1> ;	THIS ROUTINE WAITS FOR THE OPERATION THEN ACCEPTS THE STATUS 
  2528                              <1> ;	FROM THE NEC FOR THE READ/WRITE/VERIFY/FORWAT OPERATION.
  2529                              <1> ;
  2530                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  2531                              <1> ;-------------------------------------------------------------------------------
  2532                              <1> NEC_TERM:
  2533                              <1> 
  2534                              <1> ;-----	LET THE OPERATION HAPPEN
  2535                              <1> 
  2536 000049A3 56                  <1> 	push	esi			; SAVE HEAD #, # OF SECTORS
  2537 000049A4 E8CD030000          <1> 	call	WAIT_INT		; WAIT FOR THE INTERRUPT
  2538 000049A9 9C                  <1> 	pushf
  2539 000049AA E8F6030000          <1> 	call	RESULTS			; GET THE NEC STATUS
  2540 000049AF 724B                <1> 	jc	short SET_END_POP
  2541 000049B1 9D                  <1> 	popf
  2542 000049B2 723E                <1> 	jc	short SET_END		; LOOK FOR ERROR
  2543                              <1> 
  2544                              <1> ;-----	CHECK THE RESULTS RETURNED BY THE CONTROLLER
  2545                              <1> 
  2546 000049B4 FC                  <1> 	cld				; SET THE CORRECT DIRECTION
  2547 000049B5 BE[11780100]        <1> 	mov	esi, NEC_STATUS		; POINT TO STATUS FIELD
  2548 000049BA AC                  <1> 	lodsb				; GET ST0
  2549 000049BB 24C0                <1> 	and	AL, 11000000B		; TEST FOR NORMAL TERMINATION
  2550 000049BD 7433                <1> 	jz	short SET_END
  2551 000049BF 3C40                <1> 	cmp	AL,01000000B		; TEST FOR ABNORMAL TERMINATION
  2552 000049C1 7527                <1> 	jnz	short J18		; NOT ABNORMAL, BAD NEC
  2553                              <1> 
  2554                              <1> ;-----	ABNORMAL TERMINATION, FIND OUT WHY
  2555                              <1> 
  2556 000049C3 AC                  <1> 	lodsb				; GET ST1
  2557 000049C4 D0E0                <1> 	sal	al, 1			; TEST FOR EDT FOUND
  2558 000049C6 B404                <1> 	mov	ah, RECORD_NOT_FND
  2559 000049C8 7222                <1> 	jc	short J19
  2560 000049CA C0E002              <1> 	sal	al, 2
  2561 000049CD B410                <1> 	mov	ah, BAD_CRC
  2562 000049CF 721B                <1> 	jc	short J19
  2563 000049D1 D0E0                <1> 	sal	al, 1			; TEST FOR DMA OVERRUN
  2564 000049D3 B408                <1> 	mov	ah, BAD_DMA
  2565 000049D5 7215                <1> 	jc	short J19
  2566 000049D7 C0E002              <1> 	sal	al, 2			; TEST FOR RECORD NOT FOUND
  2567 000049DA B404                <1> 	mov	ah, RECORD_NOT_FND
  2568 000049DC 720E                <1> 	jc	short J19
  2569 000049DE D0E0                <1> 	sal	al, 1
  2570 000049E0 B403                <1> 	mov	ah, WRITE_PROTECT	; TEST FOR WRITE_PROTECT
  2571 000049E2 7208                <1> 	jc	short J19
  2572 000049E4 D0E0                <1> 	sal	al, 1			; TEST MISSING ADDRESS MARK
  2573 000049E6 B402                <1> 	mov	ah, BAD_ADDR_MARK
  2574 000049E8 7202                <1> 	jc	short J19
  2575                              <1> 
  2576                              <1> ;----- 	NEC MUST HAVE FAILED
  2577                              <1> J18:
  2578 000049EA B420                <1> 	mov	ah, BAD_NEC
  2579                              <1> J19:
  2580 000049EC 0825[10780100]      <1> 	or	[DSKETTE_STATUS], ah
  2581                              <1> SET_END:
  2582 000049F2 803D[10780100]01    <1> 	cmp	byte [DSKETTE_STATUS], 1 ; SET ERROR CONDITION
  2583 000049F9 F5                  <1> 	cmc
  2584 000049FA 5E                  <1> 	pop	esi
  2585 000049FB C3                  <1> 	retn				; RESTORE HEAD #, # OF SECTORS
  2586                              <1> 
  2587                              <1> SET_END_POP:
  2588 000049FC 9D                  <1> 	popf
  2589 000049FD EBF3                <1> 	jmp	short SET_END
  2590                              <1> 
  2591                              <1> ;-------------------------------------------------------------------------------
  2592                              <1> ; DSTATE:	ESTABLISH STATE UPON SUCCESSFUL OPERATION.
  2593                              <1> ;-------------------------------------------------------------------------------
  2594                              <1> DSTATE:
  2595 000049FF 803D[10780100]00    <1> 	cmp	byte [DSKETTE_STATUS], 0 ; CHECK FOR ERROR
  2596 00004A06 753E                <1> 	jnz	short SETBAC		; IF ERROR JUMP
  2597 00004A08 808F[1B780100]10    <1> 	or	byte [DSK_STATE+edi], MED_DET
  2598                              <1> 					; NO ERROR, MARK MEDIA AS DETERMINED
  2599 00004A0F F687[1B780100]04    <1> 	test	byte [DSK_STATE+edi], DRV_DET ; DRIVE DETERMINED ?
  2600 00004A16 752E                <1> 	jnz	short SETBAC		; IF DETERMINED NO TRY TO DETERMINE
  2601 00004A18 8A87[1B780100]      <1> 	mov	al, [DSK_STATE+edi]	; LOAD STATE
  2602 00004A1E 24C0                <1> 	and	al, RATE_MSK		; KEEP ONLY RATE
  2603 00004A20 3C80                <1> 	cmp	al, RATE_250		; RATE 250 ?
  2604 00004A22 751B                <1> 	jne	short M_12		; NO, MUST BE 1.2M OR 1.44M DRIVE
  2605                              <1> 
  2606                              <1> ;----- 	CHECK IF IT IS 1.44M
  2607                              <1> 
  2608 00004A24 E846010000          <1> 	call	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  2609                              <1> 	;;20/02/2015
  2610                              <1> 	;;jc	short M_12		; CMOS BAD
  2611 00004A29 7414                <1> 	jz	short M_12 ;; 20/02/2015
  2612 00004A2B 3C04                <1> 	cmp	al, 4			; 1.44MB DRIVE ?
  2613 00004A2D 7410                <1> 	je	short M_12		; YES
  2614                              <1> M_720:
  2615 00004A2F 80A7[1B780100]FD    <1> 	and	byte [DSK_STATE+edi], ~FMT_CAPA ; TURN OFF FORMAT CAPABILITY
  2616 00004A36 808F[1B780100]04    <1> 	or	byte [DSK_STATE+edi], DRV_DET ; MARK DRIVE DETERMINED
  2617 00004A3D EB07                <1> 	jmp	short SETBAC		; BACK
  2618                              <1> M_12:	
  2619 00004A3F 808F[1B780100]06    <1> 	or	byte [DSK_STATE+edi], DRV_DET+FMT_CAPA 
  2620                              <1> 					; TURN ON DETERMINED & FMT CAPA
  2621                              <1> SETBAC:
  2622 00004A46 C3                  <1> 	retn
  2623                              <1> 
  2624                              <1> ;-------------------------------------------------------------------------------
  2625                              <1> ; RETRY	
  2626                              <1> ;	DETERMINES WHETHER A RETRY IS NECESSARY. 
  2627                              <1> ;	IF RETRY IS REQUIRED THEN STATE INFORMATION IS UPDATED FOR RETRY.
  2628                              <1> ;
  2629                              <1> ; ON EXIT:	CY = 1 FOR RETRY, CY = 0 FOR NO RETRY
  2630                              <1> ;-------------------------------------------------------------------------------
  2631                              <1> RETRY:
  2632                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2633 00004A47 803D[10780100]00    <1> 	cmp	byte [DSKETTE_STATUS], 0 ; GET STATUS OF OPERATION
  2634 00004A4E 7445                <1> 	jz	short NO_RETRY		; SUCCESSFUL OPERATION
  2635 00004A50 803D[10780100]80    <1> 	cmp	byte [DSKETTE_STATUS], TIME_OUT ; IF TIME OUT NO RETRY
  2636 00004A57 743C                <1> 	jz	short NO_RETRY
  2637 00004A59 8AA7[1B780100]      <1> 	mov	ah, [DSK_STATE+edi]	; GET MEDIA STATE OF DRIVE
  2638 00004A5F F6C410              <1> 	test	ah, MED_DET		; ESTABLISHED/DETERMINED ?
  2639 00004A62 7531                <1> 	jnz	short NO_RETRY		; IF ESTABLISHED STATE THEN TRUE ERROR
  2640 00004A64 80E4C0              <1> 	and	ah, RATE_MSK		; ISOLATE RATE
  2641 00004A67 8A2D[18780100]      <1> 	mov	ch, [LASTRATE]		; GET START OPERATION STATE
  2642 00004A6D C0C504              <1> 	rol	ch, 4			; TO CORRESPONDING BITS
  2643 00004A70 80E5C0              <1> 	and	ch, RATE_MSK		; ISOLATE RATE BITS
  2644 00004A73 38E5                <1> 	cmp	ch, ah			; ALL RATES TRIED
  2645 00004A75 741E                <1> 	je	short NO_RETRY		; IF YES, THEN TRUE ERROR
  2646                              <1> 
  2647                              <1> ;	SETUP STATE INDICATOR FOR RETRY ATTEMPT TO NEXT RATE
  2648                              <1> ;	 00000000B (500) -> 10000000B	(250)
  2649                              <1> ;	 10000000B (250) -> 01000000B	(300)
  2650                              <1> ;	 01000000B (300) -> 00000000B	(500)
  2651                              <1> 
  2652 00004A77 80FC01              <1> 	cmp	ah, RATE_500+1		; SET CY FOR RATE 500
  2653 00004A7A D0DC                <1> 	rcr	ah, 1			; TO NEXT STATE
  2654 00004A7C 80E4C0              <1> 	and	ah, RATE_MSK		; KEEP ONLY RATE BITS
  2655 00004A7F 80A7[1B780100]1F    <1> 	and	byte [DSK_STATE+edi], ~(RATE_MSK+DBL_STEP)
  2656                              <1> 					; RATE, DBL STEP OFF
  2657 00004A86 08A7[1B780100]      <1> 	or	[DSK_STATE+edi], ah	; TURN ON NEW RATE
  2658 00004A8C C605[10780100]00    <1> 	mov	byte [DSKETTE_STATUS], 0  ; RESET STATUS FOR RETRY
  2659 00004A93 F9                  <1> 	stc				; SET CARRY FOR RETRY
  2660 00004A94 C3                  <1> 	retn				; RETRY RETURN
  2661                              <1> 
  2662                              <1> NO_RETRY:
  2663                              <1> 	; 06/08/2022
  2664                              <1> 	;clc				; CLEAR CARRY NO RETRY
  2665 00004A95 C3                  <1> 	retn				; NO RETRY RETURN
  2666                              <1> 
  2667                              <1> ;-------------------------------------------------------------------------------
  2668                              <1> ; NUM_TRANS
  2669                              <1> ;	THIS ROUTINE CALCULATES THE NUMBER OF SECTORS THAT WERE
  2670                              <1> ;	ACTUALLY TRANSFERRED TO/FROM THE DISKETTE.
  2671                              <1> ;
  2672                              <1> ; ON ENTRY:	[BP+1] = TRACK
  2673                              <1> ;		SI-HI  = HEAD
  2674                              <1> ;		[BP]   = START SECTOR
  2675                              <1> ;
  2676                              <1> ; ON EXIT:	AL = NUMBER ACTUALLY TRANSFERRED
  2677                              <1> ;-------------------------------------------------------------------------------
  2678                              <1> NUM_TRANS:
  2679                              <1> 	; 10/08/2022
  2680                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2681 00004A96 30C0                <1> 	xor	al, al			; CLEAR FOR ERROR
  2682                              <1> 	;cmp	byte [DSKETTE_STATUS], 0
  2683 00004A98 3805[10780100]      <1> 	cmp	[DSKETTE_STATUS], al ; 0 ; CHECK FOR ERROR
  2684 00004A9E 752D                <1> 	jnz	short NT_OUT		; IF ERROR 0 TRANSFERRED
  2685                              <1> 	;mov	dl, 4			; SECTORS/TRACK OFFSET TO DL
  2686                              <1> 	; 06/08/2022
  2687 00004AA0 B004                <1> 	mov	al, 4
  2688 00004AA2 E8D1000000          <1> 	call	GET_PARM		; AH = SECTORS/TRACK
  2689 00004AA7 8A1D[16780100]      <1> 	mov	bl, [NEC_STATUS+5]	; GET ENDING SECTOR
  2690                              <1> 	;mov	cx, si			; CH = HEAD # STARTED
  2691                              <1> 	; 06/08/2022
  2692 00004AAD 89F1                <1> 	mov	ecx, esi
  2693 00004AAF 3A2D[15780100]      <1> 	cmp	ch, [NEC_STATUS+4]	; GET HEAD ENDED UP ON
  2694 00004AB5 750E                <1> 	jnz	short DIF_HD		; IF ON SAME HEAD, THEN NO ADJUST
  2695 00004AB7 8A2D[14780100]      <1> 	mov	ch, [NEC_STATUS+3]	; GET TRACK ENDED UP ON
  2696                              <1> 	;cmp	ch, [ebp+1]		; IS IT ASKED FOR TRACK
  2697                              <1> 	; 10/08/2022
  2698 00004ABD 3A6C241D            <1> 	cmp	ch, [esp+29] ; CH = TRACK #
  2699 00004AC1 7404                <1> 	jz	short SAME_TRK		; IF SAME TRACK NO INCREASE
  2700 00004AC3 00E3                <1> 	add	bl, ah			; ADD SECTORS/TRACK
  2701                              <1> DIF_HD:
  2702 00004AC5 00E3                <1> 	add	bl, ah			; ADD SECTORS/TRACK
  2703                              <1> SAME_TRK:
  2704                              <1> 	;sub	bl, [ebp]		; SUBTRACT START FROM END
  2705                              <1> 	; 10/08/2022
  2706 00004AC7 2A5C241C            <1> 	sub	bl, [esp+28] ; CL = SECTOR #	
  2707 00004ACB 88D8                <1> 	mov	al, bl			; TO AL
  2708                              <1> NT_OUT:
  2709 00004ACD C3                  <1> 	retn
  2710                              <1> 
  2711                              <1> ;-------------------------------------------------------------------------------
  2712                              <1> ; SETUP_DBL
  2713                              <1> ;	CHECK DOUBLE STEP.
  2714                              <1> ;
  2715                              <1> ; ON ENTRY :	DI = DRIVE
  2716                              <1> ;
  2717                              <1> ; ON EXIT :	CY = 1 MEANS ERROR
  2718                              <1> ;-------------------------------------------------------------------------------
  2719                              <1> SETUP_DBL:
  2720                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2721 00004ACE 8AA7[1B780100]      <1> 	mov	ah, [DSK_STATE+edi]	; ACCESS STATE
  2722 00004AD4 F6C410              <1> 	test	ah, MED_DET		; ESTABLISHED STATE ?
  2723 00004AD7 7578                <1> 	jnz	short NO_DBL		; IF ESTABLISHED THEN DOUBLE DONE
  2724                              <1> 
  2725                              <1> ;-----	CHECK FOR TRACK 0 TO SPEED UP ACKNOWLEDGE OF UNFORMATTED DISKETTE
  2726                              <1> 
  2727 00004AD9 C605[0D780100]00    <1> 	mov	byte [SEEK_STATUS], 0	; SET RECALIBRATE REQUIRED ON ALL DRIVES
  2728 00004AE0 E8CE000000          <1> 	call	MOTOR_ON		; ENSURE MOTOR STAY ON
  2729 00004AE5 B500                <1> 	mov	ch, 0			; LOAD TRACK 0
  2730 00004AE7 E8B9010000          <1> 	call	SEEK			; SEEK TO TRACK 0
  2731 00004AEC E861000000          <1> 	call	READ_ID			; READ ID FUNCTION
  2732 00004AF1 7243                <1> 	jc	short SD_ERR		; IF ERROR NO TRACK 0
  2733                              <1> 
  2734                              <1> ;-----	INITIALIZE START AND MAX TRACKS (TIMES 2 FOR BOTH HEADS)
  2735                              <1> 
  2736 00004AF3 66B95004            <1> 	mov	cx, 0450h 		; START, MAX TRACKS
  2737 00004AF7 F687[1B780100]01    <1> 	test	byte [DSK_STATE+edi], TRK_CAPA ; TEST FOR 80 TRACK CAPABILITY
  2738 00004AFE 7402                <1> 	jz	short CNT_OK		; IF NOT COUNT IS SETUP
  2739 00004B00 B1A0                <1> 	mov	cl, 0A0h		; MAXIMUM TRACK 1.2 MB
  2740                              <1> 
  2741                              <1> ;	ATTEMPT READ ID OF ALL TRACKS, ALL HEADS UNTIL SUCCESS; UPON SUCCESS,
  2742                              <1> ;	MUST SEE IF ASKED FOR TRACK IN SINGLE STEP MODE = TRACK ID READ; IF NOT
  2743                              <1> ;	THEN SET DOUBLE STEP ON.
  2744                              <1> 
  2745                              <1> CNT_OK:
  2746                              <1> 	; 11/04/2021 (32 bit push/pop)
  2747 00004B02 C605[0F780100]FF    <1>         mov     byte [MOTOR_COUNT], 0FFh ; ENSURE MOTOR STAYS ON FOR OPERATION
  2748 00004B09 51                  <1> 	push	ecx			; SAVE TRACK, COUNT
  2749 00004B0A C605[10780100]00    <1> 	mov	byte [DSKETTE_STATUS], 0 ; CLEAR STATUS, EXPECT ERRORS
  2750                              <1> 	;xor	ax, ax			; CLEAR AX
  2751                              <1> 	; 06/08/2022
  2752 00004B11 31C0                <1> 	xor	eax, eax
  2753 00004B13 D0ED                <1> 	shr	ch, 1			; HALVE TRACK, CY = HEAD
  2754 00004B15 C0D003              <1> 	rcl	al, 3			; AX = HEAD IN CORRECT BIT
  2755 00004B18 50                  <1> 	push	eax			; SAVE HEAD
  2756 00004B19 E887010000          <1> 	call	SEEK			; SEEK TO TRACK
  2757 00004B1E 58                  <1> 	pop	eax			; RESTORE HEAD
  2758                              <1> 	;or	di, ax			; DI = HEAD OR'ED DRIVE
  2759                              <1> 	; 06/08/2022
  2760 00004B1F 09C7                <1> 	or	edi, eax
  2761 00004B21 E82C000000          <1> 	call	READ_ID			; READ ID HEAD 0
  2762 00004B26 9C                  <1> 	pushf				; SAVE RETURN FROM READ_ID
  2763 00004B27 6681E7FB00          <1> 	and	di, 11111011b		; TURN OFF HEAD 1 BIT
  2764 00004B2C 9D                  <1> 	popf				; RESTORE ERROR RETURN
  2765 00004B2D 59                  <1> 	pop	ecx			; RESTORE COUNT
  2766 00004B2E 7308                <1> 	jnc	short DO_CHK		; IF OK, ASKED = RETURNED TRACK ?
  2767 00004B30 FEC5                <1> 	inc	ch			; INC FOR NEXT TRACK
  2768 00004B32 38CD                <1> 	cmp	ch, cl			; REACHED MAXIMUM YET
  2769 00004B34 75CC                <1> 	jnz	short CNT_OK		; CONTINUE TILL ALL TRIED
  2770                              <1> 
  2771                              <1> ;-----	FALL THRU, READ ID FAILED FOR ALL TRACKS
  2772                              <1> 
  2773                              <1> SD_ERR:	
  2774 00004B36 F9                  <1> 	stc				; SET CARRY FOR ERROR
  2775 00004B37 C3                  <1> 	retn				; SETUP_DBL ERROR EXIT
  2776                              <1> 
  2777                              <1> DO_CHK:
  2778 00004B38 8A0D[14780100]      <1> 	mov	cl, [NEC_STATUS+3]	; LOAD RETURNED TRACK
  2779 00004B3E 888F[1D780100]      <1> 	mov	[DSK_TRK+edi], cl	; STORE TRACK NUMBER
  2780 00004B44 D0ED                <1> 	shr	ch, 1			; HALVE TRACK
  2781 00004B46 38CD                <1> 	cmp	ch, cl			; IS IT THE SAME AS ASKED FOR TRACK
  2782 00004B48 7407                <1> 	jz	short NO_DBL		; IF SAME THEN NO DOUBLE STEP
  2783 00004B4A 808F[1B780100]20    <1> 	or	byte [DSK_STATE+edi], DBL_STEP ; TURN ON DOUBLE STEP REQUIRED
  2784                              <1> NO_DBL:
  2785                              <1> 	; 06/08/2022
  2786                              <1> 	;clc				; CLEAR ERROR FLAG
  2787 00004B51 C3                  <1> 	retn
  2788                              <1> 
  2789                              <1> ;-------------------------------------------------------------------------------
  2790                              <1> ; READ_ID
  2791                              <1> ;	READ ID FUNCTION.
  2792                              <1> ;
  2793                              <1> ; ON ENTRY:	DI : BIT 2 = HEAD; BITS 1,0 = DRIVE
  2794                              <1> ;
  2795                              <1> ; ON EXIT: 	DI : BIT 2 IS RESET, BITS 1,0 = DRIVE
  2796                              <1> ;		@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  2797                              <1> ;-------------------------------------------------------------------------------
  2798                              <1> READ_ID:
  2799                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2800 00004B52 B8[6E4B0000]        <1> 	mov	eax, ER_3		; MOVE NEC OUTPUT ERROR ADDRESS
  2801 00004B57 50                  <1> 	push	eax
  2802 00004B58 B44A                <1> 	mov	ah, 4Ah			; READ ID COMMAND
  2803 00004B5A E80F010000          <1> 	call	NEC_OUTPUT		; TO CONTROLLER
  2804                              <1> 	;mov	ax, di			; DRIVE # TO AH, HEAD 0
  2805                              <1> 	; 06/08/2022
  2806 00004B5F 89F8                <1> 	mov	eax, edi
  2807 00004B61 88C4                <1> 	mov	ah, al
  2808 00004B63 E806010000          <1> 	call	NEC_OUTPUT		; TO CONTROLLER
  2809 00004B68 E836FEFFFF          <1> 	call	NEC_TERM		; WAIT FOR OPERATION, GET STATUS
  2810 00004B6D 58                  <1> 	pop	eax			; THROW AWAY ERROR ADDRESS
  2811                              <1> ER_3:
  2812 00004B6E C3                  <1> 	retn
  2813                              <1> 
  2814                              <1> ;-------------------------------------------------------------------------------
  2815                              <1> ; CMOS_TYPE
  2816                              <1> ;	RETURNS DISKETTE TYPE FROM CMOS
  2817                              <1> ;
  2818                              <1> ; ON ENTRY:	DI = DRIVE #
  2819                              <1> ;
  2820                              <1> ; ON EXIT:	AL = TYPE; CY REFLECTS STATUS
  2821                              <1> ;-------------------------------------------------------------------------------
  2822                              <1> 
  2823                              <1> CMOS_TYPE: ; 11/12/2014
  2824 00004B6F 8A87[2C650000]      <1> 	mov	al, [edi+fd0_type]
  2825 00004B75 20C0                <1> 	and 	al, al ; 18/12/2014
  2826 00004B77 C3                  <1> 	retn
  2827                              <1> 
  2828                              <1> ;CMOS_TYPE:
  2829                              <1> ;	mov	al, CMOS_DIAG		; CMOS DIAGNOSTIC STATUS BYTE ADDRESS
  2830                              <1> ;	call	CMOS_READ		; GET CMOS STATUS
  2831                              <1> ;	test	al, BAD_BAT+BAD_CKSUM	; BATTERY GOOD AND CHECKSUM VALID
  2832                              <1> ;	stc				; SET CY = 1 INDICATING ERROR FOR RETURN
  2833                              <1> ;	jnz	short BAD_CM		; ERROR IF EITHER BIT ON
  2834                              <1> ;	mov	al, CMOS_DISKETTE	; ADDRESS OF DISKETTE BYTE IN CMOS
  2835                              <1> ;	call	CMOS_READ		; GET DISKETTE BYTE
  2836                              <1> ;	or	di, di			; SEE WHICH DRIVE IN QUESTION
  2837                              <1> ;	jnz	short TB		; IF DRIVE 1, DATA IN LOW NIBBLE
  2838                              <1> ;	ror	al, 4			; EXCHANGE NIBBLES IF SECOND DRIVE
  2839                              <1> ;TB:
  2840                              <1> ;	and	al, 0Fh			; KEEP ONLY DRIVE DATA, RESET CY, 0
  2841                              <1> ;BAD_CM:
  2842                              <1> ;	retn				; CY, STATUS OF READ
  2843                              <1> 
  2844                              <1> ;-------------------------------------------------------------------------------
  2845                              <1> ; GET_PARM
  2846                              <1> ;	THIS ROUTINE FETCHES THE INDEXED POINTER FROM THE DISK_BASE
  2847                              <1> ;	BLOCK POINTED TO BY THE DATA VARIABLE @DISK_POINTER. A BYTE FROM
  2848                              <1> ;	THAT TABLE IS THEN MOVED INTO AH, THE INDEX OF THAT BYTE BEING
  2849                              <1> ;	THE PARAMETER IN DL.
  2850                              <1> ;
  2851                              <1> ; ON ENTRY:	DL = INDEX OF BYTE TO BE FETCHED
  2852                              <1> ;
  2853                              <1> ; ON EXIT:	AH = THAT BYTE FROM BLOCK
  2854                              <1> ;		AL, DH DESTROYED
  2855                              <1> ;-------------------------------------------------------------------------------
  2856                              <1> GET_PARM:
  2857                              <1> 	; 09/08/2022
  2858                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2859                              <1> 	; AL = INDEX
  2860                              <1> 	; EDI = (current) DRIVE #
  2861                              <1> 	;;push	ds
  2862                              <1> 	;push	esi
  2863                              <1>     	;;sub	ax, ax			; DS = 0, BIOS DATA AREA
  2864                              <1>     	;;mov	ds, ax
  2865                              <1> 	;;mov	ax, cs
  2866                              <1> 	;;mov	ds, ax
  2867                              <1> 	; 08/02/2015 (protected mode modifications, bx -> ebx)
  2868                              <1> 	;xchg	edx, ebx		; BL = INDEX
  2869                              <1> 	; 06/08/2022
  2870 00004B78 53                  <1> 	push	ebx			; SAVE EBX	
  2871                              <1> 	;movzx	ebx, dl			; EBX = INDEX
  2872 00004B79 0FB6D8              <1> 	movzx	ebx, al ; 06/08/2022
  2873                              <1> 	;;sub	bh, bh			; BX = INDEX
  2874                              <1> 	;and	ebx, 0FFh
  2875                              <1>     	;;lds	si, [DISK_POINTER]	; POINT TO BLOCK
  2876                              <1> 	;
  2877                              <1> 	; 17/12/2014
  2878                              <1> 	;mov	ax, [cfd]		; current (AL) and previous fd (AH)
  2879                              <1> 	; 06/08/2022
  2880 00004B7C 89F8                <1> 	mov	eax, edi		; EDI = DRIVE #
  2881                              <1> 	;cmp	al, ah
  2882 00004B7E 3A05[1D650000]      <1> 	cmp	al, [pfd]	
  2883 00004B84 7423                <1> 	je	short gpndc
  2884 00004B86 A2[1D650000]        <1> 	mov	[pfd], al		; current drive -> previous drive
  2885 00004B8B 53                  <1> 	push	ebx ; 08/02/2015
  2886                              <1> 	;mov	bl, al 
  2887                              <1> 	;; 11/12/2014
  2888                              <1> 	;mov	al, [ebx+fd0_type]	; Drive type (0,1,2,3,4)
  2889                              <1> 	; 09/08/2022
  2890 00004B8C 8A87[2C650000]      <1> 	mov	al, [edi+fd0_type]	; Drive type (0,1,2,3,4)
  2891                              <1> 	; 18/12/2014
  2892 00004B92 20C0                <1> 	and	al, al
  2893 00004B94 7507                <1> 	jnz	short gpdtc
  2894 00004B96 BB[07650000]        <1> 	mov	ebx, MD_TBL6		; 1.44 MB param. tbl. (default)
  2895 00004B9B EB05                <1>         jmp     short gpdpu
  2896                              <1> gpdtc:	
  2897 00004B9D E809FBFFFF          <1> 	call	DR_TYPE_CHECK
  2898                              <1> 	; cf = 1 -> ebx points to 1.44MB fd parameter table (default)
  2899                              <1> gpdpu:
  2900 00004BA2 891D[A4640000]      <1> 	mov	[DISK_POINTER], ebx
  2901 00004BA8 5B                  <1> 	pop	ebx
  2902                              <1> gpndc:
  2903                              <1> 	;mov	esi, [DISK_POINTER] ; 08/02/2015, si -> esi
  2904                              <1> 	; 06/08/2022
  2905 00004BA9 031D[A4640000]      <1> 	add	ebx, [DISK_POINTER]
  2906                              <1> 	;mov	ah, [esi+ebx]		; GET THE WORD
  2907 00004BAF 8A23                <1> 	mov	ah, [ebx]
  2908                              <1> 	;xchg	edx, ebx		; RESTORE BX
  2909                              <1> 	; 06/08/2022
  2910 00004BB1 5B                  <1> 	pop	ebx			; RESTORE EBX
  2911                              <1> 	;pop	esi
  2912                              <1> 	;;pop	ds
  2913 00004BB2 C3                  <1> 	retn
  2914                              <1> 
  2915                              <1> ;-------------------------------------------------------------------------------
  2916                              <1> ; MOTOR_ON
  2917                              <1> ;	TURN MOTOR ON AND WAIT FOR MOTOR START UP TIME. THE @MOTOR_COUNT
  2918                              <1> ;	IS REPLACED WITH A SUFFICIENTLY HIGH NUMBER (0FFH) TO ENSURE
  2919                              <1> ;	THAT THE MOTOR DOES NOT GO OFF DURING THE OPERATION. IF THE
  2920                              <1> ;	MOTOR NEEDED TO BE TURNED ON, THE MULTI-TASKING HOOK FUNCTION
  2921                              <1> ;	(AX=90FDH, INT 15) IS CALLED TELLING THE OPERATING SYSTEM
  2922                              <1> ;	THAT THE BIOS IS ABOUT TO WAIT FOR MOTOR START UP. IF THIS
  2923                              <1> ;	FUNCTION RETURNS WITH CY = 1, IT MEANS THAT THE MINIMUM WAIT
  2924                              <1> ;	HAS BEEN COMPLETED. AT THIS POINT A CHECK IS MADE TO ENSURE
  2925                              <1> ;	THAT THE MOTOR WASN'T TURNED OFF BY THE TIMER. IF THE HOOK DID
  2926                              <1> ;	NOT WAIT, THE WAIT FUNCTION (AH=086H) IS CALLED TO WAIT THE
  2927                              <1> ;	PRESCRIBED AMOUNT OF TIME. IF THE CARRY FLAG IS SET ON RETURN,
  2928                              <1> ;	IT MEANS THAT THE FUNCTION IS IN USE AND DID NOT PERFORM THE
  2929                              <1> ;	WAIT. A TIMER 1 WAIT LOOP WILL THEN DO THE WAIT.
  2930                              <1> ;
  2931                              <1> ; ON ENTRY:	DI = DRIVE #
  2932                              <1> ; ON EXIT:	AX,CX,DX DESTROYED
  2933                              <1> ;-------------------------------------------------------------------------------
  2934                              <1> MOTOR_ON:
  2935                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
  2936 00004BB3 53                  <1> 	push	ebx			; SAVE REG.
  2937 00004BB4 E825000000          <1> 	call	TURN_ON			; TURN ON MOTOR
  2938 00004BB9 7221                <1> 	jc	short MOT_IS_ON		; IF CY=1 NO WAIT
  2939                              <1> 	; 06/08/2022
  2940                              <1> 	;call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  2941 00004BBB E851FBFFFF          <1> 	call	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH,
  2942                              <1> 	;call	TURN_ON 		; CHECK AGAIN IF MOTOR ON
  2943                              <1> 	;jc	short MOT_IS_ON		; IF NO WAIT MEANS IT IS ON
  2944                              <1> M_WAIT:
  2945                              <1> 	;mov	dl, 10			; GET THE MOTOR WAIT PARAMETER
  2946                              <1> 	; 06/08/2022
  2947 00004BC0 B00A                <1> 	mov	al, 10
  2948 00004BC2 E8B1FFFFFF          <1> 	call	GET_PARM
  2949                              <1> 	;mov	al, ah			; AL = MOTOR WAIT PARAMETER
  2950                              <1> 	;xor	ah, ah			; AX = MOTOR WAIT PARAMETER
  2951                              <1> 	;cmp	al, 8			; SEE IF AT LEAST A SECOND IS SPECIFIED
  2952 00004BC7 80FC08              <1> 	cmp	ah, 8
  2953                              <1> 	;jae	short GP2		; IF YES, CONTINUE
  2954 00004BCA 7702                <1> 	ja	short J13
  2955                              <1> 	;mov	al, 8			; ONE SECOND WAIT FOR MOTOR START UP
  2956 00004BCC B408                <1> 	mov	ah, 8
  2957                              <1> 
  2958                              <1> ;-----	AS CONTAINS NUMBER OF 1/8 SECONDS (125000 MICROSECONDS) TO WAIT
  2959                              <1> GP2:	
  2960                              <1> ;----- 	FOLLOWING LOOPS REQUIRED WHEN RTC WAIT FUNCTION IS ALREADY IN USE
  2961                              <1> J13:					; WAIT FOR 1/8 SECOND PER (AL)
  2962                              <1> 	;mov	ecx, 8286		; COUNT FOR 1/8 SECOND AT 15.085737 US
  2963                              <1> 	; 11/04/2021
  2964 00004BCE B947100000          <1> 	mov	ecx, 4167 ; count of 30 micro seconds * (1/8) 
  2965 00004BD3 E8C6D7FFFF          <1> 	call	WAITF			; GO TO FIXED WAIT ROUTINE
  2966                              <1> 	;dec	al			; DECREMENT TIME VALUE
  2967 00004BD8 FECC                <1> 	dec	ah
  2968 00004BDA 75F2                <1> 	jnz	short J13		; ARE WE DONE YET
  2969                              <1> MOT_IS_ON:
  2970 00004BDC 5B                  <1> 	pop	ebx			; RESTORE REG.
  2971 00004BDD C3                  <1> 	retn
  2972                              <1> 
  2973                              <1> ;-------------------------------------------------------------------------------
  2974                              <1> ; TURN_ON
  2975                              <1> ;	TURN MOTOR ON AND RETURN WAIT STATE.
  2976                              <1> ;
  2977                              <1> ; ON ENTRY:	DI = DRIVE #
  2978                              <1> ;
  2979                              <1> ; ON EXIT:	CY = 0 MEANS WAIT REQUIRED
  2980                              <1> ;		CY = 1 MEANS NO WAIT REQUIRED
  2981                              <1> ;		AX,BX,CX,DX DESTROYED
  2982                              <1> ;-------------------------------------------------------------------------------
  2983                              <1> TURN_ON:
  2984 00004BDE 89FB                <1> 	mov	ebx, edi		; BX = DRIVE #
  2985 00004BE0 88D9                <1> 	mov	cl, bl			; CL = DRIVE #
  2986 00004BE2 C0C304              <1> 	rol	bl, 4			; BL = DRIVE SELECT
  2987 00004BE5 FA                  <1> 	cli				; NO INTERRUPTS WHILE DETERMINING STATUS
  2988 00004BE6 C605[0F780100]FF    <1> 	mov	byte [MOTOR_COUNT], 0FFh ; ENSURE MOTOR STAYS ON FOR OPERATION
  2989 00004BED A0[0E780100]        <1> 	mov	al, [MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
  2990 00004BF2 2430                <1> 	and	al, 00110000b		; KEEP ONLY DRIVE SELECT BITS
  2991 00004BF4 B401                <1> 	mov	ah, 1			; MASK FOR DETERMINING MOTOR BIT
  2992 00004BF6 D2E4                <1> 	shl	ah, cl			; AH = MOTOR ON, A=00000001, B=00000010
  2993                              <1> 
  2994                              <1> ;  AL = DRIVE SELECT FROM @MOTOR_STATUS
  2995                              <1> ;  BL = DRIVE SELECT DESIRED
  2996                              <1> ;  AH = MOTOR ON MASK DESIRED
  2997                              <1> 
  2998 00004BF8 38D8                <1> 	cmp	al, bl			; REQUESTED DRIVE ALREADY SELECTED ?
  2999 00004BFA 7508                <1> 	jnz	short TURN_IT_ON	; IF NOT SELECTED JUMP
  3000 00004BFC 8425[0E780100]      <1> 	test	ah, [MOTOR_STATUS]	; TEST MOTOR ON BIT
  3001 00004C02 7535                <1> 	jnz	short NO_MOT_WAIT	; JUMP IF MOTOR ON AND SELECTED
  3002                              <1> 
  3003                              <1> TURN_IT_ON:
  3004 00004C04 08DC                <1> 	or	ah, bl			; AH = DRIVE SELECT AND MOTOR ON
  3005 00004C06 8A3D[0E780100]      <1> 	mov	bh, [MOTOR_STATUS]	; SAVE COPY OF @MOTOR_STATUS BEFORE
  3006 00004C0C 80E70F              <1> 	and	bh, 00001111b		; KEEP ONLY MOTOR BITS
  3007 00004C0F 8025[0E780100]CF    <1> 	and	byte [MOTOR_STATUS], 11001111b ; CLEAR OUT DRIVE SELECT
  3008 00004C16 0825[0E780100]      <1> 	or	[MOTOR_STATUS], ah	; OR IN DRIVE SELECTED AND MOTOR ON
  3009 00004C1C A0[0E780100]        <1> 	mov	al, [MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
  3010 00004C21 88C3                <1> 	mov	bl, al			; BL=@MOTOR_STATUS AFTER, BH=BEFORE
  3011 00004C23 80E30F              <1> 	and	bl, 00001111b		; KEEP ONLY MOTOR BITS
  3012 00004C26 FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
  3013 00004C27 243F                <1> 	and	al, 00111111b		; STRIP AWAY UNWANTED BITS
  3014 00004C29 C0C004              <1> 	rol	al, 4			; PUT BITS IN DESIRED POSITIONS
  3015 00004C2C 0C0C                <1> 	or	al, 00001100b		; NO RESET, ENABLE DMA/INTERRUPT
  3016 00004C2E 66BAF203            <1> 	mov	dx, 03F2h		; SELECT DRIVE AND TURN ON MOTOR
  3017 00004C32 EE                  <1> 	out	dx, al
  3018 00004C33 38FB                <1> 	cmp	bl, bh			; NEW MOTOR TURNED ON ?
  3019                              <1> 	;jz	short NO_MOT_WAIT	; NO WAIT REQUIRED IF JUST SELECT
  3020 00004C35 7403                <1> 	je	short no_mot_w1 ; 27/02/2015 
  3021 00004C37 F8                  <1> 	clc				; (re)SET CARRY MEANING WAIT
  3022 00004C38 C3                  <1> 	retn
  3023                              <1> 
  3024                              <1> NO_MOT_WAIT:
  3025 00004C39 FB                  <1> 	sti
  3026                              <1> no_mot_w1: ; 27/02/2015
  3027 00004C3A F9                  <1> 	stc				; SET NO WAIT REQUIRED
  3028                              <1> 	;sti				; INTERRUPTS BACK ON
  3029 00004C3B C3                  <1> 	retn
  3030                              <1> 
  3031                              <1> ;-------------------------------------------------------------------------------
  3032                              <1> ; HD_WAIT
  3033                              <1> ;	WAIT FOR HEAD SETTLE TIME.
  3034                              <1> ;
  3035                              <1> ; ON ENTRY:	DI = DRIVE #
  3036                              <1> ;
  3037                              <1> ; ON EXIT:	AX,BX,CX,DX DESTROYED
  3038                              <1> ;-------------------------------------------------------------------------------
  3039                              <1> HD_WAIT:
  3040                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  3041                              <1> 	;mov	dl,9			; GET HEAD SETTLE PARAMETER
  3042                              <1> 	; 06/08/2022
  3043 00004C3C B009                <1> 	mov	al, 9
  3044 00004C3E E835FFFFFF          <1> 	call	GET_PARM
  3045 00004C43 08E4                <1> 	or	ah, ah	; 17/12/2014
  3046 00004C45 7519                <1> 	jnz	short DO_WAT
  3047 00004C47 F605[0E780100]80    <1>         test    byte [MOTOR_STATUS], 10000000b ; SEE IF A WRITE OPERATION
  3048                              <1> 	;jz	short ISNT_WRITE	; IF NOT, DO NOT ENFORCE ANY VALUES
  3049                              <1> 	;or	ah, ah			; CHECK FOR ANY WAIT?
  3050                              <1> 	;jnz	short DO_WAT		; IF THERE DO NOT ENFORCE
  3051 00004C4E 741D                <1> 	jz	short HW_DONE
  3052 00004C50 B40F                <1> 	mov	ah, HD12_SETTLE		; LOAD 1.2M HEAD SETTLE MINIMUM
  3053 00004C52 8A87[1B780100]      <1> 	mov	al, [DSK_STATE+edi]	; LOAD STATE
  3054 00004C58 24C0                <1> 	and	al, RATE_MSK		; KEEP ONLY RATE
  3055 00004C5A 3C80                <1> 	cmp	al, RATE_250		; 1.2 M DRIVE ?
  3056 00004C5C 7502                <1> 	jnz	short DO_WAT		; DEFAULT HEAD SETTLE LOADED
  3057                              <1> ;GP3:
  3058 00004C5E B414                <1> 	mov	ah, HD320_SETTLE	; USE 320/360 HEAD SETTLE
  3059                              <1> ;	jmp	short DO_WAT
  3060                              <1> 
  3061                              <1> ;ISNT_WRITE:
  3062                              <1> ;	or	ah, ah			; CHECK FOR NO WAIT
  3063                              <1> ;	jz	short HW_DONE		; IF NOT WRITE AND 0 ITS OK
  3064                              <1> 
  3065                              <1> ;-----	AH CONTAINS NUMBER OF MILLISECONDS TO WAIT
  3066                              <1> DO_WAT:
  3067                              <1> ;	mov	al, ah			; AL = # MILLISECONDS
  3068                              <1> ;	;xor	ah, ah			; AX = # MILLISECONDS
  3069                              <1> J29:					; 	1 MILLISECOND LOOP
  3070                              <1> 	;;mov	cx, WAIT_FDU_HEAD_SETTLE ; 33 ; 1 ms in 30 micro units.
  3071                              <1> 	;mov	ecx, 66			; COUNT AT 15.085737 US PER COUNT
  3072                              <1> 	; 11/04/2021
  3073                              <1> 	;mov	ecx, WAIT_FDU_HEAD_SETTLE ; 33
  3074                              <1> 	; 06/08/2022
  3075 00004C60 29C9                <1> 	sub	ecx, ecx
  3076 00004C62 B121                <1> 	mov	cl, WAIT_FDU_HEAD_SETTLE ; 33
  3077 00004C64 E835D7FFFF          <1> 	call	WAITF			; DELAY FOR 1 MILLISECOND
  3078                              <1> 	;dec	al			; DECREMENT THE COUNT
  3079 00004C69 FECC                <1> 	dec	ah
  3080 00004C6B 75F3                <1> 	jnz	short J29		; DO AL MILLISECOND # OF TIMES
  3081                              <1> HW_DONE:
  3082 00004C6D C3                  <1> 	retn
  3083                              <1> 
  3084                              <1> ;-------------------------------------------------------------------------------
  3085                              <1> ; NEC_OUTPUT
  3086                              <1> ;	THIS ROUTINE SENDS A BYTE TO THE NEC CONTROLLER AFTER TESTING
  3087                              <1> ;	FOR CORRECT DIRECTION AND CONTROLLER READY THIS ROUTINE WILL
  3088                              <1> ;	TIME OUT IF THE BYTE IS NOT ACCEPTED WITHIN A REASONABLE AMOUNT
  3089                              <1> ;	OF TIME, SETTING THE DISKETTE STATUS ON COMPLETION.
  3090                              <1> ; 
  3091                              <1> ; ON ENTRY: 	AH = BYTE TO BE OUTPUT
  3092                              <1> ;
  3093                              <1> ; ON EXIT:	CY = 0  SUCCESS
  3094                              <1> ;		CY = 1  FAILURE -- DISKETTE STATUS UPDATED
  3095                              <1> ;		        IF A FAILURE HAS OCCURRED, THE RETURN IS MADE ONE LEVEL
  3096                              <1> ;		        HIGHER THAN THE CALLER OF NEC OUTPUT. THIS REMOVES THE
  3097                              <1> ;		        REQUIREMENT OF TESTING AFTER EVERY CALL OF NEC_OUTPUT.
  3098                              <1> ;		AX,CX,DX DESTROYED
  3099                              <1> ;-------------------------------------------------------------------------------
  3100                              <1> 
  3101                              <1> ; 09/12/2014 [Erdogan Tan] 
  3102                              <1> ;	(from 'PS2 Hardware Interface Tech. Ref. May 88', Page 09-05.)
  3103                              <1> ; Diskette Drive Controller Status Register (3F4h)
  3104                              <1> ;	This read only register facilitates the transfer of data between
  3105                              <1> ;	the system microprocessor and the controller.
  3106                              <1> ; Bit 7 - When set to 1, the Data register is ready to transfer data 
  3107                              <1> ;	  with the system micrprocessor.
  3108                              <1> ; Bit 6 - The direction of data transfer. If this bit is set to 0,
  3109                              <1> ;	  the transfer is to the controller.
  3110                              <1> ; Bit 5 - When this bit is set to 1, the controller is in the non-DMA mode.
  3111                              <1> ; Bit 4 - When this bit is set to 1, a Read or Write command is being executed.
  3112                              <1> ; Bit 3 - Reserved.
  3113                              <1> ; Bit 2 - Reserved.
  3114                              <1> ; Bit 1 - When this bit is set to 1, dskette drive 1 is in the seek mode.
  3115                              <1> ; Bit 0 - When this bit is set to 1, dskette drive 1 is in the seek mode.
  3116                              <1> 
  3117                              <1> ; Data Register (3F5h)
  3118                              <1> ; This read/write register passes data, commands and parameters, and provides
  3119                              <1> ; diskette status information.
  3120                              <1>   		
  3121                              <1> NEC_OUTPUT:
  3122                              <1> 	; 09/08/2022
  3123                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
  3124                              <1> 	;
  3125                              <1> 	;push	bx			; SAVE REG.
  3126 00004C6E 66BAF403            <1> 	mov	dx, 03F4h		; STATUS PORT
  3127                              <1> 	;mov	bl,2			; HIGH ORDER COUNTER
  3128                              <1> 	;xor	cx, cx			; COUNT FOR TIME OUT
  3129                              <1> 	; 16/12/2014
  3130                              <1> 	; waiting for (max.) 0.5 seconds
  3131                              <1>         ;;mov	byte [wait_count], 0 ;; 27/02/2015
  3132                              <1> 	;
  3133                              <1> 	; 17/12/2014
  3134                              <1> 	; Modified from AWARD BIOS 1999 - ADISK.ASM - SEND_COMMAND
  3135                              <1> 	;
  3136                              <1> 	;WAIT_FOR_PORT:	Waits for a bit at a port pointed to by DX to
  3137                              <1> 	;		go on.
  3138                              <1> 	;INPUT:
  3139                              <1> 	;	AH=Mask for isolation bits.
  3140                              <1> 	;	AL=pattern to look for.
  3141                              <1> 	;	DX=Port to test for
  3142                              <1> 	;	BH:CX=Number of memory refresh periods to delay.
  3143                              <1> 	;	     (normally 30 microseconds per period.)
  3144                              <1> 	;
  3145                              <1> 	;WFP_SHORT:  
  3146                              <1> 	;	Wait for port if refresh cycle is short (15-80 Us range).
  3147                              <1> 	;
  3148                              <1> 
  3149                              <1> ;	mov	bl, WAIT_FDU_SEND_HI+1	; 0+1
  3150                              <1> ;	mov	cx, WAIT_FDU_SEND_LO	; 16667
  3151 00004C72 B91B410000          <1> 	mov	ecx, WAIT_FDU_SEND_LH   ; 16667 (27/02/2015)
  3152                              <1> ;
  3153                              <1> ;WFPS_OUTER_LP:
  3154                              <1> ;	;
  3155                              <1> ;WFPS_CHECK_PORT:
  3156                              <1> J23:
  3157 00004C77 EC                  <1> 	in	al, dx			; GET STATUS
  3158 00004C78 24C0                <1> 	and	al, 11000000b		; KEEP STATUS AND DIRECTION
  3159 00004C7A 3C80                <1> 	cmp	al, 10000000b		; STATUS 1 AND DIRECTION 0 ?
  3160 00004C7C 7418                <1> 	jz	short J27		; STATUS AND DIRECTION OK
  3161                              <1> WFPS_HI:
  3162 00004C7E E461                <1> 	in	al, PORT_B  ; 061h	; SYS1	; wait for hi to lo
  3163 00004C80 A810                <1> 	test	al, 010h		; transition on memory
  3164 00004C82 75FA                <1> 	jnz	short WFPS_HI		; refresh.
  3165                              <1> WFPS_LO:
  3166 00004C84 E461                <1> 	in	al, PORT_B		; SYS1
  3167 00004C86 A810                <1> 	test	al, 010h
  3168 00004C88 74FA                <1> 	jz	short WFPS_LO
  3169                              <1> 	;loop	short WFPS_CHECK_PORT
  3170 00004C8A E2EB                <1> 	loop	J23	; 27/02/2015
  3171                              <1> ;	;
  3172                              <1> ;	dec	bl
  3173                              <1> ;	jnz	short WFPS_OUTER_LP
  3174                              <1> ;	jmp	short WFPS_TIMEOUT	; fail
  3175                              <1> ;J23:
  3176                              <1> ;	in	al, dx			; GET STATUS
  3177                              <1> ;	and	al, 11000000b		; KEEP STATUS AND DIRECTION
  3178                              <1> ;	cmp	al, 10000000b		; STATUS 1 AND DIRECTION 0 ?
  3179                              <1> ;	jz	short J27		; STATUS AND DIRECTION OK
  3180                              <1> 	;loop	J23			; CONTINUE TILL CX EXHAUSTED
  3181                              <1> 	;dec	bl			; DECREMENT COUNTER
  3182                              <1> 	;jnz	short J23		; REPEAT TILL DELAY FINISHED, CX = 0
  3183                              <1>    
  3184                              <1> 	;;27/02/2015
  3185                              <1> 	;16/12/2014
  3186                              <1>         ;;cmp	byte [wait_count], 10   ; (10/18.2 seconds)
  3187                              <1> 	;;jb	short J23
  3188                              <1> 
  3189                              <1> ;WFPS_TIMEOUT:
  3190                              <1> 
  3191                              <1> ;-----	FALL THRU TO ERROR RETURN
  3192                              <1> 
  3193 00004C8C 800D[10780100]80    <1> 	or	byte [DSKETTE_STATUS], TIME_OUT
  3194                              <1> 	;pop	bx			; RESTORE REG.
  3195 00004C93 58                  <1> 	pop	eax ; 08/02/2015	; DISCARD THE RETURN ADDRESS
  3196 00004C94 F9                  <1> 	stc				; INDICATE ERROR TO CALLER
  3197 00004C95 C3                  <1> 	retn
  3198                              <1> 
  3199                              <1> ;-----	DIRECTION AND STATUS OK; OUTPUT BYTE
  3200                              <1> 
  3201                              <1> J27:	
  3202 00004C96 88E0                <1> 	mov	al, ah			; GET BYTE TO OUTPUT
  3203                              <1> 	;inc	dx			; DATA PORT = STATUS PORT + 1
  3204                              <1> 	; 06/08/2022
  3205 00004C98 FEC2                <1> 	inc	dl
  3206 00004C9A EE                  <1> 	out	dx, al			; OUTPUT THE BYTE
  3207                              <1> 	;;NEWIODELAY  ;; 27/02/2015
  3208                              <1> 	; 27/02/2015
  3209                              <1> 	;pushf				; SAVE FLAGS
  3210                              <1> 	; 09/08/2022
  3211                              <1> 	; cf = 0, zf = 1
  3212                              <1> 	;mov	ecx, 3			; 30 TO 45 MICROSECONDS WAIT FOR
  3213                              <1> 	; 11/04/2021
  3214                              <1> 	;mov	ecx, 2 
  3215                              <1> 	; 06/08/2022
  3216 00004C9B 29C9                <1> 	sub	ecx, ecx
  3217 00004C9D B102                <1> 	mov	cl, 2
  3218 00004C9F E8FAD6FFFF          <1> 	call 	WAITF			; NEC FLAGS UPDATE CYCLE
  3219                              <1> 	; 09/08/2022
  3220                              <1> 	; cf = 0, zf = 1
  3221                              <1> 	;popf				; RESTORE FLAGS FOR EXIT
  3222                              <1> 	;pop	bx			; RESTORE REG
  3223 00004CA4 C3                  <1> 	retn				; CY = 0 FROM TEST INSTRUCTION
  3224                              <1> 
  3225                              <1> ;-------------------------------------------------------------------------------
  3226                              <1> ; SEEK
  3227                              <1> ;	THIS ROUTINE WILL MOVE THE HEAD ON THE NAMED DRIVE TO THE NAMED
  3228                              <1> ;	TRACK. IF THE DRIVE HAS NOT BEEN ACCESSED SINCE THE DRIVE
  3229                              <1> ;	RESET COMMAND WAS ISSUED, THE DRIVE WILL BE RECALIBRATED.
  3230                              <1> ;
  3231                              <1> ; ON ENTRY:	DI = DRIVE #
  3232                              <1> ;		CH = TRACK #
  3233                              <1> ;
  3234                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  3235                              <1> ;		AX,BX,CX DX DESTROYED
  3236                              <1> ;-------------------------------------------------------------------------------
  3237                              <1> SEEK:
  3238 00004CA5 89FB                <1> 	mov	ebx, edi		; BX = DRIVE #
  3239 00004CA7 B001                <1> 	mov	al, 1			; ESTABLISH MASK FOR RECALIBRATE TEST
  3240                              <1> 	; 06/08/2022
  3241                              <1> 	;xchg	cl, bl			; SET DRIVE VALUE INTO CL
  3242                              <1> 	;rol	al, cl			; SHIFT MASK BY THE DRIVE VALUE
  3243                              <1> 	;xchg	cl, bl			; RECOVER TRACK VALUE
  3244                              <1> 	; 06/08/2022
  3245 00004CA9 84C3                <1> 	test	bl, al ; test bl, 1
  3246 00004CAB 7402                <1> 	jz	short seek_0
  3247 00004CAD FEC0                <1> 	inc	al ; shl al, 1
  3248                              <1> seek_0:
  3249 00004CAF 8405[0D780100]      <1> 	test	al, [SEEK_STATUS]	; TEST FOR RECALIBRATE REQUIRED
  3250 00004CB5 7526                <1> 	jnz	short J28A		; JUMP IF RECALIBRATE NOT REQUIRED
  3251                              <1> 
  3252 00004CB7 0805[0D780100]      <1> 	or	[SEEK_STATUS], al	; TURN ON THE NO RECALIBRATE BIT IN FLAG
  3253 00004CBD E862000000          <1> 	call	RECAL			; RECALIBRATE DRIVE
  3254 00004CC2 730E                <1> 	jnc	short AFT_RECAL		; RECALIBRATE DONE
  3255                              <1> 
  3256                              <1> ;-----	ISSUE RECALIBRATE FOR 80 TRACK DISKETTES
  3257                              <1> 
  3258 00004CC4 C605[10780100]00    <1> 	mov	byte [DSKETTE_STATUS], 0 ; CLEAR OUT INVALID STATUS
  3259 00004CCB E854000000          <1> 	call	RECAL			; RECALIBRATE DRIVE
  3260 00004CD0 7251                <1> 	jc	short RB		; IF RECALIBRATE FAILS TWICE THEN ERROR
  3261                              <1> 
  3262                              <1> AFT_RECAL:
  3263 00004CD2 C687[1D780100]00    <1>         mov     byte [DSK_TRK+edi], 0	; SAVE NEW CYLINDER AS PRESENT POSITION
  3264 00004CD9 08ED                <1> 	or	ch, ch			; CHECK FOR SEEK TO TRACK 0
  3265 00004CDB 743F                <1> 	jz	short DO_WAIT		; HEAD SETTLE, CY = 0 IF JUMP
  3266                              <1> 
  3267                              <1> ;-----	DRIVE IS IN SYNCHRONIZATION WITH CONTROLLER, SEEK TO TRACK
  3268                              <1> 
  3269 00004CDD F687[1B780100]20    <1> J28A:	test	byte [DSK_STATE+edi], DBL_STEP ; CHECK FOR DOUBLE STEP REQUIRED
  3270 00004CE4 7402                <1> 	jz	short _R7		; SINGLE STEP REQUIRED BYPASS DOUBLE
  3271 00004CE6 D0E5                <1> 	shl	ch, 1			; DOUBLE NUMBER OF STEP TO TAKE
  3272                              <1> 
  3273 00004CE8 3AAF[1D780100]      <1> _R7:	cmp	ch, [DSK_TRK+edi]	; SEE IF ALREADY AT THE DESIRED TRACK
  3274 00004CEE 7433                <1> 	je	short RB		; IF YES, DO NOT NEED TO SEEK
  3275                              <1> 
  3276 00004CF0 BA[234D0000]        <1> 	mov	edx, NEC_ERR		; LOAD RETURN ADDRESS
  3277 00004CF5 52                  <1> 	push	edx ; (*)		; ON STACK FOR NEC OUTPUT ERROR
  3278 00004CF6 88AF[1D780100]      <1> 	mov	[DSK_TRK+edi], ch	; SAVE NEW CYLINDER AS PRESENT POSITION
  3279 00004CFC B40F                <1> 	mov	ah, 0Fh			; SEEK COMMAND TO NEC
  3280 00004CFE E86BFFFFFF          <1> 	call	NEC_OUTPUT
  3281 00004D03 89FB                <1> 	mov	ebx, edi		; BX = DRIVE #
  3282 00004D05 88DC                <1> 	mov	ah, bl			; OUTPUT DRIVE NUMBER
  3283 00004D07 E862FFFFFF          <1> 	call	NEC_OUTPUT
  3284 00004D0C 8AA7[1D780100]      <1> 	mov	ah, [DSK_TRK+edi]	; GET CYLINDER NUMBER
  3285 00004D12 E857FFFFFF          <1> 	call	NEC_OUTPUT
  3286 00004D17 E827000000          <1> 	call	CHK_STAT_2		; ENDING INTERRUPT AND SENSE STATUS
  3287                              <1> 
  3288                              <1> ;-----	WAIT FOR HEAD SETTLE
  3289                              <1> 
  3290                              <1> DO_WAIT:
  3291 00004D1C 9C                  <1> 	pushf				; SAVE STATUS
  3292 00004D1D E81AFFFFFF          <1> 	call	HD_WAIT			; WAIT FOR HEAD SETTLE TIME
  3293 00004D22 9D                  <1> 	popf				; RESTORE STATUS
  3294                              <1> RB:
  3295                              <1> NEC_ERR:
  3296                              <1> 	; 08/02/2015 (code trick here from original IBM PC/AT DISKETTE.ASM)
  3297                              <1> 	; (*) nec_err -> retn (push edx -> pop edx) -> nec_err -> retn
  3298 00004D23 C3                  <1> 	retn				; RETURN TO CALLER
  3299                              <1> 
  3300                              <1> ;-------------------------------------------------------------------------------
  3301                              <1> ; RECAL
  3302                              <1> ;	RECALIBRATE DRIVE
  3303                              <1> ;
  3304                              <1> ; ON ENTRY:	DI = DRIVE #
  3305                              <1> ;
  3306                              <1> ; ON EXIT:	CY REFLECTS STATUS OF OPERATION.
  3307                              <1> ;-------------------------------------------------------------------------------
  3308                              <1> RECAL:
  3309                              <1> 	;push	cx
  3310                              <1> 	; 11/04/2021
  3311 00004D24 51                  <1> 	push	ecx
  3312 00004D25 B8[414D0000]        <1> 	mov	eax, RC_BACK		; LOAD NEC_OUTPUT ERROR
  3313 00004D2A 50                  <1> 	push	eax
  3314 00004D2B B407                <1> 	mov	ah, 07h			; RECALIBRATE COMMAND
  3315 00004D2D E83CFFFFFF          <1> 	call	NEC_OUTPUT
  3316 00004D32 89FB                <1> 	mov	ebx, edi		; BX = DRIVE #
  3317 00004D34 88DC                <1> 	mov	ah, bl
  3318 00004D36 E833FFFFFF          <1> 	call	NEC_OUTPUT		; OUTPUT THE DRIVE NUMBER
  3319 00004D3B E803000000          <1> 	call	CHK_STAT_2		; GET THE INTERRUPT AND SENSE INT STATUS
  3320 00004D40 58                  <1> 	pop	eax			; THROW AWAY ERROR
  3321                              <1> RC_BACK:
  3322                              <1> 	;pop	cx
  3323                              <1> 	; 11/04/2021
  3324 00004D41 59                  <1> 	pop	ecx
  3325 00004D42 C3                  <1> 	retn
  3326                              <1> 
  3327                              <1> ;-------------------------------------------------------------------------------
  3328                              <1> ; CHK_STAT_2
  3329                              <1> ;	THIS ROUTINE HANDLES THE INTERRUPT RECEIVED AFTER RECALIBRATE,
  3330                              <1> ;	OR SEEK TO THE ADAPTER. THE INTERRUPT IS WAITED FOR, THE
  3331                              <1> ;	INTERRUPT STATUS SENSED, AND THE RESULT RETURNED TO THE CALLER.
  3332                              <1> ;
  3333                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  3334                              <1> ;-------------------------------------------------------------------------------
  3335                              <1> CHK_STAT_2:
  3336 00004D43 B8[6B4D0000]        <1>         mov     eax, CS_BACK            ; LOAD NEC_OUTPUT ERROR ADDRESS
  3337 00004D48 50                  <1> 	push	eax
  3338 00004D49 E828000000          <1> 	call	WAIT_INT		; WAIT FOR THE INTERRUPT
  3339 00004D4E 721A                <1> 	jc	short J34		; IF ERROR, RETURN IT
  3340 00004D50 B408                <1> 	mov	ah, 08h			; SENSE INTERRUPT STATUS COMMAND
  3341 00004D52 E817FFFFFF          <1> 	call	NEC_OUTPUT
  3342 00004D57 E849000000          <1> 	call	RESULTS			; READ IN THE RESULTS
  3343 00004D5C 720C                <1> 	jc	short J34
  3344 00004D5E A0[11780100]        <1> 	mov	al, [NEC_STATUS]	; GET THE FIRST STATUS BYTE
  3345 00004D63 2460                <1> 	and	al, 01100000B		; ISOLATE THE BITS
  3346 00004D65 3C60                <1> 	cmp	al, 01100000B		; TEST FOR CORRECT VALUE
  3347 00004D67 7403                <1> 	jz	short J35		; IF ERROR, GO MARK IT
  3348 00004D69 F8                  <1> 	clc				; GOOD RETURN
  3349                              <1> J34:
  3350 00004D6A 58                  <1> 	pop	eax			; THROW AWAY ERROR RETURN
  3351                              <1> CS_BACK:
  3352 00004D6B C3                  <1> 	retn
  3353                              <1> J35:
  3354 00004D6C 800D[10780100]40    <1> 	or	byte [DSKETTE_STATUS], BAD_SEEK
  3355 00004D73 F9                  <1> 	stc				; ERROR RETURN CODE
  3356 00004D74 EBF4                <1> 	jmp	short J34
  3357                              <1> 
  3358                              <1> ;-------------------------------------------------------------------------------
  3359                              <1> ; WAIT_INT
  3360                              <1> ;	THIS ROUTINE WAITS FOR AN INTERRUPT TO OCCUR A TIME OUT ROUTINE
  3361                              <1> ;	TAKES PLACE DURING THE WAIT, SO THAT AN ERROR MAY BE RETURNED
  3362                              <1> ;	IF THE DRIVE IS NOT READY.
  3363                              <1> ;
  3364                              <1> ; ON EXIT: 	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  3365                              <1> ;-------------------------------------------------------------------------------
  3366                              <1> 
  3367                              <1> ; 17/12/2014
  3368                              <1> ; 2.5 seconds waiting !
  3369                              <1> ;(AWARD BIOS - 1999, WAIT_FDU_INT_LOW, WAIT_FDU_INT_HI)
  3370                              <1> ; amount of time to wait for completion interrupt from NEC.
  3371                              <1> 
  3372                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  3373                              <1> WAIT_INT:
  3374 00004D76 FB                  <1> 	sti				; TURN ON INTERRUPTS, JUST IN CASE
  3375                              <1> 	; 06/08/2022
  3376                              <1> 	;clc				; CLEAR TIMEOUT INDICATOR
  3377                              <1> 	;
  3378                              <1> 	;mov	bl, 10			; CLEAR THE COUNTERS
  3379                              <1> 	;xor	cx, cx			; FOR 2 SECOND WAIT
  3380                              <1> 
  3381                              <1> 	; Modification from AWARD BIOS - 1999 (ATORGS.ASM, WAIT
  3382                              <1> 	;
  3383                              <1> 	;WAIT_FOR_MEM:	
  3384                              <1> 	;	Waits for a bit at a specified memory location pointed
  3385                              <1> 	;	to by ES:[DI] to become set.
  3386                              <1> 	;INPUT:
  3387                              <1> 	;	AH= Mask to test with.
  3388                              <1> 	;	ES:[DI] = memory location to watch.
  3389                              <1> 	;	BH:CX= Number of memory refresh periods to delay.
  3390                              <1> 	;	     (normally 30 microseconds per period.)
  3391                              <1> 
  3392                              <1> 	; waiting for (max.) 2.5 secs in 30 micro units.
  3393                              <1> ;	mov 	cx, WAIT_FDU_INT_LO		; 017798
  3394                              <1> ;;	mov 	bl, WAIT_FDU_INT_HI
  3395                              <1> ;	mov 	bl, WAIT_FDU_INT_HI + 1
  3396                              <1> 	; 27/02/2015
  3397 00004D77 B986450100          <1> 	mov 	ecx, WAIT_FDU_INT_LH	; 83334 (2.5 seconds)		
  3398                              <1> WFMS_CHECK_MEM:
  3399 00004D7C F605[0D780100]80    <1> 	test	byte [SEEK_STATUS], INT_FLAG
  3400                              <1> 					; TEST FOR INTERRUPT OCCURRING
  3401 00004D83 7516                <1>         jnz     short J37
  3402                              <1> WFMS_HI:
  3403 00004D85 E461                <1> 	in	al, PORT_B  ; 061h	; SYS1, wait for lo to hi
  3404 00004D87 A810                <1> 	test	al, 010h		; transition on memory
  3405 00004D89 75FA                <1> 	jnz	short WFMS_HI		; refresh.
  3406                              <1> WFMS_LO:
  3407 00004D8B E461                <1> 	in	al, PORT_B		; SYS1
  3408 00004D8D A810                <1> 	test	al, 010h
  3409 00004D8F 74FA                <1> 	jz	short WFMS_LO
  3410 00004D91 E2E9                <1>         loop	WFMS_CHECK_MEM
  3411                              <1> 
  3412                              <1> ;WFMS_OUTER_LP:
  3413                              <1> ;;	or	bl, bl			; check outer counter
  3414                              <1> ;;	jz	short J36A		; WFMS_TIMEOUT
  3415                              <1> ;	dec	bl
  3416                              <1> ;	jz	short J36A	
  3417                              <1> ;	jmp	short WFMS_CHECK_MEM
  3418                              <1> 
  3419                              <1> 	; 17/12/2014
  3420                              <1> 	; 16/12/2014
  3421                              <1> ;	mov	byte [wait_count], 0	; Reset (INT 08H) counter
  3422                              <1> ;J36:
  3423                              <1> ;	test	byte [SEEK_STATUS], INT_FLAG
  3424                              <1> ;					; TEST FOR INTERRUPT OCCURRING
  3425                              <1> ;	jnz	short J37
  3426                              <1> 
  3427                              <1> 	; 16/12/2014
  3428                              <1> 	;loop	J36			; COUNT DOWN WHILE WAITING
  3429                              <1> 	;dec	bl			; SECOND LEVEL COUNTER
  3430                              <1> 	;jnz	short J36
  3431                              <1> ;       cmp     byte [wait_count], 46   ; (46/18.2 seconds)
  3432                              <1> ;	jb	short J36
  3433                              <1> 
  3434                              <1> ;WFMS_TIMEOUT:
  3435                              <1> ;J36A:
  3436 00004D93 800D[10780100]80    <1> 	or	byte [DSKETTE_STATUS], TIME_OUT ; NOTHING HAPPENED
  3437 00004D9A F9                  <1> 	stc				; ERROR RETURN
  3438                              <1> J37:
  3439 00004D9B 9C                  <1> 	pushf				; SAVE CURRENT CARRY
  3440 00004D9C 8025[0D780100]7F    <1> 	and	byte [SEEK_STATUS], ~INT_FLAG ; TURN OFF INTERRUPT FLAG
  3441 00004DA3 9D                  <1> 	popf				; RECOVER CARRY
  3442 00004DA4 C3                  <1> 	retn				; GOOD RETURN CODE
  3443                              <1> 
  3444                              <1> ;-------------------------------------------------------------------------------
  3445                              <1> ; RESULTS
  3446                              <1> ;	THIS ROUTINE WILL READ ANYTHING THAT THE NEC CONTROLLER RETURNS 
  3447                              <1> ;	FOLLOWING AN INTERRUPT.
  3448                              <1> ;
  3449                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  3450                              <1> ;		AX,BX,CX,DX DESTROYED
  3451                              <1> ;-------------------------------------------------------------------------------
  3452                              <1> RESULTS:
  3453                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  3454 00004DA5 57                  <1> 	push	edi
  3455 00004DA6 BF[11780100]        <1> 	mov	edi, NEC_STATUS		; POINTER TO DATA AREA
  3456 00004DAB B307                <1> 	mov	bl, 7			; MAX STATUS BYTES
  3457 00004DAD 66BAF403            <1> 	mov	dx, 03F4h		; STATUS PORT
  3458                              <1> 
  3459                              <1> ;-----	WAIT FOR REQUEST FOR MASTER
  3460                              <1> 
  3461                              <1> _R10: 
  3462                              <1> 	; 16/12/2014
  3463                              <1> 	; wait for (max) 0.5 seconds
  3464                              <1> 	;mov	bh, 2			; HIGH ORDER COUNTER
  3465                              <1> 	;xor	cx, cx			; COUNTER
  3466                              <1> 
  3467                              <1> 	;Time to wait while waiting for each byte of NEC results = .5
  3468                              <1> 	;seconds.  .5 seconds = 500,000 micros.  500,000/30 = 16,667.
  3469                              <1> 	; 27/02/2015
  3470 00004DB1 B91B410000          <1> 	mov 	ecx, WAIT_FDU_RESULTS_LH ; 16667  
  3471                              <1> 	;mov	cx, WAIT_FDU_RESULTS_LO  ; 16667
  3472                              <1> 	;mov	bh, WAIT_FDU_RESULTS_HI+1 ; 0+1
  3473                              <1> 
  3474                              <1> WFPSR_OUTER_LP:
  3475                              <1> 	;
  3476                              <1> WFPSR_CHECK_PORT:
  3477                              <1> J39:					; WAIT FOR MASTER
  3478 00004DB6 EC                  <1> 	in	al, dx			; GET STATUS
  3479 00004DB7 24C0                <1> 	and	al, 11000000b		; KEEP ONLY STATUS AND DIRECTION
  3480 00004DB9 3CC0                <1> 	cmp	al, 11000000b		; STATUS 1 AND DIRECTION 1 ?
  3481 00004DBB 7418                <1> 	jz	short J42		; STATUS AND DIRECTION OK
  3482                              <1> WFPSR_HI:
  3483 00004DBD E461                <1> 	in	al, PORT_B	; 061h	; SYS1	; wait for hi to lo
  3484 00004DBF A810                <1> 	test	al, 010h		; transition on memory
  3485 00004DC1 75FA                <1> 	jnz	short WFPSR_HI		; refresh.
  3486                              <1> WFPSR_LO:
  3487 00004DC3 E461                <1> 	in	al, PORT_B		; SYS1
  3488 00004DC5 A810                <1> 	test	al, 010h
  3489 00004DC7 74FA                <1> 	jz	SHORT WFPSR_LO
  3490 00004DC9 E2EB                <1> 	loop	WFPSR_CHECK_PORT
  3491                              <1> 
  3492                              <1> 	;; 27/02/2015
  3493                              <1> 	;;dec	bh
  3494                              <1> 	;;jnz	short WFPSR_OUTER_LP
  3495                              <1> 	;jmp	short WFPSR_TIMEOUT	; fail
  3496                              <1> 
  3497                              <1> 	;;mov	byte [wait_count], 0
  3498                              <1> ;J39:					; WAIT FOR MASTER
  3499                              <1> ;	in	al, dx			; GET STATUS
  3500                              <1> ;	and	al, 11000000b		; KEEP ONLY STATUS AND DIRECTION
  3501                              <1> ;	cmp	al, 11000000b		; STATUS 1 AND DIRECTION 1 ?
  3502                              <1> ;	jz	short J42		; STATUS AND DIRECTION OK
  3503                              <1> 	;loop	J39			; LOOP TILL TIMEOUT
  3504                              <1> 	;dec	bh			; DECREMENT HIGH ORDER COUNTER
  3505                              <1> 	;jnz	short J39		; REPEAT TILL DELAY DONE
  3506                              <1> 	;
  3507                              <1> 	;;cmp	byte [wait_count], 10  ; (10/18.2 seconds)
  3508                              <1> 	;;jb	short J39	
  3509                              <1> 
  3510                              <1> ;WFPSR_TIMEOUT:
  3511 00004DCB 800D[10780100]80    <1> 	or	byte [DSKETTE_STATUS], TIME_OUT
  3512 00004DD2 F9                  <1> 	stc				; SET ERROR RETURN
  3513 00004DD3 EB28                <1> 	jmp	short POPRES		; POP REGISTERS AND RETURN
  3514                              <1> 
  3515                              <1> ;-----	READ IN THE STATUS
  3516                              <1> 
  3517                              <1> J42:
  3518 00004DD5 EB00                <1> 	jmp	$+2			; I/O DELAY
  3519                              <1> 	;inc	dx			; POINT AT DATA PORT
  3520                              <1> 	; 06/08/2022
  3521 00004DD7 FEC2                <1> 	inc	dl
  3522 00004DD9 EC                  <1> 	in	al, dx			; GET THE DATA
  3523                              <1> 	; 16/12/2014
  3524                              <1> 	NEWIODELAY
    83 00004DDA E6EB                <2>  out 0EBh, al
  3525 00004DDC 8807                <1>         mov     [edi], al		; STORE THE BYTE
  3526 00004DDE 47                  <1> 	inc	edi			; INCREMENT THE POINTER
  3527                              <1> 
  3528                              <1> 	; 16/12/2014
  3529                              <1> ;	push	cx
  3530                              <1> ;	mov	cx, 30
  3531                              <1> ;wdw2:
  3532                              <1> ;	NEWIODELAY
  3533                              <1> ;	loop	wdw2
  3534                              <1> ;	pop	cx
  3535                              <1> 
  3536                              <1> 	;;mov	ecx, 3			; MINIMUM 24 MICROSECONDS FOR NEC
  3537                              <1> 	; 11/04/2021
  3538                              <1> 	;mov	ecx, 2
  3539                              <1> 	; 06/08/2022
  3540 00004DDF 29C9                <1> 	sub	ecx, ecx
  3541 00004DE1 B102                <1> 	mov	cl, 2
  3542 00004DE3 E8B6D5FFFF          <1> 	call	WAITF			; WAIT 30 TO 45 MICROSECONDS
  3543                              <1> 	;dec	dx			; POINT AT STATUS PORT
  3544                              <1> 	; 06/08/2022
  3545 00004DE8 FECA                <1> 	dec	dl
  3546 00004DEA EC                  <1> 	in	al, dx			; GET STATUS
  3547                              <1> 	; 16/12/2014
  3548                              <1> 	NEWIODELAY
    83 00004DEB E6EB                <2>  out 0EBh, al
  3549                              <1> 	;
  3550 00004DED A810                <1> 	test	al, 00010000b		; TEST FOR NEC STILL BUSY
  3551 00004DEF 740C                <1> 	jz	short POPRES		; RESULTS DONE ?
  3552                              <1> 
  3553 00004DF1 FECB                <1> 	dec	bl			; DECREMENT THE STATUS COUNTER
  3554 00004DF3 75BC                <1>         jnz     short _R10              ; GO BACK FOR MORE
  3555 00004DF5 800D[10780100]20    <1> 	or	byte [DSKETTE_STATUS], BAD_NEC ; TOO MANY STATUS BYTES
  3556 00004DFC F9                  <1> 	stc				; SET ERROR FLAG
  3557                              <1> 
  3558                              <1> ;-----	RESULT OPERATION IS DONE
  3559                              <1> POPRES:
  3560 00004DFD 5F                  <1> 	pop	edi
  3561 00004DFE C3                  <1> 	retn				; RETURN WITH CARRY SET
  3562                              <1> 
  3563                              <1> ;-------------------------------------------------------------------------------
  3564                              <1> ; READ_DSKCHNG
  3565                              <1> ;	READS THE STATE OF THE DISK CHANGE LINE.
  3566                              <1> ;
  3567                              <1> ; ON ENTRY:	DI = DRIVE #
  3568                              <1> ;
  3569                              <1> ; ON EXIT:	DI = DRIVE #
  3570                              <1> ;		ZF = 0 : DISK CHANGE LINE INACTIVE
  3571                              <1> ;		ZF = 1 : DISK CHANGE LINE ACTIVE
  3572                              <1> ;		AX,CX,DX DESTROYED
  3573                              <1> ;-------------------------------------------------------------------------------
  3574                              <1> READ_DSKCHNG:
  3575 00004DFF E8AFFDFFFF          <1> 	call	MOTOR_ON		; TURN ON THE MOTOR IF OFF
  3576 00004E04 66BAF703            <1> 	mov	dx, 03F7h		; ADDRESS DIGITAL INPUT REGISTER
  3577 00004E08 EC                  <1> 	in	al, dx			; INPUT DIGITAL INPUT REGISTER
  3578 00004E09 A880                <1> 	test	al, DSK_CHG		; CHECK FOR DISK CHANGE LINE ACTIVE
  3579 00004E0B C3                  <1> 	retn				; RETURN TO CALLER WITH ZERO FLAG SET
  3580                              <1> 
  3581                              <1> fdc_int:  
  3582                              <1> 	  ; 30/07/2015	
  3583                              <1> 	  ; 16/02/2015
  3584                              <1> ;int_0Eh: ; 11/12/2014
  3585                              <1> 
  3586                              <1> ;--- HARDWARE INT 0EH -- ( IRQ LEVEL 6 ) ---------------------------------------
  3587                              <1> ; DISK_INT
  3588                              <1> ;	THIS ROUTINE HANDLES THE DISKETTE INTERRUPT.
  3589                              <1> ;
  3590                              <1> ; ON EXIT:	THE INTERRUPT FLAG IS SET IN @SEEK_STATUS.
  3591                              <1> ;-------------------------------------------------------------------------------
  3592                              <1> DISK_INT_1:
  3593                              <1> 	;push	AX			; SAVE WORK REGISTER
  3594                              <1> 	; 11/04/2021
  3595 00004E0C 50                  <1> 	push	eax
  3596 00004E0D 1E                  <1> 	push	ds
  3597 00004E0E 66B81000            <1> 	mov	ax, KDATA
  3598 00004E12 8ED8                <1> 	mov 	ds, ax
  3599 00004E14 800D[0D780100]80    <1>         or	byte [SEEK_STATUS], INT_FLAG ; TURN ON INTERRUPT OCCURRED
  3600 00004E1B B020                <1> 	mov     al, EOI			; END OF INTERRUPT MARKER
  3601 00004E1D E620                <1> 	out	INTA00, al		; INTERRUPT CONTROL PORT
  3602 00004E1F 1F                  <1> 	pop	ds
  3603                              <1> 	;pop	ax			; RECOVER REGISTER
  3604                              <1> 	; 11/04/2021
  3605 00004E20 58                  <1> 	pop	eax
  3606 00004E21 CF                  <1> 	iretd				; RETURN FROM INTERRUPT
  3607                              <1> 
  3608                              <1> ;-------------------------------------------------------------------------------
  3609                              <1> ; DSKETTE_SETUP
  3610                              <1> ;	THIS ROUTINE DOES A PRELIMINARY CHECK TO SEE WHAT TYPE OF
  3611                              <1> ;	DISKETTE DRIVES ARE ATTACH TO THE SYSTEM.
  3612                              <1> ;-------------------------------------------------------------------------------
  3613                              <1> 
  3614                              <1> ; 09/08/2022 - TRDOS 386 Kernel v2.0.5
  3615                              <1> ; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  3616                              <1> 
  3617                              <1> DSKETTE_SETUP:
  3618                              <1> 	;push	ax			; SAVE REGISTERS
  3619                              <1> 	;push	bx
  3620                              <1> 	;push	cx
  3621 00004E22 52                  <1> 	push	edx
  3622                              <1> 	;push	di
  3623                              <1> 	;;push	ds
  3624                              <1> 	; 14/12/2014
  3625                              <1> 	;mov	word [DISK_POINTER], MD_TBL6
  3626                              <1> 	;mov	[DISK_POINTER+2], cs
  3627                              <1> 	;
  3628                              <1> 	;or	byte [RTC_WAIT_FLAG], 1	; NO RTC WAIT, FORCE USE OF LOOP
  3629 00004E23 31FF                <1> 	xor	edi, edi		; INITIALIZE DRIVE POINTER
  3630                              <1> 	; 09/08/2022
  3631                              <1> 	;mov	esi, eax
  3632 00004E25 31C0                <1> 	xor	eax, eax ; eax = 0
  3633 00004E27 66A3[1B780100]      <1> 	mov	[DSK_STATE], ax		; INITIALIZE STATES
  3634 00004E2D 8025[18780100]33    <1> 	and	byte [LASTRATE], ~(STRT_MSK+SEND_MSK) ; CLEAR START & SEND
  3635 00004E34 800D[18780100]C0    <1> 	or	byte [LASTRATE], SEND_MSK ; INITIALIZE SENT TO IMPOSSIBLE
  3636 00004E3B A2[0D780100]        <1> 	mov	[SEEK_STATUS], al	; INDICATE RECALIBRATE NEEDED
  3637 00004E40 A2[0F780100]        <1> 	mov	[MOTOR_COUNT], al	; INITIALIZE MOTOR COUNT
  3638 00004E45 A2[0E780100]        <1> 	mov	[MOTOR_STATUS], al	; INITIALIZE DRIVES TO OFF STATE
  3639 00004E4A A2[10780100]        <1> 	mov	[DSKETTE_STATUS], al	; NO ERRORS
  3640                              <1> 	;
  3641                              <1> 	; 28/02/2015
  3642                              <1> 	;mov	word [cfd], 100h 
  3643 00004E4F E821F4FFFF          <1> 	call	DSK_RESET
  3644 00004E54 5A                  <1> 	pop	edx
  3645 00004E55 F8                  <1> 	clc	; 29/05/2016
  3646 00004E56 C3                  <1> 	retn
  3647                              <1> 
  3648                              <1> ;SUP0:
  3649                              <1> ;	call	DRIVE_DET		; DETERMINE DRIVE
  3650                              <1> ;	call	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  3651                              <1> ;	; 02/01/2015
  3652                              <1> ;	;inc	di			; POINT TO NEXT DRIVE
  3653                              <1> ;	;cmp	di, MAX_DRV		; SEE IF DONE
  3654                              <1> ;	;jnz	short SUP0		; REPEAT FOR EACH ORIVE
  3655                              <1> ;       cmp     byte [fd1_type], 0	
  3656                              <1> ;	jna	short sup1
  3657                              <1> ;	or	di, di
  3658                              <1> ;	jnz	short sup1
  3659                              <1> ;	inc	di
  3660                              <1> ;       jmp     short SUP0
  3661                              <1> ;sup1:
  3662                              <1> ;	mov	byte [SEEK_STATUS], 0	; FORCE RECALIBRATE
  3663                              <1> ;	;and	byte [RTC_WAIT_FLAG], 0FEh ; ALLOW FOR RTC WAIT
  3664                              <1> ;	call	SETUP_END		; VARIOUS CLEANUPS
  3665                              <1> ;	;;pop	ds			; RESTORE CALLERS REGISTERS
  3666                              <1> ;	;pop	di
  3667                              <1> ;	pop	edx
  3668                              <1> ;	;pop	cx
  3669                              <1> ;	;pop	bx
  3670                              <1> ;	;pop	ax
  3671                              <1> ;	retn
  3672                              <1> 
  3673                              <1> ;//////////////////////////////////////////////////////
  3674                              <1> ;; END OF DISKETTE I/O ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3675                              <1> 
  3676                              <1> ; 17/04/2021 (TRDOS 386 v2.0.4) 
  3677                              <1> 
  3678                              <1> ; 11/04/2021
  3679                              <1> ;int13h: ; 21/02/2015
  3680                              <1> 	;pushfd
  3681                              <1> 	;push 	cs
  3682                              <1> 	;;call 	DISK_IO
  3683                              <1> 	;;retn
  3684                              <1> 
  3685                              <1> ;;;;;; DISK I/O ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21/02/2015 ;;;
  3686                              <1> ;/////////////////////////////////////////////////////////////////////
  3687                              <1> 
  3688                              <1> ; DISK I/O - Erdogan Tan (Retro UNIX 386 v1 project)
  3689                              <1> ; 18/02/2016
  3690                              <1> ; 17/02/2016
  3691                              <1> ; 23/02/2015
  3692                              <1> ; 21/02/2015 (unix386.s)
  3693                              <1> ; 22/12/2014 - 14/02/2015 (dsectrm2.s)
  3694                              <1> ;
  3695                              <1> ; Original Source Code:
  3696                              <1> ; DISK ----- 09/25/85 FIXED DISK BIOS
  3697                              <1> ; (IBM PC XT Model 286 System BIOS Source Code, 04-21-86)
  3698                              <1> ;
  3699                              <1> ; Modifications: by reference of AWARD BIOS 1999 (D1A0622) 
  3700                              <1> ;		 Source Code - ATORGS.ASM, AHDSK.ASM
  3701                              <1> ;
  3702                              <1> 
  3703                              <1> ;The wait for controller to be not busy is 10 seconds.
  3704                              <1> ;10,000,000 / 30 = 333,333. 333,333 decimal = 051615h
  3705                              <1> ;;WAIT_HDU_CTLR_BUSY_LO	equ 1615h		
  3706                              <1> ;;WAIT_HDU_CTLR_BUSY_HI	equ 05h
  3707                              <1> WAIT_HDU_CTRL_BUSY_LH	equ 51615h	; 21/02/2015		
  3708                              <1> 
  3709                              <1> ;The wait for controller to issue completion interrupt is 10 seconds.
  3710                              <1> ;10,000,000 / 30 = 333,333.  333,333 decimal = 051615h
  3711                              <1> ;;WAIT_HDU_INT_LO	equ 1615h
  3712                              <1> ;;WAIT_HDU_INT_HI	equ 05h
  3713                              <1> WAIT_HDU_INT_LH		equ 51615h	; 21/02/2015
  3714                              <1> 
  3715                              <1> ;The wait for Data request on read and write longs is
  3716                              <1> ;2000 us. (?)
  3717                              <1> ;;WAIT_HDU_DRQ_LO	equ 1000	; 03E8h
  3718                              <1> ;;WAIT_HDU_DRQ_HI	equ 0
  3719                              <1> WAIT_HDU_DRQ_LH		equ 1000	; 21/02/2015
  3720                              <1> 
  3721                              <1> ; Port 61h (PORT_B)
  3722                              <1> SYS1	equ 61h		; PORT_B  (diskette.inc)
  3723                              <1> 
  3724                              <1> ; 23/12/2014
  3725                              <1> %define CMD_BLOCK       ebp-8  ; 21/02/2015
  3726                              <1> 
  3727                              <1> ;--- INT 13H -------------------------------------------------------------------
  3728                              <1> ;									       :
  3729                              <1> ; FIXED DISK I/O INTERFACE						       :
  3730                              <1> ;									       :
  3731                              <1> ;	THIS INTERFACE PROVIDES ACCESS TO 5 1/4" FIXED DISKS THROUGH           :
  3732                              <1> ;	THE IBM FIXED DISK CONTROLLER.					       :
  3733                              <1> ;									       :
  3734                              <1> ;	THE  BIOS  ROUTINES  ARE  MEANT  TO  BE  ACCESSED  THROUGH	       :
  3735                              <1> ;	SOFTWARE  INTERRUPTS  ONLY.    ANY  ADDRESSES  PRESENT	IN	       :
  3736                              <1> ;	THESE  LISTINGS  ARE  INCLUDED	 ONLY	FOR  COMPLETENESS,	       :
  3737                              <1> ;	NOT  FOR  REFERENCE.  APPLICATIONS   WHICH  REFERENCE  ANY	       :
  3738                              <1> ;	ABSOLUTE  ADDRESSES  WITHIN  THE  CODE	SEGMENTS  OF  BIOS	       :
  3739                              <1> ;	VIOLATE  THE  STRUCTURE  AND  DESIGN  OF  BIOS. 		       :
  3740                              <1> ;									       :
  3741                              <1> ;------------------------------------------------------------------------------:
  3742                              <1> ;									       :
  3743                              <1> ; INPUT  (AH)= HEX COMMAND VALUE					       :
  3744                              <1> ;									       :
  3745                              <1> ;	(AH)= 00H  RESET DISK (DL = 80H,81H) / DISKETTE 		       :
  3746                              <1> ;	(AH)= 01H  READ THE STATUS OF THE LAST DISK OPERATION INTO (AL)        :
  3747                              <1> ;		    NOTE: DL < 80H - DISKETTE				       :
  3748                              <1> ;			  DL > 80H - DISK				       :
  3749                              <1> ;	(AH)= 02H  READ THE DESIRED SECTORS INTO MEMORY 		       :
  3750                              <1> ;	(AH)= 03H  WRITE THE DESIRED SECTORS FROM MEMORY		       :
  3751                              <1> ;	(AH)= 04H  VERIFY THE DESIRED SECTORS				       :
  3752                              <1> ;	(AH)= 05H  FORMAT THE DESIRED TRACK				       :
  3753                              <1> ;	(AH)= 06H  UNUSED						       :
  3754                              <1> ;	(AH)= 07H  UNUSED						       :
  3755                              <1> ;	(AH)= 08H  RETURN THE CURRENT DRIVE PARAMETERS			       :
  3756                              <1> ;	(AH)= 09H  INITIALIZE DRIVE PAIR CHARACTERISTICS		       :
  3757                              <1> ;		    INTERRUPT 41 POINTS TO DATA BLOCK FOR DRIVE 0	       :
  3758                              <1> ;		    INTERRUPT 46 POINTS TO DATA BLOCK FOR DRIVE 1	       :
  3759                              <1> ;	(AH)= 0AH  READ LONG						       :
  3760                              <1> ;	(AH)= 0BH  WRITE LONG  (READ & WRITE LONG ENCOMPASS 512 + 4 BYTES ECC) :
  3761                              <1> ;	(AH)= 0CH  SEEK 						       :
  3762                              <1> ;	(AH)= 0DH  ALTERNATE DISK RESET (SEE DL)			       :
  3763                              <1> ;	(AH)= 0EH  UNUSED						       :
  3764                              <1> ;	(AH)= 0FH  UNUSED						       :
  3765                              <1> ;	(AH)= 10H  TEST DRIVE READY					       :
  3766                              <1> ;	(AH)= 11H  RECALIBRATE						       :
  3767                              <1> ;	(AH)= 12H  UNUSED						       :
  3768                              <1> ;	(AH)= 13H  UNUSED						       :
  3769                              <1> ;	(AH)= 14H  CONTROLLER INTERNAL DIAGNOSTIC			       :
  3770                              <1> ;	(AH)= 15H  READ DASD TYPE					       :
  3771                              <1> ;									       :
  3772                              <1> ;-------------------------------------------------------------------------------
  3773                              <1> ;									       :
  3774                              <1> ;	REGISTERS USED FOR FIXED DISK OPERATIONS			       :
  3775                              <1> ;									       :
  3776                              <1> ;		(DL)	-  DRIVE NUMBER     (80H-81H FOR DISK. VALUE CHECKED)  :
  3777                              <1> ;		(DH)	-  HEAD NUMBER	    (0-15 ALLOWED, NOT VALUE CHECKED)  :
  3778                              <1> ;		(CH)	-  CYLINDER NUMBER  (0-1023, NOT VALUE CHECKED)(SEE CL):
  3779                              <1> ;		(CL)	-  SECTOR NUMBER    (1-17, NOT VALUE CHECKED)	       :
  3780                              <1> ;									       :
  3781                              <1> ;			   NOTE: HIGH 2 BITS OF CYLINDER NUMBER ARE PLACED     :
  3782                              <1> ;				 IN THE HIGH 2 BITS OF THE CL REGISTER	       :
  3783                              <1> ;				 (10 BITS TOTAL)			       :
  3784                              <1> ;									       :
  3785                              <1> ;		(AL)	-  NUMBER OF SECTORS (MAXIMUM POSSIBLE RANGE 1-80H,    :
  3786                              <1> ;					      FOR READ/WRITE LONG 1-79H)       :
  3787                              <1> ;									       :
  3788                              <1> ;		(ES:BX) -  ADDRESS OF BUFFER FOR READS AND WRITES,	       :
  3789                              <1> ;			   (NOT REQUIRED FOR VERIFY)			       :
  3790                              <1> ;									       :
  3791                              <1> ;		FORMAT (AH=5) ES:BX POINTS TO A 512 BYTE BUFFER. THE FIRST     :
  3792                              <1> ;			   2*(SECTORS/TRACK) BYTES CONTAIN F,N FOR EACH SECTOR.:
  3793                              <1> ;			   F = 00H FOR A GOOD SECTOR			       :
  3794                              <1> ;			       80H FOR A BAD SECTOR			       :
  3795                              <1> ;			   N = SECTOR NUMBER				       :
  3796                              <1> ;			   FOR AN INTERLEAVE OF 2 AND 17 SECTORS/TRACK	       :
  3797                              <1> ;			   THE TABLE SHOULD BE: 			       :
  3798                              <1> ;									       :
  3799                              <1> ;		   DB	   00H,01H,00H,0AH,00H,02H,00H,0BH,00H,03H,00H,0CH     :
  3800                              <1> ;		   DB	   00H,04H,00H,0DH,00H,05H,00H,0EH,00H,06H,00H,0FH     :
  3801                              <1> ;		   DB	   00H,07H,00H,10H,00H,08H,00H,11H,00H,09H	       :
  3802                              <1> ;									       :
  3803                              <1> ;-------------------------------------------------------------------------------
  3804                              <1> 
  3805                              <1> ;-------------------------------------------------------------------------------
  3806                              <1> ; OUTPUT								       :
  3807                              <1> ;	AH = STATUS OF CURRENT OPERATION				       :
  3808                              <1> ;	     STATUS BITS ARE DEFINED IN THE EQUATES BELOW		       :
  3809                              <1> ;	CY = 0	SUCCESSFUL OPERATION (AH=0 ON RETURN)			       :
  3810                              <1> ;	CY = 1	FAILED OPERATION (AH HAS ERROR REASON)			       :
  3811                              <1> ;									       :
  3812                              <1> ;	NOTE:	ERROR 11H  INDICATES THAT THE DATA READ HAD A RECOVERABLE      :
  3813                              <1> ;		ERROR WHICH WAS CORRECTED BY THE ECC ALGORITHM.  THE DATA      :
  3814                              <1> ;		IS PROBABLY GOOD,   HOWEVER THE BIOS ROUTINE INDICATES AN      :
  3815                              <1> ;		ERROR TO ALLOW THE CONTROLLING PROGRAM A CHANCE TO DECIDE      :
  3816                              <1> ;		FOR ITSELF.  THE  ERROR  MAY  NOT  RECUR  IF  THE DATA IS      :
  3817                              <1> ;		REWRITTEN.						       :
  3818                              <1> ;									       :
  3819                              <1> ;	IF DRIVE PARAMETERS WERE REQUESTED (DL >= 80H), 		       :
  3820                              <1> ;	   INPUT:							       :
  3821                              <1> ;	     (DL) = DRIVE NUMBER					       :	
  3822                              <1> ;	     ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)						       :	 	
  3823                              <1> ;	     EBX = Buffer address for fixed disk parameters table (32 bytes)   :
  3824                              <1> ;	   OUTPUT:							       :
  3825                              <1> ;	     (DL) = NUMBER OF CONSECUTIVE ACKNOWLEDGING DRIVES ATTACHED (1-2)  :
  3826                              <1> ;		    (CONTROLLER CARD ZERO TALLY ONLY)			       :
  3827                              <1> ;	     (DH) = MAXIMUM USEABLE VALUE FOR HEAD NUMBER		       :
  3828                              <1> ;	     (CH) = MAXIMUM USEABLE VALUE FOR CYLINDER NUMBER		       :
  3829                              <1> ;	     (CL) = MAXIMUM USEABLE VALUE FOR SECTOR NUMBER		       :
  3830                              <1> ;		    AND CYLINDER NUMBER HIGH BITS			       :
  3831                              <1> ;									       :
  3832                              <1> ;	IF READ DASD TYPE WAS REQUESTED,				       :
  3833                              <1> ;									       :
  3834                              <1> ;	AH = 0 - NOT PRESENT						       :
  3835                              <1> ;	     1 - DISKETTE - NO CHANGE LINE AVAILABLE			       :
  3836                              <1> ;	     2 - DISKETTE - CHANGE LINE AVAILABLE			       :
  3837                              <1> ;	     3 - FIXED DISK						       :
  3838                              <1> ;									       :
  3839                              <1> ;	CX,DX = NUMBER OF 512 BYTE BLOCKS WHEN AH = 3			       :
  3840                              <1> ;									       :
  3841                              <1> ;	REGISTERS WILL BE PRESERVED EXCEPT WHEN THEY ARE USED TO RETURN        :
  3842                              <1> ;	INFORMATION.							       :
  3843                              <1> ;									       :
  3844                              <1> ;	NOTE: IF AN ERROR IS REPORTED BY THE DISK CODE, THE APPROPRIATE        :
  3845                              <1> ;		ACTION IS TO RESET THE DISK, THEN RETRY THE OPERATION.	       :
  3846                              <1> ;									       :
  3847                              <1> ;-------------------------------------------------------------------------------
  3848                              <1> 
  3849                              <1> SENSE_FAIL	EQU	0FFH		; NOT IMPLEMENTED
  3850                              <1> NO_ERR		EQU	0E0H		; STATUS ERROR/ERROR REGISTER=0
  3851                              <1> WRITE_FAULT	EQU	0CCH		; WRITE FAULT ON SELECTED DRIVE
  3852                              <1> UNDEF_ERR	EQU	0BBH		; UNDEFINED ERROR OCCURRED
  3853                              <1> NOT_RDY 	EQU	0AAH		; DRIVE NOT READY
  3854                              <1> TIME_OUT	EQU	80H		; ATTACHMENT FAILED TO RESPOND
  3855                              <1> BAD_SEEK	EQU	40H		; SEEK OPERATION FAILED
  3856                              <1> BAD_CNTLR	EQU	20H		; CONTROLLER HAS FAILED
  3857                              <1> DATA_CORRECTED	EQU	11H		; ECC CORRECTED DATA ERROR
  3858                              <1> BAD_ECC 	EQU	10H		; BAD ECC ON DISK READ
  3859                              <1> BAD_TRACK	EQU	0BH		; NOT IMPLEMENTED
  3860                              <1> BAD_SECTOR	EQU	0AH		; BAD SECTOR FLAG DETECTED
  3861                              <1> ;DMA_BOUNDARY	EQU	09H		; DATA EXTENDS TOO FAR
  3862                              <1> INIT_FAIL	EQU	07H		; DRIVE PARAMETER ACTIVITY FAILED
  3863                              <1> BAD_RESET	EQU	05H		; RESET FAILED
  3864                              <1> ;RECORD_NOT_FND	EQU	04H		; REQUESTED SECTOR NOT FOUND
  3865                              <1> ;BAD_ADDR_MARK	EQU	02H		; ADDRESS MARK NOT FOUND
  3866                              <1> ;BAD_CMD 	EQU	01H		; BAD COMMAND PASSED TO DISK I/O
  3867                              <1> 
  3868                              <1> ;--------------------------------------------------------
  3869                              <1> ;							:
  3870                              <1> ; FIXED DISK PARAMETER TABLE				:
  3871                              <1> ;  -  THE TABLE IS COMPOSED OF A BLOCK DEFINED AS:	:
  3872                              <1> ;							:
  3873                              <1> ;  +0	(1 WORD) - MAXIMUM NUMBER OF CYLINDERS		:
  3874                              <1> ;  +2	(1 BYTE) - MAXIMUM NUMBER OF HEADS		:
  3875                              <1> ;  +3	(1 WORD) - NOT USED/SEE PC-XT			:
  3876                              <1> ;  +5	(1 WORD) - STARTING WRITE PRECOMPENSATION CYL	:
  3877                              <1> ;  +7	(1 BYTE) - MAXIMUM ECC DATA BURST LENGTH	:
  3878                              <1> ;  +8	(1 BYTE) - CONTROL BYTE 			:
  3879                              <1> ;		   BIT	  7 DISABLE RETRIES -OR-	:
  3880                              <1> ;		   BIT	  6 DISABLE RETRIES		:
  3881                              <1> ;		   BIT	  3 MORE THAN 8 HEADS		:
  3882                              <1> ;  +9	(3 BYTES)- NOT USED/SEE PC-XT			:
  3883                              <1> ; +12	(1 WORD) - LANDING ZONE 			:
  3884                              <1> ; +14	(1 BYTE) - NUMBER OF SECTORS/TRACK		:
  3885                              <1> ; +15	(1 BYTE) - RESERVED FOR FUTURE USE		:
  3886                              <1> ;							:
  3887                              <1> ;	 - TO DYNAMICALLY DEFINE A SET OF PARAMETERS	:
  3888                              <1> ;	   BUILD A TABLE FOR UP TO 15 TYPES AND PLACE	:
  3889                              <1> ;	   THE CORRESPONDING VECTOR INTO INTERRUPT 41	:
  3890                              <1> ;	   FOR DRIVE 0 AND INTERRUPT 46 FOR DRIVE 1.	:
  3891                              <1> ;							:
  3892                              <1> ;--------------------------------------------------------
  3893                              <1> 
  3894                              <1> ;--------------------------------------------------------
  3895                              <1> ;							:
  3896                              <1> ; HARDWARE SPECIFIC VALUES				:
  3897                              <1> ;							:
  3898                              <1> ;  -  CONTROLLER I/O PORT				:
  3899                              <1> ;							:
  3900                              <1> ;     > WHEN READ FROM: 				:
  3901                              <1> ;	HF_PORT+0 - READ DATA (FROM CONTROLLER TO CPU)	:
  3902                              <1> ;	HF_PORT+1 - GET ERROR REGISTER			:
  3903                              <1> ;	HF_PORT+2 - GET SECTOR COUNT			:
  3904                              <1> ;	HF_PORT+3 - GET SECTOR NUMBER			:
  3905                              <1> ;	HF_PORT+4 - GET CYLINDER LOW			:
  3906                              <1> ;	HF_PORT+5 - GET CYLINDER HIGH (2 BITS)		:
  3907                              <1> ;	HF_PORT+6 - GET SIZE/DRIVE/HEAD 		:
  3908                              <1> ;	HF_PORT+7 - GET STATUS REGISTER 		:
  3909                              <1> ;							:
  3910                              <1> ;     > WHEN WRITTEN TO:				:
  3911                              <1> ;	HF_PORT+0 - WRITE DATA (FROM CPU TO CONTROLLER) :
  3912                              <1> ;	HF_PORT+1 - SET PRECOMPENSATION CYLINDER	:
  3913                              <1> ;	HF_PORT+2 - SET SECTOR COUNT			:
  3914                              <1> ;	HF_PORT+3 - SET SECTOR NUMBER			:
  3915                              <1> ;	HF_PORT+4 - SET CYLINDER LOW			:
  3916                              <1> ;	HF_PORT+5 - SET CYLINDER HIGH (2 BITS)		:
  3917                              <1> ;	HF_PORT+6 - SET SIZE/DRIVE/HEAD 		:
  3918                              <1> ;	HF_PORT+7 - SET COMMAND REGISTER		:
  3919                              <1> ;							:
  3920                              <1> ;--------------------------------------------------------
  3921                              <1> 
  3922                              <1> ;HF_PORT 	EQU	01F0H	; DISK PORT
  3923                              <1> ;HF1_PORT	equ	0170h	
  3924                              <1> ;HF_REG_PORT	EQU	03F6H
  3925                              <1> ;HF1_REG_PORT	equ	0376h
  3926                              <1> 
  3927                              <1> HDC1_BASEPORT	equ	1F0h
  3928                              <1> HDC2_BASEPORT	equ	170h		
  3929                              <1> 
  3930 00004E57 90                  <1> align 2
  3931                              <1> 
  3932                              <1> ;-----		STATUS REGISTER
  3933                              <1> 
  3934                              <1> ST_ERROR	EQU	00000001B	;
  3935                              <1> ST_INDEX	EQU	00000010B	;
  3936                              <1> ST_CORRCTD	EQU	00000100B	; ECC CORRECTION SUCCESSFUL
  3937                              <1> ST_DRQ		EQU	00001000B	;
  3938                              <1> ST_SEEK_COMPL	EQU	00010000B	; SEEK COMPLETE
  3939                              <1> ST_WRT_FLT	EQU	00100000B	; WRITE FAULT
  3940                              <1> ST_READY	EQU	01000000B	;
  3941                              <1> ST_BUSY 	EQU	10000000B	;
  3942                              <1> 
  3943                              <1> ;-----		ERROR REGISTER
  3944                              <1> 
  3945                              <1> ERR_DAM 	EQU	00000001B	; DATA ADDRESS MARK NOT FOUND
  3946                              <1> ERR_TRK_0	EQU	00000010B	; TRACK 0 NOT FOUND ON RECAL
  3947                              <1> ERR_ABORT	EQU	00000100B	; ABORTED COMMAND
  3948                              <1> ;		EQU	00001000B	; NOT USED
  3949                              <1> ERR_ID		EQU	00010000B	; ID NOT FOUND
  3950                              <1> ;		EQU	00100000B	; NOT USED
  3951                              <1> ERR_DATA_ECC	EQU	01000000B
  3952                              <1> ERR_BAD_BLOCK	EQU	10000000B
  3953                              <1> 
  3954                              <1> 
  3955                              <1> RECAL_CMD	EQU	00010000B	; DRIVE RECAL	(10H)
  3956                              <1> READ_CMD	EQU	00100000B	;	READ	(20H)
  3957                              <1> WRITE_CMD	EQU	00110000B	;	WRITE	(30H)
  3958                              <1> VERIFY_CMD	EQU	01000000B	;	VERIFY	(40H)
  3959                              <1> FMTTRK_CMD	EQU	01010000B	; FORMAT TRACK	(50H)
  3960                              <1> INIT_CMD	EQU	01100000B	;   INITIALIZE	(60H)
  3961                              <1> SEEK_CMD	EQU	01110000B	;	SEEK	(70H)
  3962                              <1> DIAG_CMD	EQU	10010000B	; DIAGNOSTIC	(90H)
  3963                              <1> SET_PARM_CMD	EQU	10010001B	; DRIVE PARMS	(91H)
  3964                              <1> NO_RETRIES	EQU	00000001B	; CHD MODIFIER	(01H)
  3965                              <1> ECC_MODE	EQU	00000010B	; CMD MODIFIER	(02H)
  3966                              <1> BUFFER_MODE	EQU	00001000B	; CMD MODIFIER	(08H)
  3967                              <1> 
  3968                              <1> ;MAX_FILE	EQU	2
  3969                              <1> ;S_MAX_FILE	EQU	2
  3970                              <1> MAX_FILE	equ	4		; 22/12/2014
  3971                              <1> S_MAX_FILE	equ	4		; 22/12/2014
  3972                              <1> 
  3973                              <1> DELAY_1 	EQU	25H		; DELAY FOR OPERATION COMPLETE
  3974                              <1> DELAY_2 	EQU	0600H		; DELAY FOR READY
  3975                              <1> DELAY_3 	EQU	0100H		; DELAY FOR DATA REQUEST
  3976                              <1> 
  3977                              <1> HF_FAIL 	EQU	08H		; CMOS FLAG IN BYTE 0EH
  3978                              <1> 
  3979                              <1> ;-----		COMMAND BLOCK REFERENCE
  3980                              <1> 
  3981                              <1> ;CMD_BLOCK      EQU     BP-8            ; @CMD_BLOCK REFERENCES BLOCK HEAD IN SS
  3982                              <1> 					;  (BP) POINTS TO COMMAND BLOCK TAIL
  3983                              <1> 					;	AS DEFINED BY THE "ENTER" PARMS
  3984                              <1> ; 19/12/2014
  3985                              <1> ORG_VECTOR	equ	4*13h		; INT 13h vector
  3986                              <1> DISK_VECTOR	equ	4*40h		; INT 40h vector (for floppy disks)
  3987                              <1> ;HDISK_INT	equ	4*76h		; Primary HDC - Hardware interrupt (IRQ14)
  3988                              <1> ;HDISK_INT1	equ	4*76h		; Primary HDC - Hardware interrupt (IRQ14)
  3989                              <1> ;HDISK_INT2	equ	4*77h		; Secondary HDC - Hardware interrupt (IRQ15)
  3990                              <1> ;HF_TBL_VEC	equ	4*41h		; Pointer to 1st fixed disk parameter table
  3991                              <1> ;HF1_TBL_VEC	equ	4*46h		; Pointer to 2nd fixed disk parameter table
  3992                              <1> 
  3993                              <1> align 2
  3994                              <1> 
  3995                              <1> ;----------------------------------------------------------------
  3996                              <1> ; FIXED DISK I/O SETUP						:
  3997                              <1> ;								:
  3998                              <1> ;  -  ESTABLISH TRANSFER VECTORS FOR THE FIXED DISK		:
  3999                              <1> ;  -  PERFORM POWER ON DIAGNOSTICS				:
  4000                              <1> ;     SHOULD AN ERROR OCCUR A "1701" MESSAGE IS DISPLAYED       :
  4001                              <1> ;								:
  4002                              <1> ;----------------------------------------------------------------
  4003                              <1> 
  4004                              <1> ; 09/08/2022
  4005                              <1> ; 06/08/2022 - TRDOS 386 Kernel v2.0.5
  4006                              <1> ; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  4007                              <1> 
  4008                              <1> DISK_SETUP:
  4009                              <1> 	;CLI
  4010                              <1> 	;;mov	ax, ABS0 		; GET ABSOLUTE SEGMENT
  4011                              <1> 	;xor	ax, ax
  4012                              <1> 	;mov	ds, ax			; SET SEGMENT REGISTER
  4013                              <1> 	;mov	ax, [ORG_VECTOR] 	; GET DISKETTE VECTOR
  4014                              <1> 	;mov	[DISK_VECTOR], ax	;  INTO INT 40H
  4015                              <1> 	;mov	ax, [ORG_VECTOR+2]
  4016                              <1> 	;mov	[DISK_VECTOR+2], ax
  4017                              <1> 	;mov	word [ORG_VECTOR], DISK_IO ; FIXED DISK HANDLER
  4018                              <1> 	;mov	[ORG_VECTOR+2], cs
  4019                              <1> 	; 1st controller (primary master, slave)   - IRQ 14
  4020                              <1> 	;;mov	word [HDISK_INT], HD_INT   ; FIXED DISK INTERRUPT
  4021                              <1> 	;mov	word [HDISK_INT1], HD_INT  ;
  4022                              <1> 	;;mov	[HDISK_INT+2], cs
  4023                              <1> 	;mov	[HDISK_INT1+2], cs
  4024                              <1> 	; 2nd controller (secondary master, slave) - IRQ 15
  4025                              <1> 	;mov	word [HDISK_INT2], HD1_INT ;
  4026                              <1> 	;mov	[HDISK_INT2+2], cs
  4027                              <1> 	;
  4028                              <1> 	;;mov	word [HF_TBL_VEC], HD0_DPT	; PARM TABLE DRIVE 80
  4029                              <1> 	;;mov	word [HF_TBL_VEC+2], DPT_SEGM
  4030                              <1> 	;;mov	word [HF1_TBL_VEC], HD1_DPT	; PARM TABLE DRIVE 81
  4031                              <1> 	;;mov	word [HF1_TBL_VEC+2], DPT_SEGM
  4032                              <1> 	;push	cs
  4033                              <1> 	;pop	ds
  4034                              <1> 	;mov	word [HDPM_TBL_VEC], HD0_DPT	; PARM TABLE DRIVE 80h
  4035                              <1> 	;mov	word [HDPM_TBL_VEC+2], DPT_SEGM
  4036 00004E58 C705[24780100]0000- <1> 	mov 	dword [HDPM_TBL_VEC], (DPT_SEGM*16)+HD0_DPT
  4036 00004E60 0900                <1>
  4037                              <1> 	;mov	word [HDPS_TBL_VEC], HD1_DPT	; PARM TABLE DRIVE 81h
  4038                              <1> 	;mov	word [HDPS_TBL_VEC+2], DPT_SEGM
  4039 00004E62 C705[28780100]2000- <1> 	mov 	dword [HDPS_TBL_VEC], (DPT_SEGM*16)+HD1_DPT
  4039 00004E6A 0900                <1>
  4040                              <1> 	;mov	word [HDSM_TBL_VEC], HD2_DPT	; PARM TABLE DRIVE 82h
  4041                              <1> 	;mov	word [HDSM_TBL_VEC+2], DPT_SEGM
  4042 00004E6C C705[2C780100]4000- <1> 	mov 	dword [HDSM_TBL_VEC], (DPT_SEGM*16)+HD2_DPT
  4042 00004E74 0900                <1>
  4043                              <1> 	;mov	word [HDSS_TBL_VEC], HD3_DPT	; PARM TABLE DRIVE 83h
  4044                              <1> 	;mov	word [HDSS_TBL_VEC+2], DPT_SEGM
  4045 00004E76 C705[30780100]6000- <1> 	mov 	dword [HDSS_TBL_VEC], (DPT_SEGM*16)+HD3_DPT
  4045 00004E7E 0900                <1>
  4046                              <1> 	;
  4047                              <1> 	;;in	al, INTB01		; TURN ON SECOND INTERRUPT CHIP
  4048                              <1> 	;;;and	al, 0BFh
  4049                              <1> 	;;and	al, 3Fh			; enable IRQ 14 and IRQ 15
  4050                              <1> 	;;;jmp	$+2
  4051                              <1> 	;;IODELAY
  4052                              <1> 	;;out	INTB01, al
  4053                              <1> 	;;IODELAY
  4054                              <1> 	;;in	al, INTA01		; LET INTERRUPTS PASS THRU TO
  4055                              <1> 	;;and	al, 0FBh 		;  SECOND CHIP
  4056                              <1> 	;;;jmp	$+2
  4057                              <1> 	;;IODELAY
  4058                              <1> 	;;out	INTA01, al
  4059                              <1> 	;
  4060                              <1> 	;sti
  4061                              <1> 	;;push	ds			; MOVE ABS0 POINTER TO
  4062                              <1> 	;;pop	es			; EXTRA SEGMENT POINTER
  4063                              <1> 	;;;call	DDS			; ESTABLISH DATA SEGMENT
  4064                              <1> 	;;mov	byte [DISK_STATUS1], 0 	; RESET THE STATUS INDICATOR
  4065                              <1> 	;;mov	byte [HF_NUM], 0	; ZERO NUMBER OF FIXED DISKS
  4066                              <1> 	;;mov	byte [CONTROL_BYTE], 0
  4067                              <1> 	;;mov	byte [PORT_OFF], 0	; ZERO CARD OFFSET
  4068                              <1> 	; 20/12/2014 - private code by Erdogan Tan
  4069                              <1> 		      ; (out of original PC-AT, PC-XT BIOS code)
  4070                              <1> 	;mov	si, hd0_type
  4071 00004E80 BE[2E650000]        <1> 	mov	esi, hd0_type
  4072                              <1> 	;;mov	cx, 4
  4073                              <1> 	;mov	ecx, 4
  4074                              <1> 	; 06/08/2022
  4075 00004E85 29C9                <1> 	sub	ecx, ecx
  4076 00004E87 B104                <1> 	mov	cl, 4
  4077                              <1> hde_l:
  4078 00004E89 AC                  <1> 	lodsb
  4079 00004E8A 3C80                <1> 	cmp	al, 80h			; 8?h = existing
  4080 00004E8C 7206                <1> 	jb	short _L4
  4081 00004E8E FE05[20780100]      <1> 	inc	byte [HF_NUM]		; + 1 hard (fixed) disk drives
  4082                              <1> _L4: ; 26/02/2015
  4083 00004E94 E2F3                <1> 	loop	hde_l	
  4084                              <1> ;_L4:					; 0 <= [HF_NUM] =< 4
  4085                              <1> ;L4:
  4086                              <1> 	;; 31/12/2014 - cancel controller diagnostics here
  4087                              <1> 	;;;mov 	cx, 3  ; 26/12/2014 (Award BIOS 1999)
  4088                              <1> 	;;mov 	cl, 3
  4089                              <1> 	;;
  4090                              <1> 	;;mov	DL, 80H			; CHECK THE CONTROLLER
  4091                              <1> ;;hdc_dl:
  4092                              <1> 	;;mov	AH, 14H			; USE CONTROLLER DIAGNOSTIC COMMAND
  4093                              <1> 	;;INT	13H			; CALL BIOS WITH DIAGNOSTIC COMMAND
  4094                              <1> 	;;;jc	short CTL_ERRX		; DISPLAY ERROR MESSAGE IF BAD RETURN
  4095                              <1> 	;;;jc	short POD_DONE ;22/12/2014
  4096                              <1> 	;;jnc	short hdc_reset0
  4097                              <1> 	;;loop	hdc_dl
  4098                              <1> 	;;; 27/12/2014
  4099                              <1> 	;;stc
  4100                              <1> 	;;retn
  4101                              <1> 	;
  4102                              <1> ;;hdc_reset0:
  4103                              <1> 	; 18/01/2015
  4104 00004E96 8A0D[20780100]      <1> 	mov	cl, [HF_NUM]
  4105 00004E9C 20C9                <1> 	and	cl, cl
  4106 00004E9E 740D                <1> 	jz	short POD_DONE
  4107                              <1> 	;
  4108 00004EA0 B27F                <1> 	mov	dl, 7Fh
  4109                              <1> hdc_reset1:
  4110 00004EA2 FEC2                <1> 	inc	dl
  4111                              <1> 	;; 31/12/2015
  4112                              <1> 	;;push	dx
  4113                              <1> 	;;push	cx
  4114                              <1> 	;;push	ds
  4115                              <1> 	;;sub	ax, ax
  4116                              <1> 	;;mov	ds, ax
  4117                              <1> 	;;mov	ax, [TIMER_LOW]		; GET START TIMER COUNTS
  4118                              <1> 	;;pop	ds
  4119                              <1> 	;;mov	bx, ax
  4120                              <1> 	;;add	ax, 6*182		; 60 SECONDS* 18.2
  4121                              <1> 	;;mov	cx, ax
  4122                              <1> 	;;mov	word [wait_count], 0	; 22/12/2014 (reset wait counter)
  4123                              <1> 	;;
  4124                              <1> 	;; 31/12/2014 - cancel HD_RESET_1
  4125                              <1> 	;;call	HD_RESET_1		; SET UP DRIVE 0, (1,2,3)
  4126                              <1> 	;;pop	cx
  4127                              <1> 	;;pop	dx
  4128                              <1> 	;;
  4129                              <1> 	; 18/01/2015
  4130 00004EA4 B40D                <1> 	mov	ah, 0Dh ; ALTERNATE RESET
  4131                              <1> 	;int	13h
  4132 00004EA6 E8CC000000          <1> 	call	int13h
  4133 00004EAB E2F5                <1> 	loop	hdc_reset1
  4134                              <1> 	;clc 	; 29/05/2016
  4135                              <1> POD_DONE:
  4136 00004EAD C3                  <1> 	retn
  4137                              <1> 
  4138                              <1> ;;-----	POD_ERROR
  4139                              <1> 
  4140                              <1> ;;CTL_ERRX:
  4141                              <1> ;	;mov	SI,OFFSET F1782 	; CONTROLLER ERROR
  4142                              <1> ;	;call	SET_FAIL		; DO NOT IPL FROM DISK
  4143                              <1> ;	;call	E_MSG			; DISPLAY ERROR AND SET (BP) ERROR FLAG
  4144                              <1> ;	;jmp	short POD_DONE
  4145                              <1> 
  4146                              <1> ;;HD_RESET_1:
  4147                              <1> ;;	;push	BX			; SAVE TIMER LIMITS
  4148                              <1> ;;	;push	CX
  4149                              <1> ;;RES_1: mov	AH,09H			; SET DRIVE PARAMETERS
  4150                              <1> ;;	INT	13H
  4151                              <1> ;;	jc	short RES_2
  4152                              <1> ;;	mov	AH,11h			; RECALIBRATE DRIVE
  4153                              <1> ;;	INT	13H
  4154                              <1> ;;	jnc	short RES_CK		; DRIVE OK
  4155                              <1> ;;RES_2: ;call	POD_TCHK		; CHECK TIME OUT
  4156                              <1> ;;	cmp	word [wait_count], 6*182 ; waiting time (in timer ticks)
  4157                              <1> ;;					; (30 seconds)		
  4158                              <1> ;;	;cmc
  4159                              <1> ;;	;jnc	short RES_1
  4160                              <1> ;;	jb	short RES_1
  4161                              <1> ;;;RES_FL: ;mov	SI,OFFSET F1781 	; INDICATE DISK 1 FAILURE;
  4162                              <1> ;;	;test	DL,1
  4163                              <1> ;;	;jnz	short RES_E1
  4164                              <1> ;;	;mov	SI,OFFSET F1780 	; INDICATE DISK 0 FAILURE
  4165                              <1> ;;	;call	SET_FAIL		; DO NOT TRY TO IPL DISK 0
  4166                              <1> ;;	;jmp	SHORT RES_E1
  4167                              <1> ;;RES_ER: ; 22/12/2014
  4168                              <1> ;;RES_OK:
  4169                              <1> ;;	;pop	CX			; RESTORE TIMER LIMITS
  4170                              <1> ;;	;pop	BX
  4171                              <1> ;;	retn
  4172                              <1> ;;
  4173                              <1> ;;RES_RS: mov	AH,00H			; RESET THE DRIVE
  4174                              <1> ;;	INT	13H
  4175                              <1> ;;RES_CK: mov	AH,08H			; GET MAX CYLINDER,HEAD,SECTOR
  4176                              <1> ;;	mov	BL,DL			; SAVE DRIVE CODE
  4177                              <1> ;;	INT	13H
  4178                              <1> ;;	jc	short RES_ER
  4179                              <1> ;;	mov	[NEC_STATUS],CX 	; SAVE MAX CYLINDER, SECTOR
  4180                              <1> ;;	mov	DL,BL			; RESTORE DRIVE CODE
  4181                              <1> ;;RES_3: mov	AX,0401H		; VERIFY THE LAST SECTOR
  4182                              <1> ;;	INT	13H
  4183                              <1> ;;	jnc	short RES_OK		; VERIFY OK
  4184                              <1> ;;	cmp	AH,BAD_SECTOR		; OK ALSO IF JUST ID READ
  4185                              <1> ;;	JE	short RES_OK
  4186                              <1> ;;	cmp	AH,DATA_CORRECTED
  4187                              <1> ;;	JE	short RES_OK
  4188                              <1> ;;	cmp	AH,BAD_ECC
  4189                              <1> ;;	JE	short RES_OK
  4190                              <1> ;;	;call	POD_TCHK		; CHECK FOR TIME OUT
  4191                              <1> ;;	cmp	word [wait_count], 6*182 ; waiting time (in timer ticks)
  4192                              <1> ;;					; (60 seconds)		
  4193                              <1> ;;	cmc
  4194                              <1> ;;	jc	short RES_ER		; FAILED
  4195                              <1> ;;	mov	CX,[NEC_STATUS] 	; GET SECTOR ADDRESS, AND CYLINDER
  4196                              <1> ;;	mov	AL,CL			; SEPARATE OUT SECTOR NUMBER
  4197                              <1> ;;	and	AL,3FH
  4198                              <1> ;;	dec	AL			; TRY PREVIOUS ONE
  4199                              <1> ;;	jz	short RES_RS		; WE'VE TRIED ALL SECTORS ON TRACK
  4200                              <1> ;;	and	CL,0C0H 		; KEEP CYLINDER BITS
  4201                              <1> ;;	OR	CL,AL			; MERGE SECTOR WITH CYLINDER BITS
  4202                              <1> ;;	mov	[NEC_STATUS],CX 	; SAVE CYLINDER, NEW SECTOR NUMBER
  4203                              <1> ;;	jmp	short RES_3		; TRY AGAIN
  4204                              <1> ;;;RES_ER: mov	SI,OFFSET F1791 	; INDICATE DISK 1 ERROR
  4205                              <1> ;;	;test	DL,1
  4206                              <1> ;;	;jnz	short RES_E1
  4207                              <1> ;;	;mov	SI,OFFSET F1790 	; INDICATE DISK 0 ERROR
  4208                              <1> ;;;RES_E1:
  4209                              <1> ;;	;call	E_MSG			; DISPLAY ERROR AND SET (BP) ERROR FLAG
  4210                              <1> ;;;RES_OK:
  4211                              <1> ;;	;pop	CX			; RESTORE TIMER LIMITS
  4212                              <1> ;;	;pop	BX
  4213                              <1> ;;	;retn
  4214                              <1> ;
  4215                              <1> ;;SET_FAIL:
  4216                              <1> ;	;mov	AX,X*(CMOS_DIAG+NMI)	; GET CMOS ERROR BYTE
  4217                              <1> ;	;call	CMOS_READ
  4218                              <1> ;	;OR	AL,HF_FAIL		; SET DO NOT IPL FROM DISK FLAG
  4219                              <1> ;	;xchg	AH,AL			; SAVE IT
  4220                              <1> ;	;call	CMOS_WRITE		; PUT IT OUT
  4221                              <1> ;	;retn
  4222                              <1> ;
  4223                              <1> ;;POD_TCHK:				; CHECK FOR 30 SECOND TIME OUT
  4224                              <1> ;	;pop	AX			; SAVE RETURN
  4225                              <1> ;	;pop	CX			; GET TIME OUT LIMITS
  4226                              <1> ;	;pop	BX
  4227                              <1> ;	;push	BX			; AND SAVE THEM AGAIN
  4228                              <1> ;	;push	CX
  4229                              <1> ;	;push	AX
  4230                              <1> ;	;push	ds
  4231                              <1> ;	;xor	ax, ax
  4232                              <1> ;	;mov	ds, ax			; RESTORE RETURN
  4233                              <1> ;	;mov	AX, [TIMER_LOW]		; AX = CURRENT TIME
  4234                              <1> ;	;				; BX = START TIME
  4235                              <1> ;	;				; CX = END TIME
  4236                              <1> ;	;pop	ds
  4237                              <1> ;	;cmp	BX,CX
  4238                              <1> ;	;JB	short TCHK1		; START < END
  4239                              <1> ;	;cmp	BX,AX
  4240                              <1> ;	;JB	short TCHKG		; END < START < CURRENT
  4241                              <1> ;	;jmp	SHORT TCHK2		; END, CURRENT < START
  4242                              <1> ;;TCHK1: cmp	AX,BX
  4243                              <1> ;;	JB	short TCHKNG		; CURRENT < START < END
  4244                              <1> ;;TCHK2: cmp	AX,CX
  4245                              <1> ;;	JB	short TCHKG		; START < CURRENT < END
  4246                              <1> ;;					; OR CURRENT < END < START
  4247                              <1> ;;TCHKNG: STC				; CARRY SET INDICATES TIME OUT
  4248                              <1> ;;	retn
  4249                              <1> ;;TCHKG: CLC				; INDICATE STILL TIME
  4250                              <1> ;;	retn
  4251                              <1> ;;
  4252                              <1> ;;int_13h:
  4253                              <1> 
  4254                              <1> ;----------------------------------------
  4255                              <1> ;	FIXED DISK BIOS ENTRY POINT	:
  4256                              <1> ;----------------------------------------
  4257                              <1> 
  4258                              <1> ; 17/07/2022
  4259                              <1> ; 16/07/2022
  4260                              <1> ; 13/07/2022 - TRDOS 386 v2.0.5
  4261                              <1> ; 15/01/2017
  4262                              <1> ; 14/01/2017
  4263                              <1> ; 07/01/2017
  4264                              <1> ; 02/01/2017
  4265                              <1> ; 01/06/2016
  4266                              <1> ; 16/05/2016, 27/05/2016, 28/05/2016, 29/05/2016
  4267                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  4268                              <1> int33h: ; DISK I/O
  4269                              <1> 	; 29/05/2016
  4270 00004EAE 80642408FE          <1> 	and	byte [esp+8], 11111110b  ; clear carry bit of eflags register
  4271                              <1> 
  4272                              <1> 	; 13/07/2022
  4273 00004EB3 06                  <1> 	push	es
  4274                              <1> 	; 16/05/2016
  4275 00004EB4 1E                  <1> 	push	ds
  4276 00004EB5 53                  <1> 	push	ebx ; user's buffer address (virtual)
  4277                              <1> 	; 13/07/2022
  4278 00004EB6 51                  <1> 	push	ecx
  4279 00004EB7 52                  <1> 	push	edx
  4280 00004EB8 56                  <1> 	push	esi
  4281 00004EB9 57                  <1> 	push	edi
  4282                              <1> 
  4283                              <1> 	;mov	bx, KDATA ; System (Kernel's) data segment
  4284                              <1> 	;mov	ds, bx
  4285                              <1> 	; 13/07/2022
  4286 00004EBA 66BF1000            <1> 	mov	di, KDATA
  4287 00004EBE 8EDF                <1> 	mov	ds, di
  4288 00004EC0 8EC7                <1> 	mov	es, di
  4289                              <1> 
  4290                              <1> 	;;15/01/2017
  4291                              <1> 	; 14/01/2017
  4292                              <1> 	; 02/01/2017
  4293                              <1> 	;;mov	byte [intflg], 33h  ; disk io interrupt 
  4294                              <1> 	;pop	ebx
  4295                              <1> 
  4296                              <1> 	; 13/07/2022
  4297                              <1> 	;pop	dword [user_buffer] ; 01/06/2016
  4298 00004EC2 891D[10840100]      <1> 	mov	[user_buffer], ebx		
  4299                              <1> 
  4300 00004EC8 C605[4A7D0100]00    <1> 	mov	byte [scount], 0 ; sector count for transfer
  4301 00004ECF 80FC03              <1> 	cmp	ah, 03h ; chs write
  4302 00004ED2 773C                <1> 	ja	short int33h_2
  4303 00004ED4 7407                <1> 	je	short int33h_0
  4304 00004ED6 80FC02              <1> 	cmp	ah, 02h ; chs read
  4305 00004ED9 7267                <1> 	jb	short int33h_5
  4306 00004EDB EB5A                <1> 	jmp	short int33h_4
  4307                              <1> int33h_0:
  4308                              <1> 	;; 17/07/2022 - 64K r/w buffer limit check ?
  4309                              <1> 	;cmp	al, 80h ; 128	
  4310                              <1> 	;ja	short int33h_8 ; error
  4311                              <1> 	;; 17/07/2022 - zero r/w count check ?
  4312                              <1> 	;or	al, al
  4313                              <1> 	;jz	short int33h_8 ; error
  4314                              <1> 	
  4315                              <1> 	; 17/07/2022 (buffer limit and zero count check)
  4316 00004EDD FEC8                <1> 	dec	al
  4317 00004EDF 781A                <1> 	js	short int33h_8 ; error
  4318 00004EE1 FEC0                <1> 	inc	al	
  4319                              <1> 
  4320                              <1> 	; transfer user's buffer content to sector buffer
  4321 00004EE3 51                  <1> 	push	ecx
  4322 00004EE4 0FB6C8              <1> 	movzx	ecx, al
  4323                              <1> int33h_1:
  4324                              <1> 	; 13/07/2022
  4325                              <1> 	;push	esi
  4326                              <1> 	;mov	esi, [user_buffer]
  4327 00004EE7 89DE                <1> 	mov	esi, ebx
  4328                              <1> 	; esi = user's buffer address (virtual, ebx)
  4329                              <1> 	;push	edi
  4330                              <1> 	;push	es
  4331 00004EE9 50                  <1> 	push	eax
  4332                              <1> 	;mov	ax, KDATA
  4333                              <1> 	;mov	es, ax
  4334 00004EEA BF00000700          <1> 	mov	edi, Cluster_Buffer
  4335 00004EEF C1E109              <1> 	shl	ecx, 9 ; * 512
  4336 00004EF2 E8ACBE0000          <1> 	call	transfer_from_user_buffer
  4337                              <1> 		; (ecx and eax will be modified)
  4338 00004EF7 58                  <1> 	pop	eax
  4339                              <1> 	; 13/07/2022
  4340                              <1> 	;pop	es
  4341                              <1> 	;pop	edi
  4342                              <1> 	;pop	esi
  4343 00004EF8 59                  <1> 	pop	ecx
  4344 00004EF9 7347                <1> 	jnc	short int33h_5
  4345                              <1> 
  4346                              <1> 	;mov	ebx, [user_buffer] ; 01/06/2016
  4347                              <1> 	;pop	ds
  4348                              <1> 
  4349                              <1> int33h_8:
  4350                              <1> 	; 13/07/2022
  4351 00004EFB B8FF000000          <1> 	mov	eax, 0FFh ; Unknown error !?
  4352                              <1> int33h_9:
  4353 00004F00 5F                  <1> 	pop	edi
  4354 00004F01 5E                  <1> 	pop	esi
  4355 00004F02 5A                  <1> 	pop	edx
  4356 00004F03 59                  <1> 	pop	ecx
  4357 00004F04 5B                  <1> 	pop	ebx
  4358 00004F05 1F                  <1> 	pop	ds
  4359 00004F06 07                  <1> 	pop	es
  4360                              <1> 
  4361                              <1> 	; 13/07/2022
  4362 00004F07 7305                <1> 	jnc	short int33h_7
  4363                              <1> 
  4364                              <1> 	;;15/01/2017
  4365                              <1> 	; 02/01/2017
  4366                              <1> 	;cli
  4367                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
  4368                              <1> 	;
  4369                              <1> 	; (*) 29/05/2016
  4370                              <1> 	; (*) retf 4 ; skip eflags on stack
  4371                              <1> 
  4372                              <1> 	; 29/05/2016 -set carry flag on stack-
  4373                              <1> 	; [esp] = EIP
  4374                              <1> 	; [esp+4] = CS
  4375                              <1> 	; [esp+8] = E-FLAGS
  4376 00004F09 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
  4377                              <1> 	; [esp+12] = ESP (user)
  4378                              <1> 	; [esp+16] = SS (User)
  4379                              <1> 	;
  4380                              <1> 	; 13/07/2022
  4381                              <1> int33h_7:	
  4382 00004F0E FA                  <1> 	cli
  4383                              <1> 	;;15/01/2017
  4384                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
  4385                              <1> 	; cf = 0  ; use eflags which is in stack
  4386 00004F0F CF                  <1> 	iretd	
  4387                              <1> 
  4388                              <1> 	; (*) 29/05/2016 - 'retf 4' intruction causes to stack fault
  4389                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
  4390                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
  4391                              <1> 	; // RETF instruction:
  4392                              <1> 	;
  4393                              <1> 	; IF OperandMode=32 THEN
  4394                              <1>  	;    Load CS:EIP from stack;
  4395                              <1>  	;    Set CS RPL to CPL;
  4396                              <1>  	;    Increment ESP by 8 plus the immediate offset if it exists;
  4397                              <1>  	;    Load SS:ESP from stack;
  4398                              <1>  	; ELSE (* OperandMode=16 *)
  4399                              <1>  	;    Load CS:IP from stack;
  4400                              <1>  	;    Set CS RPL to CPL;
  4401                              <1>  	;    Increment ESP by 4 plus the immediate offset if it exists;
  4402                              <1> 	;    Load SS:ESP from stack;
  4403                              <1>  	; FI;
  4404                              <1> 	;
  4405                              <1> 	; //
  4406                              <1> 
  4407                              <1> int33h_2:
  4408 00004F10 80FC05              <1> 	cmp	ah, 05h ; format track
  4409 00004F13 7709                <1> 	ja	short int33h_3
  4410 00004F15 722B                <1> 	jb	short int33h_5
  4411 00004F17 51                  <1> 	push	ecx
  4412                              <1> 	;mov	ecx, 1
  4413                              <1> 	; 17/07/2022
  4414 00004F18 31C9                <1> 	xor	ecx, ecx
  4415 00004F1A FEC1                <1> 	inc	cl
  4416                              <1> 	; ecx = 1
  4417 00004F1C EBC9                <1> 	jmp	short int33h_1
  4418                              <1> int33h_3:
  4419 00004F1E 80FC1C              <1> 	cmp	ah, 1Ch ; LBA write
  4420 00004F21 771F                <1> 	ja	short int33h_5
  4421 00004F23 74B8                <1> 	je	short int33h_0
  4422 00004F25 80FC1B              <1> 	cmp	ah, 1Bh ; LBA read
  4423 00004F28 740D                <1> 	je	short int33h_4
  4424 00004F2A 80FC08              <1> 	cmp	ah, 08h ; get disk parameters
  4425 00004F2D 7513                <1> 	jne	short int33h_5
  4426                              <1> 	; 01/06/2016
  4427 00004F2F 8B1D[10840100]      <1> 	mov	ebx, [user_buffer] ; user's buffer address
  4428 00004F35 EB10                <1> 	jmp	short int33h_6
  4429                              <1> int33h_4:
  4430                              <1> 	;; 17/07/2022 - 64K r/w buffer limit check ?
  4431                              <1> 	;cmp	al, 80h ; 128	
  4432                              <1> 	;ja	short int33h_8 ; error
  4433                              <1> 	;; 17/07/2022 - zero r/w count check ?
  4434                              <1> 	;or	al, al
  4435                              <1> 	;jz	short int33h_8 ; error
  4436                              <1> 
  4437                              <1> 	; 17/07/2022 (buffer limit and zero count check)
  4438 00004F37 FEC8                <1> 	dec	al
  4439 00004F39 78C0                <1> 	js	short int33h_8 ; error
  4440 00004F3B FEC0                <1> 	inc	al
  4441                              <1> 
  4442 00004F3D A2[4A7D0100]        <1> 	mov	byte [scount], al ; <= 128 sectors
  4443                              <1> int33h_5:
  4444 00004F42 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; max. 65536 bytes
  4445                              <1> 				    ; buf. addr: 70000h	
  4446                              <1> 	;mov	byte [ClusterBuffer_Valid], 0
  4447                              <1> int33h_6:
  4448                              <1> 	; 13/07/2022
  4449                              <1> 	;pop	ds
  4450                              <1> 	;pushfd
  4451                              <1> 	;push 	cs
  4452                              <1> 	
  4453 00004F47 E83B000000          <1> 	call 	DISK_IO
  4454                              <1> 	
  4455                              <1> 	;;mov	ebx, [cs:user_buffer] ; 01/06/2016
  4456                              <1> 	;mov	ebx, [user_buffer] ; 13/07/2022 
  4457 00004F4C 72B2                <1> 	jc	short int33h_9
  4458                              <1> 	;
  4459                              <1> 	;cmp	byte [cs:scount], 0
  4460                              <1> 	;jna	short int33h_7	
  4461 00004F4E 803D[4A7D0100]00    <1> 	cmp	byte [scount], 0 ; 13/07/2022
  4462 00004F55 76A9                <1> 	jna	short int33h_9
  4463                              <1> 
  4464                              <1> 	; 13/07/2022
  4465                              <1> 
  4466                              <1> 	; transfer sector buffer content to user's buffer
  4467                              <1> 	;push	es
  4468                              <1> 	;push	ds
  4469                              <1> 	;push	eax
  4470                              <1> 	;mov	ax, KDATA
  4471                              <1> 	;mov	ds, ax
  4472                              <1> 	;mov	es, ax
  4473                              <1> 	;push	ecx
  4474                              <1> 	;push	esi
  4475                              <1> 	;push	edi
  4476                              <1> 	
  4477                              <1> 	; 13/07/2022
  4478 00004F57 50                  <1> 	push	eax
  4479 00004F58 0FB60D[4A7D0100]    <1> 	movzx	ecx, byte [scount]
  4480 00004F5F C1E109              <1> 	shl	ecx, 9 ; * 512 bytes
  4481                              <1> 	;mov	edi, ebx ; user's buffer address
  4482 00004F62 8B3D[10840100]      <1> 	mov	edi, [user_buffer] ; 13/07/2022
  4483 00004F68 BE00000700          <1> 	mov	esi, Cluster_Buffer
  4484 00004F6D E8E7BD0000          <1> 	call	transfer_to_user_buffer 
  4485                              <1> 		; (ecx and eax will be modified)
  4486 00004F72 58                  <1> 	pop	eax
  4487                              <1> 
  4488                              <1> 	; 13/07/2022
  4489 00004F73 7286                <1> 	jc	short int33h_8 ; eax = 0FFh
  4490 00004F75 EB89                <1> 	jmp	short int33h_9 ; cf = 0
  4491                              <1> 
  4492                              <1> 	;pop	edi
  4493                              <1> 	;pop	esi
  4494                              <1> 	;pop	ecx
  4495                              <1> 	;pop	eax
  4496                              <1> 	;pop	ds
  4497                              <1> 	;pop	es
  4498                              <1> 	;jc	short int33h_8
  4499                              <1> ;int33h_7:
  4500                              <1> 	;cli
  4501                              <1> 	;;;15/01/2017
  4502                              <1> 	;;;mov	byte [ss:intflg], 0 ; 07/01/2017
  4503                              <1> 	;; cf = 0  ; use eflags which is in stack
  4504                              <1> 	;iretd	
  4505                              <1> ;int33h_8:
  4506                              <1> 	;mov	eax, 0FFh ; Unknown error !?
  4507                              <1> 	; 13/07/2022
  4508                              <1> 	;xor	eax, eax
  4509                              <1> 	;dec	al  ; eax = 0FFh	
  4510                              <1> 	;jmp	short int33h_9
  4511                              <1> 	 
  4512                              <1> ;int33h_9:
  4513                              <1> 	;; cf = 1
  4514                              <1> 	;
  4515                              <1> 	;; (*) 29/05/2016	
  4516                              <1> 	;; (*) retf 4 ; skip eflags on stack
  4517                              <1> 	;; Note: This 'retf 4' was wrong, -it was causing
  4518                              <1> 	;;       to stack errors in ring 3-
  4519                              <1> 	;;	POP sequence of 'retf 4' is as
  4520                              <1> 	;;       "eip, cs, eflags, esp, ss, +4 bytes" 
  4521                              <1>         ;;       it is not as "eip, cs, +4 bytes, esp, ss" ! 
  4522                              <1> 	;
  4523                              <1> 	;; 29/05/2016 -set carry flag on stack-
  4524                              <1> 	;or	byte [esp+8], 1  ; set carry bit of eflags register
  4525                              <1> 	;;iretd
  4526                              <1> 	;jmp	short int33h_7 ; 07/01/2017
  4527                              <1> 
  4528                              <1> ;; 11/04/2021
  4529                              <1> ;int13h: ; 21/02/2015
  4530                              <1> ;	clc ; 11/04/2021
  4531                              <1> ;	pushfd
  4532                              <1> ;	push 	cs
  4533                              <1> ;	call 	DISK_IO
  4534                              <1> ;	retn
  4535                              <1> 
  4536                              <1> int13h:
  4537                              <1> 	; 13/07/2022 - TRDOS 386 v2.0.5
  4538                              <1> 	; Note: DISK_IO sets registers on stack
  4539                              <1> 	; 	as return parameters. So,
  4540                              <1> 	;	stack order (at the entry of 'DISK_IO')
  4541                              <1> 	;	must be same with 'int33h:' as above.
  4542                              <1> 		
  4543                              <1> 	;push	es ; not necessary
  4544                              <1> 	;push	ds ; not necessary
  4545                              <1> 	;
  4546                              <1> 	; following pushes are necessary
  4547                              <1> 	; for setting registers -return values- in DISK_IO
  4548 00004F77 53                  <1> 	push	ebx
  4549 00004F78 51                  <1> 	push	ecx
  4550 00004F79 52                  <1> 	push	edx
  4551 00004F7A 56                  <1> 	push	esi
  4552 00004F7B 57                  <1> 	push	edi
  4553                              <1> 	;push	ebp
  4554                              <1> 	;mov	ebp, esp
  4555                              <1> 	; edi = ebp+4
  4556                              <1> 	; esi = ebp+8
  4557                              <1> 	; edx = ebp+12
  4558                              <1> 	; ecx = ebp+16
  4559                              <1> 	; ebx = ebp+20
  4560                              <1> 	;
  4561 00004F7C E806000000          <1> 	call	DISK_IO
  4562                              <1> 	;
  4563 00004F81 5F                  <1> 	pop	edi
  4564 00004F82 5E                  <1> 	pop	esi
  4565 00004F83 5A                  <1> 	pop	edx
  4566 00004F84 59                  <1> 	pop	ecx
  4567 00004F85 5B                  <1> 	pop	ebx	
  4568                              <1> 	;
  4569                              <1> 	;pop	ds
  4570                              <1> 	;pop	es
  4571                              <1> 	;
  4572 00004F86 C3                  <1> 	retn
  4573                              <1> 
  4574                              <1> ; 10/08/2022
  4575                              <1> ; 07/08/2022
  4576                              <1> ; 17/07/2022
  4577                              <1> ; 13/07/2022 - TRDOS 386 v2.0.5
  4578                              <1> ; 18/04/2021 - TRDOS 386 v2.0.4
  4579                              <1> ; 11/04/2021 - TRDOS 386 v2.0.3
  4580                              <1> ; 30/08/2020
  4581                              <1> ; 09/12/2017
  4582                              <1> ; 29/05/2016
  4583                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  4584                              <1> 
  4585                              <1> DISK_IO:
  4586                              <1> 	; 10/08/2022
  4587                              <1> 	; 17/07/2022
  4588                              <1> 	; 13/07/2022
  4589                              <1> 	; Registers are also on stack 
  4590                              <1> 	; (with same contents) 
  4591                              <1> 	; in following order:
  4592                              <1> 	;
  4593                              <1> 	;    ebx = esp+20
  4594                              <1> 	;    ecx = esp+16
  4595                              <1> 	;    edx = esp+12
  4596                              <1> 	;    esi = esp+8
  4597                              <1> 	;    edi = esp+4
  4598                              <1> 
  4599                              <1> 	; cs = KCODE (== KDATA base address)
  4600                              <1> 	; ss = KDATA
  4601                              <1> 	; ds = KDATA
  4602                              <1> 	; es = KDATA
  4603                              <1> 
  4604                              <1> 	; 17/07/2022
  4605 00004F87 FB                  <1> 	sti				; ENABLE INTERRUPTS
  4606                              <1> 
  4607 00004F88 80FA80              <1> 	cmp	dl, 80h			; TEST FOR FIXED DISK DRIVE
  4608                              <1> 	;jae	short A1		; YES, HANDLE HERE
  4609                              <1> 	;;;int	40h			; DISKETTE HANDLER
  4610                              <1> 	;;call	int40h
  4611                              <1> 	;jb	DISKETTE_IO_1
  4612                              <1> ;RET_2:
  4613                              <1> 	;;retf	2			; BACK TO CALLER
  4614                              <1> 	;retf	4
  4615                              <1> 	; 11/04/2021
  4616 00004F8B 7305                <1> 	jnb	short A1
  4617 00004F8D E940F2FFFF          <1> 	jmp	DISKETTE_IO_1
  4618                              <1> A1:
  4619                              <1> 	;sti	 ; 17/07/2022		; ENABLE INTERRUPTS
  4620                              <1> 	
  4621                              <1> 	;; 04/01/2015
  4622                              <1> 	;;or	ah, ah
  4623                              <1> 	;;jnz	short A2
  4624                              <1> 	;;int	40h			; RESET NEC WHEN AH=0
  4625                              <1> 	;;sub	ah, ah
  4626                              <1> 	
  4627 00004F92 80FA83              <1> 	cmp	dl, (80h + S_MAX_FILE - 1)
  4628                              <1> 	;ja	short RET_2
  4629 00004F95 760A                <1> 	jna	short _A0
  4630                              <1> 	
  4631                              <1> 	; 13/07/2022
  4632                              <1> 	; (here, DS is KDATA segment already) 
  4633                              <1> 	;
  4634                              <1> 	; 29/05/2016
  4635                              <1> 	;push	ds
  4636                              <1> 	; 11/04/2021
  4637                              <1> 	;push	eax
  4638                              <1> 	;mov	ax, KDATA
  4639                              <1> 	;mov	ds, ax
  4640                              <1> 	; 11/04/2021
  4641                              <1> 	;pop	eax
  4642                              <1> 	
  4643 00004F97 B4AA                <1> 	mov     ah, 0AAh        ; Hard disk drive not ready !
  4644                              <1> 				; (Programmer's guide to AMIBIOS, 1992)
  4645 00004F99 8825[1F780100]      <1> 	mov     byte [DISK_STATUS1], ah
  4646                              <1> 	; 13/07/2022
  4647                              <1> 	;pop	ds
  4648                              <1> 	;jmp	short RET_2
  4649 00004F9F F9                  <1> 	stc
  4650 00004FA0 C3                  <1> 	retn
  4651                              <1> _A0:
  4652                              <1> 	; 18/01/2015
  4653 00004FA1 08E4                <1> 	or	ah, ah
  4654 00004FA3 742C                <1> 	jz	short A4
  4655 00004FA5 80FC0D              <1> 	cmp	ah, 0Dh	; Alternate reset
  4656 00004FA8 7504                <1> 	jne	short A2
  4657 00004FAA 28E4                <1> 	sub	ah, ah	; Reset
  4658 00004FAC EB23                <1> 	jmp	short A4
  4659                              <1> A2:
  4660                              <1> 	; 13/07/2022
  4661 00004FAE 80FC08              <1> 	cmp	ah, 08h			; GET PARAMETERS IS A SPECIAL CASE
  4662 00004FB1 7505                <1> 	jne	short A3
  4663 00004FB3 E9AC030000          <1>         jmp	GET_PARM_N
  4664                              <1> A3:	
  4665                              <1> 	; 13/07/2022
  4666 00004FB8 80FC15              <1> 	cmp	ah, 15h			; READ DASD TYPE IS ALSO
  4667 00004FBB 7514                <1> 	jne	short A4
  4668 00004FBD E947030000          <1>         jmp	READ_DASD_TYPE	; Return Drive Type
  4669                              <1> 				; (Programmer's guide to AMIBIOS, 1992)
  4670                              <1> 	; 13/07/2022
  4671                              <1> int33h_bad_cmd:
  4672                              <1> 	; 16/05/2016
  4673                              <1> 	; 30/01/2015
  4674                              <1> 	; 29/05/2016
  4675                              <1> 	;push	ds
  4676                              <1> 	;push	eax
  4677                              <1> 	;mov	ax, KDATA
  4678                              <1> 	;mov	ds, ax
  4679                              <1> 	;pop	eax
  4680                              <1> 
  4681 00004FC2 B401                <1> 	mov	ah, BAD_CMD
  4682 00004FC4 8825[1F780100]      <1> 	mov     [DISK_STATUS1], ah ; BAD_CMD  ; COMMAND ERROR
  4683                              <1>         ;jmp	short RET_2
  4684                              <1> 	; 13/07/2022
  4685                              <1> ;RET_2:
  4686                              <1> 	; (*) 29/05/2016
  4687                              <1> 	; (*) retf 4
  4688                              <1> 	;or	byte [esp+8], 1 ; set carry bit of eflags register
  4689                              <1> 	;iretd
  4690                              <1> 	
  4691                              <1> 	; 13/07/2022
  4692 00004FCA F9                  <1> 	stc
  4693                              <1> 	; cf = 1, ah = BAD_CMD
  4694 00004FCB C3                  <1> 	retn
  4695                              <1> _A4:
  4696                              <1> 	; 13/07/2022
  4697                              <1> 	; 02/02/2015
  4698 00004FCC 80FC1D              <1> 	cmp	ah, 1Dh			; (Temporary for Retro UNIX 386 v1)
  4699                              <1> 	; 12/01/2015
  4700                              <1> 	;cmc
  4701                              <1> 	;jnc	short A4
  4702                              <1> 	; 13/07/2022
  4703 00004FCF 73F1                <1> 	jnb	short int33h_bad_cmd	
  4704                              <1> A4:					; SAVE REGISTERS DURING OPERATION
  4705 00004FD1 C8080000            <1> 	enter	8, 0			; SAVE (BP) AND MAKE ROOM FOR @CMD_BLOCK
  4706                              <1> 	
  4707                              <1> 	; 13/07/2022
  4708                              <1> 	; ENTER 8, 0
  4709                              <1> 	;;push	ebp
  4710                              <1> 	;;mov	ebp, esp
  4711                              <1> 	;;sub	esp, 8
  4712                              <1> 	;
  4713                              <1> 	;push	ebx			;  IN THE STACK, THE COMMAND BLOCK IS:
  4714                              <1> 	;push	ecx			;   @CMD_BLOCK == BYTE PTR [BP]-8
  4715                              <1> 	;push	edx
  4716                              <1> 	;push	esi
  4717                              <1> 	;push	edi
  4718                              <1> 
  4719                              <1> 	; 13/07/2022
  4720                              <1> 	; edi = ebp+8
  4721                              <1> 	; esi = ebp+12
  4722                              <1> 	; edx = ebp+16
  4723                              <1> 	; ecx = ebp+20
  4724                              <1> 	; ebx = ebp+24
  4725                              <1> 
  4726                              <1> 	;;04/01/2015
  4727                              <1> 	;;or	ah, ah			; CHECK FOR RESET
  4728                              <1> 	;;jnz	short A5
  4729                              <1> 	;;mov	dl, 80h			; FORCE DRIVE 80 FOR RESET
  4730                              <1> ;;A5:	
  4731                              <1> 	; 13/07/2022
  4732 00004FD5 E880000000          <1> 	call	DISK_IO_CONT		; PERFORM THE OPERATION
  4733                              <1> 	;;call	DDS			; ESTABLISH SEGMENT
  4734 00004FDA 8A25[1F780100]      <1> 	mov	ah, [DISK_STATUS1]	; GET STATUS FROM OPERATION
  4735                              <1> 	;(*) cmp ah, 1			; SET THE CARRY FLAG TO INDICATE
  4736                              <1> 					; SUCCESS OR FAILURE
  4737                              <1> 	;pop	edi			; RESTORE REGISTERS
  4738                              <1> 	;pop	esi
  4739                              <1> 	;pop	edx
  4740                              <1> 	;pop	ecx
  4741                              <1> 	;pop	ebx
  4742                              <1> 	
  4743 00004FE0 C9                  <1> 	leave				; ADJUST (SP) AND RESTORE (BP)
  4744                              <1> 	
  4745                              <1> 	;retf	2			; THROW AWAY SAVED FLAGS
  4746                              <1> 	; (*) 29/05/2016
  4747                              <1> 	; (*) retf 4
  4748                              <1> 	
  4749                              <1> 	; 13/07/2022
  4750 00004FE1 80FC01              <1> 	cmp	ah, 1
  4751                              <1> 	;jc	short _A5 
  4752                              <1> 	;or	byte [esp+8], 1 ; set carry bit of eflags register
  4753                              <1> ;_A5:
  4754                              <1> 	;iretd
  4755                              <1> 	; 10/08/2022
  4756 00004FE4 F5                  <1> 	cmc
  4757                              <1> 	; 13/07/2022
  4758 00004FE5 C3                  <1> 	retn
  4759                              <1> 
  4760                              <1> ; 21/02/2015
  4761                              <1> ;       dw --> dd
  4762                              <1> 	; 13/07/2022
  4763                              <1> D1:					; FUNCTION TRANSFER TABLE
  4764 00004FE6 [9E510000]          <1> 	dd	DISK_RESET		; 00h
  4765 00004FEA [FE510000]          <1> 	dd	RETURN_STATUS		; 01h
  4766 00004FEE [11520000]          <1> 	dd	DISK_READ		; 02h
  4767 00004FF2 [6D520000]          <1> 	dd	DISK_WRITE		; 03h
  4768 00004FF6 [F1520000]          <1> 	dd	DISK_VERF		; 04h
  4769 00004FFA [DE520000]          <1> 	dd	FMT_TRK 		; 05h
  4770 00004FFE [94510000]          <1> 	dd	BAD_COMMAND		; 06h	FORMAT BAD SECTORS
  4771 00005002 [94510000]          <1> 	dd	BAD_COMMAND		; 07h	FORMAT DRIVE
  4772 00005006 [94510000]          <1> 	dd	BAD_COMMAND		; 08h	RETURN PARAMETERS
  4773 0000500A [E4530000]          <1> 	dd	INIT_DRV		; 09h
  4774 0000500E [0B520000]          <1> 	dd	RD_LONG 		; 0Ah
  4775 00005012 [67520000]          <1> 	dd	WR_LONG 		; 0Bh
  4776 00005016 [55540000]          <1> 	dd	DISK_SEEK		; 0Ch
  4777 0000501A [9E510000]          <1> 	dd	DISK_RESET		; 0Dh
  4778 0000501E [94510000]          <1> 	dd	BAD_COMMAND		; 0Eh	READ BUFFER
  4779 00005022 [94510000]          <1> 	dd	BAD_COMMAND		; 0Fh	WRITE BUFFER
  4780 00005026 [7D540000]          <1> 	dd	TST_RDY 		; 10h
  4781 0000502A [A1540000]          <1> 	dd	HDISK_RECAL		; 11h
  4782 0000502E [94510000]          <1> 	dd	BAD_COMMAND		; 12h	MEMORY DIAGNOSTIC
  4783 00005032 [94510000]          <1> 	dd	BAD_COMMAND		; 13h	DRIVE DIAGNOSTIC
  4784 00005036 [D7540000]          <1> 	dd	CTLR_DIAGNOSTIC 	; 14h	CONTROLLER DIAGNOSTIC
  4785                              <1> 	;; 02/02/2015 (Temporary - Retro UNIX 386 v1 - DISK I/O test)
  4786 0000503A [94510000]          <1> 	dd	BAD_COMMAND		; 15h
  4787 0000503E [94510000]          <1> 	dd	BAD_COMMAND		; 16h
  4788 00005042 [94510000]          <1> 	dd	BAD_COMMAND		; 17h
  4789 00005046 [94510000]          <1> 	dd	BAD_COMMAND		; 18h
  4790 0000504A [94510000]          <1> 	dd	BAD_COMMAND		; 19h
  4791 0000504E [94510000]          <1> 	dd	BAD_COMMAND		; 1Ah
  4792 00005052 [11520000]          <1> 	dd	DISK_READ		; 1Bh ; LBA read
  4793 00005056 [6D520000]          <1> 	dd	DISK_WRITE		; 1Ch ; LBA write
  4794                              <1> D1L     EQU    $ - D1
  4795                              <1> 
  4796                              <1> 	; 07/08/2022
  4797                              <1> 	; 17/07/2022 - TRDOS 386 v2.0.5
  4798                              <1> DISK_IO_CONT:
  4799                              <1> 	;;call	DDS			; ESTABLISH SEGMENT
  4800                              <1> 	; 11/04/2021
  4801 0000505A 80FC01              <1> 	cmp	ah, 01h			; RETURN STATUS
  4802 0000505D 7505                <1> 	jne	short SU0
  4803 0000505F E99A010000          <1> 	jmp	RETURN_STATUS
  4804                              <1> SU0:
  4805 00005064 C605[1F780100]00    <1> 	mov	byte [DISK_STATUS1], 0 	; RESET THE STATUS INDICATOR
  4806                              <1> 	; 13/07/2022
  4807 0000506B 89DE                <1> 	mov	esi, ebx ; 21/02/2015	; SAVE DATA ADDRESS
  4808 0000506D 8A1D[20780100]      <1> 	mov	bl, [HF_NUM]		; GET NUMBER OF DRIVES
  4809 00005073 80E27F              <1> 	and	dl, 7Fh			; GET DRIVE AS 0 OR 1
  4810                              <1> 					; (get drive number as 0 to 3)
  4811                              <1> 	; 14/02/2015 
  4812 00005076 38D3                <1> 	cmp	bl, dl
  4813                              <1> 	;jbe	short BAD_COMMAND	; INVALID DRIVE
  4814                              <1> 	; 07/08/2022
  4815 00005078 7705                <1> 	ja	short SU0X
  4816 0000507A E915010000          <1> 	jmp	BAD_COMMAND
  4817                              <1> SU0X:
  4818                              <1> 	;;03/01/2015
  4819 0000507F 29DB                <1> 	sub	ebx, ebx
  4820 00005081 88D3                <1> 	mov	bl, dl
  4821 00005083 883D[34780100]      <1> 	mov	[LBAMode], bh 	; 0
  4822                              <1> 	
  4823                              <1> 	;test	byte [ebx+hd0_type], 1 	; LBA ready ?
  4824                              <1> 	;jz	short su1		; no
  4825                              <1> 	;inc	byte [LBAMode]
  4826                              <1> ;su1:
  4827                              <1> 	; 11/04/2021 (32 bit push/pop)
  4828                              <1> 	; 21/02/2015 (32 bit modification)
  4829                              <1> 	; 04/01/2015
  4830 00005089 50                  <1> 	push	eax ; ***
  4831                              <1> 	;push	es  ; **
  4832 0000508A 52                  <1> 	push	edx ; *
  4833 0000508B 50                  <1> 	push	eax ; ****
  4834 0000508C E8ED050000          <1> 	call	GET_VEC 		; GET DISK PARAMETERS
  4835                              <1> 	; 02/02/2015
  4836                              <1> 	;mov	ax, [ES:BX+16] ; I/O port base address (1F0h, 170h)
  4837 00005091 668B4310            <1> 	mov	ax, [ebx+16]
  4838 00005095 66A3[1E650000]      <1> 	mov	[HF_PORT], ax
  4839                              <1> 	;mov	dx, [ES:BX+18] ; control port address (3F6h, 376h)
  4840 0000509B 668B5312            <1> 	mov	dx, [ebx+18]
  4841 0000509F 668915[20650000]    <1> 	mov	[HF_REG_PORT], dx
  4842                              <1> 	;mov	al, [ES:BX+20] ; head register upper nibble (A0h,B0h,E0h,F0h)
  4843 000050A6 8A4314              <1> 	mov	al, [ebx+20]
  4844                              <1> 	; 23/02/2015
  4845 000050A9 A840                <1> 	test	al, 40h	 ; LBA bit (bit 6)
  4846 000050AB 7406                <1> 	jz 	short su1
  4847 000050AD FE05[34780100]      <1> 	inc	byte [LBAMode] ; 1 
  4848                              <1> su1: 	 
  4849 000050B3 C0E804              <1> 	shr 	al, 4
  4850 000050B6 2401                <1> 	and	al, 1			
  4851 000050B8 A2[22650000]        <1> 	mov	[hf_m_s], al 
  4852                              <1> 	;
  4853                              <1> 	; 03/01/2015
  4854                              <1> 	;mov	al, [ES:BX+8]		; GET CONTROL BYTE MODIFIER
  4855 000050BD 8A4308              <1> 	mov	al, [ebx+8]
  4856                              <1> 	;mov	dx, [HF_REG_PORT]	; Device Control register
  4857 000050C0 EE                  <1> 	out	dx, al			; SET EXTRA HEAD OPTION
  4858                              <1> 					; -here-
  4859                              <1> 					; Control Byte: (= 08h)
  4860                              <1> 					;  bit 0 - 0
  4861                              <1> 					;  bit 1 - nIEN (1 = disable irq)
  4862                              <1> 					;  bit 2 - SRST (software RESET)
  4863                              <1> 					;  bit 3 - use extra heads (8 to 15)
  4864                              <1> 					;          -always set to 1-	
  4865                              <1> 					;  (bits 3 to 7 are reserved
  4866                              <1> 					;          for ATA devices)
  4867 000050C1 8A25[21780100]      <1> 	mov	ah, [CONTROL_BYTE]	; SET EXTRA HEAD OPTION IN
  4868 000050C7 80E4C0              <1> 	and	ah, 0C0h 		; CONTROL BYTE
  4869 000050CA 08C4                <1> 	or	ah, al
  4870 000050CC 8825[21780100]      <1> 	mov	[CONTROL_BYTE], ah
  4871                              <1> 	
  4872                              <1> 	; 11/04/2021 (32 bit push/pop)
  4873                              <1> 	; 04/01/2015
  4874 000050D2 58                  <1> 	pop	eax ; ****
  4875 000050D3 5A                  <1> 	pop	edx ; * ; 14/02/2015
  4876 000050D4 20E4                <1> 	and	ah, ah	; Reset function ?
  4877 000050D6 7506                <1> 	jnz	short su2
  4878                              <1> 	;pop	es ; **
  4879 000050D8 58                  <1> 	pop	eax ; ***
  4880 000050D9 E9C0000000          <1>         jmp     DISK_RESET
  4881                              <1> su2:
  4882 000050DE 803D[34780100]00    <1> 	cmp	byte [LBAMode], 0
  4883 000050E5 765F                <1> 	jna	short su3
  4884                              <1> 	;
  4885                              <1> 	; 02/02/2015 (LBA read/write function calls)
  4886 000050E7 80FC1B              <1> 	cmp	ah, 1Bh
  4887 000050EA 720B                <1> 	jb	short lbarw1
  4888 000050EC 80FC1C              <1> 	cmp	ah, 1Ch
  4889 000050EF 775A                <1> 	ja 	short invldfnc
  4890                              <1> 	;;pop	edx ; * ; 14/02/2015
  4891                              <1> 	;mov	ax, cx ; Lower word of LBA address (bits 0-15)
  4892 000050F1 89C8                <1> 	mov	eax, ecx ; LBA address (21/02/2015)
  4893                              <1> 	; 13/07/2022
  4894 000050F3 88D1                <1> 	mov	cl, dl ; 14/02/2015
  4895 000050F5 EB2F                <1> 	jmp	short lbarw2
  4896                              <1> 
  4897                              <1> lbarw1:
  4898                              <1> 	; convert CHS to LBA
  4899                              <1> 	;
  4900                              <1> 	; LBA calculation - AWARD BIOS - 1999 - AHDSK.ASM
  4901                              <1> 	; LBA = "# of Heads" * Sectors/Track * Cylinder + Head * Sectors/Track
  4902                              <1> 	;	+ Sector - 1
  4903                              <1> 	; 11/04/2021 (32 bit push/pop)
  4904 000050F7 52                  <1> 	push	edx ; * ;; 14/02/2015
  4905                              <1> 	;xor	dh, dh
  4906 000050F8 31D2                <1> 	xor	edx, edx
  4907                              <1> 	;mov	dl, [ES:BX+14]	; sectors per track (logical)
  4908 000050FA 8A530E              <1> 	mov	dl, [ebx+14]
  4909                              <1> 	;xor	ah, ah
  4910 000050FD 31C0                <1> 	xor	eax, eax
  4911                              <1> 	;mov	al, [ES:BX+2]	; heads (logical) 	
  4912 000050FF 8A4302              <1> 	mov	al, [ebx+2]
  4913 00005102 FEC8                <1> 	dec	al
  4914 00005104 6640                <1> 	inc	ax		; 0 = 256
  4915 00005106 66F7E2              <1> 	mul 	dx
  4916                              <1> 		; AX = # of Heads * Sectors/Track
  4917 00005109 6689CA              <1> 	mov	dx, cx
  4918                              <1> 	;and	cx, 3Fh	 ; sector  (1 to 63)
  4919 0000510C 83E13F              <1> 	and	ecx, 3Fh
  4920 0000510F 86D6                <1> 	xchg	dl, dh
  4921 00005111 C0EE06              <1> 	shr	dh, 6
  4922                              <1> 		; DX = cylinder (0 to 1023)
  4923                              <1> 	;mul 	dx
  4924                              <1> 		; DX:AX = # of Heads" * Sectors/Track * Cylinder
  4925 00005114 F7E2                <1> 	mul	edx
  4926 00005116 FEC9                <1> 	dec	cl ; sector - 1
  4927                              <1> 	;add	ax, cx
  4928                              <1> 	;adc	dx, 0
  4929                              <1> 		; DX:AX = # of Heads" * Sectors/Track * Cylinder + Sector - 1
  4930 00005118 01C8                <1> 	add	eax, ecx
  4931                              <1> 	; 11/04/2021 (32 bit push/pop)
  4932 0000511A 59                  <1> 	pop	ecx ; * ; ch = head, cl = drive number (zero based)
  4933                              <1> 	;push	dx
  4934                              <1> 	;push	ax
  4935 0000511B 50                  <1> 	push	eax
  4936                              <1> 	; 13/07/2022
  4937 0000511C 29C0                <1> 	sub	eax, eax
  4938                              <1> 	;mov	al, [ES:BX+14]	; sectors per track (logical)	
  4939 0000511E 8A430E              <1> 	mov	al, [ebx+14]
  4940 00005121 F6E5                <1> 	mul	ch
  4941                              <1> 		; AX = Head * Sectors/Track
  4942                              <1>         ; 13/07/2022
  4943                              <1> 	;movzx	eax, ax ; 09/12/2017
  4944                              <1> 	;pop	dx
  4945 00005123 5A                  <1> 	pop	edx
  4946                              <1> 	;add	ax, dx
  4947                              <1> 	;pop	dx
  4948                              <1> 	;adc	dx, 0 ; add carry bit
  4949 00005124 01D0                <1> 	add	eax, edx
  4950                              <1> lbarw2:
  4951 00005126 29D2                <1> 	sub	edx, edx ; 21/02/2015
  4952 00005128 88CA                <1> 	mov	dl, cl ; 21/02/2015
  4953 0000512A C645F800            <1>         mov     byte [CMD_BLOCK], 0 ; Features Register
  4954                              <1> 				; NOTE: Features register (1F1h, 171h)
  4955                              <1> 				; is not used for ATA device R/W functions. 
  4956                              <1> 				; It is old/obsolete 'write precompensation'
  4957                              <1> 				; register and error register
  4958                              <1> 				; for old ATA/IDE devices.
  4959                              <1> 	; 18/01/2014
  4960                              <1> 	;mov	ch, [hf_m_s]	; Drive 0 (master) or 1 (slave)
  4961 0000512E 8A0D[22650000]      <1> 	mov	cl, [hf_m_s]
  4962                              <1> 	;shl	ch, 4		; bit 4 (drive bit)
  4963                              <1> 	;or	ch, 0E0h	; bit 5 = 1
  4964                              <1> 				; bit 6 = 1 = LBA mode
  4965                              <1> 				; bit 7 = 1
  4966 00005134 80C90E              <1> 	or	cl, 0Eh ; 1110b
  4967                              <1> 	;and	dh, 0Fh		; LBA byte 4 (bits 24 to 27)
  4968 00005137 25FFFFFF0F          <1> 	and	eax, 0FFFFFFFh
  4969 0000513C C1E11C              <1> 	shl	ecx, 28 ; 21/02/2015
  4970                              <1> 	;or	dh, ch
  4971 0000513F 09C8                <1> 	or	eax, ecx	
  4972                              <1> 	;;mov	[CMD_BLOCK+2], al ; LBA byte 1 (bits 0 to 7)
  4973                              <1> 				  ; (Sector Number Register)
  4974                              <1> 	;;mov	[CMD_BLOCK+3], ah ; LBA byte 2 (bits 8 to 15)
  4975                              <1> 				  ; (Cylinder Low Register)
  4976                              <1> 	;mov	[CMD_BLOCK+2], ax ; LBA byte 1, 2
  4977                              <1> 	;mov	[CMD_BLOCK+4], dl ; LBA byte 3 (bits 16 to 23)
  4978                              <1> 				  ; (Cylinder High Register)
  4979                              <1> 	;;mov	[CMD_BLOCK+5], dh ; LBA byte 4 (bits 24 to 27)
  4980                              <1> 				  ; (Drive/Head Register)
  4981                              <1> 	
  4982                              <1> 	;mov	[CMD_BLOCK+4], dx ; LBA byte 4, LBA & DEV select bits
  4983 00005141 8945FA              <1> 	mov	[CMD_BLOCK+2], eax ; 21/02/2015
  4984                              <1> 	; 14/02/2015
  4985                              <1> 	;mov	dl, cl ; Drive number (INIT_DRV)		
  4986 00005144 EB36                <1> 	jmp	short su4
  4987                              <1> su3:
  4988                              <1> 	; 07/08/2022
  4989                              <1> 	; 13/07/2022
  4990                              <1> 	; 02/02/2015 
  4991                              <1> 	; (1Bh & 1Ch functions are not valid for CHS mode) 
  4992 00005146 80FC14              <1> 	cmp 	ah, 14h
  4993 00005149 7603                <1> 	jna 	short chsfnc
  4994                              <1> invldfnc:
  4995                              <1>         ; 14/02/2015  
  4996                              <1> 	;pop	es ; **
  4997                              <1> 	; 11/04/2021
  4998 0000514B 58                  <1> 	pop	eax ; *** 
  4999 0000514C EB46                <1>         jmp     short BAD_COMMAND
  5000                              <1> chsfnc:	
  5001                              <1> 	;mov	ax, [ES:BX+5]		; GET WRITE PRE-COMPENSATION CYLINDER
  5002 0000514E 668B4305            <1> 	mov	ax, [ebx+5]
  5003                              <1> 	;shr	ax, 2
  5004                              <1> 	; 07/08/2022
  5005 00005152 C1E802              <1> 	shr	eax, 2
  5006 00005155 8845F8              <1> 	mov	[CMD_BLOCK], al
  5007                              <1> 	
  5008                              <1> 	;;mov	al, [ES:BX+8]		; GET CONTROL BYTE MODIFIER
  5009                              <1> 	;;push	edx ; *
  5010                              <1> 	;;mov	dx, [HF_REG_PORT]
  5011                              <1> 	;;out	dx, al			; SET EXTRA HEAD OPTION
  5012                              <1> 	;;pop	edx ; * 
  5013                              <1> 	;;pop	es  ; **
  5014                              <1> 	;;mov	ah, [CONTROL_BYTE]	; SET EXTRA HEAD OPTION IN
  5015                              <1> 	;;and	ah, 0C0h 		; CONTROL BYTE	
  5016                              <1> 	;;or	ah, al
  5017                              <1> 	;;mov	[CONTROL_BYTE], ah
  5018                              <1> 	
  5019 00005158 88C8                <1> 	mov	al, cl			; GET SECTOR NUMBER
  5020 0000515A 243F                <1> 	and	al, 3Fh
  5021 0000515C 8845FA              <1> 	mov	[CMD_BLOCK+2], al
  5022 0000515F 886DFB              <1> 	mov	[CMD_BLOCK+3], ch 	; GET CYLINDER NUMBER
  5023 00005162 88C8                <1> 	mov	al, cl
  5024 00005164 C0E806              <1> 	shr	al, 6
  5025 00005167 8845FC              <1> 	mov	[CMD_BLOCK+4], al 	; CYLINDER HIGH ORDER 2 BITS
  5026                              <1> 	
  5027                              <1> 	;;05/01/2015
  5028                              <1> 	;;mov	al, dl			; DRIVE NUMBER
  5029 0000516A A0[22650000]        <1> 	mov	al, [hf_m_s]
  5030 0000516F C0E004              <1> 	shl	al, 4
  5031 00005172 80E60F              <1> 	and	dh, 0Fh			; HEAD NUMBER
  5032 00005175 08F0                <1> 	or	al, dh
  5033                              <1> 	;or	al, 80h or 20h
  5034 00005177 0CA0                <1> 	or	al, 80h+20h		; ECC AND 512 BYTE SECTORS
  5035 00005179 8845FD              <1> 	mov	[CMD_BLOCK+5], al 	; ECC/SIZE/DRIVE/HEAD
  5036                              <1> su4:
  5037                              <1> 	;pop	es ; **
  5038                              <1>         ;; 14/02/2015
  5039                              <1>         ;;pop	ax
  5040                              <1>         ;;mov	[CMD_BLOCK+1], al	; SECTOR COUNT
  5041                              <1>         ;;push	ax
  5042                              <1>         ;;mov	al, ah			; GET INTO LOW BYTE
  5043                              <1>         ;;xor	ah, ah			; ZERO HIGH BYTE
  5044                              <1>         ;;sal	ax, 1			; *2 FOR TABLE LOOKUP
  5045                              <1>         ; 11/04/2021
  5046 0000517C 58                  <1> 	pop	eax ; *** 
  5047 0000517D 8845F9              <1>         mov     [CMD_BLOCK+1], al
  5048 00005180 29DB                <1>         sub	ebx, ebx
  5049                              <1> 	;xor	bh, bh
  5050 00005182 88E3                <1> 	mov     bl, ah
  5051                              <1>         ;sal	bx, 1
  5052                              <1>         ; 17/07/2022
  5053 00005184 C1E302              <1> 	sal	ebx, 2	; 32 bit offset (21/02/2015)
  5054                              <1> 	;mov	si, ax			; PUT INTO SI FOR BRANCH
  5055                              <1>         ; 13/07/2022
  5056                              <1> 	;cmp	bx, D1L			; TEST WITHIN RANGE
  5057                              <1> 	;jnb	short BAD_COMMAND_POP
  5058 00005187 83FB74              <1> 	cmp	ebx, D1L		; TEST WITHIN RANGE
  5059 0000518A 7308                <1> 	jnb	short BAD_COMMAND
  5060                              <1>         ;xchg	bx, si
  5061 0000518C 87DE                <1>         xchg	ebx, esi
  5062                              <1> 	;;;pop	ax			; RESTORE AX
  5063                              <1> 	;;;pop	bx			; AND DATA ADDRESS
  5064                              <1> 	
  5065                              <1> 	;;push	cx
  5066                              <1> 	;;push	ax			; ADJUST ES:BX
  5067                              <1> 	;mov	cx, bx			; GET 3 HIGH ORDER NIBBLES OF BX
  5068                              <1> 	;shr	cx, 4
  5069                              <1> 	;mov	ax, es
  5070                              <1> 	;add	ax, cx
  5071                              <1> 	;mov	es, ax
  5072                              <1> 	;and	bx, 000Fh		; ES:BX CHANGED TO ES:000X
  5073                              <1> 	;;pop	ax
  5074                              <1> 	;;pop	cx
  5075                              <1> 	;;jmp	word [CS:SI+D1]
  5076                              <1> 	;jmp	word [SI+D1]
  5077                              <1> 	
  5078 0000518E FFA6[E64F0000]      <1> 	jmp	dword [esi+D1]
  5079                              <1> 
  5080                              <1> 	; 07/08/2022
  5081                              <1> 	; 13/07/2022
  5082                              <1> BAD_COMMAND:
  5083 00005194 C605[1F780100]01    <1>         mov	byte [DISK_STATUS1], BAD_CMD ; COMMAND ERROR
  5084 0000519B B000                <1> 	mov	al, 0
  5085 0000519D C3                  <1> 	retn
  5086                              <1> 
  5087                              <1> ; 09/08/2022
  5088                              <1> ; 07/08/2022
  5089                              <1> ; 17/07/2022
  5090                              <1> ; 16/07/2022 - TRDOS 386 v2.0.5
  5091                              <1> ; 10/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
  5092                              <1> 
  5093                              <1> ;----------------------------------------
  5094                              <1> ;	RESET THE DISK SYSTEM  (AH=00H) :
  5095                              <1> ;----------------------------------------
  5096                              <1> 
  5097                              <1> ; 18-1-2015 : one controller reset (not other one)
  5098                              <1> 
  5099                              <1> DISK_RESET:
  5100 0000519E FA                  <1> 	cli
  5101 0000519F E4A1                <1> 	in	al, INTB01		; GET THE MASK REGISTER
  5102                              <1> 	;jmp	$+2
  5103                              <1> 	IODELAY
    78 000051A1 EB00                <2>  jmp short $+2
    79 000051A3 EB00                <2>  jmp short $+2
  5104                              <1> 	;and	al, 0BFh 		; ENABLE FIXED DISK INTERRUPT
  5105 000051A5 243F                <1> 	and	al, 3Fh			; 22/12/2014 (IRQ 14 & IRQ 15)
  5106 000051A7 E6A1                <1> 	out	INTB01, al
  5107 000051A9 FB                  <1> 	sti				; START INTERRUPTS
  5108                              <1> 	; 14/02/2015
  5109                              <1> 	;mov	di, dx
  5110                              <1> 	; 24/12/2021
  5111 000051AA 89D7                <1> 	mov	edi, edx	
  5112                              <1> 	; 04/01/2015
  5113                              <1> 	;xor	di,di
  5114                              <1> drst0:
  5115 000051AC B004                <1> 	mov	al, 04h  ; bit 2 - SRST 
  5116                              <1> 	;mov	dx, HF_REG_PORT
  5117 000051AE 668B15[20650000]    <1> 	mov	dx, [HF_REG_PORT]
  5118 000051B5 EE                  <1> 	out	dx, al			; RESET
  5119                              <1> ;	mov	cx, 10			; DELAY COUNT
  5120                              <1> ;DRD:	dec	cx
  5121                              <1> ;	jnz	short DRD		; WAIT 4.8 MICRO-SEC
  5122                              <1> 	;mov	cx, 2			; wait for 30 micro seconds	
  5123                              <1>         ;mov	ecx, 2 ; 21/02/2015
  5124                              <1> 	; 10/07/2022
  5125 000051B6 29C9                <1> 	sub	ecx, ecx
  5126 000051B8 B102                <1> 	mov	cl, 2
  5127 000051BA E8DFD1FFFF          <1> 	call    WAITF                   ; (Award Bios 1999 - WAIT_REFRESH,
  5128                              <1>                                         ; 40 micro seconds)
  5129 000051BF A0[21780100]        <1> 	mov	al, [CONTROL_BYTE]
  5130 000051C4 240F                <1> 	and	al, 0Fh			; SET HEAD OPTION
  5131 000051C6 EE                  <1> 	out	dx, al			; TURN RESET OFF
  5132 000051C7 E8FD030000          <1> 	call	NOT_BUSY
  5133 000051CC 7514                <1> 	jnz	short DRERR		; TIME OUT ON RESET
  5134 000051CE 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  5135 000051D5 FEC2                <1> 	inc	dl  ; HF_PORT+1
  5136                              <1> 	; 02/01/2015 - Award BIOS 1999 - AHDSK.ASM
  5137                              <1>         ;mov	cl, 10
  5138                              <1>         ;mov	ecx, 10 ; 21/02/2015
  5139                              <1> 	; 17/07/2022
  5140                              <1> 	;xor	ecx, ecx
  5141 000051D7 B10A                <1> 	mov	cl, 10
  5142                              <1> drst1:
  5143 000051D9 EC                  <1> 	in	al, dx			; GET RESET STATUS
  5144 000051DA 3C01                <1> 	cmp	al, 1
  5145                              <1> 	; 04/01/2015
  5146 000051DC 740C                <1> 	jz	short drst2
  5147                              <1> 	;jnz	short DRERR		; BAD RESET STATUS
  5148                              <1>         	; Drive/Head Register - bit 4
  5149                              <1> 	;loop	drst1
  5150                              <1> 	; 17/07/2022
  5151 000051DE FEC9                <1> 	dec	cl
  5152 000051E0 75F7                <1> 	jnz	short drst1
  5153                              <1> DRERR:	
  5154 000051E2 C605[1F780100]05    <1> 	mov	byte [DISK_STATUS1], BAD_RESET ; CARD FAILED
  5155 000051E9 C3                  <1> 	retn
  5156                              <1> drst2:
  5157                              <1> 	; 14/02/2015
  5158                              <1> 	;mov	dx, di
  5159                              <1> 	; 07/08/2022
  5160 000051EA 89FA                <1> 	mov	edx, edi
  5161                              <1> ;drst3:
  5162                              <1> ;	; 05/01/2015
  5163                              <1> ;	shl 	di, 1
  5164                              <1> ;	; 04/01/2015
  5165                              <1> ;	mov	ax, [di+hd_cports]
  5166                              <1> ;	cmp	ax, [HF_REG_PORT]
  5167                              <1> ;	je	short drst4
  5168                              <1> ;	mov	[HF_REG_PORT], ax
  5169                              <1> ;	; 03/01/2015
  5170                              <1> ;	mov	ax, [di+hd_ports]
  5171                              <1> ;       mov     [HF_PORT], ax
  5172                              <1> ;	; 05/01/2014
  5173                              <1> ;	shr	di, 1
  5174                              <1> ;	; 04/01/2015
  5175                              <1> ;	jmp	short drst0	; reset other controller
  5176                              <1> ;drst4:
  5177                              <1> ;	; 05/01/2015
  5178                              <1> ;	shr	di, 1
  5179                              <1> ;	mov	al, [di+hd_dregs]
  5180                              <1> ;	and	al, 10h ; bit 4 only
  5181                              <1> ;	shr	al, 4 ; bit 4  -> bit 0
  5182                              <1> ;	mov	[hf_m_s], al ; (0 = master, 1 = slave)
  5183                              <1> 	;
  5184                              <1> ; 09/08/2022
  5185                              <1> ; (('INIT_DRV' prodedure sets [CMD_BLOCKS+5] value))
  5186                              <1> ;
  5187                              <1> ;	mov	al, [hf_m_s] ; 18/01/2015
  5188                              <1> ;	test	al, 1
  5189                              <1> ;	;jnz	short drst6
  5190                              <1> ;       jnz     short drst4
  5191                              <1> ;	and	byte [CMD_BLOCK+5], 0EFh ; SET TO DRIVE 0
  5192                              <1> ;drst5:
  5193                              <1> drst3:
  5194 000051EC E8F3010000          <1> 	call	INIT_DRV		; SET MAX HEADS
  5195                              <1> 	;mov	dx, di
  5196 000051F1 E8AB020000          <1> 	call	HDISK_RECAL		; RECAL TO RESET SEEK SPEED
  5197                              <1> 	; 04/01/2014
  5198                              <1> ;	inc	di
  5199                              <1> ;	mov	dx, di
  5200                              <1> ;	cmp	dl, [HF_NUM]
  5201                              <1> ;	jb	short drst3
  5202                              <1> ;DRE:
  5203 000051F6 C605[1F780100]00    <1> 	mov	byte [DISK_STATUS1], 0 	; IGNORE ANY SET UP ERRORS
  5204 000051FD C3                  <1> 	retn
  5205                              <1> ;drst6:
  5206                              <1> drst4:		; Drive/Head Register - bit 4
  5207                              <1> ;	or	byte [CMD_BLOCK+5], 010h ; SET TO DRIVE 1
  5208                              <1> ;       ;jmp    short drst5
  5209                              <1> ;       jmp     short drst3
  5210                              <1> 
  5211                              <1> ;----------------------------------------
  5212                              <1> ;	DISK STATUS ROUTINE  (AH = 01H) :
  5213                              <1> ;----------------------------------------
  5214                              <1> 
  5215                              <1> RETURN_STATUS:
  5216 000051FE A0[1F780100]        <1> 	mov	al, [DISK_STATUS1]	; OBTAIN PREVIOUS STATUS
  5217 00005203 C605[1F780100]00    <1> 	mov	byte [DISK_STATUS1], 0	; RESET STATUS
  5218 0000520A C3                  <1> 	retn
  5219                              <1> 
  5220                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  5221                              <1> 
  5222                              <1> ;----------------------------------------
  5223                              <1> ;	READ LONG	     (AH = 0AH) :
  5224                              <1> ;----------------------------------------
  5225                              <1> 
  5226                              <1> RD_LONG:
  5227                              <1> 	;mov	@CMD_BLOCK+6, READ_CMD OR ECC_MODE
  5228 0000520B C645FE22            <1> 	mov     byte [CMD_BLOCK+6], READ_CMD + ECC_MODE 
  5229 0000520F EB04                <1> 	jmp	short COMMANDI
  5230                              <1> 
  5231                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  5232                              <1> 
  5233                              <1> ;----------------------------------------
  5234                              <1> ;	DISK READ ROUTINE    (AH = 02H) :
  5235                              <1> ;----------------------------------------
  5236                              <1> 
  5237                              <1> DISK_READ:
  5238 00005211 C645FE20            <1> 	mov	byte [CMD_BLOCK+6], READ_CMD
  5239                              <1>         ;jmp	COMMANDI
  5240                              <1> 
  5241                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  5242                              <1> 
  5243                              <1> ;----------------------------------------
  5244                              <1> ; COMMANDI				:
  5245                              <1> ;	REPEATEDLY INPUTS DATA TILL	:
  5246                              <1> ;	NSECTOR RETURNS ZERO		:
  5247                              <1> ;----------------------------------------
  5248                              <1> COMMANDI:
  5249                              <1> 	; 16/07/2022 
  5250                              <1> 	;	(check 64K boundary is not needed)
  5251                              <1> 	;call	CHECK_DMA		; CHECK 64K BOUNDARY ERROR
  5252                              <1> 	;jc	short CMD_ABORT
  5253                              <1> 
  5254                              <1> 	;mov	di, bx
  5255 00005215 89DF                <1> 	mov	edi, ebx ; 21/02/2015
  5256 00005217 E80B030000          <1> 	call	COMMAND 		; OUTPUT COMMAND
  5257 0000521C 7548                <1> 	jnz	short CMD_ABORT
  5258                              <1> CMD_I1:
  5259 0000521E E876030000          <1> 	call	_WAIT			; WAIT FOR DATA REQUEST INTERRUPT
  5260 00005223 7541                <1> 	jnz	short TM_OUT		; TIME OUT
  5261                              <1> cmd_i1x:
  5262                              <1> 	; 18/02/2016
  5263                              <1> 	;;mov	cx, 256			; SECTOR SIZE IN WORDS
  5264                              <1> 	;mov	ecx, 256 ; 21/02/2015	
  5265                              <1> 	; 16/07/2022
  5266 00005225 29C9                <1> 	sub	ecx, ecx
  5267 00005227 FEC5                <1> 	inc	ch  ; ecx = 256
  5268                              <1> 	;mov	dh, HF_PORT
  5269 00005229 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  5270 00005230 FA                  <1> 	cli
  5271 00005231 FC                  <1> 	cld
  5272 00005232 F3666D              <1> 	rep	insw			; GET THE SECTOR
  5273 00005235 FB                  <1> 	sti
  5274                              <1> 
  5275 00005236 F645FE02            <1> 	test	byte [CMD_BLOCK+6], ECC_MODE ; CHECK FOR NORMAL INPUT
  5276 0000523A 7418                <1> 	jz	short CMD_I3
  5277 0000523C E8AF030000          <1> 	call	WAIT_DRQ		; WAIT FOR DATA REQUEST
  5278 00005241 7223                <1> 	jc	short TM_OUT
  5279                              <1> 	;mov	dx, HF_PORT
  5280 00005243 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  5281                              <1> 	;;mov	cx, 4			; GET ECC BYTES
  5282                              <1> 	;mov 	ecx, 4 ; mov cx, 4
  5283                              <1> 	; 16/07/2022
  5284 0000524A 31C9                <1>  	xor	ecx, ecx
  5285 0000524C B104                <1> 	mov	cl, 4
  5286                              <1> CMD_I2:
  5287 0000524E EC                  <1> 	in	al, dx
  5288 0000524F 8807                <1> 	mov 	[edi], al ; 21/02/2015	; GO SLOW FOR BOARD
  5289 00005251 47                  <1> 	inc	edi
  5290 00005252 E2FA                <1> 	loop	CMD_I2
  5291                              <1> CMD_I3: 
  5292                              <1> 	; wait for 400 ns
  5293 00005254 80C207              <1> 	add 	dl, 7
  5294 00005257 EC                  <1> 	in	al, dx
  5295 00005258 EC                  <1> 	in	al, dx
  5296 00005259 EC                  <1> 	in	al, dx
  5297                              <1> 	;
  5298 0000525A E8DE010000          <1> 	call	CHECK_STATUS
  5299 0000525F 7505                <1> 	jnz	short CMD_ABORT		; ERROR RETURNED
  5300 00005261 FE4DF9              <1> 	dec	byte [CMD_BLOCK+1]	; CHECK FOR MORE
  5301                              <1> 	;jnz	short CMD_I1
  5302 00005264 75BF                <1> 	jnz	short cmd_i1x ; 18/02/2016
  5303                              <1> CMD_ABORT:
  5304                              <1> TM_OUT: 
  5305 00005266 C3                  <1> 	retn
  5306                              <1> 
  5307                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  5308                              <1> 
  5309                              <1> ;----------------------------------------
  5310                              <1> ;	WRITE LONG	     (AH = 0BH) :
  5311                              <1> ;----------------------------------------
  5312                              <1> 
  5313                              <1> WR_LONG:
  5314                              <1> 	;mov	@CMD_BLOCK+6, WRITE_CMD OR ECC_MODE
  5315 00005267 C645FE32            <1> 	mov	byte [CMD_BLOCK+6], WRITE_CMD + ECC_MODE
  5316 0000526B EB04                <1> 	jmp	short COMMANDO
  5317                              <1> 
  5318                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  5319                              <1> 	
  5320                              <1> ;----------------------------------------
  5321                              <1> ;	DISK WRITE ROUTINE   (AH = 03H) :
  5322                              <1> ;----------------------------------------
  5323                              <1> 
  5324                              <1> DISK_WRITE:
  5325 0000526D C645FE30            <1> 	mov	byte [CMD_BLOCK+6], WRITE_CMD
  5326                              <1> 	;jmp	COMMANDO
  5327                              <1> 
  5328                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  5329                              <1> 
  5330                              <1> ;----------------------------------------
  5331                              <1> ; COMMANDO				:
  5332                              <1> ;	REPEATEDLY OUTPUTS DATA TILL	:
  5333                              <1> ;	NSECTOR RETURNS ZERO		:
  5334                              <1> ;----------------------------------------
  5335                              <1> COMMANDO:
  5336                              <1> 	; 16/07/2022 
  5337                              <1> 	;	(check 64K boundary is not needed)
  5338                              <1> 	;call	CHECK_DMA		; CHECK 64K BOUNDARY ERROR
  5339                              <1> 	;jc	short CMD_ABORT
  5340                              <1> CMD_OF: 
  5341 00005271 89DE                <1> 	mov	esi, ebx ; 21/02/2015
  5342 00005273 E8AF020000          <1> 	call	COMMAND 		; OUTPUT COMMAND
  5343 00005278 75EC                <1> 	jnz	short CMD_ABORT
  5344 0000527A E871030000          <1> 	call	WAIT_DRQ		; WAIT FOR DATA REQUEST
  5345 0000527F 72E5                <1> 	jc	short TM_OUT		; TOO LONG
  5346                              <1> CMD_O1: 
  5347                              <1> 	; 16/07/2022
  5348 00005281 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  5349                              <1> 
  5350                              <1> 	;mov	ecx, 256 ; 21/02/2015
  5351 00005288 31C9                <1> 	xor	ecx, ecx
  5352 0000528A FEC5                <1> 	inc	ch
  5353                              <1> 	; ecx = 256
  5354 0000528C FA                  <1> 	cli
  5355 0000528D FC                  <1> 	cld
  5356 0000528E F3666F              <1> 	rep	outsw
  5357 00005291 FB                  <1> 	sti
  5358                              <1> 
  5359 00005292 F645FE02            <1> 	test	byte [CMD_BLOCK+6], ECC_MODE ; CHECK FOR NORMAL OUTPUT
  5360 00005296 7418                <1> 	jz	short CMD_O3
  5361 00005298 E853030000          <1> 	call	WAIT_DRQ		; WAIT FOR DATA REQUEST
  5362 0000529D 72C7                <1> 	jc	short TM_OUT
  5363                              <1> 	;mov	dx, HF_PORT
  5364 0000529F 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  5365                              <1> 					; OUTPUT THE ECC BYTES
  5366                              <1> 	;mov	ecx, 4  ; mov cx, 4
  5367                              <1> 	; 16/07/2022
  5368 000052A6 29C9                <1> 	sub	ecx, ecx
  5369 000052A8 B104                <1> 	mov	cl, 4
  5370                              <1> CMD_O2:
  5371 000052AA 8A06                <1> 	mov	al, [esi]
  5372 000052AC EE                  <1> 	out	dx, al
  5373 000052AD 46                  <1> 	inc	esi
  5374 000052AE E2FA                <1> 	loop	CMD_O2
  5375                              <1> CMD_O3:
  5376 000052B0 E8E4020000          <1> 	call	_WAIT			; WAIT FOR SECTOR COMPLETE INTERRUPT
  5377 000052B5 75AF                <1> 	jnz	short TM_OUT		; ERROR RETURNED
  5378 000052B7 E881010000          <1> 	call	CHECK_STATUS
  5379 000052BC 75A8                <1> 	jnz	short CMD_ABORT
  5380 000052BE F605[19780100]08    <1> 	test	byte [HF_STATUS], ST_DRQ ; CHECK FOR MORE
  5381 000052C5 75BA                <1> 	jnz	short CMD_O1
  5382                              <1> 	;mov	dx, HF_PORT+2		; CHECK RESIDUAL SECTOR COUNT
  5383 000052C7 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  5384 000052CE 80C202              <1> 	add	dl, 2
  5385                              <1> 	;inc	dl
  5386                              <1> 	;inc	dl
  5387 000052D1 EC                  <1> 	in	al, dx			;
  5388 000052D2 A8FF                <1> 	test	al, 0FFh 		;
  5389 000052D4 7407                <1> 	jz	short CMD_O4		; COUNT = 0 OK
  5390 000052D6 C605[1F780100]BB    <1> 	mov	byte [DISK_STATUS1], UNDEF_ERR 
  5391                              <1> 					; OPERATION ABORTED - PARTIAL TRANSFER
  5392                              <1> CMD_O4:
  5393 000052DD C3                  <1> 	retn
  5394                              <1> 
  5395                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  5396                              <1> 
  5397                              <1> ;----------------------------------------
  5398                              <1> ;	FORMATTING	     (AH = 05H) :
  5399                              <1> ;----------------------------------------
  5400                              <1> 
  5401                              <1> FMT_TRK:				; FORMAT TRACK (AH = 005H)
  5402 000052DE C645FE50            <1> 	mov	byte [CMD_BLOCK+6], FMTTRK_CMD
  5403                              <1> 	;push	es
  5404                              <1> 	;push	bx
  5405 000052E2 53                  <1> 	push	ebx
  5406 000052E3 E896030000          <1> 	call	GET_VEC 		; GET DISK PARAMETERS ADDRESS
  5407                              <1> 	;mov	al, [ES:BX+14]		; GET SECTORS/TRACK
  5408 000052E8 8A430E              <1> 	mov	al, [ebx+14]
  5409 000052EB 8845F9              <1> 	mov	[CMD_BLOCK+1], al	; SET SECTOR COUNT IN COMMAND
  5410 000052EE 5B                  <1> 	pop	ebx
  5411                              <1> 	;pop	bx
  5412                              <1> 	;pop	es
  5413 000052EF EB80                <1> 	jmp	short CMD_OF		; GO EXECUTE THE COMMAND
  5414                              <1> 
  5415                              <1> ;----------------------------------------
  5416                              <1> ;	DISK VERIFY	     (AH = 04H) :
  5417                              <1> ;----------------------------------------
  5418                              <1> 
  5419                              <1> DISK_VERF:
  5420 000052F1 C645FE40            <1> 	mov	byte [CMD_BLOCK+6], VERIFY_CMD
  5421 000052F5 E82D020000          <1> 	call	COMMAND
  5422 000052FA 750C                <1> 	jnz	short VERF_EXIT		; CONTROLLER STILL BUSY
  5423 000052FC E898020000          <1> 	call	_WAIT			; (Original: CALL WAIT)	
  5424 00005301 7505                <1> 	jnz	short VERF_EXIT		; TIME OUT
  5425 00005303 E835010000          <1> 	call	CHECK_STATUS
  5426                              <1> VERF_EXIT:
  5427 00005308 C3                  <1> 	retn
  5428                              <1> 
  5429                              <1> ;----------------------------------------
  5430                              <1> ;	READ DASD TYPE	     (AH = 15H) :
  5431                              <1> ;----------------------------------------
  5432                              <1> 
  5433                              <1> RETURN_DRIVE_TYPE:
  5434                              <1> 	; 10/08/2022
  5435                              <1> 	; 13/07/2022
  5436                              <1> 	; (Ref: Programmer's Guide to the AMIBIOS -Page 214-, 1992)
  5437                              <1> 	;
  5438                              <1> 	; INPUT:
  5439                              <1> 	;	DL = Disk number (>= 80h)
  5440                              <1> 	;   TRDOS 386 v2.0.5 Feature:
  5441                              <1> 	;	If AL = 0FFh, return disk size in ECX
  5442                              <1> 	;		otherwise in CX:DX
  5443                              <1> 	; OUTPUT:
  5444                              <1> 	;	AH = 00h - No drive present
  5445                              <1> 	;	   = 03h - Hard disk drive
  5446                              <1> 	;	CF = 0 - No error
  5447                              <1> 	;	   = 1 - Error  	 
  5448                              <1> 	;   TRDOS 386 v2.0.5 Feature:
  5449                              <1> 	;	AL = 00h - LBA not ready !	
  5450                              <1> 	;	   = 01h - LBA ready 
  5451                              <1> 	;		(28 bit or 48 bit LBA r/w depending
  5452                              <1> 	;		on disk size in CX:DX)
  5453                              <1> 	;	CX:DX = Number of 512 byte sectors
  5454                              <1> 	;
  5455                              <1> 	; (Note: High words of ECX and EDX will be zero at return)
  5456                              <1> 	; ((If AL input is 0FFh, disk size will be in ECX only))
  5457                              <1> 
  5458                              <1> READ_DASD_TYPE:
  5459                              <1> READ_D_T:				; GET DRIVE PARAMETERS
  5460                              <1> 	;push	ds			; SAVE REGISTERS
  5461                              <1> 	
  5462                              <1> 	;;push	es
  5463                              <1> 	; 18/04/2021
  5464                              <1> 	;push	ebx
  5465                              <1> 	;;call	DDS			; ESTABLISH ADDRESSING
  5466                              <1> 	;;push	cs
  5467                              <1> 	;;pop	ds
  5468                              <1>         
  5469                              <1> 	; 18/04/2021
  5470                              <1> 	;mov	bx, KDATA
  5471                              <1> 	;mov	ds, bx
  5472                              <1> 	;;mov	es, bx
  5473                              <1> 	;mov	byte [DISK_STATUS1], 0
  5474                              <1> 	;mov	bl, [HF_NUM]		; GET NUMBER OF DRIVES
  5475                              <1> 	;and	dl, 7Fh			; GET DRIVE NUMBER
  5476                              <1> 	;cmp	bl, dl
  5477                              <1> 	;jbe	short RDT_NOT_PRESENT 	; RETURN DRIVE NOT PRESENT
  5478                              <1> 	
  5479                              <1> 	;mov	ax, KDATA
  5480                              <1> 	;mov	ds, ax
  5481                              <1> 	
  5482 00005309 C605[1F780100]00    <1> 	mov	byte [DISK_STATUS1], 0
  5483 00005310 8A0D[20780100]      <1> 	mov	cl, [HF_NUM]
  5484 00005316 80E27F              <1> 	and	dl, 7Fh
  5485 00005319 38D1                <1> 	cmp	cl, dl
  5486 0000531B 7631                <1> 	jbe	short RDT_NOT_PRESENT
  5487                              <1> 
  5488                              <1> 	; 18/04/2021 - TRDOS 386 v2.0.4
  5489                              <1> 	
  5490                              <1> 	;call	GET_VEC 		; GET DISK PARAMETER ADDRESS
  5491                              <1> 	;
  5492                              <1> 	;;mov	al, [ES:BX+2]		; HEADS
  5493                              <1> 	;mov	al, [ebx+2]  ; heads (logical)
  5494                              <1> 	;;;mov	cl, [ES:BX+14]
  5495                              <1> 	;;mov	cl, [ebx+14]
  5496                              <1> 	;; 17/04/2021
  5497                              <1> 	;mov	ah, [ebx+14] ; sectors per track (logical)
  5498                              <1> 	;;imul	cl			; * NUMBER OF SECTORS
  5499                              <1> 	;;mov	cx, [ES:BX]		; MAX NUMBER OF CYLINDERS
  5500                              <1> 	;mov	cx, [ebx]    ; cylinders (logical)
  5501                              <1> 	;; 02/01/2015 
  5502                              <1> 	;; ** leave the last cylinder as reserved for diagnostics **
  5503                              <1> 	;; (Also in Award BIOS - 1999, AHDSK.ASM, FUN15 -> sub ax, 1)
  5504                              <1> 	;dec	cx			; LEAVE ONE FOR DIAGNOSTICS
  5505                              <1> 	;;imul	cx			; NUMBER OF SECTORS	 	
  5506                              <1> 	;; 17/04/2021
  5507                              <1> 	;mul	ah
  5508                              <1> 	;; ax = spt*heads
  5509                              <1> 	;mul	cx	 
  5510                              <1> 	;; dx:ax = number of sectors
  5511                              <1> 	;
  5512                              <1> 	;mov	cx, dx			; HIGH ORDER HALF
  5513                              <1> 	;mov	dx, ax			; LOW ORDER HALF
  5514                              <1> 
  5515                              <1> 	; 18/04/2021
  5516 0000531D B102                <1> 	mov	cl, 2
  5517 0000531F 00CA                <1> 	add	dl, cl ; hd0 = 2
  5518                              <1> 
  5519                              <1> 	; 13/07/2022
  5520 00005321 0FB6D2              <1> 	movzx	edx, dl
  5521 00005324 8A9A[4E650000]      <1> 	mov	bl, [edx+drv.status]
  5522 0000532A 80E301              <1> 	and	bl, 1 ; LBA ready bit (bit 0) 
  5523                              <1> 
  5524 0000532D D2E2                <1> 	shl	dl, cl ; * 4
  5525                              <1> 	
  5526                              <1> 	;mov	eax, [edx+drv.size]
  5527                              <1> 	;mov	dx, ax
  5528                              <1> 	;shr	eax, 16
  5529                              <1> 	;mov	cx, ax
  5530                              <1> 
  5531 0000532F 8B8A[32650000]      <1> 	mov	ecx, [edx+drv.size]
  5532                              <1> 
  5533                              <1> 	; 13/07/2022
  5534                              <1> 	;cmp	al, 0FFh   ; return disk size in ecx ?
  5535                              <1> 	;je	short RDT1 ; yes
  5536 00005335 FEC0                <1> 	inc	al  ; 0FFh -> 0
  5537 00005337 740A                <1> 	jz	short RDT1
  5538                              <1> 
  5539 00005339 6689CA              <1> 	mov	dx, cx
  5540 0000533C C1E910              <1> 	shr	ecx, 16
  5541                              <1> 
  5542                              <1> 	; 13/07/2022
  5543                              <1> 	; ebx = esp+20
  5544                              <1> 	; ecx = esp+16
  5545                              <1> 	; edx = esp+12
  5546                              <1> 	; esi = esp+8
  5547                              <1> 	; edi = esp+4
  5548                              <1> 
  5549                              <1> 	; return disk size in user's registers
  5550 0000533F 8954240C            <1> 	mov	[esp+12], edx
  5551                              <1> 	; cx:dx = disk size
  5552                              <1> RDT1:
  5553                              <1> 	;mov	[esp+16], ecx
  5554                              <1> 
  5555                              <1> 	;;sub	al, al
  5556 00005343 29C0                <1> 	sub	eax, eax
  5557 00005345 B403                <1> 	mov	ah, 03h			; INDICATE FIXED DISK
  5558 00005347 88D8                <1> 	mov	al, bl
  5559                              <1> 	; al = 1 -> LBA r/w ready/applicable
  5560                              <1> 	;    = 0 -> LBA r/w not ready/applicable	 
  5561                              <1> 	; cf = 0
  5562                              <1> RDT2:
  5563 00005349 894C2410            <1> 	mov	[esp+16], ecx	
  5564                              <1> ;RDT2:
  5565                              <1> 	; 13/07/2022
  5566                              <1> 	; 18/04/2021
  5567                              <1> 	;pop	ebx			; RESTORE REGISTERS
  5568                              <1> 	;;pop	es
  5569                              <1> 	;pop	ds
  5570                              <1> 	; (*) clc			; CLEAR CARRY
  5571                              <1> 	;retf	2
  5572                              <1> 	; (*) 29/05/2016
  5573                              <1> 	; (*) retf 4
  5574                              <1> 	;and	byte [esp+8], 0FEh ; clear carry bit of eflags register
  5575                              <1> 	;iretd
  5576                              <1> 
  5577                              <1> 	; 13/07/2022
  5578                              <1> 	; [DISK_STATUS1] = 0
  5579                              <1> 	; ah = 3
  5580                              <1> 	; al = 0 or 1 (LBA ready)
  5581                              <1> 	; cf = 0	
  5582                              <1> 	
  5583 0000534D C3                  <1> 	retn
  5584                              <1> 
  5585                              <1> RDT_NOT_PRESENT:
  5586                              <1> 	;;sub	ax, ax			; DRIVE NOT PRESENT RETURN
  5587                              <1> 	;; 18/04/2021
  5588                              <1> 	;sub	eax, eax
  5589                              <1> 	;;mov	cx, ax			; ZERO BLOCK COUNT
  5590                              <1> 	;;mov	dx, ax
  5591                              <1> 	;mov	ecx, eax
  5592                              <1> 	;mov	edx, eax
  5593                              <1> 	;jmp	short RDT2
  5594                              <1> 	; 13/07/2022
  5595 0000534E 29C9                <1> 	sub	ecx, ecx
  5596 00005350 88C1                <1> 	mov	cl, al ; if AL = 0FFh, disk size will be in ECX
  5597                              <1> 		       ; if not, disk size will be in CX:DX 
  5598 00005352 29C0                <1> 	sub	eax, eax
  5599 00005354 FEC1                <1> 	inc	cl ; 0FFh -> 0
  5600 00005356 80F901              <1> 	cmp	cl, 1
  5601 00005359 72EE                <1> 	jb	short RDT2 ; ecx = 0
  5602                              <1> 	; 10/08/2022
  5603 0000535B 28C9                <1> 	sub	cl, cl
  5604                              <1> 	; ecx = 0
  5605 0000535D 8944240C            <1> 	mov	[esp+12], eax ; edx = 0
  5606 00005361 F9                  <1> 	stc
  5607 00005362 EBE5                <1> 	jmp	short RDT2 ; cf = 1, eax = 0	
  5608                              <1> 
  5609                              <1> ; 10/08/2022
  5610                              <1> ; 07/08/2022
  5611                              <1> ; 13/07/2022 - TRDOS 386 v2.0.5
  5612                              <1> ; 28/05/2016
  5613                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  5614                              <1> 
  5615                              <1> ;----------------------------------------
  5616                              <1> ;	GET PARAMETERS	     (AH = 08H) :
  5617                              <1> ;----------------------------------------
  5618                              <1> 
  5619                              <1> GET_PARM_N:
  5620                              <1> 	; ebx = user's buffer address for parameters table
  5621                              <1> 	; 10/08/2022
  5622                              <1> 	; 13/07/2022
  5623                              <1> 	; (if ebx = 0, HDPT will not be returned to user)
  5624                              <1> 	;	
  5625                              <1> ;GET_PARM:				; GET DRIVE PARAMETERS
  5626                              <1> 	;push	ds			; SAVE REGISTERS
  5627                              <1> 	;push	es
  5628                              <1> 	
  5629                              <1> 	;push	ebx
  5630 00005364 89DF                <1> 	mov	edi, ebx ; 13/07/2022 	
  5631                              <1> 
  5632                              <1> 	; 13/07/2022
  5633                              <1> 	; ((IBM PC XT-286 ROM BIOS source code remainders))
  5634                              <1> 	;;mov	ax, ABS0 		; ESTABLISH ADDRESSING
  5635                              <1> 	;;mov	ds, ax
  5636                              <1> 	
  5637                              <1> 	;;test	dl, 1			; CHECK FOR DRIVE 1
  5638                              <1> 	;;jz	short G0
  5639                              <1> 	;;les	bx, @HF1_TBL_VEC
  5640                              <1> 	;;jmp	short G1
  5641                              <1> ;;G0:	
  5642                              <1> 	;les	bx, @HF_TBL_VEC
  5643                              <1> ;;G1:
  5644                              <1> 	;;call	DDS			; ESTABLISH SEGMENT
  5645                              <1> 	
  5646                              <1> 	; 13/07/2022
  5647                              <1> 	; 22/12/2014
  5648                              <1> 	;;push	cs
  5649                              <1> 	;;pop	ds
  5650                              <1> 	;mov	bx, KDATA
  5651                              <1> 	;mov	ds, bx
  5652                              <1> 	;mov	es, bx	; 27/05/2016
  5653                              <1> 	;
  5654                              <1> 	; 18/04/2021
  5655 00005366 29C9                <1> 	sub	ecx, ecx
  5656                              <1> 	;
  5657 00005368 80EA80              <1> 	sub	dl, 80h
  5658 0000536B 80FA04              <1> 	cmp	dl, MAX_FILE		; TEST WITHIN RANGE
  5659 0000536E 7344                <1> 	jae	short G2 ; 13/07/2022
  5660                              <1> 	;
  5661                              <1>  	; 21/02/2015
  5662 00005370 31DB                <1> 	xor	ebx, ebx
  5663                              <1> 	; 18/04/2021
  5664                              <1> 	;sub	ecx, ecx
  5665                              <1> 	; 22/12/2014
  5666 00005372 88D3                <1> 	mov	bl, dl
  5667                              <1> 	;xor	bh, bh  
  5668 00005374 C0E302              <1> 	shl	bl, 2			; convert index to offset
  5669                              <1> 	;add	bx, HF_TBL_VEC
  5670 00005377 81C3[24780100]      <1> 	add	ebx, HF_TBL_VEC
  5671                              <1> 	;mov	ax, [bx+2]
  5672                              <1> 	;mov	es, ax			; dpt segment
  5673                              <1> 	;mov	bx, [bx]		; dpt offset
  5674 0000537D 8B1B                <1> 	mov	ebx, [ebx] ; 32 bit offset	
  5675                              <1> 	; 18/04/2021
  5676 0000537F 29D2                <1> 	sub	edx, edx
  5677 00005381 8815[1F780100]      <1>  	mov	[DISK_STATUS1], dl ; 0
  5678                              <1> 
  5679                              <1> 	;mov	byte [DISK_STATUS1], 0
  5680                              <1>         ;mov	ax, [ES:BX]		; MAX NUMBER OF CYLINDERS
  5681 00005387 668B03              <1> 	mov	ax, [ebx]
  5682                              <1> 	;;sub	ax, 2			; ADJUST FOR 0-N
  5683 0000538A 6648                <1> 	dec	ax			; max. cylinder number
  5684 0000538C 88C5                <1> 	mov	ch, al
  5685 0000538E 66250003            <1> 	and	ax, 0300h		; HIGH TWO BITS OF CYLINDER
  5686                              <1> 	;shr	ax, 1
  5687                              <1> 	;shr	ax, 1
  5688                              <1> 	; 13/07/2022
  5689                              <1> 	;shr	ax, 2
  5690                              <1> 	; 07/08/2022
  5691 00005392 C1E802              <1> 	shr	eax, 2
  5692                              <1> 	;or	al, [ES:BX+14]		; SECTORS
  5693 00005395 0A430E              <1> 	or	al, [ebx+14]
  5694 00005398 88C1                <1> 	mov	cl, al
  5695                              <1> 	;mov	dh, [ES:BX+2]		; HEADS
  5696 0000539A 8A7302              <1> 	mov	dh, [ebx+2]
  5697 0000539D FECE                <1> 	dec	dh			; 0-N RANGE
  5698 0000539F 8A15[20780100]      <1> 	mov	dl, [HF_NUM]		; DRIVE COUNT
  5699                              <1> 	;;sub	ax, ax
  5700                              <1> 	; 18/04/2021
  5701                              <1> 	;sub	eax, eax
  5702                              <1> 
  5703                              <1> 	; 27/12/2014 
  5704                              <1> 	;mov	di, bx			; HDPT offset
  5705                              <1> 
  5706                              <1> 	; 13/07/2022
  5707                              <1> 	; ebx = esp+20
  5708                              <1> 	; ecx = esp+16
  5709                              <1> 	; edx = esp+12
  5710                              <1> 	; esi = esp+8
  5711                              <1> 	; edi = esp+4
  5712                              <1> 
  5713                              <1> 	; 13/07/2022
  5714                              <1> 	; set return register contents/values
  5715 000053A5 894C2410            <1> 	mov	[esp+16], ecx
  5716 000053A9 8954240C            <1> 	mov	[esp+12], edx
  5717                              <1> 
  5718                              <1> 	; is hard disk parameters table requested ?
  5719 000053AD 09FF                <1> 	or	edi, edi ; (edi = [ebp+24] = ebx)
  5720 000053AF 751B                <1> 	jnz	short G3 ; yes
  5721                              <1> 
  5722 000053B1 29C0                <1> 	sub	eax, eax	
  5723                              <1> 
  5724                              <1> 	; [DISK_STATUS1] = 0
  5725                              <1> 	; eax = 0
  5726                              <1> 	; cf = 0
  5727                              <1> 
  5728 000053B3 C3                  <1> 	retn
  5729                              <1> 
  5730                              <1> G2:
  5731                              <1> 	;mov	ah, INIT_FAIL
  5732                              <1> 	;mov	byte [DISK_STATUS1], ah ; (INIT_FAIL)
  5733                              <1> 	;				; OPERATION FAILED
  5734                              <1> 	;sub	al, al
  5735                              <1> 	;sub	dx, dx
  5736                              <1> 	;sub	cx, cx
  5737                              <1> 	; 18/04/2021
  5738 000053B4 29C0                <1> 	sub	eax, eax
  5739 000053B6 B407                <1> 	mov	ah, INIT_FAIL
  5740 000053B8 8825[1F780100]      <1> 	mov     [DISK_STATUS1], ah	; OPERATION FAILED
  5741                              <1> 
  5742                              <1> 	; 13/07/2022
  5743                              <1> 	;sub	edx, edx
  5744                              <1> 	;sub	ecx, ecx
  5745                              <1> 	; ecx = 0
  5746 000053BE 894C240C            <1> 	mov	[esp+12], ecx ; 0 ; edx (heads-1, drive count)
  5747 000053C2 894C2410            <1> 	mov	[esp+16], ecx ; 0 ; ecx (cylinders-1, sectors)
  5748 000053C6 894C2414            <1> 	mov	[esp+20], ecx ; 0 ; ebx (HDPT address)
  5749                              <1> 
  5750 000053CA F9                  <1> 	stc
  5751 000053CB C3                  <1> 	retn
  5752                              <1> 
  5753                              <1> 	; 13/07/2022
  5754                              <1> 	; 29/05/2016 (*)
  5755                              <1> 	;;stc				; SET ERROR FLAG
  5756                              <1> 	;;jmp	short G5
  5757                              <1> 	;jmp	short _G6
  5758                              <1> 
  5759                              <1> G3:	
  5760                              <1> 	; 27/05/2016
  5761                              <1> 	; return fixed disk parameters table to user
  5762                              <1> 	; in user's buffer, which is pointed by EBX
  5763                              <1> 	
  5764                              <1> 	;xchg	edi, [esp]		; ebx (input)-> edi, edi -> [esp]
  5765                              <1> 	; 13/07/2022
  5766                              <1> 	;pop	edi
  5767                              <1> 	; edi = user's buffer address
  5768                              <1> 	;push	esi
  5769 000053CC 89DE                <1> 	mov	esi, ebx		; hard disk parameter table (32 bytes)	
  5770                              <1> 	;mov	ebx, edi		; ebx = user's buffer address
  5771 000053CE 51                  <1> 	push	ecx
  5772                              <1> 	;push	eax
  5773                              <1> 	;mov	ecx, 32 ; 32 bytes
  5774 000053CF 30ED                <1> 	xor	ch, ch
  5775 000053D1 B120                <1> 	mov	cl, 32
  5776                              <1> 	; ecx = 32
  5777 000053D3 E881B90000          <1> 	call	transfer_to_user_buffer ; trdosk6.s (16/05/2016)
  5778                              <1> 	;pop	eax
  5779 000053D8 59                  <1> 	pop	ecx
  5780                              <1> 	; 10/08/2022
  5781                              <1> 	;pop	esi
  5782                              <1> 	;pop	edi
  5783 000053D9 7306                <1> 	jnc	short G4
  5784                              <1> 	; 29/05/2016 (*)
  5785 000053DB B8FF000000          <1> 	mov	eax, 0FFh ; unknown error !
  5786                              <1> 	; [DISK_STATUS1] = 0
  5787                              <1> 	; ah = 0, al = 0FFh
  5788                              <1> 	; cf = 1
  5789                              <1> 	
  5790 000053E0 C3                  <1> 	retn
  5791                              <1> ;_G6:
  5792                              <1> 	;or	byte [esp+16], 1 ; set carry bit of eflags register
  5793                              <1> ;G5:
  5794                              <1> 	; 27/05/2016
  5795                              <1> 	;pop	ebx			; RESTORE REGISTERS
  5796                              <1> 	;pop	es
  5797                              <1> 	;pop	ds
  5798                              <1> 	;;retf	2
  5799                              <1> 	; (*) 29/05/2016
  5800                              <1> 	; (*) retf 4
  5801                              <1> 	; (*) or byte [esp+8], 1 ; set carry bit of eflags register
  5802                              <1> 	;iretd
  5803                              <1> 
  5804                              <1> G4:
  5805                              <1> 	; 13/07/2022
  5806 000053E1 31C0                <1> 	xor	eax, eax
  5807                              <1> 
  5808                              <1> 	; [user_buffer] = [ebp+24] = HDPT
  5809                              <1> 	; [DISK_STATUS1] = 0
  5810                              <1> 	; eax = 0
  5811                              <1> 	; cf = 0
  5812                              <1> 
  5813 000053E3 C3                  <1> 	retn
  5814                              <1> 
  5815                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  5816                              <1> 	
  5817                              <1> ;----------------------------------------
  5818                              <1> ;	INITIALIZE DRIVE     (AH = 09H) :
  5819                              <1> ;----------------------------------------
  5820                              <1> 	; 03/01/2015
  5821                              <1> 	; According to ATA-ATAPI specification v2.0 to v5.0
  5822                              <1> 	; logical sector per logical track
  5823                              <1> 	; and logical heads - 1 would be set but
  5824                              <1> 	; it is seen as it will be good
  5825                              <1> 	; if physical parameters will be set here
  5826                              <1> 	; because, number of heads <= 16.
  5827                              <1> 	; (logical heads usually more than 16)
  5828                              <1> 	; NOTE: ATA logical parameters (software C, H, S)
  5829                              <1> 	;	== INT 13h physical parameters
  5830                              <1> 
  5831                              <1> ;INIT_DRV:
  5832                              <1> ;	mov	byte [CMD_BLOCK+6], SET_PARM_CMD
  5833                              <1> ;	call	GET_VEC 		; ES:BX -> PARAMETER BLOCK
  5834                              <1> ;	mov	al, [es:bx+2]		; GET NUMBER OF HEADS
  5835                              <1> ;	dec	al			; CONVERT TO 0-INDEX
  5836                              <1> ;	mov	ah, [CMD_BLOCK+5] 	; GET SDH REGISTER
  5837                              <1> ;	and	ah, 0F0h 		; CHANGE HEAD NUMBER
  5838                              <1> ;	or	ah, al			; TO MAX HEAD
  5839                              <1> ;	mov	[CMD_BLOCK+5], ah
  5840                              <1> ;	mov	al, [es:bx+14]		; MAX SECTOR NUMBER
  5841                              <1> ;	mov	[CMD_BLOCK+1], al
  5842                              <1> ;	sub	ax, ax
  5843                              <1> ;	mov	[CMD_BLOCK+3], al 	; ZERO FLAGS
  5844                              <1> ;	call	COMMAND 		; TELL CONTROLLER
  5845                              <1> ;	jnz	short INIT_EXIT		; CONTROLLER BUSY ERROR
  5846                              <1> ;	call	NOT_BUSY		; WAIT FOR IT TO BE DONE
  5847                              <1> ;	jnz	short INIT_EXIT		; TIME OUT
  5848                              <1> ;	call	CHECK_STATUS
  5849                              <1> ;INIT_EXIT:
  5850                              <1> ;	retn
  5851                              <1> 
  5852                              <1> ; 16/07/2022 - TRDOS 386 v2.0.5
  5853                              <1> 
  5854                              <1> ; 04/01/2015
  5855                              <1> ; 02/01/2015 - Derived from from AWARD BIOS 1999
  5856                              <1> ;				 AHDSK.ASM - INIT_DRIVE
  5857                              <1> INIT_DRV:
  5858                              <1> 	;xor	ah,ah
  5859 000053E4 31C0                <1> 	xor	eax, eax ; 21/02/2015
  5860 000053E6 B00B                <1> 	mov	al, 11 ; Physical heads from translated HDPT
  5861 000053E8 3825[34780100]      <1>         cmp     [LBAMode], ah   ; 0
  5862 000053EE 7702                <1> 	ja	short idrv0
  5863 000053F0 B002                <1> 	mov	al, 2  ; Physical heads from standard HDPT
  5864                              <1> idrv0:
  5865                              <1> 	; DL = drive number (0 based)
  5866 000053F2 E887020000          <1> 	call	GET_VEC
  5867                              <1> 	;push	bx
  5868 000053F7 53                  <1> 	push	ebx ; 21/02/2015
  5869                              <1> 	;add	bx, ax
  5870 000053F8 01C3                <1> 	add	ebx, eax
  5871                              <1> 	;; 05/01/2015
  5872 000053FA 8A25[22650000]      <1> 	mov	ah, [hf_m_s] ; drive number (0= master, 1= slave)
  5873                              <1> 	;;and 	ah, 1 
  5874 00005400 C0E404              <1> 	shl	ah, 4
  5875 00005403 80CCA0              <1> 	or	ah, 0A0h  ; Drive/Head register - 10100000b (A0h)	
  5876                              <1> 	;mov	al, [es:bx]
  5877 00005406 8A03                <1> 	mov	al, [ebx] ; 21/02/2015
  5878 00005408 FEC8                <1> 	dec	al	 ; last head number 
  5879                              <1> 	;and	al, 0Fh
  5880 0000540A 08E0                <1> 	or	al, ah	 ; lower 4 bits for head number
  5881                              <1> 	;
  5882 0000540C C645FE91            <1> 	mov	byte [CMD_BLOCK+6], SET_PARM_CMD
  5883 00005410 8845FD              <1> 	mov	[CMD_BLOCK+5], al
  5884                              <1> 	;pop	bx
  5885 00005413 5B                  <1> 	pop	ebx
  5886 00005414 29C0                <1> 	sub	eax, eax ; 21/02/2015
  5887 00005416 B004                <1> 	mov	al, 4	; Physical sec per track from translated HDPT
  5888 00005418 803D[34780100]00    <1> 	cmp	byte [LBAMode], 0
  5889 0000541F 7702                <1> 	ja	short idrv1
  5890 00005421 B00E                <1> 	mov	al, 14	; Physical sec per track from standard HDPT
  5891                              <1> idrv1:
  5892                              <1> 	;xor	ah, ah
  5893                              <1> 	;add	bx, ax
  5894 00005423 01C3                <1> 	add	ebx, eax ; 21/02/2015
  5895                              <1> 	;mov	al, [es:bx]
  5896                              <1> 			; sector number
  5897 00005425 8A03                <1> 	mov	al, [ebx]
  5898 00005427 8845F9              <1> 	mov	[CMD_BLOCK+1], al
  5899 0000542A 28C0                <1> 	sub	al, al
  5900 0000542C 8845FB              <1> 	mov	[CMD_BLOCK+3], al ; ZERO FLAGS
  5901 0000542F E8F3000000          <1> 	call	COMMAND 	  ; TELL CONTROLLER
  5902 00005434 751E                <1> 	jnz	short INIT_EXIT	  ; CONTROLLER BUSY ERROR
  5903 00005436 E88E010000          <1> 	call	NOT_BUSY	  ; WAIT FOR IT TO BE DONE
  5904 0000543B 7517                <1> 	jnz	short INIT_EXIT	  ; TIME OUT
  5905                              <1> 	; 16/07/2022
  5906                              <1> 	;call	CHECK_STATUS
  5907                              <1> 	;jmp	short CHECK_STATUS
  5908                              <1> ;INIT_EXIT:
  5909                              <1> 	;retn
  5910                              <1> 
  5911                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  5912                              <1> 	; 10/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
  5913                              <1> 
  5914                              <1> ;----------------------------------------
  5915                              <1> ;	CHECK FIXED DISK STATUS 	:
  5916                              <1> ;----------------------------------------
  5917                              <1> CHECK_STATUS:
  5918 0000543D E8D9010000          <1> 	call	CHECK_ST		; CHECK THE STATUS BYTE
  5919                              <1> 	;jnz	short CHECK_S1		; AN ERROR WAS FOUND
  5920                              <1> 	; 10/07/2022
  5921 00005442 7510                <1> 	jnz	short CHECK_S2
  5922 00005444 A801                <1> 	test	al, ST_ERROR		; WERE THERE ANY OTHER ERRORS
  5923 00005446 7405                <1> 	jz	short CHECK_S1		; NO ERROR REPORTED
  5924 00005448 E80E020000          <1> 	call	CHECK_ER		; ERROR REPORTED
  5925                              <1> CHECK_S1:
  5926 0000544D 803D[1F780100]00    <1> 	cmp	byte [DISK_STATUS1], 0 	; SET STATUS FOR CALLER
  5927                              <1> CHECK_S2:
  5928                              <1> INIT_EXIT:	; 10/07/2022
  5929 00005454 C3                  <1> 	retn
  5930                              <1> 
  5931                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  5932                              <1> 
  5933                              <1> ;----------------------------------------
  5934                              <1> ;	SEEK		     (AH = 0CH) :
  5935                              <1> ;----------------------------------------
  5936                              <1> 
  5937                              <1> DISK_SEEK:
  5938 00005455 C645FE70            <1>         mov	byte [CMD_BLOCK+6], SEEK_CMD
  5939 00005459 E8C9000000          <1> 	call	COMMAND
  5940 0000545E 751C                <1> 	jnz	short DS_EXIT		; CONTROLLER BUSY ERROR
  5941 00005460 E834010000          <1> 	call	_WAIT
  5942 00005465 7515                <1>         jnz	short DS_EXIT		; TIME OUT ON SEEK
  5943 00005467 E8D1FFFFFF          <1> 	call	CHECK_STATUS
  5944 0000546C 803D[1F780100]40    <1>         cmp	byte [DISK_STATUS1], BAD_SEEK
  5945 00005473 7507                <1> 	jne	short DS_EXIT
  5946 00005475 C605[1F780100]00    <1>         mov	byte [DISK_STATUS1], 0
  5947                              <1> DS_EXIT:
  5948 0000547C C3                  <1> 	retn
  5949                              <1> 
  5950                              <1> ;----------------------------------------
  5951                              <1> ;	TEST DISK READY      (AH = 10H) :
  5952                              <1> ;----------------------------------------
  5953                              <1> 
  5954                              <1> TST_RDY:				; WAIT FOR CONTROLLER
  5955 0000547D E847010000          <1> 	call	NOT_BUSY
  5956 00005482 751C                <1> 	jnz	short TR_EX
  5957 00005484 8A45FD              <1> 	mov	al, [CMD_BLOCK+5] 	; SELECT DRIVE
  5958 00005487 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  5959 0000548E 80C206              <1> 	add	dl, 6
  5960 00005491 EE                  <1> 	out	dx, al
  5961 00005492 E884010000          <1> 	call	CHECK_ST		; CHECK STATUS ONLY
  5962 00005497 7507                <1> 	jnz	short TR_EX
  5963 00005499 C605[1F780100]00    <1> 	mov	byte [DISK_STATUS1], 0 	; WIPE OUT DATA CORRECTED ERROR
  5964                              <1> TR_EX:	
  5965 000054A0 C3                  <1> 	retn
  5966                              <1> 
  5967                              <1> ;----------------------------------------
  5968                              <1> ;	RECALIBRATE	     (AH = 11H) :
  5969                              <1> ;----------------------------------------
  5970                              <1> 
  5971                              <1> HDISK_RECAL:
  5972 000054A1 C645FE10            <1>         mov	byte [CMD_BLOCK+6], RECAL_CMD ; 10h, 16
  5973 000054A5 E87D000000          <1> 	call	COMMAND 		; START THE OPERATION
  5974 000054AA 7523                <1> 	jnz	short RECAL_EXIT	; ERROR
  5975 000054AC E8E8000000          <1> 	call	_WAIT			; WAIT FOR COMPLETION
  5976 000054B1 7407                <1> 	jz	short RECAL_X 		; TIME OUT ONE OK ?
  5977 000054B3 E8E1000000          <1> 	call	_WAIT			; WAIT FOR COMPLETION LONGER
  5978 000054B8 7515                <1> 	jnz	short RECAL_EXIT	; TIME OUT TWO TIMES IS ERROR
  5979                              <1> RECAL_X:
  5980 000054BA E87EFFFFFF          <1> 	call	CHECK_STATUS
  5981 000054BF 803D[1F780100]40    <1> 	cmp	byte [DISK_STATUS1], BAD_SEEK ; SEEK NOT COMPLETE
  5982 000054C6 7507                <1> 	jne	short RECAL_EXIT	; IS OK
  5983 000054C8 C605[1F780100]00    <1> 	mov	byte [DISK_STATUS1], 0
  5984                              <1> RECAL_EXIT:
  5985 000054CF 803D[1F780100]00    <1>         cmp	byte [DISK_STATUS1], 0
  5986 000054D6 C3                  <1> 	retn
  5987                              <1> 
  5988                              <1> ;----------------------------------------
  5989                              <1> ;      CONTROLLER DIAGNOSTIC (AH = 14H) :
  5990                              <1> ;----------------------------------------
  5991                              <1> 
  5992                              <1> CTLR_DIAGNOSTIC:
  5993                              <1> 	; 07/08/2022 - TRDOS 386 v2.0.5
  5994 000054D7 FA                  <1> 	cli				; DISABLE INTERRUPTS WHILE CHANGING MASK
  5995 000054D8 E4A1                <1> 	in	al, INTB01		; TURN ON SECOND INTERRUPT CHIP
  5996                              <1> 	;and	al, 0BFH
  5997 000054DA 243F                <1> 	and	al, 3Fh			; enable IRQ 14 & IRQ 15
  5998                              <1> 	;jmp	$+2
  5999                              <1> 	IODELAY
    78 000054DC EB00                <2>  jmp short $+2
    79 000054DE EB00                <2>  jmp short $+2
  6000 000054E0 E6A1                <1> 	out	INTB01, al
  6001                              <1> 	IODELAY
    78 000054E2 EB00                <2>  jmp short $+2
    79 000054E4 EB00                <2>  jmp short $+2
  6002 000054E6 E421                <1> 	in	al, INTA01		; LET INTERRUPTS PASS THRU TO
  6003 000054E8 24FB                <1> 	and	al, 0FBh 		;  SECOND CHIP
  6004                              <1> 	;jmp	$+2
  6005                              <1> 	IODELAY
    78 000054EA EB00                <2>  jmp short $+2
    79 000054EC EB00                <2>  jmp short $+2
  6006 000054EE E621                <1> 	out	INTA01, al
  6007 000054F0 FB                  <1> 	sti
  6008 000054F1 E8D3000000          <1> 	call	NOT_BUSY		; WAIT FOR CARD
  6009 000054F6 7526                <1> 	jnz	short CD_ERR		; BAD CARD
  6010                              <1> 	;mov	dx, PORT+7
  6011 000054F8 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  6012 000054FF 80C207              <1> 	add	dl, 7
  6013 00005502 B090                <1> 	mov	al, DIAG_CMD		; START DIAGNOSE
  6014 00005504 EE                  <1> 	out	dx, al
  6015 00005505 E8BF000000          <1> 	call	NOT_BUSY		; WAIT FOR IT TO COMPLETE
  6016 0000550A B480                <1> 	mov	ah, TIME_OUT
  6017 0000550C 7512                <1> 	jnz	short CD_EXIT 		; TIME OUT ON DIAGNOSTIC
  6018                              <1> 	;mov	dx, HF_PORT+1		; GET ERROR REGISTER
  6019 0000550E 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  6020 00005515 FEC2                <1> 	inc	dl
  6021 00005517 EC                  <1> 	in	al, dx
  6022                              <1> 	; 07/08/2022
  6023                              <1> 	;mov	[HF_ERROR], al		; SAVE IT
  6024 00005518 B400                <1> 	mov	ah, 0
  6025 0000551A 3C01                <1> 	cmp	al, 1			; CHECK FOR ALL OK
  6026 0000551C 7402                <1> 	je	short CD_EXIT
  6027                              <1> CD_ERR:
  6028 0000551E B420                <1> 	mov	ah, BAD_CNTLR
  6029                              <1> CD_EXIT:
  6030 00005520 8825[1F780100]      <1> 	mov	[DISK_STATUS1], ah
  6031 00005526 C3                  <1> 	retn
  6032                              <1> 
  6033                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  6034                              <1> 	; 10/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
  6035                              <1> 
  6036                              <1> ;--------------------------------------------------------
  6037                              <1> ; COMMAND						:
  6038                              <1> ;	THIS ROUTINE OUTPUTS THE COMMAND BLOCK		:
  6039                              <1> ; OUTPUT						:
  6040                              <1> ;	BL = STATUS					:
  6041                              <1> ;	BH = ERROR REGISTER				:
  6042                              <1> ;--------------------------------------------------------
  6043                              <1> 
  6044                              <1> COMMAND:
  6045                              <1> 	;push	ebx ; 10/07/2022	; WAIT FOR SEEK COMPLETE AND READY
  6046                              <1> 	;;mov	ecx, DELAY_2		; SET INITIAL DELAY BEFORE TEST
  6047                              <1> COMMAND1:
  6048                              <1> 	;;push	ecx			; SAVE LOOP COUNT
  6049 00005527 E851FFFFFF          <1> 	call	TST_RDY 		; CHECK DRIVE READY
  6050                              <1> 	;;pop	ecx
  6051                              <1> 	;pop	ebx ; 10/07/2022
  6052 0000552C 7418                <1> 	jz	short COMMAND2		; DRIVE IS READY
  6053 0000552E 803D[1F780100]80    <1>         cmp	byte [DISK_STATUS1], TIME_OUT ; TST_RDY TIMED OUT--GIVE UP
  6054                              <1> 	;jz	short CMD_TIMEOUT
  6055                              <1> 	;;loop	COMMAND1		; KEEP TRYING FOR A WHILE
  6056                              <1> 	;jmp	short COMMAND4		; ITS NOT GOING TO GET READY
  6057 00005535 7507                <1> 	jne	short COMMAND4
  6058                              <1> CMD_TIMEOUT:
  6059 00005537 C605[1F780100]20    <1> 	mov	byte [DISK_STATUS1], BAD_CNTLR
  6060                              <1> COMMAND4:
  6061                              <1> 	;;pop	ebx ; 10/07/2022
  6062 0000553E 803D[1F780100]00    <1>         cmp	byte [DISK_STATUS1], 0	; SET CONDITION CODE FOR CALLER
  6063 00005545 C3                  <1> 	retn
  6064                              <1> COMMAND2:
  6065                              <1> 	;;pop	ebx ; 10/07/2022
  6066                              <1> 	;push	edi ; 10/07/2022
  6067 00005546 C605[1A780100]00    <1> 	mov	byte [HF_INT_FLAG], 0	; RESET INTERRUPT FLAG
  6068 0000554D FA                  <1> 	cli				; INHIBIT INTERRUPTS WHILE CHANGING MASK
  6069 0000554E E4A1                <1> 	in	al, INTB01		; TURN ON SECOND INTERRUPT CHIP
  6070                              <1> 	;and	al, 0BFh
  6071 00005550 243F                <1> 	and	al, 3Fh			; Enable IRQ 14 & 15
  6072                              <1> 	;jmp	$+2
  6073                              <1> 	IODELAY
    78 00005552 EB00                <2>  jmp short $+2
    79 00005554 EB00                <2>  jmp short $+2
  6074 00005556 E6A1                <1> 	out	INTB01, al
  6075 00005558 E421                <1> 	in	al, INTA01		; LET INTERRUPTS PASS THRU TO
  6076 0000555A 24FB                <1> 	and	al, 0FBh 		; SECOND CHIP
  6077                              <1> 	;jmp	$+2
  6078                              <1> 	IODELAY
    78 0000555C EB00                <2>  jmp short $+2
    79 0000555E EB00                <2>  jmp short $+2
  6079 00005560 E621                <1> 	out	INTA01, al
  6080 00005562 FB                  <1> 	sti
  6081                              <1> 	;xor	edi, edi		; INDEX THE COMMAND TABLE
  6082                              <1> 	; 10/07/2022
  6083 00005563 31C9                <1> 	xor	ecx, ecx
  6084                              <1> 	;mov	dx, HF_PORT+1		; DISK ADDRESS
  6085 00005565 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  6086 0000556C FEC2                <1> 	inc	dl
  6087 0000556E F605[21780100]C0    <1> 	test	byte [CONTROL_BYTE], 0C0h ; CHECK FOR RETRY SUPPRESSION
  6088 00005575 7411                <1> 	jz	short COMMAND3
  6089 00005577 8A45FE              <1> 	mov	al, [CMD_BLOCK+6] 	; YES-GET OPERATION CODE
  6090 0000557A 24F0                <1> 	and	al, 0F0h 		; GET RID OF MODIFIERS
  6091 0000557C 3C20                <1> 	cmp	al, 20h			; 20H-40H IS READ, WRITE, VERIFY
  6092 0000557E 7208                <1> 	jb	short COMMAND3
  6093 00005580 3C40                <1> 	cmp	al, 40h
  6094 00005582 7704                <1> 	ja	short COMMAND3
  6095 00005584 804DFE01            <1> 	or	byte [CMD_BLOCK+6], NO_RETRIES 
  6096                              <1> 					; VALID OPERATION FOR RETRY SUPPRESS
  6097                              <1> COMMAND3:
  6098                              <1> 	;mov	al, [CMD_BLOCK+edi]	; GET THE COMMAND STRING BYTE
  6099                              <1> 	; 10/07/2022
  6100 00005588 8A440DF8            <1> 	mov	al, [CMD_BLOCK+ecx]
  6101 0000558C EE                  <1> 	out	dx, al			; GIVE IT TO CONTROLLER
  6102                              <1> 	IODELAY
    78 0000558D EB00                <2>  jmp short $+2
    79 0000558F EB00                <2>  jmp short $+2
  6103                              <1> 	;inc	edi			; NEXT BYTE IN COMMAND BLOCK
  6104                              <1> 	; 10/07/2022
  6105 00005591 41                  <1> 	inc	ecx
  6106                              <1> 	;inc	dx			; NEXT DISK ADAPTER REGISTER
  6107 00005592 42                  <1> 	inc	edx   ; 10/07/2022	
  6108                              <1> 	;cmp	di, 7 ; 01/01/2015	; ALL DONE?
  6109                              <1> 	;jne	short COMMAND3		; NO--GO DO NEXT ONE
  6110 00005593 80F907              <1> 	cmp	cl, 7 ; 10/07/2022
  6111 00005596 72F0                <1> 	jb	short COMMAND3
  6112                              <1> 	;pop	edi ; 10/07/2022
  6113 00005598 C3                  <1> 	retn				; ZERO FLAG IS SET
  6114                              <1> 
  6115                              <1> ;CMD_TIMEOUT:
  6116                              <1> ;	mov	byte [DISK_STATUS1], BAD_CNTLR
  6117                              <1> ;COMMAND4:
  6118                              <1> ;	pop	ebx
  6119                              <1> ;	cmp	byte [DISK_STATUS1], 0 	; SET CONDITION CODE FOR CALLER
  6120                              <1> ;	retn
  6121                              <1> 
  6122                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  6123                              <1> 	; 10/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
  6124                              <1> 
  6125                              <1> ;----------------------------------------
  6126                              <1> ;	WAIT FOR INTERRUPT		:
  6127                              <1> ;----------------------------------------
  6128                              <1> ;WAIT:
  6129                              <1> _WAIT:
  6130 00005599 FB                  <1> 	sti				; MAKE SURE INTERRUPTS ARE ON
  6131                              <1> 	;sub	cx, cx			; SET INITIAL DELAY BEFORE TEST
  6132                              <1> 	;clc
  6133                              <1> 	;mov	ax, 9000h		; DEVICE WAIT INTERRUPT
  6134                              <1> 	;int	15h
  6135                              <1> 	;jc	short WT2		; DEVICE TIMED OUT
  6136                              <1> 	;mov	bl, DELAY_1		; SET DELAY COUNT
  6137                              <1> 
  6138                              <1> 	;mov	bl, WAIT_HDU_INT_HI
  6139                              <1> 	;; 21/02/2015
  6140                              <1> 	;;mov	bl, WAIT_HDU_INT_HI + 1
  6141                              <1> 	;;mov	cx, WAIT_HDU_INT_LO
  6142 0000559A B915160500          <1> 	mov	ecx, WAIT_HDU_INT_LH
  6143                              <1> 					; (AWARD BIOS -> WAIT_FOR_MEM)
  6144                              <1> ;-----	WAIT LOOP
  6145                              <1> 
  6146                              <1> WT1:	
  6147                              <1> 	;test	byte [HF_INT_FLAG], 80h	; TEST FOR INTERRUPT
  6148 0000559F F605[1A780100]C0    <1> 	test 	byte [HF_INT_FLAG], 0C0h
  6149                              <1> 	;loopz	WT1
  6150 000055A6 7512                <1> 	jnz	short WT3		; INTERRUPT--LETS GO
  6151                              <1> 	;dec	bl
  6152                              <1> 	;jnz	short WT1		; KEEP TRYING FOR A WHILE
  6153                              <1> 
  6154                              <1> WT1_hi:
  6155 000055A8 E461                <1> 	in	al, SYS1 ; 61h (PORT_B)	; wait for lo to hi
  6156 000055AA A810                <1> 	test	al, 10h			; transition on memory
  6157 000055AC 75FA                <1> 	jnz	short WT1_hi		; refresh.
  6158                              <1> WT1_lo:
  6159 000055AE E461                <1> 	in	al, SYS1 		; 061h (PORT_B)	
  6160 000055B0 A810                <1> 	test	al, 10h			
  6161 000055B2 74FA                <1> 	jz	short WT1_lo
  6162 000055B4 E2E9                <1> 	loop	WT1
  6163                              <1> 	;;or	bl, bl
  6164                              <1> 	;;jz	short WT2	
  6165                              <1> 	;;dec	bl
  6166                              <1> 	;;jmp	short WT1
  6167                              <1> 	;dec	bl
  6168                              <1> 	;jnz	short WT1	
  6169                              <1> WT2:	
  6170                              <1> 	; 10/07/2022
  6171                              <1> 	;mov	byte [DISK_STATUS1], TIME_OUT ; REPORT TIME OUT ERROR
  6172 000055B6 B080                <1> 	mov	al, TIME_OUT
  6173 000055B8 EB07                <1> 	jmp	short WT4
  6174                              <1> WT3:
  6175                              <1> 	;mov	byte [DISK_STATUS1], 0
  6176                              <1> 	;mov	byte [HF_INT_FLAG], 0
  6177 000055BA 28C0                <1> 	sub	al, al ; 0
  6178 000055BC A2[1A780100]        <1> 	mov	byte [HF_INT_FLAG], al
  6179                              <1> WT4:
  6180                              <1> NB2:	
  6181 000055C1 A2[1F780100]        <1> 	mov	byte [DISK_STATUS1], al
  6182                              <1> 
  6183                              <1> 	;cmp	byte [DISK_STATUS1], 0 	; SET CONDITION CODE FOR CALLER
  6184 000055C6 20C0                <1> 	and	al, al
  6185                              <1> 	; zf = 0 -> time out, zf = 1 -> ok
  6186 000055C8 C3                  <1> 	retn
  6187                              <1> 
  6188                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  6189                              <1> 	; 10/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
  6190                              <1> 
  6191                              <1> ;----------------------------------------
  6192                              <1> ;	WAIT FOR CONTROLLER NOT BUSY	:
  6193                              <1> ;----------------------------------------
  6194                              <1> NOT_BUSY:
  6195 000055C9 FB                  <1> 	sti				; MAKE SURE INTERRUPTS ARE ON
  6196                              <1> 	;push	ebx
  6197                              <1> 	;sub	cx, cx			; SET INITIAL DELAY BEFORE TEST
  6198 000055CA 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  6199 000055D1 80C207              <1> 	add	dl, 7			; Status port (HF_PORT+7)
  6200                              <1> 	;mov	bl, DELAY_1
  6201                              <1> 					; wait for 10 seconds
  6202                              <1> 	;mov 	cx, WAIT_HDU_INT_LO	; 1615h
  6203                              <1> 	;;mov 	bl, WAIT_HDU_INT_HI	;   05h
  6204                              <1> 	;mov	bl, WAIT_HDU_INT_HI + 1
  6205 000055D4 B915160500          <1> 	mov	ecx, WAIT_HDU_INT_LH  ; 21/02/2015
  6206                              <1> 	;
  6207                              <1> 	;;mov	byte [wait_count], 0    ; Reset wait counter
  6208                              <1> NB1:	
  6209 000055D9 EC                  <1> 	in	al, dx			; CHECK STATUS
  6210                              <1> 	;test	al, ST_BUSY
  6211 000055DA 2480                <1> 	and	al, ST_BUSY
  6212                              <1> 	;loopnz NB1
  6213 000055DC 74E3                <1> 	jz	short NB2 ; al = 0	; NOT BUSY--LETS GO
  6214                              <1> 	;dec	bl			
  6215                              <1> 	;jnz	short NB1		; KEEP TRYING FOR A WHILE
  6216                              <1> 
  6217                              <1> NB1_hi: 
  6218 000055DE E461                <1> 	in	al, SYS1		; wait for hi to lo
  6219 000055E0 A810                <1> 	test	al, 010h		; transition on memory
  6220 000055E2 75FA                <1> 	jnz	short NB1_hi		; refresh.
  6221                              <1> NB1_lo: 
  6222 000055E4 E461                <1> 	in	al, SYS1
  6223 000055E6 A810                <1> 	test	al, 010h
  6224 000055E8 74FA                <1> 	jz	short NB1_lo
  6225 000055EA E2ED                <1> 	loop	NB1
  6226                              <1> 	;dec	bl
  6227                              <1> 	;jnz	short NB1
  6228                              <1> 	;
  6229                              <1> 	;;cmp	byte [wait_count], 182  ; 10 seconds (182 timer ticks)
  6230                              <1> 	;;jb	short NB1
  6231                              <1> 	;
  6232                              <1> 	;mov	byte [DISK_STATUS1], TIME_OUT ; REPORT TIME OUT ERROR
  6233                              <1> 	;jmp	short NB3
  6234 000055EC B080                <1> 	mov	al, TIME_OUT
  6235                              <1> ;NB2:	
  6236 000055EE EBD1                <1> 	jmp	short NB2 ; 10/07/2022
  6237                              <1> 
  6238                              <1> ;	;mov	byte [DISK_STATUS1], 0
  6239                              <1> ;;NB3:	
  6240                              <1> ;	;pop	ebx
  6241                              <1> ;	mov	[DISK_STATUS1], al	;;; will be set after return
  6242                              <1> ;	;cmp	byte [DISK_STATUS1], 0 	; SET CONDITION CODE FOR CALLER
  6243                              <1> ;	or	al, al			; (zf = 0 --> timeout)
  6244                              <1> ;	retn
  6245                              <1> 
  6246                              <1> ;----------------------------------------
  6247                              <1> ;	WAIT FOR DATA REQUEST		:
  6248                              <1> ;----------------------------------------
  6249                              <1> WAIT_DRQ:
  6250                              <1> 	;mov	cx, DELAY_3
  6251                              <1> 	;mov	dx, HF_PORT+7
  6252 000055F0 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  6253 000055F7 80C207              <1> 	add	dl, 7
  6254                              <1> 	;;mov	bl, WAIT_HDU_DRQ_HI	; 0
  6255                              <1> 	;mov	cx, WAIT_HDU_DRQ_LO	; 1000 (30 milli seconds)
  6256                              <1> 					; (but it is written as 2000
  6257                              <1> 					; micro seconds in ATORGS.ASM file
  6258                              <1> 					; of Award Bios - 1999, D1A0622)
  6259 000055FA B9E8030000          <1> 	mov 	ecx, WAIT_HDU_DRQ_LH ; 21/02/2015 
  6260                              <1> WQ_1:
  6261 000055FF EC                  <1> 	in	al, dx			; GET STATUS
  6262 00005600 A808                <1> 	test	al, ST_DRQ		; WAIT FOR DRQ
  6263 00005602 7516                <1> 	jnz	short WQ_OK
  6264                              <1> 	;loop	WQ_1			; KEEP TRYING FOR A SHORT WHILE
  6265                              <1> WQ_hi:	
  6266 00005604 E461                <1> 	in	al, SYS1		; wait for hi to lo
  6267 00005606 A810                <1> 	test	al, 010h		; transition on memory
  6268 00005608 75FA                <1> 	jnz	short WQ_hi		; refresh.
  6269                              <1> WQ_lo:  
  6270 0000560A E461                <1> 	in	al, SYS1
  6271 0000560C A810                <1> 	test	al, 010h
  6272 0000560E 74FA                <1> 	jz	short WQ_lo
  6273 00005610 E2ED                <1> 	loop	WQ_1
  6274                              <1> 
  6275 00005612 C605[1F780100]80    <1> 	mov	byte [DISK_STATUS1], TIME_OUT ; ERROR
  6276 00005619 F9                  <1> 	stc
  6277                              <1> WQ_OK:
  6278 0000561A C3                  <1> 	retn
  6279                              <1> ;WQ_OK:
  6280                              <1> 	;clc
  6281                              <1> 	;ret
  6282                              <1> 
  6283                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  6284                              <1> 
  6285                              <1> ;----------------------------------------
  6286                              <1> ;	CHECK FIXED DISK STATUS BYTE	:
  6287                              <1> ;----------------------------------------
  6288                              <1> CHECK_ST:
  6289                              <1> 	;mov	dx, HF_PORT+7		; GET THE STATUS
  6290 0000561B 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]
  6291 00005622 80C207              <1> 	add	dl, 7
  6292                              <1> 	
  6293                              <1> 	; 17/02/2016
  6294                              <1> 	;(http://wiki.osdev.org/ATA_PIO_Mode)
  6295                              <1> 	;"delay 400ns to allow drive to set new values of BSY and DRQ"
  6296 00005625 EC                  <1> 	in	al, dx
  6297                              <1> 	;in	al, dx ; 100ns
  6298                              <1> 	;in	al, dx ; 100ns
  6299                              <1>  	;in	al, dx ; 100ns
  6300                              <1> 	NEWIODELAY ; 18/02/2016 (AWARD BIOS - 1999, 'CKST' in AHSDK.ASM)
    83 00005626 E6EB                <2>  out 0EBh, al
  6301                              <1> 	;
  6302                              <1> 
  6303                              <1> 	; 16/07/2022
  6304 00005628 A2[19780100]        <1> 	mov	[HF_STATUS], al
  6305                              <1> 	;mov	ah, 0
  6306 0000562D 28E4                <1> 	sub	ah, ah ; 0
  6307 0000562F A880                <1> 	test	al, ST_BUSY		; IF STILL BUSY
  6308 00005631 751A                <1> 	jnz	short CKST_EXIT		; REPORT OK
  6309 00005633 B4CC                <1> 	mov	ah, WRITE_FAULT
  6310 00005635 A820                <1> 	test 	al, ST_WRT_FLT		; CHECK FOR WRITE FAULT
  6311 00005637 7514                <1> 	jnz	short CKST_EXIT
  6312 00005639 B4AA                <1> 	mov	ah, NOT_RDY
  6313 0000563B A840                <1> 	test	al, ST_READY		; CHECK FOR NOT READY
  6314 0000563D 740E                <1> 	jz	short CKST_EXIT
  6315 0000563F B440                <1> 	mov	ah, BAD_SEEK
  6316 00005641 A810                <1> 	test	al, ST_SEEK_COMPL	; CHECK FOR SEEK NOT COMPLETE
  6317 00005643 7408                <1> 	jz	short CKST_EXIT
  6318 00005645 B411                <1> 	mov	ah, DATA_CORRECTED
  6319 00005647 A804                <1> 	test	al, ST_CORRCTD		; CHECK FOR CORRECTED ECC
  6320 00005649 7502                <1> 	jnz	short CKST_EXIT
  6321                              <1> 	;mov	ah, 0
  6322 0000564B 30E4                <1> 	xor	ah, ah ; 0
  6323                              <1> CKST_EXIT:
  6324 0000564D 8825[1F780100]      <1> 	mov	[DISK_STATUS1], ah	; SET ERROR FLAG
  6325 00005653 80FC11              <1> 	cmp	ah, DATA_CORRECTED	; KEEP GOING WITH DATA CORRECTED
  6326 00005656 7402                <1> 	je	short CKST_EX1
  6327                              <1> 	;cmp	ah, 0
  6328 00005658 20E4                <1> 	and	ah, ah
  6329                              <1> CKST_EX1:
  6330 0000565A C3                  <1> 	retn
  6331                              <1> 
  6332                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  6333                              <1> 
  6334                              <1> ;----------------------------------------
  6335                              <1> ;	CHECK FIXED DISK ERROR REGISTER :
  6336                              <1> ;----------------------------------------
  6337                              <1> CHECK_ER:
  6338                              <1> 	;mov	dx, HF_PORT+1		; GET THE ERROR REGISTER
  6339 0000565B 668B15[1E650000]    <1> 	mov	dx, [HF_PORT]		;
  6340 00005662 FEC2                <1> 	inc	dl
  6341 00005664 EC                  <1> 	in	al, dx
  6342                              <1> 	; 16/07/2022
  6343                              <1> 	;mov	[HF_ERROR], al
  6344                              <1> 	;push	ebx  ; 21/02/2015
  6345 00005665 29C9                <1> 	sub	ecx, ecx
  6346                              <1> 	;mov	ecx, 8			; TEST ALL 8 BITS
  6347 00005667 B108                <1> 	mov	cl, 8
  6348                              <1> CK1:	
  6349 00005669 D0E0                <1> 	shl	al, 1			; MOVE NEXT ERROR BIT TO CARRY
  6350 0000566B 7202                <1> 	jc	short CK2		; FOUND THE ERROR
  6351 0000566D E2FA                <1> 	loop	CK1			; KEEP TRYING
  6352                              <1> CK2:
  6353                              <1> 	;mov	ebx, ERR_TBL		; COMPUTE ADDRESS OF
  6354                              <1> 	;add	ebx, ecx		; ERROR CODE
  6355 0000566F 81C1[14650000]      <1> 	add	ecx, ERR_TBL ; 16/07/2022	
  6356                              <1> 
  6357                              <1> 	;;;mov	ah, byte [cs:bx]	; GET ERROR CODE
  6358                              <1> 	;;mov	ah, [bx]
  6359                              <1> 	;mov	ah, [ebx] ; 21/02/2015
  6360 00005675 8A21                <1> 	mov	ah, [ecx]	
  6361                              <1> CKEX:
  6362 00005677 8825[1F780100]      <1> 	mov	[DISK_STATUS1], ah	; SAVE ERROR CODE
  6363                              <1> 	; 16/07/2022
  6364                              <1> 	;pop	ebx
  6365                              <1> 	;;cmp	ah, 0
  6366                              <1> 	;and	ah, ah
  6367 0000567D C3                  <1> 	retn
  6368                              <1> 
  6369                              <1> ;--------------------------------------------------------
  6370                              <1> ; CHECK_DMA						:
  6371                              <1> ;  -CHECK ES:BX AND # SECTORS TO MAKE SURE THAT IT WILL :
  6372                              <1> ;   FIT WITHOUT SEGMENT OVERFLOW.			:
  6373                              <1> ;  -ES:BX HAS BEEN REVISED TO THE FORMAT SSSS:000X	:
  6374                              <1> ;  -OK IF # SECTORS < 80H (7FH IF LONG READ OR WRITE)	:
  6375                              <1> ;  -OK IF # SECTORS = 80H (7FH) AND BX <= 00H (04H)	:
  6376                              <1> ;  -ERROR OTHERWISE					:
  6377                              <1> ;--------------------------------------------------------
  6378                              <1> 
  6379                              <1> 	; 16/07/2022 - TRDOS 386 v2.0.5
  6380                              <1> 	; (not needed for hard disks and 32 bit OS)
  6381                              <1> 
  6382                              <1> ;CHECK_DMA:
  6383                              <1> ;	; 11/04/2021 (32 bit push/pop)
  6384                              <1> ;	push	eax			; SAVE REGISTERS
  6385                              <1> ;	mov	ax, 8000h		; AH = MAX # SECTORS
  6386                              <1> ;					; AL = MAX OFFSET
  6387                              <1> ;	test	byte [CMD_BLOCK+6], ECC_MODE
  6388                              <1> ;	jz	short CKD1
  6389                              <1> ;	mov	ah, 7F04h		; ECC IS 4 MORE BYTES
  6390                              <1> ;CKD1:	
  6391                              <1> ;	cmp	ah, [CMD_BLOCK+1] 	; NUMBER OF SECTORS
  6392                              <1> ;	ja	short CKDOK		; IT WILL FIT
  6393                              <1> ;	jb	short CKDERR		; TOO MANY
  6394                              <1> ;	cmp	al, bl			; CHECK OFFSET ON MAX SECTORS
  6395                              <1> ;	;jb	short CKDERR		; ERROR
  6396                              <1> ;	jnb	short CKDOK ; 16/07/2022
  6397                              <1> ;;CKDOK:	
  6398                              <1> ;	;clc				; CLEAR CARRY
  6399                              <1> ;	;pop	eax
  6400                              <1> ;	;retn				; NORMAL RETURN
  6401                              <1> ;CKDERR:
  6402                              <1> ;	;stc				; INDICATE ERROR
  6403                              <1> ;	mov	byte [DISK_STATUS1], DMA_BOUNDARY
  6404                              <1> ;CKDOK:
  6405                              <1> ;	pop	eax
  6406                              <1> ;	retn
  6407                              <1> 
  6408                              <1> ;----------------------------------------
  6409                              <1> ;	SET UP EBX-> DISK PARMS		:
  6410                              <1> ;----------------------------------------
  6411                              <1> 					
  6412                              <1> ; INPUT -> DL = 0 based drive number
  6413                              <1> ; OUTPUT -> EBX = disk parameter table address
  6414                              <1> 
  6415                              <1> GET_VEC:
  6416                              <1> 	;sub	ax, ax			; GET DISK PARAMETER ADDRESS
  6417                              <1> 	;mov	es, ax
  6418                              <1> 	;test	dl, 1
  6419                              <1> 	;jz	short GV_0
  6420                              <1> ;	les	bx, [HF1_TBL_VEC] 	; ES:BX -> DRIVE PARAMETERS
  6421                              <1> ;	jmp	short GV_EXIT
  6422                              <1> ;GV_0:
  6423                              <1> ;	les 	bx,[HF_TBL_VEC]		; ES:BX -> DRIVE PARAMETERS
  6424                              <1> ;
  6425 0000567E 31DB                <1> 	xor	ebx, ebx
  6426 00005680 88D3                <1> 	mov	bl, dl
  6427                              <1> 	;02/01/2015
  6428                              <1> 	;xor	bh, bh
  6429                              <1> 	;shl	bl, 1			; port address offset
  6430                              <1> 	;mov	ax, [bx+hd_ports]	; Base port address (1F0h, 170h)
  6431                              <1> 	;shl	bl, 1			; dpt pointer offset
  6432 00005682 C0E302              <1> 	shl	bl, 2
  6433                              <1> 	;add	bx, HF_TBL_VEC		; Disk parameter table pointer
  6434 00005685 81C3[24780100]      <1> 	add	ebx, HF_TBL_VEC ; 21/02/2015
  6435                              <1> 	;push	word [bx+2]		; dpt segment
  6436                              <1> 	;pop	es
  6437                              <1> 	;mov	bx, [bx]		; dpt offset
  6438 0000568B 8B1B                <1> 	mov	ebx, [ebx]		
  6439                              <1> ;GV_EXIT:
  6440 0000568D C3                  <1> 	retn
  6441                              <1> 
  6442                              <1> hdc1_int: ; 21/02/2015
  6443                              <1> ;--- HARDWARE INT 76H -- ( IRQ LEVEL 14 ) -----------------------
  6444                              <1> ;								:
  6445                              <1> ;	FIXED DISK INTERRUPT ROUTINE				:
  6446                              <1> ;								:
  6447                              <1> ;----------------------------------------------------------------
  6448                              <1> 
  6449                              <1> ; 22/12/2014
  6450                              <1> ; IBM PC-XT Model 286 System BIOS Source Code - DISK.ASM (HD_INT)
  6451                              <1> ;	 '11/15/85'
  6452                              <1> ; AWARD BIOS 1999 (D1A0622) 
  6453                              <1> ;	Source Code - ATORGS.ASM (INT_HDISK, INT_HDISK1)
  6454                              <1> 
  6455                              <1> ;int_76h:
  6456                              <1> HD_INT:
  6457                              <1> 	; 11/04/2021 (32 bit push/pop)
  6458 0000568E 50                  <1> 	push	eax
  6459 0000568F 1E                  <1> 	push	ds
  6460                              <1> 	;call	DDS
  6461                              <1> 	; 21/02/2015 (32 bit, 386 pm modification)
  6462 00005690 66B81000            <1> 	mov	ax, KDATA
  6463 00005694 8ED8                <1> 	mov 	ds, ax
  6464                              <1> 	;
  6465                              <1> 	;;mov	@HF_INT_FLAG,0FFH	; ALL DONE
  6466                              <1>         ;mov	byte [CS:HF_INT_FLAG], 0FFh
  6467 00005696 C605[1A780100]FF    <1> 	mov	byte [HF_INT_FLAG], 0FFh
  6468                              <1> 	;
  6469 0000569D 52                  <1> 	push	edx
  6470 0000569E 66BAF701            <1> 	mov	dx, HDC1_BASEPORT+7	; Status Register (1F7h)
  6471                              <1> 					; Clear Controller
  6472                              <1> Clear_IRQ1415:				; (Award BIOS - 1999)
  6473 000056A2 EC                  <1> 	in	al, dx			;
  6474 000056A3 5A                  <1> 	pop	edx
  6475                              <1> 	NEWIODELAY
    83 000056A4 E6EB                <2>  out 0EBh, al
  6476                              <1> 	;
  6477 000056A6 B020                <1> 	mov	al, EOI			; NON-SPECIFIC END OF INTERRUPT
  6478 000056A8 E6A0                <1> 	out	INTB00, al		; FOR CONTROLLER #2
  6479                              <1> 	;jmp	$+2			; WAIT
  6480                              <1> 	NEWIODELAY
    83 000056AA E6EB                <2>  out 0EBh, al
  6481 000056AC E620                <1> 	out	INTA00, al		; FOR CONTROLLER #1
  6482 000056AE 1F                  <1> 	pop	ds
  6483                              <1> 	;sti				; RE-ENABLE INTERRUPTS
  6484                              <1> 	;mov	ax, 9100h		; DEVICE POST
  6485                              <1> 	;int	15h			;  INTERRUPT
  6486                              <1> irq15_iret: ; 25/02/2015
  6487 000056AF 58                  <1> 	pop	eax
  6488 000056B0 CF                  <1> 	iretd				; RETURN FROM INTERRUPT
  6489                              <1> 
  6490                              <1> hdc2_int: ; 21/02/2015
  6491                              <1> ;--- HARDWARE INT 77H -- ( IRQ LEVEL 15 ) -----------------------
  6492                              <1> ;								:
  6493                              <1> ;	FIXED DISK INTERRUPT ROUTINE				:
  6494                              <1> ;								:
  6495                              <1> ;----------------------------------------------------------------
  6496                              <1> 
  6497                              <1> ;int_77h:
  6498                              <1> HD1_INT:
  6499                              <1> 	; 11/04/2021 (32 bit push/pop)
  6500 000056B1 50                  <1> 	push	eax
  6501                              <1> 	; Check if that is a spurious IRQ (from slave PIC)
  6502                              <1> 	; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  6503 000056B2 B00B                <1> 	mov	al, 0Bh  ; In-Service Register
  6504 000056B4 E6A0                <1> 	out	0A0h, al
  6505 000056B6 EB00                <1>         jmp short $+2
  6506 000056B8 EB00                <1> 	jmp short $+2
  6507 000056BA E4A0                <1> 	in	al, 0A0h
  6508 000056BC 2480                <1> 	and 	al, 80h ; bit 7 (is it real IRQ 15 or fake?)
  6509 000056BE 74EF                <1> 	jz	short irq15_iret ; Fake (spurious) IRQ, do not send EOI)
  6510                              <1> 	;
  6511 000056C0 1E                  <1> 	push	ds
  6512                              <1> 	;call	DDS
  6513                              <1> 	; 21/02/2015 (32 bit, 386 pm modification)
  6514 000056C1 66B81000            <1> 	mov	ax, KDATA
  6515 000056C5 8ED8                <1> 	mov 	ds, ax
  6516                              <1> 	;
  6517                              <1> 	;;mov	@HF_INT_FLAG,0FFH	; ALL DONE
  6518                              <1>         ;or	byte [CS:HF_INT_FLAG],0C0h 
  6519 000056C7 800D[1A780100]C0    <1> 	or	byte [HF_INT_FLAG], 0C0h
  6520                              <1> 	;
  6521 000056CE 52                  <1> 	push	edx
  6522 000056CF 66BA7701            <1> 	mov	dx, HDC2_BASEPORT+7	; Status Register (177h)
  6523                              <1> 					; Clear Controller (Award BIOS 1999)
  6524 000056D3 EBCD                <1> 	jmp	short Clear_IRQ1415
  6525                              <1> 
  6526                              <1> ;%include 'diskdata.inc' ; 11/03/2015
  6527                              <1> ;%include 'diskbss.inc' ; 11/03/2015
  6528                              <1> 
  6529                              <1> ;////////////////////////////////////////////////////////////////////
  6530                              <1> ;; END OF DISK I/O SYTEM ///
  3038                                  %include 'memory.s'  ; 09/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.7 - memory.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 20/10/2023  (Previous: 29/08/2023)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; memory.inc (18/10/2015)
    15                              <1> ; ****************************************************************************
    16                              <1> 
    17                              <1> ; MEMORY.ASM - Retro UNIX 386 v1 MEMORY MANAGEMENT FUNCTIONS (PROCEDURES)
    18                              <1> ; Retro UNIX 386 v1 Kernel (unix386.s, v0.2.0.14) - MEMORY.INC
    19                              <1> ; Last Modification: 18/10/2015
    20                              <1> 
    21                              <1> ; ///////// MEMORY MANAGEMENT FUNCTIONS (PROCEDURES) ///////////////
    22                              <1> 
    23                              <1> ;;04/11/2014 (unix386.s)	
    24                              <1> ;PDE_A_PRESENT	equ	1		; Present flag for PDE
    25                              <1> ;PDE_A_WRITE	equ 	2		; Writable (write permission) flag
    26                              <1> ;PDE_A_USER	equ	4		; User (non-system/kernel) page flag
    27                              <1> ;;
    28                              <1> ;PTE_A_PRESENT	equ	1		; Present flag for PTE (bit 0)
    29                              <1> ;PTE_A_WRITE	equ 	2		; Writable (write permission) flag (bit 1)
    30                              <1> ;PTE_A_USER	equ	4		; User (non-system/kernel) page flag (bit 2)
    31                              <1> ;PTE_A_ACCESS   equ	32		; Accessed flag (bit 5) ; 09/03/2015
    32                              <1> 
    33                              <1> ; 27/04/2015
    34                              <1> ; 09/03/2015
    35                              <1> PAGE_SIZE 	equ 4096		; page size in bytes
    36                              <1> PAGE_SHIFT 	equ 12			; page table shift count
    37                              <1> PAGE_D_SHIFT 	equ 22	; 12 + 10	; page directory shift count
    38                              <1> PAGE_OFF	equ 0FFFh		; 12 bit byte offset in page frame
    39                              <1> PTE_MASK 	equ 03FFh		; page table entry mask
    40                              <1> PTE_DUPLICATED  equ 200h		; duplicated page sign (AVL bit 0)
    41                              <1> PDE_A_CLEAR	equ 0F000h		; to clear PDE attribute bits
    42                              <1> PTE_A_CLEAR	equ 0F000h		; to clear PTE attribute bits
    43                              <1> LOGIC_SECT_SIZE equ 512			; logical sector size
    44                              <1> ERR_MAJOR_PF	equ 0E0h		; major error: page fault
    45                              <1> ERR_MINOR_IM	equ 4 ;15/10/2016 (1->4); insufficient (out of) memory
    46                              <1> ERR_MINOR_PV	equ 6 ;15/10/2016 (1->4); protection violation
    47                              <1> SWP_DISK_READ_ERR 	   equ 40
    48                              <1> SWP_DISK_NOT_PRESENT_ERR   equ 41
    49                              <1> SWP_SECTOR_NOT_PRESENT_ERR equ 42
    50                              <1> SWP_NO_FREE_SPACE_ERR      equ 43
    51                              <1> SWP_DISK_WRITE_ERR         equ 44
    52                              <1> SWP_NO_PAGE_TO_SWAP_ERR    equ 45
    53                              <1> PTE_A_ACCESS_BIT equ 5  ; Bit 5 (accessed flag)        
    54                              <1> SECTOR_SHIFT     equ 3  ; sector shift (to convert page block number)
    55                              <1> ; 12/07/2016
    56                              <1> PTE_SHARED	 equ 400h		; AVL bit 1, direct memory access bit	
    57                              <1> 					; (Indicates that the page is not allocated
    58                              <1> 					; for the process, it is a shared or system
    59                              <1>                                         ; page, it must not be deallocated!)
    60                              <1> ; 14/12/2020
    61                              <1> ; (Linear Frame Buffer - video memory mark : AVL bit 1, outside M.A.T.)
    62                              <1> PDE_EXTERNAL	equ 400h	; Page directory entry for external memory blocks
    63                              <1> PTE_EXTERNAL	equ 400h	; Allocated kernel pages for Linear Frame Buffer
    64                              <1> 				; (Out of memory allocation table)	
    65                              <1> 
    66                              <1> ;
    67                              <1> ;; Retro Unix 386 v1 - paging method/principles
    68                              <1> ;;
    69                              <1> ;; 10/10/2014
    70                              <1> ;; RETRO UNIX 386 v1 - PAGING METHOD/PRINCIPLES
    71                              <1> ;;
    72                              <1> ;; KERNEL PAGE MAP: 1 to 1 physical memory page map
    73                              <1> ;;	(virtual address = physical address)
    74                              <1> ;; KERNEL PAGE TABLES:
    75                              <1> ;;	Kernel page directory and all page tables are
    76                              <1> ;;	on memory as initialized, as equal to physical memory
    77                              <1> ;;	layout. Kernel pages can/must not be swapped out/in.
    78                              <1> ;;
    79                              <1> ;;	what for: User pages may be swapped out, when accessing
    80                              <1> ;;	a page in kernel/system mode, if it would be swapped out,
    81                              <1> ;;	kernel would have to swap it in! But it is also may be
    82                              <1> ;;	in use by a user process. (In system/kernel mode
    83                              <1> ;;	kernel can access all memory pages even if they are
    84                              <1> ;;	reserved/allocated for user processes. Swap out/in would
    85                              <1> ;;	cause conflicts.) 
    86                              <1> ;;	
    87                              <1> ;;	As result of these conditions,
    88                              <1> ;;	all kernel pages must be initialized as equal to 
    89                              <1> ;;	physical layout for preventing page faults. 
    90                              <1> ;;	Also, calling "allocate page" procedure after
    91                              <1> ;;	a page fault can cause another page fault (double fault)
    92                              <1> ;;	if all kernel page tables would not be initialized.
    93                              <1> ;;
    94                              <1> ;;	[first_page] = Beginning of users space, as offset to 
    95                              <1> ;;	memory allocation table. (double word aligned)
    96                              <1> ;;
    97                              <1> ;;	[next_page] = first/next free space to be searched
    98                              <1> ;;	as offset to memory allocation table. (dw aligned)
    99                              <1> ;;
   100                              <1> ;;	[last_page] = End of memory (users space), as offset
   101                              <1> ;;	to memory allocation table. (double word aligned)
   102                              <1> ;;
   103                              <1> ;; USER PAGE TABLES:
   104                              <1> ;;	Demand paging (& 'copy on write' allocation method) ...
   105                              <1> ;;		'ready only' marked copies of the 
   106                              <1> ;;		parent process's page table entries (for
   107                              <1> ;;		same physical memory).
   108                              <1> ;;		(A page will be copied to a new page after
   109                              <1> ;;		 if it causes R/W page fault.)
   110                              <1> ;;
   111                              <1> ;;	Every user process has own (different)
   112                              <1> ;;	page directory and page tables.	
   113                              <1> ;;
   114                              <1> ;;	Code starts at virtual address 0, always.
   115                              <1> ;;	(Initial value of EIP is 0 in user mode.)
   116                              <1> ;;	(Programs can be written/developed as simple
   117                              <1> ;;	 flat memory programs.)
   118                              <1> ;;
   119                              <1> ;; MEMORY ALLOCATION STRATEGY:
   120                              <1> ;;	Memory page will be allocated by kernel only 
   121                              <1> ;;		(in kernel/system mode only).
   122                              <1> ;;	* After a
   123                              <1> ;;	  - 'not present' page fault
   124                              <1> ;;	  - 'writing attempt on read only page' page fault 	 	
   125                              <1> ;;	* For loading (opening, reading) a file or disk/drive
   126                              <1> ;;	* As responce to 'allocate additional memory blocks' 
   127                              <1> ;;	  request by running process.
   128                              <1> ;;	* While creating a process, allocating a new buffer,
   129                              <1> ;;	  new page tables etc.
   130                              <1> ;;
   131                              <1> ;;	At first,
   132                              <1> ;;	- 'allocate page' procedure will be called;
   133                              <1> ;,	   if it will return with a valid (>0) physical address
   134                              <1> ;;	   (that means the relevant M.A.T. bit has been RESET)	
   135                              <1> ;;	   relevant memory page/block will be cleared (zeroed).
   136                              <1> ;;	- 'allocate page' will be called for allocating page
   137                              <1> ;;	   directory, page table and running space (data/code).
   138                              <1> ;;	- every successful 'allocate page' call will decrease
   139                              <1> ;;	  'free_pages' count (pointer).
   140                              <1> ;;	- 'out of (insufficient) memory error' will be returned
   141                              <1> ;;	  if 'free_pages' points to a ZERO.
   142                              <1> ;;	- swapping out and swapping in (if it is not a new page)
   143                              <1> ;;	  procedures will be called as responce to 'out of memory'
   144                              <1> ;;	  error except errors caused by attribute conflicts.
   145                              <1> ;;	 (swapper functions)	 
   146                              <1> ;;					
   147                              <1> ;;	At second,
   148                              <1> ;;	- page directory entry will be updated then page table
   149                              <1> ;;	  entry will be updated.		
   150                              <1> ;;
   151                              <1> ;; MEMORY ALLOCATION TABLE FORMAT:
   152                              <1> ;;	- M.A.T. has a size according to available memory as
   153                              <1> ;;	  follows:
   154                              <1> ;;		  - 1 (allocation) bit per 1 page (4096 bytes)
   155                              <1> ;;		  - a bit with value of 0 means allocated page
   156                              <1> ;;		  - a bit with value of 1 means a free page
   157                              <1> ;,	- 'free_pages' pointer holds count of free pages
   158                              <1> ;;	  depending on M.A.T.
   159                              <1> ;;		(NOTE: Free page count will not be checked
   160                              <1> ;;		again -on M.A.T.- after initialization. 
   161                              <1> ;;		Kernel will trust on initial count.)
   162                              <1> ;,	- 'free_pages' count will be decreased by allocation
   163                              <1> ;;	  and it will be increased by deallocation procedures.
   164                              <1> ;;	
   165                              <1> ;;	- Available memory will be calculated during
   166                              <1> ;;	  the kernel's initialization stage (in real mode).
   167                              <1> ;;	  Memory allocation table and kernel page tables 
   168                              <1> ;;	  will be formatted/sized as result of available
   169                              <1> ;;	  memory calculation before paging is enabled.
   170                              <1> ;;
   171                              <1> ;; For 4GB Available/Present Memory: (max. possible memory size)
   172                              <1> ;;	- Memory Allocation Table size will be 128 KB.
   173                              <1> ;;	- Memory allocation for kernel page directory size 
   174                              <1> ;;	  is always 4 KB. (in addition to total allocation size
   175                              <1> ;;	  for page tables)
   176                              <1> ;;	- Memory allocation for kernel page tables (1024 tables)
   177                              <1> ;;	  is 4 MB (1024*4*1024 bytes).
   178                              <1> ;;	- User (available) space will be started 
   179                              <1> ;;	  at 6th MB of the memory (after 1MB+4MB).
   180                              <1> ;;	- The first 640 KB is for kernel's itself plus
   181                              <1> ;;	  memory allocation table and kernel's page directory
   182                              <1> ;;	  (D0000h-EFFFFh may be used as kernel space...)	
   183                              <1> ;;	- B0000h to B7FFFh address space (32 KB) will be used
   184                              <1> ;; 	  for buffers.
   185                              <1> ;;	- ROMBIOS, VIDEO BUFFER and VIDEO ROM space are reserved.
   186                              <1> ;,	  (A0000h-AFFFFh, C0000h-CFFFFh, F0000h-FFFFFh)
   187                              <1> ;;	- Kernel page tables start at 100000h (2nd MB)
   188                              <1> ;;
   189                              <1> ;; For 1GB Available Memory:
   190                              <1> ;;	- Memory Allocation Table size will be 32 KB.
   191                              <1> ;;	- Memory allocation for kernel page directory size 
   192                              <1> ;;	  is always 4 KB. (in addition to total allocation size
   193                              <1> ;;	  for page tables)
   194                              <1> ;;	- Memory allocation for kernel page tables (256 tables)
   195                              <1> ;;	  is 1 MB (256*4*1024 bytes).
   196                              <1> ;;	- User (available) space will be started 
   197                              <1> ;;	  at 3th MB of the memory (after 1MB+1MB).
   198                              <1> ;;	- The first 640 KB is for kernel's itself plus
   199                              <1> ;;	  memory allocation table and kernel's page directory
   200                              <1> ;;	  (D0000h-EFFFFh may be used as kernel space...)	
   201                              <1> ;;	- B0000h to B7FFFh address space (32 KB) will be used
   202                              <1> ;; 	  for buffers.
   203                              <1> ;;	- ROMBIOS, VIDEO BUFFER and VIDEO ROM space are reserved.
   204                              <1> ;,	  (A0000h-AFFFFh, C0000h-CFFFFh, F0000h-FFFFFh)
   205                              <1> ;;	- Kernel page tables start at 100000h (2nd MB).	
   206                              <1> ;;
   207                              <1> ;;
   208                              <1> 
   209                              <1> 
   210                              <1> ;;************************************************************************************
   211                              <1> ;; 
   212                              <1> ;; RETRO UNIX 386 v1 - Paging (Method for Copy On Write paging principle)
   213                              <1> ;; DEMAND PAGING - PARENT&CHILD PAGE TABLE DUPLICATION PRINCIPLES (23/04/2015)
   214                              <1> 
   215                              <1> ;; Main factor: "sys fork" system call 
   216                              <1> ;;	
   217                              <1> ;; 		FORK
   218                              <1> ;;                      |----> parent - duplicated PTEs, read only pages
   219                              <1> ;;  writable pages ---->|
   220                              <1> ;;                      |----> child - duplicated PTEs, read only pages
   221                              <1> ;; 
   222                              <1> ;; AVL bit (0) of Page Table Entry is used as duplication sign 
   223                              <1> ;; 
   224                              <1> ;; AVL Bit 0 [PTE Bit 9] = 'Duplicated PTE belongs to child' sign/flag (if it is set)
   225                              <1> ;; Note: Dirty bit (PTE bit 6) may be used instead of AVL bit 0 (PTE bit 9)
   226                              <1> ;;       -while R/W bit is 0-. 
   227                              <1> ;; 
   228                              <1> ;; Duplicate page tables with writable pages (the 1st sys fork in the process):
   229                              <1> ;; # Parent's Page Table Entries are updated to point same pages as read only, 
   230                              <1> ;;   as duplicated PTE bit  -AVL bit 0, PTE bit 9- are reset/clear.
   231                              <1> ;; # Then Parent's Page Table is copied to Child's Page Table.
   232                              <1> ;; # Child's Page Table Entries are updated as duplicated child bit
   233                              <1> ;;   -AVL bit 0, PTE bit 9- is set.	  
   234                              <1> ;; 
   235                              <1> ;; Duplicate page tables with read only pages (several sys fork system calls):
   236                              <1> ;; # Parent's read only pages are copied to new child pages. 
   237                              <1> ;;   Parent's PTE attributes are not changed.
   238                              <1> ;;   (Because, there is another parent-child fork before this fork! We must not
   239                              <1> ;;    destroy/mix previous fork result).
   240                              <1> ;; # Child's Page Table Entries (which are corresponding to Parent's 
   241                              <1> ;;   read only pages) are set as writable (while duplicated PTE bit is clear). 
   242                              <1> ;; # Parent's PTEs with writable page attribute are updated to point same pages 
   243                              <1> ;;   as read only, (while) duplicated PTE bit is reset (clear).
   244                              <1> ;; # Parent's Page Table Entries (with writable page attribute) are duplicated 
   245                              <1> ;;   as Child's Page Table Entries without copying actual page.
   246                              <1> ;; # Child 's Page Table Entries (which are corresponding to Parent's writable 
   247                              <1> ;;   pages) are updated as duplicated PTE bit (AVL bit 0, PTE bit 9- is set.
   248                              <1> ;; 
   249                              <1> ;; !? WHAT FOR (duplication after duplication):
   250                              <1> ;; In UNIX method for sys fork (a typical 'fork' application in /etc/init)
   251                              <1> ;; program/executable code continues from specified location as child process, 
   252                              <1> ;; returns back previous code location as parent process, every child after 
   253                              <1> ;; every sys fork uses last image of code and data just prior the fork.
   254                              <1> ;; Even if the parent code changes data, the child will not see the changed data 
   255                              <1> ;; after the fork. In Retro UNIX 8086 v1, parent's process segment (32KB)
   256                              <1> ;; was copied to child's process segment (all of code and data) according to
   257                              <1> ;; original UNIX v1 which copies all of parent process code and data -core- 
   258                              <1> ;; to child space -core- but swaps that core image -of child- on to disk.
   259                              <1> ;; If I (Erdogan Tan) would use a method of to copy parent's core
   260                              <1> ;; (complete running image of parent process) to the child process; 
   261                              <1> ;; for big sizes, i would force Retro UNIX 386 v1 to spend many memory pages 
   262                              <1> ;; and times only for a sys fork. (It would excessive reservation for sys fork,
   263                              <1> ;; because sys fork usually is prior to sys exec; sys exec always establishes
   264                              <1> ;; a new/fresh core -running space-, by clearing all code/data content). 
   265                              <1> ;; 'Read Only' page flag ensures page fault handler is needed only for a few write
   266                              <1> ;; attempts between sys fork and sys exec, not more... (I say so by thinking 
   267                              <1> ;; of "/etc/init" content, specially.) sys exec will clear page tables and
   268                              <1> ;; new/fresh pages will be used to load and run new executable/program.
   269                              <1> ;; That is what for i have preferred "copy on write", "duplication" method
   270                              <1> ;; for sharing same read only pages between parent and child processes.
   271                              <1> ;; That is a pitty i have to use new private flag (AVL bit 0, "duplicated PTE 
   272                              <1> ;; belongs to child" sign) for cooperation on duplicated pages between a parent 
   273                              <1> ;; and it's child processes; otherwise parent process would destroy data belongs
   274                              <1> ;; to its child or vice versa; or some pages would remain unclaimed 
   275                              <1> ;; -deallocation problem-.
   276                              <1> ;; Note: to prevent conflicts, read only pages must not be swapped out... 
   277                              <1> ;; 
   278                              <1> ;; WHEN PARENT TRIES TO WRITE IT'S READ ONLY (DUPLICATED) PAGE:
   279                              <1> ;; # Page fault handler will do those:
   280                              <1> ;;   - 'Duplicated PTE' flag (PTE bit 9) is checked (on the failed PTE).
   281                              <1> ;;   - If it is reset/clear, there is a child uses same page.
   282                              <1> ;;   - Parent's read only page -previous page- is copied to a new writable page. 
   283                              <1> ;;   - Parent's PTE is updated as writable page, as unique page (AVL=0)
   284                              <1> ;;   - (Page fault handler whill check this PTE later, if child process causes to
   285                              <1> ;;     page fault due to write attempt on read only page. Of course, the previous 
   286                              <1> ;;     read only page will be converted to writable and unique page which belongs
   287                              <1> ;;     to child process.)	
   288                              <1> ;; WHEN CHILD TRIES TO WRITE IT'S READ ONLY (DUPLICATED) PAGE:
   289                              <1> ;; # Page fault handler will do those:
   290                              <1> ;;   - 'Duplicated PTE' flag (PTE bit 9) is checked (on the failed PTE).
   291                              <1> ;;   - If it is set, there is a parent uses -or was using- same page.
   292                              <1> ;;   - Same PTE address within parent's page table is checked if it has same page
   293                              <1> ;;     address or not. 
   294                              <1> ;;   - If parent's PTE has same address, child will continue with a new writable page.
   295                              <1> ;;     Parent's PTE will point to same (previous) page as writable, unique (AVL=0).	
   296                              <1> ;;   - If parent's PTE has different address, child will continue with it's 
   297                              <1> ;;     own/same page but read only flag (0) will be changed to writable flag (1) and
   298                              <1> ;;     'duplicated PTE (belongs to child)' flag/sign will be cleared/reset. 	  	
   299                              <1> ;; 
   300                              <1> ;; NOTE: When a child process is terminated, read only flags of parent's page tables
   301                              <1> ;;       will be set as writable (and unique) in case of child process was using 
   302                              <1> ;;       same pages with duplicated child PTE sign... Depending on sys fork and 
   303                              <1> ;;       duplication method details, it is not possible multiple child processes
   304                              <1> ;;       were using same page with duplicated PTEs.
   305                              <1> ;; 
   306                              <1> ;;************************************************************************************   
   307                              <1> 
   308                              <1> ;; 08/10/2014
   309                              <1> ;; 11/09/2014 - Retro UNIX 386 v1 PAGING (further) draft
   310                              <1> ;;		by Erdogan Tan (Based on KolibriOS 'memory.inc')
   311                              <1> 
   312                              <1> ;; 'allocate_page' code is derived and modified from KolibriOS
   313                              <1> ;; 'alloc_page' procedure in 'memory.inc' 
   314                              <1> ;; (25/08/2014, Revision: 5057) file 
   315                              <1> ;; by KolibriOS Team (2004-2012)
   316                              <1> 
   317                              <1> allocate_page:
   318                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
   319                              <1> 	;	 (temporary modifications)
   320                              <1> 	; 01/07/2015
   321                              <1> 	; 05/05/2015
   322                              <1> 	; 30/04/2015
   323                              <1> 	; 16/10/2014
   324                              <1> 	; 08/10/2014
   325                              <1> 	; 09/09/2014 (Retro UNIX 386 v1 - beginning)
   326                              <1> 	;
   327                              <1> 	; INPUT -> none
   328                              <1> 	;
   329                              <1> 	; OUTPUT ->
   330                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
   331                              <1> 	;	(corresponding MEMORY ALLOCATION TABLE bit is RESET)
   332                              <1> 	;
   333                              <1> 	;	CF = 1 and EAX = 0 
   334                              <1> 	; 		   if there is not a free page to be allocated	
   335                              <1> 	;
   336                              <1> 	; Modified Registers -> none (except EAX)
   337                              <1> 	;
   338 000056D5 A1[90770100]        <1> 	mov	eax, [free_pages]
   339 000056DA 21C0                <1> 	and	eax, eax
   340 000056DC 7438                <1> 	jz	short out_of_memory
   341                              <1> 	;
   342 000056DE 53                  <1> 	push	ebx
   343 000056DF 51                  <1> 	push	ecx
   344                              <1> 	;
   345 000056E0 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table offset
   346 000056E5 89D9                <1> 	mov	ecx, ebx
   347                              <1>  				     ; NOTE: 32 (first_page) is initial
   348                              <1> 				     ; value of [next_page].
   349                              <1> 				     ; It points to the first available
   350                              <1> 				     ; page block for users (ring 3) ...	
   351                              <1> 				     ; (MAT offset 32 = 1024/32)	
   352                              <1> 				     ; (at the of the first 4 MB)		
   353 000056E7 031D[94770100]      <1> 	add	ebx, [next_page] ; Free page searching starts from here
   354                              <1> 				 ; next_free_page >> 5
   355 000056ED 030D[98770100]      <1> 	add	ecx, [last_page] ; Free page searching ends here
   356                              <1> 				 ; (total_pages - 1) >> 5
   357                              <1> al_p_scan:
   358 000056F3 39CB                <1> 	cmp	ebx, ecx
   359 000056F5 770A                <1> 	ja	short al_p_notfound
   360                              <1> 	;
   361                              <1> 	; 01/07/2015
   362                              <1> 	; AMD64 Architecture Programmers Manual
   363                              <1> 	; Volume 3:
   364                              <1> 	; General-Purpose and System Instructions
   365                              <1> 	;
   366                              <1> 	; BSF - Bit Scan Forward
   367                              <1> 	;
   368                              <1> 	;   Searches the value in a register or a memory location
   369                              <1> 	;   (second operand) for the least-significant set bit. 
   370                              <1> 	;   If a set bit is found, the instruction clears the zero flag (ZF)
   371                              <1> 	;   and stores the index of the least-significant set bit in a destination
   372                              <1> 	;   register (first operand). If the second operand contains 0, 
   373                              <1> 	;   the instruction sets ZF to 1 and does not change the contents of the 
   374                              <1> 	;   destination register. The bit index is an unsigned offset from bit 0 
   375                              <1> 	;   of the searched value
   376                              <1> 	;
   377 000056F7 0FBC03              <1> 	bsf	eax, [ebx] ; Scans source operand for first bit set (1).
   378                              <1> 			   ; Clear ZF if a bit is found set (1) and 
   379                              <1> 			   ; loads the destination with an index to
   380                              <1> 			   ; first set bit. (0 -> 31) 
   381                              <1> 			   ; Sets ZF to 1 if no bits are found set.
   382 000056FA 751C                <1> 	jnz	short al_p_found ; ZF = 0 -> a free page has been found
   383                              <1> 			 ;
   384                              <1> 			 ; NOTE:  a Memory Allocation Table bit 
   385                              <1> 			 ;	  with value of 1 means 
   386                              <1> 			 ;	  the corresponding page is free 
   387                              <1> 			 ;	  (Retro UNIX 386 v1 feature only!)
   388 000056FC 83C304              <1> 	add	ebx, 4
   389                              <1> 			 ; We return back for searching next page block
   390                              <1> 			 ; NOTE: [free_pages] is not ZERO; so, 
   391                              <1> 			 ;	 we always will find at least 1 free page here.
   392 000056FF EBF2                <1>         jmp     short al_p_scan
   393                              <1> 	;
   394                              <1> al_p_notfound:
   395 00005701 81E900001000        <1> 	sub	ecx, MEM_ALLOC_TBL
   396 00005707 890D[94770100]      <1> 	mov	[next_page], ecx ; next/first free page = last page 
   397                              <1> 				 ; (deallocate_page procedure will change it)
   398 0000570D 31C0                <1> 	xor	eax, eax
   399 0000570F A3[90770100]        <1> 	mov	[free_pages], eax ; 0
   400 00005714 59                  <1> 	pop	ecx
   401 00005715 5B                  <1> 	pop	ebx
   402                              <1> 	;
   403                              <1> ; 17/04/2021
   404                              <1> ; ('swap_out' procedure call is disabled as temporary)
   405                              <1> 
   406                              <1> out_of_memory:
   407                              <1> ;	call	swap_out
   408                              <1> ;	jnc	short al_p_ok  ; [free_pages] = 0, re-allocation by swap_out
   409                              <1> ;	;
   410                              <1> ;	sub 	eax, eax ; 0
   411 00005716 F9                  <1> 	stc
   412 00005717 C3                  <1> 	retn
   413                              <1> 
   414                              <1> al_p_found:
   415 00005718 89D9                <1> 	mov	ecx, ebx
   416 0000571A 81E900001000        <1> 	sub	ecx, MEM_ALLOC_TBL
   417 00005720 890D[94770100]      <1> 	mov	[next_page], ecx ; Set first free page searching start
   418                              <1> 				 ; address/offset (to the next)
   419 00005726 FF0D[90770100]      <1>         dec     dword [free_pages] ; 1 page has been allocated (X = X-1) 
   420                              <1> 	;
   421 0000572C 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
   422                              <1> 				 ; is copied into the Carry Flag and then cleared
   423                              <1> 				 ; in the destination.
   424                              <1> 				 ;
   425                              <1> 				 ; Reset the bit which is corresponding to the 
   426                              <1> 				 ; (just) allocated page.
   427                              <1> 	; 01/07/2015 (4*8 = 32, 1 allocation byte = 8 pages)	
   428 0000572F C1E103              <1> 	shl	ecx, 3		 ; (page block offset * 32) + page index
   429 00005732 01C8                <1> 	add	eax, ecx	 ; = page number
   430 00005734 C1E00C              <1> 	shl	eax, 12		 ; physical address of the page (flat/real value)
   431                              <1> 	; EAX = physical address of memory page
   432                              <1> 	;
   433                              <1> 	; NOTE: The relevant page directory and page table entry will be updated
   434                              <1> 	;       according to this EAX value...
   435 00005737 59                  <1> 	pop	ecx
   436 00005738 5B                  <1> 	pop	ebx
   437                              <1> al_p_ok:
   438 00005739 C3                  <1> 	retn
   439                              <1> 
   440                              <1> make_page_dir:
   441                              <1> 	; 18/04/2015
   442                              <1> 	; 12/04/2015
   443                              <1> 	; 23/10/2014
   444                              <1> 	; 16/10/2014
   445                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
   446                              <1> 	;
   447                              <1> 	; INPUT ->
   448                              <1> 	;	none
   449                              <1> 	; OUTPUT ->
   450                              <1> 	;	(EAX = 0)
   451                              <1> 	;	cf = 1 -> insufficient (out of) memory error
   452                              <1> 	;	cf = 0 ->
   453                              <1> 	;	u.pgdir = page directory (physical) address of the current
   454                              <1> 	;		  process/user.
   455                              <1> 	;
   456                              <1> 	; Modified Registers -> EAX
   457                              <1> 	;
   458 0000573A E896FFFFFF          <1> 	call	allocate_page
   459 0000573F 7216                <1> 	jc	short mkpd_error
   460                              <1> 	;
   461 00005741 A3[74010300]        <1> 	mov	[u.pgdir], eax    ; Page dir address for current user/process
   462                              <1> 				  ; (Physical address)
   463                              <1> clear_page:
   464                              <1> 	; 18/04/2015
   465                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
   466                              <1> 	;
   467                              <1> 	; INPUT ->
   468                              <1> 	;	EAX = physical address of the page
   469                              <1> 	; OUTPUT ->
   470                              <1> 	;	all bytes of the page will be cleared
   471                              <1> 	;
   472                              <1> 	; Modified Registers -> none
   473                              <1> 	;
   474 00005746 57                  <1> 	push	edi
   475 00005747 51                  <1> 	push	ecx
   476 00005748 50                  <1> 	push	eax
   477 00005749 B900040000          <1> 	mov	ecx, PAGE_SIZE / 4
   478 0000574E 89C7                <1> 	mov	edi, eax
   479 00005750 31C0                <1> 	xor	eax, eax
   480 00005752 F3AB                <1> 	rep	stosd
   481 00005754 58                  <1> 	pop	eax
   482 00005755 59                  <1> 	pop	ecx
   483 00005756 5F                  <1> 	pop	edi
   484                              <1> mkpd_error:
   485                              <1> mkpt_error:
   486 00005757 C3                  <1> 	retn
   487                              <1> 
   488                              <1> make_page_table:
   489                              <1> 	; 23/06/2015
   490                              <1> 	; 18/04/2015
   491                              <1> 	; 12/04/2015
   492                              <1> 	; 16/10/2014
   493                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
   494                              <1> 	;
   495                              <1> 	; INPUT ->
   496                              <1> 	;	EBX = virtual (linear) address
   497                              <1> 	;	ECX = page table attributes (lower 12 bits)
   498                              <1> 	;	      (higher 20 bits must be ZERO)
   499                              <1> 	;	      (bit 0 must be 1)	 
   500                              <1> 	;	u.pgdir = page directory (physical) address
   501                              <1> 	; OUTPUT ->
   502                              <1> 	;	EDX = Page directory entry address
   503                              <1> 	;	EAX = Page table address
   504                              <1> 	;	cf = 1 -> insufficient (out of) memory error
   505                              <1> 	;	cf = 0 -> page table address in the PDE (EDX)
   506                              <1> 	;
   507                              <1> 	; Modified Registers -> EAX, EDX
   508                              <1> 	;
   509 00005758 E878FFFFFF          <1> 	call	allocate_page
   510 0000575D 72F8                <1> 	jc	short mkpt_error
   511 0000575F E811000000          <1> 	call	set_pde	
   512 00005764 EBE0                <1> 	jmp	short clear_page
   513                              <1> 
   514                              <1> make_page:
   515                              <1> 	; 24/07/2015
   516                              <1> 	; 23/06/2015 ; (Retro UNIX 386 v1 - beginning)
   517                              <1> 	;
   518                              <1> 	; INPUT ->
   519                              <1> 	;	EBX = virtual (linear) address
   520                              <1> 	;	ECX = page attributes (lower 12 bits)
   521                              <1> 	;	      (higher 20 bits must be ZERO)
   522                              <1> 	;	      (bit 0 must be 1)	 
   523                              <1> 	;	u.pgdir = page directory (physical) address
   524                              <1> 	; OUTPUT ->
   525                              <1> 	;	EBX = Virtual address
   526                              <1> 	;	(EDX = PTE value)
   527                              <1> 	;	EAX = Physical address
   528                              <1> 	;	cf = 1 -> insufficient (out of) memory error
   529                              <1> 	;
   530                              <1> 	; Modified Registers -> EAX, EDX
   531                              <1> 	;
   532 00005766 E86AFFFFFF          <1> 	call	allocate_page
   533 0000576B 7207                <1> 	jc	short mkp_err
   534 0000576D E821000000          <1> 	call	set_pte	
   535 00005772 73D2                <1> 	jnc	short clear_page ; 18/04/2015
   536                              <1> mkp_err:
   537 00005774 C3                  <1> 	retn
   538                              <1> 
   539                              <1> 
   540                              <1> set_pde:	; Set page directory entry (PDE)
   541                              <1> 	; 20/07/2015
   542                              <1> 	; 18/04/2015
   543                              <1> 	; 12/04/2015
   544                              <1> 	; 23/10/2014
   545                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   546                              <1> 	;
   547                              <1> 	; INPUT ->
   548                              <1> 	;	EAX = physical address
   549                              <1> 	;	      (use present value if EAX = 0)
   550                              <1> 	;	EBX = virtual (linear) address
   551                              <1> 	;	ECX = page table attributes (lower 12 bits)
   552                              <1> 	;	      (higher 20 bits must be ZERO)
   553                              <1> 	;	      (bit 0 must be 1)	 
   554                              <1> 	;	u.pgdir = page directory (physical) address
   555                              <1> 	; OUTPUT ->
   556                              <1> 	;	EDX = PDE address
   557                              <1> 	;	EAX = page table address (physical)
   558                              <1> 	;	;(CF=1 -> Invalid page address)
   559                              <1> 	;
   560                              <1> 	; Modified Registers -> EDX
   561                              <1> 	;
   562 00005775 89DA                <1> 	mov	edx, ebx
   563 00005777 C1EA16              <1> 	shr	edx, PAGE_D_SHIFT ; 22
   564 0000577A C1E202              <1> 	shl	edx, 2 ; offset to page directory (1024*4)
   565 0000577D 0315[74010300]      <1> 	add	edx, [u.pgdir]
   566                              <1> 	;
   567 00005783 21C0                <1> 	and	eax, eax
   568 00005785 7506                <1> 	jnz	short spde_1
   569                              <1> 	;
   570 00005787 8B02                <1> 	mov	eax, [edx]  ; old PDE value
   571                              <1> 	;test	al, 1
   572                              <1> 	;jz	short spde_2
   573 00005789 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h  ; clear lower 12 bits
   574                              <1> spde_1:
   575                              <1> 	;and	cx, 0FFFh
   576 0000578D 8902                <1> 	mov	[edx], eax
   577 0000578F 66090A              <1> 	or	[edx], cx
   578 00005792 C3                  <1> 	retn
   579                              <1> ;spde_2: ; error
   580                              <1> ;	stc
   581                              <1> ;	retn
   582                              <1> 
   583                              <1> set_pte:	; Set page table entry (PTE)
   584                              <1> 	; 24/07/2015
   585                              <1> 	; 20/07/2015
   586                              <1> 	; 23/06/2015
   587                              <1> 	; 18/04/2015
   588                              <1> 	; 12/04/2015
   589                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   590                              <1> 	;
   591                              <1> 	; INPUT ->
   592                              <1> 	;	EAX = physical page address
   593                              <1> 	;	      (use present value if EAX = 0)
   594                              <1> 	;	EBX = virtual (linear) address
   595                              <1> 	;	ECX = page attributes (lower 12 bits)
   596                              <1> 	;	      (higher 20 bits must be ZERO)
   597                              <1> 	;	      (bit 0 must be 1)	 
   598                              <1> 	;	u.pgdir = page directory (physical) address
   599                              <1> 	; OUTPUT ->
   600                              <1> 	;	EAX = physical page address
   601                              <1> 	;	(EDX = PTE value)
   602                              <1> 	;	EBX = virtual address
   603                              <1> 	;
   604                              <1> 	;	CF = 1 -> error
   605                              <1> 	;
   606                              <1> 	; Modified Registers -> EAX, EDX
   607                              <1> 	;
   608 00005793 50                  <1> 	push	eax
   609 00005794 A1[74010300]        <1> 	mov	eax, [u.pgdir] ; 20/07/2015
   610 00005799 E837000000          <1> 	call 	get_pde
   611                              <1> 		; EDX = PDE address
   612                              <1> 		; EAX = PDE value
   613 0000579E 5A                  <1> 	pop	edx ; physical page address
   614 0000579F 722A                <1> 	jc	short spte_err ; PDE not present
   615                              <1> 	;
   616 000057A1 53                  <1> 	push	ebx ; 24/07/2015
   617 000057A2 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 bits
   618                              <1> 			    ; EDX = PT address (physical)	
   619 000057A6 C1EB0C              <1> 	shr	ebx, PAGE_SHIFT ; 12
   620 000057A9 81E3FF030000        <1> 	and	ebx, PTE_MASK	; 03FFh
   621                              <1> 			 ; clear higher 10 bits (PD bits)
   622 000057AF C1E302              <1> 	shl	ebx, 2   ; offset to page table (1024*4)
   623 000057B2 01C3                <1> 	add	ebx, eax
   624                              <1> 	;
   625 000057B4 8B03                <1> 	mov	eax, [ebx] ; Old PTE value
   626 000057B6 A801                <1> 	test	al, 1
   627 000057B8 740C                <1> 	jz	short spte_0
   628 000057BA 09D2                <1> 	or	edx, edx
   629 000057BC 750F                <1> 	jnz	short spte_1
   630 000057BE 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 bits
   631 000057C2 89C2                <1> 	mov	edx, eax
   632 000057C4 EB09                <1> 	jmp	short spte_2	
   633                              <1> spte_0:
   634                              <1> 	; If this PTE contains a swap (disk) address,
   635                              <1> 	; it can be updated by using 'swap_in' procedure
   636                              <1> 	; only!
   637 000057C6 21C0                <1> 	and	eax, eax
   638 000057C8 7403                <1> 	jz	short spte_1
   639                              <1> 	; 24/07/2015
   640                              <1> 	; swapped page ! (on disk)
   641 000057CA 5B                  <1> 	pop	ebx
   642                              <1> spte_err:
   643 000057CB F9                  <1> 	stc
   644 000057CC C3                  <1> 	retn
   645                              <1> spte_1: 
   646 000057CD 89D0                <1> 	mov	eax, edx
   647                              <1> spte_2:
   648 000057CF 09CA                <1> 	or	edx, ecx
   649                              <1> 	; 23/06/2015
   650 000057D1 8913                <1> 	mov	[ebx], edx ; PTE value in EDX
   651                              <1> 	; 24/07/2015
   652 000057D3 5B                  <1> 	pop	ebx
   653 000057D4 C3                  <1> 	retn
   654                              <1> 
   655                              <1> get_pde:	; Get present value of the relevant PDE
   656                              <1> 	; 20/07/2015
   657                              <1> 	; 18/04/2015
   658                              <1> 	; 12/04/2015
   659                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   660                              <1> 	;
   661                              <1> 	; INPUT ->
   662                              <1> 	;	EBX = virtual (linear) address
   663                              <1> 	;	EAX = page directory (physical) address
   664                              <1> 	; OUTPUT ->
   665                              <1> 	;	EDX = Page directory entry address
   666                              <1> 	;	EAX = Page directory entry value
   667                              <1> 	;	CF = 1 -> PDE not present or invalid ? 
   668                              <1> 	; Modified Registers -> EDX, EAX
   669                              <1> 	;
   670 000057D5 89DA                <1> 	mov	edx, ebx
   671 000057D7 C1EA16              <1> 	shr	edx, PAGE_D_SHIFT ; 22  (12+10)
   672 000057DA C1E202              <1> 	shl 	edx, 2 ; offset to page directory (1024*4)
   673 000057DD 01C2                <1> 	add	edx, eax ; page directory address (physical)
   674 000057DF 8B02                <1> 	mov	eax, [edx]
   675 000057E1 A801                <1> 	test	al, PDE_A_PRESENT ; page table is present or not !
   676 000057E3 751F                <1> 	jnz	short gpte_retn
   677 000057E5 F9                  <1> 	stc
   678                              <1> gpde_retn:	
   679 000057E6 C3                  <1> 	retn
   680                              <1> 
   681                              <1> get_pte:
   682                              <1> 		; Get present value of the relevant PTE
   683                              <1> 	; 29/07/2015
   684                              <1> 	; 20/07/2015
   685                              <1> 	; 18/04/2015
   686                              <1> 	; 12/04/2015
   687                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   688                              <1> 	;
   689                              <1> 	; INPUT ->
   690                              <1> 	;	EBX = virtual (linear) address
   691                              <1> 	;	EAX = page directory (physical) address
   692                              <1> 	; OUTPUT ->
   693                              <1> 	;	EDX = Page table entry address (if CF=0)
   694                              <1> 	;	      Page directory entry address (if CF=1)
   695                              <1> 	;            (Bit 0 value is 0 if PT is not present)
   696                              <1> 	;	EAX = Page table entry value (page address)
   697                              <1> 	;	CF = 1 -> PDE not present or invalid ? 
   698                              <1> 	; Modified Registers -> EAX, EDX
   699                              <1> 	;
   700 000057E7 E8E9FFFFFF          <1> 	call 	get_pde
   701 000057EC 72F8                <1> 	jc	short gpde_retn	; page table is not present
   702                              <1> 	;jnc	short gpte_1
   703                              <1> 	;retn
   704                              <1> ;gpte_1:
   705 000057EE 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 bits
   706 000057F2 89DA                <1> 	mov	edx, ebx
   707 000057F4 C1EA0C              <1> 	shr	edx, PAGE_SHIFT ; 12
   708 000057F7 81E2FF030000        <1> 	and	edx, PTE_MASK	; 03FFh
   709                              <1> 			 ; clear higher 10 bits (PD bits)
   710 000057FD C1E202              <1> 	shl	edx, 2 ; offset from start of page table (1024*4)
   711 00005800 01C2                <1> 	add	edx, eax
   712 00005802 8B02                <1> 	mov	eax, [edx]
   713                              <1> gpte_retn:
   714 00005804 C3                  <1> 	retn
   715                              <1> 
   716                              <1> deallocate_page_dir:
   717                              <1> 	; 15/09/2015
   718                              <1> 	; 05/08/2015
   719                              <1> 	; 30/04/2015
   720                              <1> 	; 28/04/2015
   721                              <1> 	; 17/10/2014
   722                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
   723                              <1> 	;
   724                              <1> 	; INPUT ->
   725                              <1> 	;	EAX = PHYSICAL ADDRESS OF THE PAGE DIRECTORY (CHILD)
   726                              <1> 	;	EBX = PHYSICAL ADDRESS OF THE PARENT'S PAGE DIRECTORY
   727                              <1> 	; OUTPUT ->
   728                              <1> 	;	All of page tables in the page directory
   729                              <1> 	;	and page dir's itself will be deallocated
   730                              <1> 	;	except 'read only' duplicated pages (will be converted
   731                              <1> 	;	to writable pages).
   732                              <1> 	;
   733                              <1> 	; Modified Registers -> EAX
   734                              <1> 	;
   735                              <1> 	;
   736 00005805 56                  <1> 	push	esi
   737 00005806 51                  <1> 	push	ecx
   738 00005807 50                  <1> 	push	eax
   739 00005808 89C6                <1> 	mov	esi, eax 
   740 0000580A 31C9                <1> 	xor	ecx, ecx
   741                              <1> 	; The 1st PDE points to Kernel Page Table 0 (the 1st 4MB),
   742                              <1> 	; it must not be deallocated
   743 0000580C 890E                <1> 	mov	[esi], ecx ; 0 ; clear PDE 0
   744                              <1> dapd_0:
   745 0000580E AD                  <1> 	lodsd
   746 0000580F A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
   747 00005811 7409                <1> 	jz	short dapd_1	
   748 00005813 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
   749 00005817 E812000000          <1> 	call	deallocate_page_table			
   750                              <1> dapd_1:
   751 0000581C 41                  <1> 	inc	ecx ; page directory entry index
   752 0000581D 81F900040000        <1> 	cmp	ecx, PAGE_SIZE / 4 ; 1024
   753 00005823 72E9                <1> 	jb	short dapd_0
   754                              <1> dapd_2:
   755 00005825 58                  <1> 	pop	eax
   756 00005826 E869000000          <1> 	call	deallocate_page	; deallocate the page dir's itself
   757 0000582B 59                  <1> 	pop	ecx
   758 0000582C 5E                  <1> 	pop	esi
   759 0000582D C3                  <1> 	retn
   760                              <1> 
   761                              <1> deallocate_page_table:
   762                              <1> 	; 29/08/2023 - TRDOS 386 v2.0.6
   763                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
   764                              <1> 	;	 (temporary modifications)
   765                              <1> 	; 12/07/2016
   766                              <1> 	; 19/09/2015
   767                              <1> 	; 15/09/2015
   768                              <1> 	; 05/08/2015
   769                              <1> 	; 30/04/2015
   770                              <1> 	; 28/04/2015
   771                              <1> 	; 24/10/2014
   772                              <1> 	; 23/10/2014
   773                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
   774                              <1> 	;
   775                              <1> 	; INPUT ->
   776                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE PAGE TABLE
   777                              <1> 	;	EBX = PHYSICAL ADDRESS OF THE PARENT'S PAGE DIRECTORY
   778                              <1> 	;	(ECX = page directory entry index)
   779                              <1> 	; OUTPUT ->
   780                              <1> 	;	All of pages in the page table and page table's itself
   781                              <1> 	;	will be deallocated except 'read only' duplicated pages
   782                              <1> 	;	(will be converted to writable pages).
   783                              <1> 	;
   784                              <1> 	; Modified Registers -> EAX
   785                              <1> 	;
   786 0000582E 56                  <1> 	push	esi
   787 0000582F 57                  <1> 	push	edi
   788 00005830 52                  <1> 	push	edx
   789 00005831 50                  <1> 	push	eax ; *
   790 00005832 89C6                <1> 	mov	esi, eax 
   791 00005834 31FF                <1> 	xor	edi, edi ; 0
   792                              <1> dapt_0:
   793 00005836 AD                  <1> 	lodsd
   794 00005837 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
   795 00005839 744C                <1> 	jz	short dapt_1
   796                              <1> 	;
   797 0000583B A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
   798                              <1> 				  ; (must be 1)
   799 0000583D 753D                <1> 	jnz	short dapt_3
   800                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
   801 0000583F 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
   802                              <1> 				   ; as child's page ?
   803 00005843 7442                <1> 	jz	short dapt_4 ; Clear PTE but don't deallocate the page!
   804                              <1> 	; check the parent's PTE value is read only & same page or not.. 
   805                              <1> 	; ECX = page directory entry index (0-1023)
   806 00005845 53                  <1> 	push	ebx
   807 00005846 51                  <1> 	push	ecx
   808                              <1> 	;shl	cx, 2 ; *4
   809                              <1> 	; 29/08/2023
   810 00005847 C1E102              <1> 	shl	ecx, 2
   811 0000584A 01CB                <1> 	add	ebx, ecx ; PDE offset (for the parent)
   812 0000584C 8B0B                <1> 	mov	ecx, [ebx]
   813 0000584E F6C101              <1> 	test	cl, PDE_A_PRESENT ; present (valid) or not ?
   814 00005851 7427                <1> 	jz	short dapt_2	; parent process does not use this page
   815 00005853 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
   816                              <1> 	; EDI = page table entry index (0-1023)
   817 00005858 89FA                <1> 	mov	edx, edi 
   818                              <1> 	;shl	dx, 2 ; *4
   819                              <1> 	; 29/08/2023
   820 0000585A C1E202              <1> 	shl	edx, 2
   821 0000585D 01CA                <1> 	add	edx, ecx ; PTE offset (for the parent)
   822 0000585F 8B1A                <1> 	mov	ebx, [edx]
   823 00005861 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
   824 00005864 7414                <1> 	jz	short dapt_2	; parent process does not use this page
   825 00005866 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
   826 0000586A 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
   827 0000586F 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
   828 00005871 7507                <1> 	jne	short dapt_2	; not same page
   829                              <1> 				; deallocate the child's page
   830 00005873 800A02              <1>         or      byte [edx], PTE_A_WRITE ; convert to writable page (parent)
   831 00005876 59                  <1> 	pop	ecx
   832 00005877 5B                  <1> 	pop	ebx
   833 00005878 EB0D                <1> 	jmp	short dapt_4
   834                              <1> 
   835                              <1> ; 17/04/2021
   836                              <1> ; ('dapt_1' is disabled as temporary)
   837                              <1> ;
   838                              <1> ;dapt_1:
   839                              <1> ;	or	eax, eax	; swapped page ?
   840                              <1> ;	jz	short dapt_5	; no
   841                              <1> ;				; yes
   842                              <1> ;	shr	eax, 1
   843                              <1> ;	call	unlink_swap_block ; Deallocate swapped page block
   844                              <1> ;				  ; on the swap disk (or in file)
   845                              <1> ;	jmp	short dapt_5
   846                              <1> dapt_2:
   847 0000587A 59                  <1> 	pop	ecx
   848 0000587B 5B                  <1> 	pop	ebx
   849                              <1> dapt_3:	
   850                              <1> 	; 12/07/2016
   851 0000587C 66A90004            <1> 	test	ax, PTE_SHARED ; shared or direct memory access indicator
   852 00005880 7505                <1> 	jnz	short dapt_4   ; AVL bit 1 = 1, do not deallocate this page!
   853                              <1> 	;
   854                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
   855 00005882 E80D000000          <1> 	call	deallocate_page ; set the mem allocation bit of this page
   856                              <1> dapt_4:
   857                              <1> 	; 20/10/2023
   858                              <1> 	; PTE clearing here was/is not necessary
   859                              <1> 	; because this page table is being deallocated
   860                              <1> 	; and it's PTEs will be ineffective.
   861                              <1> 
   862                              <1> 	;mov	dword [esi-4], 0 ; clear/reset PTE (child, dupl. as parent)
   863                              <1> 
   864                              <1> dapt_1:	; 17/04/2021 (temporary)
   865                              <1> dapt_5:
   866 00005887 47                  <1> 	inc	edi ; page table entry index
   867 00005888 81FF00040000        <1> 	cmp	edi, PAGE_SIZE / 4 ; 1024
   868 0000588E 72A6                <1> 	jb	short dapt_0
   869                              <1> 	;
   870 00005890 58                  <1> 	pop	eax ; *
   871 00005891 5A                  <1> 	pop	edx
   872 00005892 5F                  <1> 	pop	edi	
   873 00005893 5E                  <1> 	pop	esi
   874                              <1> 	;
   875                              <1> 	;call	deallocate_page	; deallocate the page table's itself
   876                              <1> 	;retn
   877                              <1> 
   878                              <1> deallocate_page:
   879                              <1> 	; 15/09/2015
   880                              <1> 	; 28/04/2015
   881                              <1> 	; 10/03/2015
   882                              <1> 	; 17/10/2014
   883                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
   884                              <1> 	;
   885                              <1> 	; INPUT -> 
   886                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
   887                              <1> 	; OUTPUT ->
   888                              <1> 	;	[free_pages] is increased
   889                              <1> 	;	(corresponding MEMORY ALLOCATION TABLE bit is SET)
   890                              <1> 	;	CF = 1 if the page is already deallocated
   891                              <1> 	; 	       (or not allocated) before.  
   892                              <1> 	;
   893                              <1> 	; Modified Registers -> EAX
   894                              <1> 	;
   895 00005894 53                  <1> 	push	ebx
   896 00005895 52                  <1> 	push	edx
   897                              <1> 	;
   898 00005896 C1E80C              <1> 	shr	eax, PAGE_SHIFT      ; shift physical address to 
   899                              <1> 				     ; 12 bits right
   900                              <1> 				     ; to get page number
   901 00005899 89C2                <1> 	mov	edx, eax
   902                              <1> 	; 15/09/2015
   903 0000589B C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
   904                              <1> 				     ; (1 allocation bit = 1 page)
   905                              <1> 				     ; (1 allocation bytes = 8 pages)
   906 0000589E 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
   907                              <1> 				     ; (to get 32 bit position)			
   908                              <1> 	;
   909 000058A1 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table address
   910 000058A6 01D3                <1> 	add	ebx, edx
   911 000058A8 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only
   912                              <1> 				     ; (allocation bit position)	 
   913 000058AB 3B15[94770100]      <1> 	cmp 	edx, [next_page]     ; is the new free page address lower
   914                              <1> 				     ; than the address in 'next_page' ?
   915                              <1> 				     ; (next/first free page value)		
   916 000058B1 7306                <1> 	jnb	short dap_1	     ; no	
   917 000058B3 8915[94770100]      <1> 	mov	[next_page], edx     ; yes
   918                              <1> dap_1:
   919 000058B9 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate page
   920                              <1> 				     ; set relevant bit to 1.
   921                              <1> 				     ; set CF to the previous bit value	
   922                              <1> 	;cmc			     ; complement carry flag	
   923                              <1> 	;jc	short dap_2	     ; do not increase free_pages count
   924                              <1> 				     ; if the page is already deallocated
   925                              <1> 				     ; before.	
   926 000058BC FF05[90770100]      <1>         inc     dword [free_pages]
   927                              <1> dap_2:
   928 000058C2 5A                  <1> 	pop	edx
   929 000058C3 5B                  <1> 	pop	ebx
   930 000058C4 C3                  <1> 	retn
   931                              <1> 
   932                              <1> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   933                              <1> ;;                                                              ;;
   934                              <1> ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
   935                              <1> ;; Distributed under terms of the GNU General Public License    ;;
   936                              <1> ;;                                                              ;;
   937                              <1> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   938                              <1> 
   939                              <1> ;;$Revision: 5057 $
   940                              <1> 
   941                              <1> 
   942                              <1> ;;align 4
   943                              <1> ;;proc alloc_page
   944                              <1> 
   945                              <1> ;;        pushfd
   946                              <1> ;;        cli
   947                              <1> ;;        push    ebx
   948                              <1> ;;;//-
   949                              <1> ;;        cmp     [pg_data.pages_free], 1
   950                              <1> ;;        jle     .out_of_memory
   951                              <1> ;;;//-
   952                              <1> ;;
   953                              <1> ;;        mov     ebx, [page_start]
   954                              <1> ;;        mov     ecx, [page_end]
   955                              <1> ;;.l1:
   956                              <1> ;;        bsf     eax, [ebx];
   957                              <1> ;;        jnz     .found
   958                              <1> ;;        add     ebx, 4
   959                              <1> ;;        cmp     ebx, ecx
   960                              <1> ;;        jb      .l1
   961                              <1> ;;        pop     ebx
   962                              <1> ;;        popfd
   963                              <1> ;;        xor     eax, eax
   964                              <1> ;;        ret
   965                              <1> ;;.found:
   966                              <1> ;;;//-
   967                              <1> ;;        dec     [pg_data.pages_free]
   968                              <1> ;;        jz      .out_of_memory
   969                              <1> ;;;//-
   970                              <1> ;;        btr     [ebx], eax
   971                              <1> ;;        mov     [page_start], ebx
   972                              <1> ;;        sub     ebx, sys_pgmap
   973                              <1> ;;        lea     eax, [eax+ebx*8]
   974                              <1> ;;        shl     eax, 12
   975                              <1> ;;;//-       dec [pg_data.pages_free]
   976                              <1> ;;        pop     ebx
   977                              <1> ;;        popfd
   978                              <1> ;;        ret
   979                              <1> ;;;//-
   980                              <1> ;;.out_of_memory:
   981                              <1> ;;        mov     [pg_data.pages_free], 1
   982                              <1> ;;        xor     eax, eax
   983                              <1> ;;        pop     ebx
   984                              <1> ;;        popfd
   985                              <1> ;;        ret
   986                              <1> ;;;//-
   987                              <1> ;;endp
   988                              <1> 
   989                              <1> duplicate_page_dir:
   990                              <1> 	; 21/09/2015
   991                              <1> 	; 31/08/2015
   992                              <1> 	; 20/07/2015
   993                              <1> 	; 28/04/2015
   994                              <1> 	; 27/04/2015
   995                              <1> 	; 18/04/2015
   996                              <1> 	; 12/04/2015
   997                              <1> 	; 18/10/2014
   998                              <1> 	; 16/10/2014 (Retro UNIX 386 v1 - beginning)
   999                              <1> 	;
  1000                              <1> 	; INPUT -> 
  1001                              <1> 	;	[u.pgdir] = PHYSICAL (real/flat) ADDRESS of the parent's
  1002                              <1> 	;		    page directory.
  1003                              <1> 	; OUTPUT ->
  1004                              <1> 	;	EAX =  PHYSICAL (real/flat) ADDRESS of the child's
  1005                              <1> 	;	       page directory.
  1006                              <1> 	;	(New page directory with new page table entries.)
  1007                              <1> 	;	(New page tables with read only copies of the parent's
  1008                              <1> 	;	pages.)
  1009                              <1> 	;	EAX = 0 -> Error (CF = 1)
  1010                              <1> 	;
  1011                              <1> 	; Modified Registers -> none (except EAX)
  1012                              <1> 	;
  1013 000058C5 E80BFEFFFF          <1> 	call	allocate_page
  1014 000058CA 723E                <1> 	jc	short dpd_err
  1015                              <1> 	;
  1016 000058CC 55                  <1> 	push	ebp ; 20/07/2015
  1017 000058CD 56                  <1> 	push	esi
  1018 000058CE 57                  <1> 	push	edi
  1019 000058CF 53                  <1> 	push	ebx
  1020 000058D0 51                  <1> 	push	ecx
  1021 000058D1 8B35[74010300]      <1> 	mov	esi, [u.pgdir]
  1022 000058D7 89C7                <1> 	mov	edi, eax
  1023 000058D9 50                  <1> 	push	eax ; save child's page directory address
  1024                              <1> 	; 31/08/2015
  1025                              <1> 	; copy PDE 0 from the parent's page dir to the child's page dir
  1026                              <1> 	; (use same system space for all user page tables) 
  1027 000058DA A5                  <1> 	movsd
  1028 000058DB BD00004000          <1> 	mov	ebp, 1024*4096 ; pass the 1st 4MB (system space)
  1029 000058E0 B9FF030000          <1> 	mov	ecx, (PAGE_SIZE / 4) - 1 ; 1023
  1030                              <1> dpd_0:	
  1031 000058E5 AD                  <1> 	lodsd
  1032                              <1> 	;or	eax, eax
  1033                              <1>         ;jnz     short dpd_1
  1034 000058E6 A801                <1> 	test	al, PDE_A_PRESENT ;  bit 0 =  1
  1035 000058E8 7508                <1> 	jnz	short dpd_1
  1036                              <1>  	; 20/07/2015 (virtual address at the end of the page table)	
  1037 000058EA 81C500004000        <1> 	add	ebp, 1024*4096 ; page size * PTE count
  1038 000058F0 EB0F                <1> 	jmp	short dpd_2
  1039                              <1> dpd_1:	
  1040 000058F2 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear attribute bits
  1041 000058F6 89C3                <1> 	mov	ebx, eax
  1042                              <1> 	; EBX = Parent's page table address
  1043 000058F8 E81F000000          <1> 	call	duplicate_page_table
  1044 000058FD 720C                <1> 	jc	short dpd_p_err
  1045                              <1> 	; EAX = Child's page table address
  1046 000058FF 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
  1047                              <1> 			 ; set bit 0, bit 1 and bit 2 to 1
  1048                              <1> 			 ; (present, writable, user)
  1049                              <1> dpd_2:
  1050 00005901 AB                  <1> 	stosd
  1051 00005902 E2E1                <1> 	loop	dpd_0
  1052                              <1> 	;
  1053 00005904 58                  <1> 	pop	eax  ; restore child's page directory address
  1054                              <1> dpd_3:
  1055 00005905 59                  <1> 	pop	ecx
  1056 00005906 5B                  <1> 	pop	ebx
  1057 00005907 5F                  <1> 	pop	edi
  1058 00005908 5E                  <1> 	pop	esi
  1059 00005909 5D                  <1> 	pop	ebp ; 20/07/2015
  1060                              <1> dpd_err:
  1061 0000590A C3                  <1> 	retn
  1062                              <1> dpd_p_err:
  1063                              <1> 	; release the allocated pages missing (recover free space)
  1064 0000590B 58                  <1> 	pop	eax  ; the new page directory address (physical)
  1065 0000590C 8B1D[74010300]      <1> 	mov	ebx, [u.pgdir] ; parent's page directory address 
  1066 00005912 E8EEFEFFFF          <1> 	call 	deallocate_page_dir
  1067 00005917 29C0                <1> 	sub	eax, eax ; 0
  1068 00005919 F9                  <1> 	stc
  1069 0000591A EBE9                <1> 	jmp	short dpd_3	
  1070                              <1> 
  1071                              <1> duplicate_page_table:
  1072                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  1073                              <1> 	;	 (temporary modifications)
  1074                              <1> 	; 20/02/2017
  1075                              <1> 	; 21/09/2015
  1076                              <1> 	; 20/07/2015
  1077                              <1> 	; 05/05/2015
  1078                              <1> 	; 28/04/2015
  1079                              <1> 	; 27/04/2015
  1080                              <1> 	; 18/04/2015
  1081                              <1> 	; 18/10/2014
  1082                              <1> 	; 16/10/2014 (Retro UNIX 386 v1 - beginning)
  1083                              <1> 	;
  1084                              <1> 	; INPUT -> 
  1085                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS of the parent's page table.
  1086                              <1> 	;       20/02/2017		 
  1087                              <1> 	;	EBP = Linear address of the page (from 'duplicate_page_dir')
  1088                              <1> 	;	      (Linear address = CORE + user's virtual address) 	
  1089                              <1> 	; OUTPUT ->
  1090                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS of the child's page table.
  1091                              <1> 	;	      (with 'read only' attribute of page table entries)
  1092                              <1> 	;	20/02/2017
  1093                              <1> 	;	EBP = Next linear page address (for 'duplicate_page_dir')
  1094                              <1> 	;	
  1095                              <1> 	;	CF = 1 -> error 
  1096                              <1> 	;
  1097                              <1> 	; Modified Registers -> EBP (except EAX)
  1098                              <1> 	;
  1099 0000591C E8B4FDFFFF          <1> 	call	allocate_page
  1100 00005921 7258                <1> 	jc	short dpt_err
  1101                              <1> 	;
  1102 00005923 50                  <1> 	push	eax ; *
  1103 00005924 56                  <1> 	push	esi
  1104 00005925 57                  <1> 	push	edi
  1105 00005926 52                  <1> 	push	edx
  1106 00005927 51                  <1> 	push	ecx
  1107                              <1> 	;
  1108 00005928 89DE                <1> 	mov	esi, ebx
  1109 0000592A 89C7                <1> 	mov	edi, eax
  1110 0000592C 89C2                <1> 	mov	edx, eax
  1111 0000592E 81C200100000        <1> 	add	edx, PAGE_SIZE 	
  1112                              <1> dpt_0:
  1113 00005934 AD                  <1> 	lodsd
  1114 00005935 21C0                <1> 	and	eax, eax
  1115 00005937 7432                <1> 	jz	short dpt_3
  1116 00005939 A801                <1> 	test	al, PTE_A_PRESENT ;  bit 0 =  1
  1117                              <1> 	; 17/04/2021 (temporary)
  1118                              <1> 	;jnz	short dpt_1
  1119 0000593B 7439                <1> 	jz	short dpt_p_err
  1120                              <1> 
  1121                              <1> ; 17/04/2021
  1122                              <1> ; ('reload_page' procedure call is disabled as temporary)
  1123                              <1> ;
  1124                              <1> ;	; 20/07/2015
  1125                              <1> ;	; ebp = virtual (linear) address of the memory page
  1126                              <1> ;	call	reload_page ; 28/04/2015
  1127                              <1> ;	jc	short dpt_p_err
  1128                              <1> dpt_1:
  1129                              <1> 	; 21/09/2015
  1130 0000593D 89C1                <1> 	mov	ecx, eax
  1131 0000593F 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  1132 00005943 F6C102              <1> 	test	cl, PTE_A_WRITE ; writable page ?
  1133 00005946 751A                <1> 	jnz	short dpt_2
  1134                              <1> 	; Read only (parent) page
  1135                              <1> 	; 	- there is a third process which uses this page -
  1136                              <1> 	; Allocate a new page for the child process
  1137 00005948 E888FDFFFF          <1> 	call	allocate_page
  1138 0000594D 7227                <1> 	jc	short dpt_p_err
  1139 0000594F 57                  <1> 	push	edi
  1140 00005950 56                  <1> 	push	esi
  1141 00005951 89CE                <1> 	mov	esi, ecx
  1142 00005953 89C7                <1> 	mov	edi, eax
  1143 00005955 B900040000          <1> 	mov	ecx, PAGE_SIZE/4
  1144 0000595A F3A5                <1> 	rep	movsd	; copy page (4096 bytes)
  1145 0000595C 5E                  <1> 	pop	esi
  1146 0000595D 5F                  <1> 	pop	edi
  1147                              <1> 	;
  1148                              <1> 
  1149                              <1> ; 17/04/2021
  1150                              <1> ; ('add_to_swap_queue' procedure call is disabled as temporary)
  1151                              <1> ; 
  1152                              <1> ;	push	ebx
  1153                              <1> ;	push	eax
  1154                              <1> ;	; 20/07/2015
  1155                              <1> ;	mov	ebx, ebp
  1156                              <1> ;	; ebx = virtual (linear) address of the memory page
  1157                              <1> ;	call	add_to_swap_queue
  1158                              <1> ;	pop	eax
  1159                              <1> ;	pop	ebx
  1160                              <1> 
  1161                              <1> 	; 21/09/2015
  1162 0000595E 0C07                <1> 	or	al, PTE_A_USER+PTE_A_WRITE+PTE_A_PRESENT 
  1163                              <1> 		; user + writable + present page
  1164 00005960 EB09                <1> 	jmp	short dpt_3
  1165                              <1> dpt_2:
  1166                              <1> 	;or	ax, PTE_A_USER+PTE_A_PRESENT 
  1167 00005962 0C05                <1> 	or	al, PTE_A_USER+PTE_A_PRESENT 
  1168                              <1> 		    ; (read only page!)
  1169 00005964 8946FC              <1> 	mov	[esi-4], eax ; update parent's PTE
  1170 00005967 660D0002            <1> 	or      ax, PTE_DUPLICATED  ; (read only page & duplicated PTE!)
  1171                              <1> dpt_3:
  1172 0000596B AB                  <1> 	stosd  ; EDI points to child's PTE  	 
  1173                              <1> 	;
  1174 0000596C 81C500100000        <1> 	add	ebp, 4096 ; 20/07/2015 (next page)
  1175                              <1> 	;
  1176 00005972 39D7                <1> 	cmp	edi, edx
  1177 00005974 72BE                <1> 	jb	short dpt_0
  1178                              <1> dpt_p_err:
  1179 00005976 59                  <1> 	pop	ecx
  1180 00005977 5A                  <1> 	pop	edx
  1181 00005978 5F                  <1> 	pop	edi
  1182 00005979 5E                  <1> 	pop	esi
  1183 0000597A 58                  <1> 	pop	eax ; *
  1184                              <1> dpt_err:
  1185 0000597B C3                  <1> 	retn
  1186                              <1> 
  1187                              <1> page_fault_handler:	; CPU EXCEPTION 0Eh (14) : Page Fault !
  1188                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  1189                              <1> 	;	 (temporary modifications)
  1190                              <1> 	; 21/09/2015
  1191                              <1> 	; 19/09/2015
  1192                              <1> 	; 17/09/2015
  1193                              <1> 	; 28/08/2015
  1194                              <1> 	; 20/07/2015
  1195                              <1> 	; 28/06/2015
  1196                              <1> 	; 03/05/2015
  1197                              <1> 	; 30/04/2015
  1198                              <1> 	; 18/04/2015
  1199                              <1> 	; 12/04/2015
  1200                              <1> 	; 30/10/2014
  1201                              <1> 	; 11/09/2014
  1202                              <1> 	; 10/09/2014 (Retro UNIX 386 v1 - beginning)
  1203                              <1> 	;
  1204                              <1> 	; Note: This is not an interrupt/exception handler.
  1205                              <1> 	;	This is a 'page fault remedy' subroutine 
  1206                              <1> 	;	which will be called by standard/uniform
  1207                              <1> 	;	exception handler.
  1208                              <1> 	;
  1209                              <1> 	; INPUT -> 
  1210                              <1> 	;	[error_code] = 32 bit ERROR CODE (lower 5 bits are valid)
  1211                              <1> 	;
  1212                              <1> 	;	cr2 = the virtual (linear) address 
  1213                              <1> 	;	      which has caused to page fault (19/09/2015)
  1214                              <1> 	;
  1215                              <1> 	; OUTPUT ->
  1216                              <1> 	;	(corresponding PAGE TABLE ENTRY is mapped/set)
  1217                              <1> 	;	EAX = 0 -> no error
  1218                              <1> 	;	EAX > 0 -> error code in EAX (also CF = 1)
  1219                              <1> 	;
  1220                              <1> 	; Modified Registers -> none (except EAX)
  1221                              <1> 	;	
  1222                              <1>         ;
  1223                              <1>         ; ERROR CODE:
  1224                              <1> 	;	 31  .....	4   3	2   1	0
  1225                              <1> 	;	+---+-- --+---+---+---+---+---+---+
  1226                              <1> 	;	|   Reserved  | I | R | U | W | P |
  1227                              <1> 	;	+---+-- --+---+---+---+---+---+---+
  1228                              <1> 	;
  1229                              <1> 	; P : PRESENT -	When set, the page fault was caused by 
  1230                              <1>     	;		a page-protection violation. When not set,
  1231                              <1> 	;		it was caused by a non-present page.
  1232                              <1> 	; W : WRITE   -	When set, the page fault was caused by
  1233                              <1> 	;		a page write. When not set, it was caused
  1234                              <1> 	;		by a page read.
  1235                              <1> 	; U : USER    -	When set, the page fault was caused 
  1236                              <1> 	;		while CPL = 3. 
  1237                              <1> 	;		This does not necessarily mean that
  1238                              <1> 	;		the page fault was a privilege violation.
  1239                              <1> 	; R : RESERVD -	When set, the page fault was caused by
  1240                              <1> 	;     WRITE	reading a 1 in a reserved field.
  1241                              <1> 	; I : INSTRUC -	When set, the page fault was caused by
  1242                              <1> 	;     FETCH	an instruction fetch
  1243                              <1> 	;
  1244                              <1> 	;; x86 (32 bit) VIRTUAL ADDRESS TRANSLATION
  1245                              <1> 	;  31               22                  12 11                    0
  1246                              <1> 	; +-------------------+-------------------+-----------------------+
  1247                              <1>        	; | PAGE DIR. ENTRY # | PAGE TAB. ENTRY # |        OFFSET         |
  1248                              <1>        	; +-------------------+-------------------+-----------------------+
  1249                              <1> 	;
  1250                              <1> 
  1251                              <1> 	;; CR3 REGISTER (Control Register 3)
  1252                              <1> 	;  31                                   12             5 4 3 2   0
  1253                              <1> 	; +---------------------------------------+-------------+---+-----+
  1254                              <1>       	; |                                       |  		|P|P|     |
  1255                              <1>       	; |   PAGE DIRECTORY TABLE BASE ADDRESS   |  reserved	|C|W|rsvrd|
  1256                              <1>       	; |                                       | 		|D|T|     |
  1257                              <1>    	; +---------------------------------------+-------------+---+-----+
  1258                              <1> 	;
  1259                              <1> 	;	PWT    - WRITE THROUGH
  1260                              <1> 	;	PCD    - CACHE DISABLE		
  1261                              <1> 	;
  1262                              <1> 	;
  1263                              <1> 	;; x86 PAGE DIRECTORY ENTRY (4 KByte Page)
  1264                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  1265                              <1> 	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1266                              <1>       	; |                                       |     | | | | |P|P|U|R| |
  1267                              <1>       	; |     PAGE TABLE BASE ADDRESS 31..12    | AVL |G|0|D|A|C|W|/|/|P|
  1268                              <1>       	; |                                       |     | | | | |D|T|S|W| |
  1269                              <1>    	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1270                              <1> 	;
  1271                              <1>         ;       P      - PRESENT
  1272                              <1>         ;       R/W    - READ/WRITE
  1273                              <1>         ;       U/S    - USER/SUPERVISOR
  1274                              <1> 	;	PWT    - WRITE THROUGH
  1275                              <1> 	;	PCD    - CACHE DISABLE	
  1276                              <1> 	;	A      - ACCESSED	
  1277                              <1>         ;       D      - DIRTY (IGNORED)
  1278                              <1> 	;	PAT    - PAGE ATTRIBUTE TABLE INDEX (CACHE BEHAVIOR)
  1279                              <1> 	;	G      - GLOBAL	(IGNORED) 
  1280                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  1281                              <1> 	;
  1282                              <1> 	;
  1283                              <1> 	;; x86 PAGE TABLE ENTRY (4 KByte Page)
  1284                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  1285                              <1> 	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1286                              <1>       	; |                                       |     | |P| | |P|P|U|R| |
  1287                              <1>       	; |     PAGE FRAME BASE ADDRESS 31..12    | AVL |G|A|D|A|C|W|/|/|P|
  1288                              <1>       	; |                                       |     | |T| | |D|T|S|W| |
  1289                              <1>    	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1290                              <1> 	;
  1291                              <1>         ;       P      - PRESENT
  1292                              <1>         ;       R/W    - READ/WRITE
  1293                              <1>         ;       U/S    - USER/SUPERVISOR
  1294                              <1> 	;	PWT    - WRITE THROUGH
  1295                              <1> 	;	PCD    - CACHE DISABLE	
  1296                              <1> 	;	A      - ACCESSED	
  1297                              <1>         ;       D      - DIRTY
  1298                              <1> 	;	PAT    - PAGE ATTRIBUTE TABLE INDEX (CACHE BEHAVIOR)
  1299                              <1> 	;	G      - GLOBAL	 
  1300                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  1301                              <1> 	;
  1302                              <1> 	;
  1303                              <1> 	;; 80386 PAGE TABLE ENTRY (4 KByte Page)
  1304                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  1305                              <1> 	; +---------------------------------------+-----+-+-+-+-+---+-+-+-+
  1306                              <1>       	; |                                       |     | | | | | | |U|R| |
  1307                              <1>       	; |     PAGE FRAME BASE ADDRESS 31..12    | AVL |0|0|D|A|0|0|/|/|P|
  1308                              <1>       	; |                                       |     | | | | | | |S|W| |
  1309                              <1>       	; +---------------------------------------+-----+-+-+-+-+---+-+-+-+
  1310                              <1> 	;
  1311                              <1>         ;       P      - PRESENT
  1312                              <1>         ;       R/W    - READ/WRITE
  1313                              <1>         ;       U/S    - USER/SUPERVISOR
  1314                              <1>         ;       D      - DIRTY
  1315                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  1316                              <1> 	;
  1317                              <1>         ;       NOTE: 0 INDICATES INTEL RESERVED. DO NOT DEFINE.
  1318                              <1> 	;
  1319                              <1> 	;
  1320                              <1> 	;; Invalid Page Table Entry
  1321                              <1> 	; 31                                                           1 0
  1322                              <1>       	; +-------------------------------------------------------------+-+
  1323                              <1>       	; |                                                             | |
  1324                              <1>       	; |                          AVAILABLE                          |0|
  1325                              <1>       	; |                                                             | |
  1326                              <1>       	; +-------------------------------------------------------------+-+
  1327                              <1> 	;
  1328                              <1> 
  1329 0000597C 53                  <1> 	push	ebx
  1330 0000597D 52                  <1> 	push	edx
  1331 0000597E 51                  <1> 	push	ecx
  1332                              <1> 	;
  1333                              <1> 	; 21/09/2015 (debugging)
  1334 0000597F FF05[88010300]      <1> 	inc	dword [u.pfcount] ; page fault count for running process
  1335 00005985 FF05[34030300]      <1> 	inc	dword [PF_Count] ; total page fault count	
  1336                              <1> 	; 28/06/2015
  1337                              <1> 	;mov	edx, [error_code] ; Lower 5 bits are valid
  1338 0000598B 8A15[2C030300]      <1> 	mov	dl, [error_code]
  1339                              <1> 	;
  1340 00005991 F6C201              <1> 	test	dl, 1	; page fault was caused by a non-present page
  1341                              <1> 			; sign
  1342 00005994 741A                <1> 	jz	short pfh_alloc_np
  1343                              <1> 	; 
  1344                              <1> 	; If it is not a 'write on read only page' type page fault
  1345                              <1> 	; major page fault error with minor reason must be returned without 
  1346                              <1> 	; fixing the problem. 'sys_exit with error' will be needed
  1347                              <1> 	; after return here!
  1348                              <1> 	; Page fault will be remedied, by copying page contents
  1349                              <1> 	; to newly allocated page with write permission;
  1350                              <1> 	; sys_fork -> sys_exec -> copy on write, demand paging method is 
  1351                              <1> 	; used for working with minimum possible memory usage. 
  1352                              <1> 	; sys_fork will duplicate page directory and tables of parent  
  1353                              <1> 	; process with 'read only' flag. If the child process attempts to
  1354                              <1> 	; write on these read only pages, page fault will be directed here
  1355                              <1> 	; for allocating a new page with same data/content. 
  1356                              <1> 	;
  1357                              <1> 	; IMPORTANT : Retro UNIX 386 v1 (and SINGLIX and TR-DOS)
  1358                              <1> 	; will not force to separate CODE and DATA space 
  1359                              <1> 	; in a process/program... 
  1360                              <1> 	; CODE segment/section may contain DATA!
  1361                              <1> 	; It is flat, smoth and simplest programming method already as in 
  1362                              <1> 	; Retro UNIX 8086 v1 and MS-DOS programs.
  1363                              <1> 	;	
  1364 00005996 F6C202              <1> 	test	dl, 2	; page fault was caused by a page write
  1365                              <1> 			; sign
  1366 00005999 0F8481000000        <1>         jz      pfh_p_err
  1367                              <1> 	; 31/08/2015
  1368 0000599F F6C204              <1> 	test	dl, 4	; page fault was caused while CPL = 3 (user mode)
  1369                              <1> 			; sign.  (U+W+P = 4+2+1 = 7)
  1370 000059A2 747C                <1>         jz	pfh_pv_err
  1371                              <1> 	;
  1372                              <1> 	; make a new page and copy the parent's page content
  1373                              <1> 	; as the child's new page content
  1374                              <1> 	;
  1375 000059A4 0F20D3              <1> 	mov	ebx, cr2 ; CR2 contains the linear address 
  1376                              <1> 			 ; which has caused to page fault
  1377 000059A7 E87C000000          <1> 	call 	copy_page
  1378 000059AC 726B                <1>         jc      pfh_im_err ; insufficient memory
  1379                              <1> 	;
  1380 000059AE EB63                <1>         jmp     pfh_cpp_ok
  1381                              <1> 	;
  1382                              <1> pfh_alloc_np:
  1383 000059B0 E820FDFFFF          <1> 	call	allocate_page	; (allocate a new page)
  1384 000059B5 7262                <1>         jc      pfh_im_err	; 'insufficient memory' error
  1385                              <1> pfh_chk_cpl:
  1386                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  1387                              <1> 		; (Lower 12 bits are ZERO, because 
  1388                              <1> 		;	the address is on a page boundary)
  1389 000059B7 80E204              <1> 	and	dl, 4	; CPL = 3 ?
  1390 000059BA 7505                <1> 	jnz	short pfh_um
  1391                              <1> 			; Page fault handler for kernel/system mode (CPL=0)		
  1392 000059BC 0F20DB              <1> 	mov	ebx, cr3 ; CR3 (Control Register 3) contains physical address
  1393                              <1> 			 ; of the current/active page directory
  1394                              <1> 			 ; (Always kernel/system mode page directory, here!)
  1395                              <1> 			 ; Note: Lower 12 bits are 0. (page boundary)
  1396 000059BF EB06                <1> 	jmp	short pfh_get_pde
  1397                              <1> 	;
  1398                              <1> pfh_um:			; Page fault handler for user/appl. mode (CPL=3)
  1399 000059C1 8B1D[74010300]      <1>  	mov	ebx, [u.pgdir] ; Page directory of current/active process
  1400                              <1> 			; Physical address of the USER's page directory
  1401                              <1> 			; Note: Lower 12 bits are 0. (page boundary)
  1402                              <1> pfh_get_pde:
  1403 000059C7 80CA03              <1> 	or	dl, 3	; USER + WRITE + PRESENT or SYSTEM + WRITE + PRESENT
  1404 000059CA 0F20D1              <1> 	mov	ecx, cr2 ; CR2 contains the virtual address 
  1405                              <1> 			 ; which has been caused to page fault
  1406                              <1> 			 ;
  1407 000059CD C1E914              <1> 	shr	ecx, 20	 ; shift 20 bits right
  1408 000059D0 80E1FC              <1> 	and	cl, 0FCh ; mask lower 2 bits to get PDE offset		
  1409                              <1> 	;
  1410 000059D3 01CB                <1> 	add	ebx, ecx ; now, EBX points to the relevant page dir entry 
  1411 000059D5 8B0B                <1> 	mov	ecx, [ebx] ; physical (base) address of the page table 	
  1412 000059D7 F6C101              <1> 	test	cl, 1	 ; check bit 0 is set (1) or not (0).
  1413 000059DA 740B                <1> 	jz	short pfh_set_pde ; Page directory entry is not valid,
  1414                              <1> 			  	  ; set/validate page directory entry
  1415 000059DC 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  1416 000059E1 89CB                <1> 	mov	ebx, ecx ; Physical address of the page table
  1417 000059E3 89C1                <1> 	mov	ecx, eax ; new page address (physical) 	
  1418 000059E5 EB16                <1> 	jmp	short pfh_get_pte
  1419                              <1> pfh_set_pde:
  1420                              <1> 	;; NOTE: Page directories and page tables never be swapped out!
  1421                              <1> 	;;	 (So, we know this PDE is empty or invalid)
  1422                              <1> 	;
  1423 000059E7 08D0                <1> 	or	al, dl	 ; lower 3 bits are used as U/S, R/W, P flags
  1424 000059E9 8903                <1> 	mov	[ebx], eax ; Let's put the new page directory entry here !
  1425 000059EB 30C0                <1> 	xor	al, al	 ; clear lower (3..8) bits
  1426 000059ED 89C3                <1> 	mov	ebx, eax
  1427 000059EF E8E1FCFFFF          <1> 	call	allocate_page	 ; (allocate a new page)
  1428 000059F4 7223                <1> 	jc	short pfh_im_err   ; 'insufficient memory' error
  1429                              <1> pfh_spde_1:
  1430                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  1431 000059F6 89C1                <1> 	mov	ecx, eax
  1432 000059F8 E849FDFFFF          <1> 	call	clear_page ; Clear page content
  1433                              <1> pfh_get_pte:
  1434 000059FD 0F20D0              <1> 	mov	eax, cr2 ; virtual address
  1435                              <1> 			 ; which has been caused to page fault
  1436 00005A00 89C7                <1> 	mov	edi, eax ; 20/07/2015
  1437 00005A02 C1E80C              <1> 	shr	eax, 12	 ; shift 12 bit right to get 
  1438                              <1> 			 ; higher 20 bits of the page fault address 
  1439 00005A05 25FF030000          <1> 	and	eax, 3FFh ; mask PDE# bits, the result is PTE# (0 to 1023)
  1440 00005A0A C1E002              <1> 	shl	eax, 2	; shift 2 bits left to get PTE offset
  1441 00005A0D 01C3                <1> 	add	ebx, eax ; now, EBX points to the relevant page table entry 
  1442                              <1> ; 17/04/2021 temporary
  1443                              <1> ;	mov	eax, [ebx] ; get previous value of pte
  1444                              <1> ;		; bit 0 of EAX is always 0 (otherwise we would not be here)
  1445                              <1> 
  1446                              <1> ; 17/04/2021
  1447                              <1> ; ('swap_in' procedure call has been disabled as temporary)
  1448                              <1> ;
  1449                              <1> ;	and	eax, eax
  1450                              <1> ;	jz	short pfh_gpte_1
  1451                              <1> ;	; 20/07/2015
  1452                              <1> ;	xchg	ebx, ecx ; new page address (physical)
  1453                              <1> ;	push	ebp ; 20/07/2015
  1454                              <1> ;	mov	ebp, cr2
  1455                              <1> ;		; ECX = physical address of the page table entry
  1456                              <1> ;		; EBX = Memory page address (physical!)
  1457                              <1> ;		; EAX = Swap disk (offset) address
  1458                              <1> ;		; EBP = virtual address (page fault address)
  1459                              <1> ;	call	swap_in
  1460                              <1> ;	pop	ebp
  1461                              <1> ;	jc      short pfh_err_retn
  1462                              <1> ;	xchg	ecx, ebx
  1463                              <1> ;		; EBX = physical address of the page table entry
  1464                              <1> ;		; ECX = new page
  1465                              <1> pfh_gpte_1:
  1466 00005A0F 08D1                <1> 	or	cl, dl	; lower 3 bits are used as U/S, R/W, P flags
  1467 00005A11 890B                <1> 	mov	[ebx], ecx ; Let's put the new page table entry here !
  1468                              <1> pfh_cpp_ok:
  1469                              <1> ; 17/04/2021
  1470                              <1> ; ('add_to_swap_queue' procedure call has been disabled as temporary)
  1471                              <1> ;
  1472                              <1> ;	; 20/07/2015
  1473                              <1> ;	mov	ebx, cr2
  1474                              <1> ;	call 	add_to_swap_queue
  1475                              <1> 	;
  1476                              <1> 	; The new PTE (which contains the new page) will be added to 
  1477                              <1> 	; the swap queue, here. 
  1478                              <1> 	; (Later, if memory will become insufficient, 
  1479                              <1> 	; one page will be swapped out which is at the head of 
  1480                              <1> 	; the swap queue by using FIFO and access check methods.)
  1481                              <1> 	;
  1482 00005A13 31C0                <1> 	xor	eax, eax  ; 0
  1483                              <1> 	;
  1484                              <1> pfh_err_retn:
  1485 00005A15 59                  <1> 	pop	ecx
  1486 00005A16 5A                  <1> 	pop	edx
  1487 00005A17 5B                  <1> 	pop	ebx
  1488 00005A18 C3                  <1> 	retn 
  1489                              <1> 	
  1490                              <1> pfh_im_err:
  1491 00005A19 B8E4000000          <1> 	mov	eax, ERR_MAJOR_PF + ERR_MINOR_IM ; Error code in AX
  1492                              <1> 			; Major (Primary) Error: Page Fault
  1493                              <1> 			; Minor (Secondary) Error: Insufficient Memory !
  1494 00005A1E EBF5                <1> 	jmp	short pfh_err_retn
  1495                              <1> 
  1496                              <1> pfh_p_err: ; 09/03/2015
  1497                              <1> pfh_pv_err:
  1498                              <1> 	; Page fault was caused by a protection-violation
  1499 00005A20 B8E6000000          <1> 	mov	eax, ERR_MAJOR_PF + ERR_MINOR_PV ; Error code in AX
  1500                              <1> 			; Major (Primary) Error: Page Fault
  1501                              <1> 			; Minor (Secondary) Error: Protection violation !
  1502 00005A25 F9                  <1> 	stc
  1503 00005A26 EBED                <1> 	jmp	short pfh_err_retn
  1504                              <1> 
  1505                              <1> copy_page:
  1506                              <1> 	; 29/08/2023 (TRDOS 386 v2.0.6)
  1507                              <1> 	; 22/09/2015
  1508                              <1> 	; 21/09/2015
  1509                              <1> 	; 19/09/2015
  1510                              <1> 	; 07/09/2015
  1511                              <1> 	; 31/08/2015
  1512                              <1> 	; 20/07/2015
  1513                              <1> 	; 05/05/2015
  1514                              <1> 	; 03/05/2015
  1515                              <1> 	; 18/04/2015
  1516                              <1> 	; 12/04/2015
  1517                              <1> 	; 30/10/2014
  1518                              <1> 	; 18/10/2014 (Retro UNIX 386 v1 - beginning)
  1519                              <1> 	;
  1520                              <1> 	; INPUT -> 
  1521                              <1> 	;	EBX = Virtual (linear) address of source page
  1522                              <1> 	;	     (Page fault address)
  1523                              <1> 	; OUTPUT ->
  1524                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
  1525                              <1> 	;	(corresponding PAGE TABLE ENTRY is mapped/set)
  1526                              <1> 	;	EAX = 0 (CF = 1) 
  1527                              <1> 	;		if there is not a free page to be allocated
  1528                              <1> 	;	(page content of the source page will be copied
  1529                              <1> 	;	onto the target/new page) 	
  1530                              <1> 	;
  1531                              <1> 	; Modified Registers -> ecx, ebx (except EAX)
  1532                              <1> 	;	
  1533 00005A28 56                  <1> 	push	esi
  1534 00005A29 57                  <1> 	push	edi
  1535                              <1> 	;push	ebx
  1536                              <1> 	;push	ecx
  1537 00005A2A 31F6                <1> 	xor 	esi, esi
  1538 00005A2C C1EB0C              <1> 	shr	ebx, 12 ; shift 12 bits right to get PDE & PTE numbers
  1539 00005A2F 89D9                <1> 	mov	ecx, ebx ; save page fault address (as 12 bit shifted)
  1540 00005A31 C1EB08              <1> 	shr	ebx, 8	 ; shift 8 bits right and then
  1541 00005A34 80E3FC              <1> 	and	bl, 0FCh ; mask lower 2 bits to get PDE offset	
  1542 00005A37 89DF                <1> 	mov 	edi, ebx ; save it for the parent of current process
  1543 00005A39 031D[74010300]      <1> 	add	ebx, [u.pgdir] ; EBX points to the relevant page dir entry 
  1544 00005A3F 8B03                <1> 	mov	eax, [ebx] ; physical (base) address of the page table
  1545 00005A41 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits 	
  1546 00005A45 89CB                <1> 	mov	ebx, ecx   ; (restore higher 20 bits of page fault address)
  1547 00005A47 81E3FF030000        <1> 	and	ebx, 3FFh  ; mask PDE# bits, the result is PTE# (0 to 1023)
  1548                              <1> 	;shl	bx, 2	   ; shift 2 bits left to get PTE offset
  1549                              <1> 	; 29/08/2023
  1550 00005A4D C1E302              <1> 	shl	ebx, 2
  1551 00005A50 01C3                <1> 	add	ebx, eax   ; EBX points to the relevant page table entry 
  1552                              <1> 	; 07/09/2015
  1553 00005A52 66F7030002          <1>         test    word [ebx], PTE_DUPLICATED ; (Does current process share this
  1554                              <1> 				     ; read only page as a child process?)	
  1555 00005A57 7509                <1> 	jnz	short cpp_0 ; yes
  1556 00005A59 8B0B                <1> 	mov	ecx, [ebx] ; PTE value
  1557 00005A5B 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; 0F000h  ; clear page attributes
  1558 00005A60 EB31                <1> 	jmp	short cpp_1
  1559                              <1> cpp_0:
  1560 00005A62 89FE                <1> 	mov	esi, edi
  1561 00005A64 0335[78010300]      <1> 	add	esi, [u.ppgdir] ; the parent's page directory entry
  1562 00005A6A 8B06                <1> 	mov	eax, [esi] ; physical (base) address of the page table
  1563 00005A6C 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  1564 00005A70 89CE                <1> 	mov	esi, ecx   ; (restore higher 20 bits of page fault address)	
  1565 00005A72 81E6FF030000        <1> 	and	esi, 3FFh  ; mask PDE# bits, the result is PTE# (0 to 1023)
  1566                              <1> 	;shl	si, 2	   ; shift 2 bits left to get PTE offset
  1567                              <1> 	; 29/08/2023
  1568 00005A78 C1E602              <1> 	shl	esi, 2
  1569 00005A7B 01C6                <1> 	add	esi, eax   ; EDX points to the relevant page table entry  	
  1570 00005A7D 8B0E                <1> 	mov	ecx, [esi] ; PTE value of the parent process
  1571                              <1> 	; 21/09/2015
  1572 00005A7F 8B03                <1> 	mov	eax, [ebx] ; PTE value of the child process
  1573 00005A81 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear page attributes	
  1574                              <1> 	;
  1575 00005A85 F6C101              <1> 	test	cl, PTE_A_PRESENT ; is it a present/valid page ?
  1576 00005A88 7424                <1> 	jz	short cpp_3 ; the parent's page is not same page  	
  1577                              <1> 	;
  1578 00005A8A 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; 0F000h ; clear page attributes
  1579 00005A8F 39C8                <1> 	cmp	eax, ecx   ; Same page?	
  1580 00005A91 751B                <1> 	jne	short cpp_3 ; Parent page and child page are not same 
  1581                              <1> 			    ; Convert child's page to writable page
  1582                              <1> cpp_1:
  1583 00005A93 E83DFCFFFF          <1> 	call	allocate_page
  1584 00005A98 721A                <1> 	jc	short cpp_4 ; 'insufficient memory' error
  1585 00005A9A 21F6                <1> 	and	esi, esi    ; check ESI is valid or not
  1586 00005A9C 7405                <1> 	jz	short cpp_2
  1587                              <1> 		; Convert read only page to writable page 
  1588                              <1> 		;(for the parent of the current process)
  1589                              <1> 	;and	word [esi], PTE_A_CLEAR ; 0F000h
  1590                              <1> 	; 22/09/2015
  1591 00005A9E 890E                <1> 	mov	[esi], ecx
  1592 00005AA0 800E07              <1> 	or	byte [esi], PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER
  1593                              <1> 				 ; 1+2+4 = 7
  1594                              <1> cpp_2:
  1595 00005AA3 89C7                <1> 	mov	edi, eax ; new page address of the child process
  1596                              <1> 	; 07/09/2015
  1597 00005AA5 89CE                <1> 	mov	esi, ecx ; the page address of the parent process
  1598 00005AA7 B900040000          <1> 	mov	ecx, PAGE_SIZE / 4
  1599 00005AAC F3A5                <1> 	rep	movsd ; 31/08/2015
  1600                              <1> cpp_3:		
  1601 00005AAE 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER ; 1+2+4 = 7
  1602 00005AB0 8903                <1> 	mov	[ebx], eax ; Update PTE
  1603 00005AB2 28C0                <1> 	sub	al, al ; clear attributes
  1604                              <1> cpp_4:
  1605                              <1> 	;pop	ecx
  1606                              <1> 	;pop	ebx
  1607 00005AB4 5F                  <1> 	pop	edi
  1608 00005AB5 5E                  <1> 	pop	esi
  1609 00005AB6 C3                  <1> 	retn
  1610                              <1> 
  1611                              <1> ;; 28/04/2015
  1612                              <1> ;; 24/10/2014
  1613                              <1> ;; 21/10/2014 (Retro UNIX 386 v1 - beginning)
  1614                              <1> ;; SWAP_PAGE_QUEUE (4096 bytes)
  1615                              <1> ;;
  1616                              <1> ;;   0000   0001   0002   0003   ....   1020   1021   1022   1023	
  1617                              <1> ;; +------+------+------+------+-    -+------+------+------+------+
  1618                              <1> ;; |  pg1 |  pg2 |  pg3 |  pg4 | .... |pg1021|pg1022|pg1023|pg1024|
  1619                              <1> ;; +------+------+------+------+-    -+------+------+------+------+    
  1620                              <1> ;;
  1621                              <1> ;; [swpq_last] = 0 to 4096 (step 4) -> the last position on the queue
  1622                              <1> ;;
  1623                              <1> ;; Method:
  1624                              <1> ;;	Swap page queue is a list of allocated pages with physical
  1625                              <1> ;;	addresses (system mode virtual adresses = physical addresses).
  1626                              <1> ;;	It is used for 'swap_in' and 'swap_out' procedures.
  1627                              <1> ;;	When a new page is being allocated, swap queue is updated
  1628                              <1> ;;	by 'swap_queue_shift' procedure, header of the queue (offset 0)
  1629                              <1> ;;	is checked for 'accessed' flag. If the 1st page on the queue
  1630                              <1> ;;	is 'accessed' or 'read only', it is dropped from the list;
  1631                              <1> ;;	other pages from the 2nd to the last (in [swpq_last]) shifted
  1632                              <1> ;; 	to head then the 2nd page becomes the 1st and '[swpq_last]' 
  1633                              <1> ;;	offset value becomes it's previous offset value - 4.
  1634                              <1> ;;	If the 1st page of the swap page queue is not 'accessed'	
  1635                              <1> ;;	the queue/list is not shifted.
  1636                              <1> ;;	After the queue/list shift, newly allocated page is added
  1637                              <1> ;;	to the tail of the queue at the [swpq_count*4] position.
  1638                              <1> ;;	But, if [swpq_count] > 1023, the newly allocated page
  1639                              <1> ;;	will not be added to the tail of swap page queue.  		 
  1640                              <1> ;;	
  1641                              <1> ;;	During 'swap_out' procedure, swap page queue is checked for
  1642                              <1> ;;	the first non-accessed, writable page in the list, 
  1643                              <1> ;;	from the head to the tail. The list is shifted to left 
  1644                              <1> ;;	(to the head) till a non-accessed page will be found in the list.
  1645                              <1> ;;	Then, this page	is swapped out (to disk) and then it is dropped
  1646                              <1> ;;	from the list by a final swap queue shift. [swpq_count] value
  1647                              <1> ;;	is changed. If all pages on the queue' are 'accessed', 
  1648                              <1> ;;	'insufficient memory' error will be returned ('swap_out' 
  1649                              <1> ;;	procedure will be failed)...
  1650                              <1> ;;
  1651                              <1> ;;	Note: If the 1st page of the queue is an 'accessed' page,
  1652                              <1> ;;	'accessed' flag of the page will be reset (0) and that page
  1653                              <1> ;;	(PTE) will be added to the tail of the queue after
  1654                              <1> ;;	the check, if [swpq_count] < 1023. If [swpq_count] = 1024
  1655                              <1> ;;	the queue will be rotated and the PTE in the head will be
  1656                              <1> ;;	added to the tail after resetting 'accessed' bit. 
  1657                              <1> ;;
  1658                              <1> ;;
  1659                              <1> ;;	
  1660                              <1> ;; SWAP DISK/FILE (with 4096 bytes swapped page blocks)
  1661                              <1> ;;
  1662                              <1> ;;  00000000  00000004  00000008  0000000C   ...   size-8    size-4
  1663                              <1> ;; +---------+---------+---------+---------+-- --+---------+---------+
  1664                              <1> ;; |descriptr| page(1) | page(2) | page(3) | ... |page(n-1)| page(n) |
  1665                              <1> ;; +---------+---------+---------+---------+-- --+---------+---------+    
  1666                              <1> ;;
  1667                              <1> ;; [swpd_next] = the first free block address in swapped page records
  1668                              <1> ;;    		 for next free block search by 'swap_out' procedure.
  1669                              <1> ;; [swpd_size] = swap disk/file size in sectors (512 bytes)
  1670                              <1> ;;		 NOTE: max. possible swap disk size is 1024 GB
  1671                              <1> ;; 		 (entire swap space must be accessed by using
  1672                              <1> ;;		 31 bit offset address) 
  1673                              <1> ;; [swpd_free] = free block (4096 bytes) count in swap disk/file space
  1674                              <1> ;; [swpd_start] = absolute/start address of the swap disk/file
  1675                              <1> ;;		  0 for file, or beginning sector of the swap partition
  1676                              <1> ;; [swp_drv] = logical drive description table addr. of swap disk/file
  1677                              <1> ;;
  1678                              <1> ;; 					
  1679                              <1> ;; Method:
  1680                              <1> ;;	When the memory (ram) becomes insufficient, page allocation
  1681                              <1> ;;	procedure swaps out a page from memory to the swap disk 
  1682                              <1> ;;	(partition) or swap file to get a new free page at the memory.
  1683                              <1> ;;	Swapping out is performed by using swap page queue.
  1684                              <1> ;;
  1685                              <1> ;; 	Allocation block size of swap disk/file is equal to page size
  1686                              <1> ;;	(4096 bytes). Swapping address (in sectors) is recorded
  1687                              <1> ;;	into relevant page file entry as 31 bit physical (logical)
  1688                              <1> ;;	offset address as 1 bit shifted to left for present flag (0).
  1689                              <1> ;;	Swapped page address is between 1 and swap disk/file size - 4.	  
  1690                              <1> ;;	Absolute physical (logical) address of the swapped page is 
  1691                              <1> ;;	calculated by adding offset value to the swap partition's 
  1692                              <1> ;;	start address. If the swap device (disk) is a virtual disk 
  1693                              <1> ;;	or it is a file, start address of the swap disk/volume is 0, 
  1694                              <1> ;;	and offset value is equal to absolute (physical or logical)
  1695                              <1> ;;	address/position. (It has not to be ZERO if the swap partition 
  1696                              <1> ;;	is in a partitioned virtual hard disk.) 
  1697                              <1> ;;
  1698                              <1> ;;	Note: Swap addresses are always specified/declared in sectors, 
  1699                              <1> ;;	not in bytes or	in blocks/zones/clusters (4096 bytes) as unit.
  1700                              <1> ;;
  1701                              <1> ;;	Swap disk/file allocation is mapped via 'Swap Allocation Table'
  1702                              <1> ;;	at memory as similar to 'Memory Allocation Table'.
  1703                              <1> ;;
  1704                              <1> ;;	Every bit of Swap Allocation Table repsesents one swap block
  1705                              <1> ;;	(equal to page size) respectively. Bit 0 of the S.A.T. byte 0
  1706                              <1> ;;	is reserved for swap disk/file block 0 as descriptor block
  1707                              <1> ;;	(also for compatibility with PTE). If bit value is ZERO,
  1708                              <1> ;;	it means relevant (respective) block is in use, and, 
  1709                              <1> ;;	of course, if bit value is 1, it means relevant (respective)
  1710                              <1> ;;      swap disk/file block is free.
  1711                              <1> ;;	For example: bit 1 of the byte 128 repsesents block 1025 
  1712                              <1> ;;	(128*8+1) or sector (offset) 8200 on the swap disk or
  1713                              <1> ;;	byte (offset/position) 4198400 in the swap file. 
  1714                              <1> ;;	4GB swap space is represented via 128KB Swap Allocation Table.
  1715                              <1> ;;	Initial layout of Swap Allocation Table is as follows:
  1716                              <1> ;;	------------------------------------------------------------
  1717                              <1> ;;	0111111111111111111111111 .... 11111111111111111111111111111
  1718                              <1> ;;	------------------------------------------------------------
  1719                              <1> ;;	(0 is reserved block, 1s represent free blocks respectively.)
  1720                              <1> ;;	(Note: Allocation cell/unit of the table is bit, not byte)
  1721                              <1> ;;
  1722                              <1> ;;	..............................................................
  1723                              <1> ;;
  1724                              <1> ;;	'swap_out' procedure checks 'free_swap_blocks' count at first,
  1725                              <1> ;;	then it searches Swap Allocation Table if free count is not
  1726                              <1> ;;	zero. From begining the [swpd_next] dword value, the first bit 
  1727                              <1> ;;	position with value of 1 on the table is converted to swap
  1728                              <1> ;;	disk/file offset address, in sectors (not 4096 bytes block).
  1729                              <1> ;;	'ldrv_write' procedure is called with ldrv (logical drive
  1730                              <1> ;;	number of physical swap disk or virtual swap disk)
  1731                              <1> ;;	number, sector offset (not absolute sector -LBA- number),
  1732                              <1> ;;	and sector count (8, 512*8 = 4096) and buffer adress
  1733                              <1> ;;	(memory page). That will be a direct disk write procedure.
  1734                              <1> ;;	(for preventing late memory allocation, significant waiting). 
  1735                              <1> ;;	If disk write procedure returns with error or free count of 
  1736                              <1> ;;	swap blocks is ZERO, 'swap_out' procedure will return with
  1737                              <1> ;;	'insufficient memory error' (cf=1). 
  1738                              <1> ;;
  1739                              <1> ;;	(Note: Even if free swap disk/file blocks was not zero,
  1740                              <1> ;;	any disk write error will not be fixed by 'swap_out' procedure,
  1741                              <1> ;;	in other words, 'swap_out' will not check the table for other
  1742                              <1> ;;	free blocks after a disk write error. It will return to 
  1743                              <1> ;;	the caller with error (CF=1) which means swapping is failed. 
  1744                              <1> ;;
  1745                              <1> ;;	After writing the page on to swap disk/file address/sector,
  1746                              <1> ;;	'swap_out' procesure returns with that swap (offset) sector
  1747                              <1> ;;	address (cf=0). 
  1748                              <1> ;;
  1749                              <1> ;;	..............................................................
  1750                              <1> ;;
  1751                              <1> ;;	'swap_in' procedure loads addressed (relevant) swap disk or
  1752                              <1> ;;	file sectors at specified memory page. Then page allocation
  1753                              <1> ;;	procedure updates relevant page table entry with 'present' 
  1754                              <1> ;;	attribute. If swap disk or file reading fails there is nothing
  1755                              <1> ;;	to do, except to terminate the process which is the owner of
  1756                              <1> ;;	the swapped page.
  1757                              <1> ;;
  1758                              <1> ;;	'swap_in' procedure sets the relevant/respective bit value
  1759                              <1> ;;	in the Swap Allocation Table (as free block). 'swap_in' also
  1760                              <1> ;;	updates [swpd_first] pointer if it is required.
  1761                              <1> ;;
  1762                              <1> ;;	..............................................................	 
  1763                              <1> ;;
  1764                              <1> ;;	Note: If [swap_enabled] value is ZERO, that means there is not
  1765                              <1> ;;	a swap disk or swap file in use... 'swap_in' and 'swap_out'
  1766                              <1> ;;	procedures ans 'swap page que' procedures will not be active...
  1767                              <1> ;;	'Insufficient memory' error will be returned by 'swap_out'
  1768                              <1> ;;	and 'general protection fault' will be returned by 'swap_in'
  1769                              <1> ;;	procedure, if it is called mistakenly (a wrong value in a PTE).		
  1770                              <1> ;;
  1771                              <1> 
  1772                              <1> ; 17/04/2021
  1773                              <1> ; ('swap_in' procedure call is disabled as temporary)
  1774                              <1> 
  1775                              <1> swap_in:
  1776                              <1> 	; 31/08/2015
  1777                              <1> 	; 20/07/2015
  1778                              <1> 	; 28/04/2015
  1779                              <1> 	; 18/04/2015
  1780                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  1781                              <1> 	;
  1782                              <1> 	; INPUT -> 
  1783                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS OF THE MEMORY PAGE
  1784                              <1> 	;	EBP = VIRTUAL (LINEAR) ADDRESS (page fault address)
  1785                              <1> 	;	EAX = Offset Address for the swapped page on the
  1786                              <1> 	;	      swap disk or in the swap file.
  1787                              <1> 	;
  1788                              <1> 	; OUTPUT ->
  1789                              <1> 	;	EAX = 0 if loading at memory has been successful
  1790                              <1> 	;
  1791                              <1> 	;	CF = 1 -> swap disk reading error (disk/file not present
  1792                              <1> 	;		  or sector not present or drive not ready
  1793                              <1> 	;	     EAX = Error code
  1794                              <1> 	;	     [u.error] = EAX 
  1795                              <1> 	;		       = The last error code for the process
  1796                              <1> 	;		         (will be reset after returning to user)	  
  1797                              <1> 	;
  1798                              <1> 	; Modified Registers -> EAX
  1799                              <1> 	;
  1800                              <1> 
  1801                              <1> ;       cmp     dword [swp_drv], 0
  1802                              <1> ;	jna	short swpin_dnp_err
  1803                              <1> ;
  1804                              <1> ;	cmp	eax, [swpd_size]
  1805                              <1> ;	jnb	short swpin_snp_err
  1806                              <1> ;
  1807                              <1> ;	push	esi
  1808                              <1> ;	push	ebx
  1809                              <1> ;	push	ecx
  1810                              <1> ;	mov	esi, [swp_drv]	
  1811                              <1> ;	mov	ecx, PAGE_SIZE / LOGIC_SECT_SIZE  ; 8 !
  1812                              <1> ;		; Note: Even if corresponding physical disk's sector 
  1813                              <1> ;		; size different than 512 bytes, logical disk sector
  1814                              <1> ;		; size is 512 bytes and disk reading procedure
  1815                              <1> ;		; will be performed for reading 4096 bytes
  1816                              <1> ;		; (2*2048, 8*512). 
  1817                              <1> ;	; ESI = Logical disk description table address
  1818                              <1> ;	; EBX = Memory page (buffer) address (physical!)
  1819                              <1> ;	; EAX = Sector adress (offset address, logical sector number)
  1820                              <1> ;	; ECX = Sector count ; 8 sectors
  1821                              <1> ;	push	eax
  1822                              <1> ;	call	logical_disk_read
  1823                              <1> ;	pop	eax
  1824                              <1> ;	jnc	short swpin_read_ok
  1825                              <1> ;	;
  1826                              <1> ;	mov	eax, SWP_DISK_READ_ERR ; drive not ready or read error
  1827                              <1> ;	mov	[u.error], eax
  1828                              <1> ;	jmp	short swpin_retn
  1829                              <1> ;	;
  1830                              <1> ;swpin_read_ok:
  1831                              <1> ;	; EAX = Offset address (logical sector number)
  1832                              <1> ;	call	unlink_swap_block  ; Deallocate swap block	
  1833                              <1> ;	;
  1834                              <1> ;	; EBX = Memory page (buffer) address (physical!)
  1835                              <1> ;	; 20/07/2015
  1836                              <1> ;	mov	ebx, ebp ; virtual address (page fault address)
  1837                              <1> ;       and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
  1838                              <1> ;	mov	bl, [u.uno] ; current process number
  1839                              <1> ;	; EBX = Virtual (Linear) address & process number combination
  1840                              <1> ;	call	swap_queue_shift
  1841                              <1> ;	; eax = 0 ; 10/06/2016 (if ebx input > 0, eax output = 0)
  1842                              <1> ;	;sub	eax, eax  ; 0 ; Error Code = 0  (no error)
  1843                              <1> ;	; zf = 1
  1844                              <1> ;swpin_retn:
  1845                              <1> ;	pop	ecx
  1846                              <1> ;	pop	ebx
  1847                              <1> ;	pop	esi
  1848                              <1> ;	retn
  1849                              <1> ;
  1850                              <1> ;swpin_dnp_err:
  1851                              <1> ;	mov	eax, SWP_DISK_NOT_PRESENT_ERR
  1852                              <1> ;swpin_err_retn:
  1853                              <1> ;	mov	[u.error], eax
  1854                              <1> ;	stc
  1855                              <1> ;	retn
  1856                              <1> ;
  1857                              <1> ;swpin_snp_err:
  1858                              <1> ;	mov	eax, SWP_SECTOR_NOT_PRESENT_ERR
  1859                              <1> ;	jmp	short swpin_err_retn
  1860                              <1> 
  1861                              <1> ; 17/04/2021
  1862                              <1> ; ('swap_out' procedure call is disabled as temporary)
  1863                              <1> 
  1864                              <1> swap_out:
  1865                              <1> 	; 10/06/2016
  1866                              <1> 	; 07/06/2016
  1867                              <1>         ; 23/05/2016
  1868                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  1869                              <1> 	; 24/10/2014 - 31/08/2015 (Retro UNIX 386 v1)
  1870                              <1> 	;
  1871                              <1> 	; INPUT -> 
  1872                              <1> 	;	none
  1873                              <1> 	;
  1874                              <1> 	; OUTPUT ->
  1875                              <1> 	;	EAX = Physical page address (which is swapped out
  1876                              <1> 	;	      for allocating a new page)
  1877                              <1> 	;	CF = 1 -> swap disk writing error (disk/file not present
  1878                              <1> 	;		  or sector not present or drive not ready
  1879                              <1> 	;	     EAX = Error code
  1880                              <1> 	;	     [u.error] = EAX 
  1881                              <1> 	;		       = The last error code for the process
  1882                              <1> 	;		         (will be reset after returning to user)	  
  1883                              <1> 	;
  1884                              <1> 	; Modified Registers -> none (except EAX)
  1885                              <1> 	;
  1886                              <1> 
  1887                              <1> ;	cmp 	word [swpq_count], 1
  1888                              <1> ;       jc      swpout_im_err ; 'insufficient memory'
  1889                              <1> ;
  1890                              <1> ;       ;cmp    dword [swp_drv], 1
  1891                              <1> ;	;jc	short swpout_dnp_err ; 'swap disk/file not present'
  1892                              <1> ;
  1893                              <1> ;       cmp     dword [swpd_free], 1
  1894                              <1> ;       jc      swpout_nfspc_err ; 'no free space on swap disk'
  1895                              <1> ;
  1896                              <1> ;	push	ebx ; *
  1897                              <1> ;swpout_1:
  1898                              <1> ;	; 10/06/2016
  1899                              <1> ;	xor	ebx, ebx ; shift the queue and return a PTE value
  1900                              <1> ;	call	swap_queue_shift
  1901                              <1> ;	and	eax, eax	; 0 = empty queue (improper entries)
  1902                              <1> ;       jz      swpout_npts_err        ; There is not any proper PTE
  1903                              <1> ;				       ; pointer in the swap queue
  1904                              <1> ;	; EAX = PTE value of the page
  1905                              <1> ;	; EBX = PTE address of the page
  1906                              <1> ;	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  1907                              <1> ;	;
  1908                              <1> ;	; 07/06/2016
  1909                              <1> ;	; 19/05/2016
  1910                              <1> ;	; check this page is in timer events or not
  1911                              <1> ;	
  1912                              <1> ;swpout_timer_page_0:
  1913                              <1> ;	push	edx ; **
  1914                              <1> ;
  1915                              <1> ;	; 07/06/2016
  1916                              <1> ;	cmp	byte [timer_events], 0 
  1917                              <1> ;	jna	short swpout_2
  1918                              <1> ;	;
  1919                              <1> ;	mov	dl, [timer_events]
  1920                              <1> ;
  1921                              <1> ;	push	ecx ; ***
  1922                              <1> ;	push	ebx ; ****
  1923                              <1> ;	mov	ebx, timer_set ; beginning address of timer event
  1924                              <1> ;			       ; structures 
  1925                              <1> ;swpout_timer_page_1:
  1926                              <1> ;	mov	cl, [ebx]
  1927                              <1> ;	or	cl, cl ; 0 = free, >0 = process number
  1928                              <1> ;	jz	short swpout_timer_page_3
  1929                              <1> ;	mov	ecx, [ebx+12] ; response (signal return) address
  1930                              <1> ;	and	cx, PTE_A_CLEAR ; clear offset part (right 12 bits)
  1931                              <1> ;				; of the response byte address, to
  1932                              <1> ;				; get beginning of the page address)
  1933                              <1> ;	cmp	eax, ecx
  1934                              <1> ;	jne	short swpout_timer_page_2 ; not same page
  1935                              <1> ;	
  1936                              <1> ;	; !same page!
  1937                              <1> ;	;
  1938                              <1> ;	; NOTE: // 19/05/2016 // - TRDOS 386 feature only ! -
  1939                              <1> ;	; This page will be used by the kernel to put timer event
  1940                              <1> ;	; response (signal return) byte at the requested address;
  1941                              <1> ;	; in order to prevent a possible wrong write (while
  1942                              <1> ;	; this page is swapped out) on physical memory,
  1943                              <1> ;	; we must protect this page against to be swapped out!
  1944                              <1> ;	;
  1945                              <1> ;	pop	ebx ; ****
  1946                              <1> ;	pop	ecx ; ***
  1947                              <1> ;	pop	edx ; **
  1948                              <1> ;	jmp	short swpout_1	; do not swap out this page !
  1949                              <1> ; 
  1950                              <1> ;swpout_timer_page_2:
  1951                              <1> ;	; 07/06/2016
  1952                              <1> ;	dec	dl
  1953                              <1> ;	jz	short swpout_timer_page_4
  1954                              <1> ;swpout_timer_page_3:
  1955                              <1> ;	;cmp	ebx, timer_set + 240 ; last timer event (15*16) 
  1956                              <1> ;	;jnb	short swpout_timer_page_4
  1957                              <1> ;	add	ebx, 16
  1958                              <1> ;	jmp	short swpout_timer_page_1	
  1959                              <1> ;
  1960                              <1> ;swpout_timer_page_4:
  1961                              <1> ;	pop	ebx ; ****
  1962                              <1> ;	pop	ecx ; ***
  1963                              <1> ;swpout_2:
  1964                              <1> ;	mov	edx, ebx	       ; Page table entry address	
  1965                              <1> ;	mov	ebx, eax	       ; Buffer (Page) Address				
  1966                              <1> ;	;
  1967                              <1> ;	call	link_swap_block
  1968                              <1> ;	jnc	short swpout_3	       ; It may not be needed here	
  1969                              <1> ;				       ; because [swpd_free] value
  1970                              <1> ;				       ; was checked at the beginging. 	
  1971                              <1> ;	pop	edx ; **
  1972                              <1> ;	pop	ebx ; *
  1973                              <1> ;	jmp	short swpout_nfspc_err 
  1974                              <1> ;swpout_3:
  1975                              <1> ;	test	eax, 80000000h ; test bit 31 (this may not be needed!)
  1976                              <1> ;	jnz	short swpout_nfspc_err  ; 10/06/2016 (bit 31 = 1 !)
  1977                              <1> ;	;	
  1978                              <1> ;	push	esi ; **
  1979                              <1> ;	push	ecx ; ***
  1980                              <1> ;	push	eax ; sector address ; (31 bit !, bit 31 = 0)
  1981                              <1> ;	mov	esi, [swp_drv]	
  1982                              <1> ;	mov	ecx, PAGE_SIZE / LOGIC_SECT_SIZE  ; 8 !
  1983                              <1> ;		; Note: Even if corresponding physical disk's sector 
  1984                              <1> ;		; size different than 512 bytes, logical disk sector
  1985                              <1> ;		; size is 512 bytes and disk writing procedure
  1986                              <1> ;		; will be performed for writing 4096 bytes
  1987                              <1> ;		; (2*2048, 8*512). 
  1988                              <1> ;	; ESI = Logical disk description table address
  1989                              <1> ;	; EBX = Buffer (Page) address
  1990                              <1> ;	; EAX = Sector adress (offset address, logical sector number)
  1991                              <1> ;	; ECX = Sector count ; 8 sectors
  1992                              <1> ;	; edx = PTE address
  1993                              <1> ;	call	logical_disk_write
  1994                              <1> ;	; edx = PTE address
  1995                              <1> ;	pop	ecx ; sector address	
  1996                              <1> ;	jnc	short swpout_write_ok
  1997                              <1> ;	;
  1998                              <1> ;	;; call	unlink_swap_block ; this block must be left as 'in use'
  1999                              <1> ;swpout_dw_err:
  2000                              <1> ;	mov	eax, SWP_DISK_WRITE_ERR ; drive not ready or write error
  2001                              <1> ;	mov	[u.error], eax
  2002                              <1> ;	jmp	short swpout_retn
  2003                              <1> ;	;
  2004                              <1> ;swpout_write_ok:
  2005                              <1> ;	; EBX = Buffer (page) address
  2006                              <1> ;	; EDX = Page Table Entry address
  2007                              <1> ;	; ECX = Swap disk sector (file block) address (31 bit)
  2008                              <1> ;	shl 	ecx, 1  ; 31 bit sector address from bit 1 to bit 31 
  2009                              <1> ;	mov 	[edx], ecx 
  2010                              <1> ;		; bit 0 = 0 (swapped page)
  2011                              <1> ;	mov	eax, ebx
  2012                              <1> ;swpout_retn:
  2013                              <1> ;	pop	ecx ; ***
  2014                              <1> ;	pop	esi ; **
  2015                              <1> ;	pop	ebx ; *
  2016                              <1> ;	retn
  2017                              <1> ;
  2018                              <1> ;;swpout_dnp_err:
  2019                              <1> ;;	mov	eax, SWP_DISK_NOT_PRESENT_ERR ; disk not present
  2020                              <1> ;;	jmp	short swpout_err_retn
  2021                              <1> ;swpout_nfspc_err:
  2022                              <1> ;	mov	eax, SWP_NO_FREE_SPACE_ERR ; no free space
  2023                              <1> ;swpout_err_retn:
  2024                              <1> ;	mov	[u.error], eax
  2025                              <1> ;	;stc
  2026                              <1> ;	retn
  2027                              <1> ;swpout_npts_err:
  2028                              <1> ;	mov	eax, SWP_NO_PAGE_TO_SWAP_ERR
  2029                              <1> ;	pop	ebx
  2030                              <1> ;	jmp	short swpout_err_retn
  2031                              <1> ;swpout_im_err:
  2032                              <1> ;	mov	eax, ERR_MINOR_IM ; insufficient (out of) memory
  2033                              <1> ;	jmp	short swpout_err_retn
  2034                              <1> 
  2035                              <1> ; 17/04/2021
  2036                              <1> ; ('swap_queue_shift' procedure call is disabled as temporary)
  2037                              <1> 
  2038                              <1> swap_queue_shift:
  2039                              <1> 	; 26/03/2017
  2040                              <1> 	; 10/06/2016
  2041                              <1> 	; 09/06/2016 - TRDOS 386 (TRDOS v2.0)
  2042                              <1> 	; 23/10/2014 - 20/07/2015 (Retro UNIX 386 v1)
  2043                              <1> 	;
  2044                              <1> 	; INPUT ->
  2045                              <1> 	;	EBX = Virtual (linear) address (bit 12 to 31) 
  2046                              <1> 	;	      and process number combination (bit 0 to 11)
  2047                              <1> 	;	EBX = 0 -> shift/drop from the head (offset 0)
  2048                              <1> 	;	
  2049                              <1> 	; OUTPUT ->
  2050                              <1> 	;	If EBX input > 0 
  2051                              <1> 	;	   the queue will be shifted 4 bytes (dword),
  2052                              <1> 	; 	   from the tail to the head, up to entry offset
  2053                              <1> 	; 	   which points to EBX input value or nothing
  2054                              <1> 	;	   to do if EBX value is not found on the queue.
  2055                              <1> 	;	   (The entry -with EBX value- will be removed
  2056                              <1> 	;	   from the queue if it is found.)
  2057                              <1> 	;
  2058                              <1> 	;	   EAX = 0		
  2059                              <1> 	;
  2060                              <1> 	;	If EBX input = 0
  2061                              <1> 	;	   the queue will be shifted 4 bytes (dword),
  2062                              <1> 	; 	   from the tail to the head, if the PTE address
  2063                              <1> 	;	   which is pointed in head of the queue is marked
  2064                              <1> 	;	   as "accessed" or it is marked as "non present".
  2065                              <1> 	;	   (If "accessed" flag of the PTE -which is pointed
  2066                              <1> 	;	   in the head- is set -to 1-, it will be reset
  2067                              <1> 	;	   -to 0- and then, the queue will be rotated 
  2068                              <1> 	;	   -without dropping pointer of the PTE from 
  2069                              <1> 	;	   the queue- for 4 bytes on head to tail direction.
  2070                              <1> 	;	   Pointer in the head will be moved into the tail,
  2071                              <1> 	;	   other PTEs will be shifted on head direction.)
  2072                              <1> 	;
  2073                              <1> 	;	   Swap queue will be shifted up to the first
  2074                              <1> 	;	   'present' or 'non accessed' page will be found
  2075                              <1> 	;	   (as pointed) on the queue head (then it will be
  2076                              <1>         ;          removed/dropped from the queue).
  2077                              <1> 	;
  2078                              <1> 	;	   EAX (> 0) = PTE value of the page which is
  2079                              <1> 	;		 (it's pointer -virtual address-) dropped
  2080                              <1> 	;		 (removed) from swap queue.
  2081                              <1> 	;	   EBX = PTE address of the page (if EAX > 0)
  2082                              <1> 	;	         which is (it's pointer -virtual address-)
  2083                              <1> 	;		 dropped (removed) from swap queue.
  2084                              <1> 	;
  2085                              <1> 	;	   EAX = 0 -> empty swap queue ! 
  2086                              <1> 	;
  2087                              <1> 	; Modified Registers -> EAX, EBX
  2088                              <1> 	;
  2089                              <1> ;	movzx   eax, word [swpq_count]  ; Max. 1024
  2090                              <1> ;	and	ax, ax
  2091                              <1> ;	jz	short swpqs_retn
  2092                              <1> ;	push	edi
  2093                              <1> ;	push	esi
  2094                              <1> ;	push	ecx
  2095                              <1> ;	mov	esi, swap_queue
  2096                              <1> ;	mov	ecx, eax
  2097                              <1> ;	or	ebx, ebx
  2098                              <1> ;	jz	short swpqs_7
  2099                              <1> ;swpqs_1:
  2100                              <1> ;	lodsd
  2101                              <1> ;	cmp	eax, ebx
  2102                              <1> ;	je	short swpqs_2
  2103                              <1> ;	loop	swpqs_1
  2104                              <1> ;	; 10/06/2016
  2105                              <1> ;	sub	eax, eax 
  2106                              <1> ;	jmp	short swpqs_6
  2107                              <1> ;swpqs_2:
  2108                              <1> ;	mov	edi, esi
  2109                              <1> ;	sub 	edi, 4
  2110                              <1> ;swpqs_3:
  2111                              <1> ;	dec	word [swpq_count]
  2112                              <1> ;	jz	short swpqs_5
  2113                              <1> ;swpqs_4:
  2114                              <1> ;	dec 	ecx
  2115                              <1> ;	rep	movsd	; shift up (to the head)
  2116                              <1> ;swpqs_5:
  2117                              <1> ;	xor	eax, eax
  2118                              <1> ;	mov	[edi], eax
  2119                              <1> ;swpqs_6:
  2120                              <1> ;	pop	ecx
  2121                              <1> ;	pop	esi
  2122                              <1> ;	pop	edi
  2123                              <1> ;swpqs_retn:
  2124                              <1> ;	retn		
  2125                              <1> ;swpqs_7:
  2126                              <1> ;	mov	edi, esi ; head
  2127                              <1> ;	lodsd
  2128                              <1> ;	; 20/07/2015
  2129                              <1> ;	mov	ebx, eax
  2130                              <1> ;	and	ebx, ~PAGE_OFF ; ~0FFFh 
  2131                              <1> ;		      ; ebx = virtual address (at page boundary)	
  2132                              <1> ;	and	eax, PAGE_OFF ; 0FFFh
  2133                              <1> ;		      ; ax = process number (1 to 4095)
  2134                              <1> ;	cmp	al, [u.uno]
  2135                              <1> ;		; Max. 16 (nproc) processes for Retro UNIX 386 v1
  2136                              <1> ;	jne	short swpqs_8
  2137                              <1> ;	mov	eax, [u.pgdir]
  2138                              <1> ;	jmp	short swpqs_9
  2139                              <1> ;swpqs_8:
  2140                              <1> ;	; 09/06/2016
  2141                              <1> ;	cmp	byte [eax+p.stat-1], 0
  2142                              <1> ;	jna	short swpqs_3     ; free (or terminated) process
  2143                              <1> ;	cmp	byte [eax+p.stat-1], 2 ; waiting
  2144                              <1> ;	ja	short swpqs_3 	  ; zombie (3) or undefined ?	
  2145                              <1> ;
  2146                              <1> ;	;shl	ax, 2
  2147                              <1> ;	shl	al, 2
  2148                              <1> ;	mov 	eax, [eax+p.upage-4]
  2149                              <1> ;	or	eax, eax
  2150                              <1> ;	jz	short swpqs_3 ; invalid upage
  2151                              <1> ;	add	eax, u.pgdir - user
  2152                              <1> ;			 ; u.pgdir value for the process
  2153                              <1> ;			 ; is in [eax]
  2154                              <1> ;	mov	eax, [eax]
  2155                              <1> ;	and	eax, eax
  2156                              <1> ;	jz	short swpqs_3 ; invalid page directory
  2157                              <1> ;swpqs_9:
  2158                              <1> ;	push	edx
  2159                              <1> ;	; eax = page directory
  2160                              <1> ;	; ebx = virtual address
  2161                              <1> ;	call	get_pte
  2162                              <1> ;	mov	ebx, edx	; PTE address
  2163                              <1> ;	pop	edx
  2164                              <1> ;	; 10/06/2016
  2165                              <1> ;	jc	short swpqs_13 ; empty PDE
  2166                              <1> ;	; EAX = PTE value
  2167                              <1> ;	test	al, PTE_A_PRESENT ; bit 0 = 1
  2168                              <1> ;	jz	short swpqs_13  ; Drop non-present page
  2169                              <1> ;			        ; from the queue (head)
  2170                              <1> ;	test	al, PTE_A_WRITE	; bit 1 = 0 (read only)
  2171                              <1> ;	jz	short swpqs_13  ; Drop read only page
  2172                              <1> ;			        ; from the queue (head) 	
  2173                              <1> ;	;test	al, PTE_A_ACCESS ; bit 5 = 1 (Accessed)
  2174                              <1> ;	;jnz	short swpqs_11  ; present
  2175                              <1> ;			        ; accessed page
  2176                              <1> ;       btr     eax, PTE_A_ACCESS_BIT ; reset 'accessed' bit
  2177                              <1> ;	jc	short swpqs_11  ; accessed page
  2178                              <1> ;
  2179                              <1> ;	dec	ecx
  2180                              <1> ;	mov	[swpq_count], cx
  2181                              <1> ;       jz      short swpqs_10
  2182                              <1> ;		; esi = head + 4
  2183                              <1> ;		; edi = head
  2184                              <1> ;	rep	movsd	 ; n = 1 to k-1, [n - 1] = [n]
  2185                              <1> ;swpqs_10:
  2186                              <1> ;	mov	[edi], ecx ; 0
  2187                              <1> ;	jmp	short swpqs_6 ; 26/03/2017
  2188                              <1> ;
  2189                              <1> ;swpqs_11:
  2190                              <1> ;	mov	[ebx], eax     ; save changed attribute
  2191                              <1> ;	; Rotation (head -> tail)
  2192                              <1> ;	dec	ecx     ; entry count -> last entry number		
  2193                              <1> ;	jz	short swpqs_10
  2194                              <1> ;		; esi = head + 4
  2195                              <1> ;		; edi = head
  2196                              <1> ;	mov	eax, [edi] ; 20/07/2015
  2197                              <1> ;	rep	movsd	 ; n = 1 to k-1, [n - 1] = [n]
  2198                              <1> ;	mov	[edi], eax ; head -> tail ; [k] = [1]
  2199                              <1> ;
  2200                              <1> ;	mov	cx, [swpq_count]
  2201                              <1> ;
  2202                              <1> ;swpqs_12:
  2203                              <1> ;	mov	esi, swap_queue ; head
  2204                              <1> ;       jmp     swpqs_7
  2205                              <1> ;
  2206                              <1> ;swpqs_13:
  2207                              <1> ;	dec	ecx
  2208                              <1> ;	mov	[swpq_count], cx
  2209                              <1> ;       jz      swpqs_5
  2210                              <1> ;	jmp	short swpqs_12
  2211                              <1> 
  2212                              <1> ; 17/04/2021
  2213                              <1> ; ('add_to_swp_queue' procedure call is disabled as temporary)
  2214                              <1> 
  2215                              <1> add_to_swap_queue:
  2216                              <1> 	; 20/02/2017
  2217                              <1> 	; 20/07/2015
  2218                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  2219                              <1> 	;
  2220                              <1> 	; Adds new page to swap queue
  2221                              <1> 	; (page directories and page tables must not be added
  2222                              <1> 	; to swap queue)	
  2223                              <1> 	;
  2224                              <1> 	; INPUT ->
  2225                              <1> 	;	EBX = Linear (Virtual) addr for current process
  2226                              <1> 	;	[u.uno]
  2227                              <1> 	;	20/02/2017
  2228                              <1> 	;	(Linear address = CORE + user's virtual address)
  2229                              <1> 	;
  2230                              <1> 	; OUTPUT ->
  2231                              <1> 	;	EAX = [swpq_count]
  2232                              <1> 	;	      (after the PTE has been added)
  2233                              <1> 	;	EAX = 0 -> Swap queue is full, (1024 entries)
  2234                              <1> 	;	      the PTE could not be added.
  2235                              <1> 	;
  2236                              <1> 	; Modified Registers -> EAX
  2237                              <1> 	;
  2238                              <1> ;	push	ebx
  2239                              <1> ;       and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
  2240                              <1> ;	mov	bl, [u.uno] ; current process number
  2241                              <1> ;	call	swap_queue_shift ; drop from the queue if
  2242                              <1> ;				 ; it is already on the queue
  2243                              <1> ;		; then add it to the tail of the queue
  2244                              <1> ;	movzx	eax, word [swpq_count]
  2245                              <1> ;	cmp	ax, 1024
  2246                              <1> ;	jb	short atsq_1
  2247                              <1> ;	sub	ax, ax
  2248                              <1> ;	pop	ebx
  2249                              <1> ;	retn
  2250                              <1> ;atsq_1:
  2251                              <1> ;	push	esi
  2252                              <1> ;	mov	esi, swap_queue
  2253                              <1> ;	and	ax, ax
  2254                              <1> ;	jz	short atsq_2
  2255                              <1> ;	shl	ax, 2	; convert to offset
  2256                              <1> ;	add	esi, eax
  2257                              <1> ;	shr	ax, 2
  2258                              <1> ;atsq_2:
  2259                              <1> ;	inc	ax
  2260                              <1> ;	mov	[esi], ebx ; Virtual address + [u.uno] combination
  2261                              <1> ;	mov	[swpq_count], ax
  2262                              <1> ;	pop	esi
  2263                              <1> ;	pop	ebx
  2264                              <1> ;	retn
  2265                              <1> 
  2266                              <1> ; 17/04/2021
  2267                              <1> ; ('unlink_swap_block' procedure call is disabled as temporary)
  2268                              <1> 
  2269                              <1> unlink_swap_block:
  2270                              <1> 	; 15/09/2015
  2271                              <1> 	; 30/04/2015
  2272                              <1> 	; 18/04/2015
  2273                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  2274                              <1> 	;
  2275                              <1> 	; INPUT -> 
  2276                              <1> 	;	EAX = swap disk/file offset address
  2277                              <1> 	;	      (bit 1 to bit 31)
  2278                              <1> 	; OUTPUT ->
  2279                              <1> 	;	[swpd_free] is increased
  2280                              <1> 	;	(corresponding SWAP DISK ALLOC. TABLE bit is SET)
  2281                              <1> 	;
  2282                              <1> 	; Modified Registers -> EAX
  2283                              <1> 	;
  2284                              <1> ;	push	ebx
  2285                              <1> ;	push	edx
  2286                              <1> ;	;
  2287                              <1> ;	shr	eax, SECTOR_SHIFT+1  ;3+1 ; shift sector address to 
  2288                              <1> ;				     ; 3 bits right
  2289                              <1> ;				     ; to get swap block/page number
  2290                              <1> ;	mov	edx, eax
  2291                              <1> ;	; 15/09/2015
  2292                              <1> ;	shr	edx, 3		     ; to get offset to S.A.T.
  2293                              <1> ;				     ; (1 allocation bit = 1 page)
  2294                              <1> ;				     ; (1 allocation bytes = 8 pages)
  2295                              <1> ;	and	dl, 0FCh 	     ; clear lower 2 bits
  2296                              <1> ;				     ; (to get 32 bit position)			
  2297                              <1> ;	;
  2298                              <1> ;	mov	ebx, swap_alloc_table ; Swap Allocation Table address
  2299                              <1> ;	add	ebx, edx
  2300                              <1> ;	and	eax, 1Fh	     ; lower 5 bits only
  2301                              <1> ;				     ; (allocation bit position)	 
  2302                              <1> ;	cmp 	eax, [swpd_next]     ; is the new free block addr. lower
  2303                              <1> ;				     ; than the address in 'swpd_next' ?
  2304                              <1> ;				     ; (next/first free block value)		
  2305                              <1> ;	jnb	short uswpbl_1	     ; no	
  2306                              <1> ;	mov	[swpd_next], eax     ; yes	
  2307                              <1> ;uswpbl_1:
  2308                              <1> ;	bts	[ebx], eax	     ; unlink/release/deallocate block
  2309                              <1> ;				     ; set relevant bit to 1.
  2310                              <1> ;				     ; set CF to the previous bit value	
  2311                              <1> ;	cmc			     ; complement carry flag	
  2312                              <1> ;	jc	short uswpbl_2	     ; do not increase swfd_free count
  2313                              <1> ;				     ; if the block is already deallocated
  2314                              <1> ;				     ; before.	
  2315                              <1> ;       inc     dword [swpd_free]
  2316                              <1> ;uswpbl_2:
  2317                              <1> ;	pop	edx
  2318                              <1> ;	pop	ebx
  2319                              <1> ;	retn
  2320                              <1> 
  2321                              <1> ; 17/04/2021
  2322                              <1> ; ('ink_swap_block' procedure call is disabled as temporary)
  2323                              <1> 
  2324                              <1> link_swap_block:
  2325                              <1> 	; 01/07/2015
  2326                              <1> 	; 18/04/2015
  2327                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  2328                              <1> 	;
  2329                              <1> 	; INPUT -> none
  2330                              <1> 	;
  2331                              <1> 	; OUTPUT ->
  2332                              <1> 	;	EAX = OFFSET ADDRESS OF THE ALLOCATED BLOCK (4096 bytes)
  2333                              <1> 	;	      in sectors (corresponding 
  2334                              <1> 	;	      SWAP DISK ALLOCATION TABLE bit is RESET)
  2335                              <1> 	;
  2336                              <1> 	;	CF = 1 and EAX = 0 
  2337                              <1> 	; 		   if there is not a free block to be allocated	
  2338                              <1> 	;
  2339                              <1> 	; Modified Registers -> none (except EAX)
  2340                              <1> 	;
  2341                              <1> 
  2342                              <1> ;	;mov	eax, [swpd_free]
  2343                              <1> ;	;and	eax, eax
  2344                              <1> ;	;jz	short out_of_swpspc
  2345                              <1> ;	;
  2346                              <1> ;	push	ebx
  2347                              <1> ;	push	ecx
  2348                              <1> ;	;
  2349                              <1> ;	mov	ebx, swap_alloc_table ; Swap Allocation Table offset
  2350                              <1> ;	mov	ecx, ebx
  2351                              <1> ;	add	ebx, [swpd_next] ; Free block searching starts from here
  2352                              <1> ;				 ; next_free_swap_block >> 5
  2353                              <1> ;	add	ecx, [swpd_last] ; Free block searching ends here
  2354                              <1> ;				 ; (total_swap_blocks - 1) >> 5
  2355                              <1> ;lswbl_scan:
  2356                              <1> ;	cmp	ebx, ecx
  2357                              <1> ;	ja	short lswbl_notfound
  2358                              <1> ;	;
  2359                              <1> ;	bsf	eax, [ebx] ; Scans source operand for first bit set (1).
  2360                              <1> ;			   ; Clears ZF if a bit is found set (1) and 
  2361                              <1> ;			   ; loads the destination with an index to
  2362                              <1> ;			   ; first set bit. (0 -> 31) 
  2363                              <1> ;			   ; Sets ZF to 1 if no bits are found set.
  2364                              <1> ;	; 01/07/2015
  2365                              <1> ;	jnz	short lswbl_found ; ZF = 0 -> a free block has been found
  2366                              <1> ;			 ;
  2367                              <1> ;			 ; NOTE:  a Swap Disk Allocation Table bit 
  2368                              <1> ;			 ;	  with value of 1 means 
  2369                              <1> ;			 ;	  the corresponding page is free 
  2370                              <1> ;			 ;	  (Retro UNIX 386 v1 feaure only!)
  2371                              <1> ;	add	ebx, 4
  2372                              <1> ;			 ; We return back for searching next page block
  2373                              <1> ;			 ; NOTE: [swpd_free] is not ZERO; so, 
  2374                              <1> ;			 ;	 we always will find at least 1 free block here.
  2375                              <1> ;	jmp    	short lswbl_scan
  2376                              <1> ;	;
  2377                              <1> ;lswbl_notfound:	
  2378                              <1> ;	sub	ecx, swap_alloc_table
  2379                              <1> ;	mov	[swpd_next], ecx ; next/first free page = last page 
  2380                              <1> ;				 ; (unlink_swap_block procedure will change it)
  2381                              <1> ;	xor	eax, eax
  2382                              <1> ;	mov	[swpd_free], eax
  2383                              <1> ;	stc
  2384                              <1> ;lswbl_ok:
  2385                              <1> ;	pop	ecx
  2386                              <1> ;	pop	ebx
  2387                              <1> ;	retn
  2388                              <1> ;	;
  2389                              <1> ;;out_of_swpspc:
  2390                              <1> ;;	stc
  2391                              <1> ;;	retn
  2392                              <1> ;
  2393                              <1> ;lswbl_found:
  2394                              <1> ;	mov	ecx, ebx
  2395                              <1> ;	sub	ecx, swap_alloc_table
  2396                              <1> ;	mov	[swpd_next], ecx ; Set first free block searching start
  2397                              <1> ;				 ; address/offset (to the next)
  2398                              <1> ;       dec     dword [swpd_free] ; 1 block has been allocated (X = X-1) 
  2399                              <1> ;	;
  2400                              <1> ;	btr	[ebx], eax	 ; The destination bit indexed by the source value
  2401                              <1> ;				 ; is copied into the Carry Flag and then cleared
  2402                              <1> ;				 ; in the destination.
  2403                              <1> ;				 ;
  2404                              <1> ;				 ; Reset the bit which is corresponding to the 
  2405                              <1> ;				 ; (just) allocated block.
  2406                              <1> ;	shl	ecx, 5		 ; (block offset * 32) + block index
  2407                              <1> ;	add	eax, ecx	 ; = block number
  2408                              <1> ;	shl	eax, SECTOR_SHIFT ; 3, sector (offset) address of the block
  2409                              <1> ;				 ; 1 block =  8 sectors
  2410                              <1> ;	;
  2411                              <1> ;	; EAX = offset address of swap disk/file sector (beginning of the block)
  2412                              <1> ;	;
  2413                              <1> ;	; NOTE: The relevant page table entry will be updated
  2414                              <1> ;	;       according to this EAX value...
  2415                              <1> ;	;
  2416                              <1> ;	jmp	short lswbl_ok
  2417                              <1> 
  2418                              <1> ; 17/04/2021
  2419                              <1> ; ('logical_disk_read' procedure call is disabled as temporary)
  2420                              <1> 
  2421                              <1> logical_disk_read:
  2422                              <1> 	; 20/07/2015
  2423                              <1> 	; 09/03/2015 (temporary code here)
  2424                              <1> 	;
  2425                              <1> 	; INPUT ->
  2426                              <1> 	; 	ESI = Logical disk description table address
  2427                              <1> 	; 	EBX = Memory page (buffer) address (physical!)
  2428                              <1> 	; 	EAX = Sector adress (offset address, logical sector number)
  2429                              <1> 	; 	ECX = Sector count
  2430                              <1> 	;
  2431                              <1> 	;
  2432                              <1> ;	retn
  2433                              <1> 
  2434                              <1> ; 17/04/2021
  2435                              <1> ; ('logical_disk_write' procedure call is disabled as temporary)
  2436                              <1> 
  2437                              <1> logical_disk_write:
  2438                              <1> 	; 20/07/2015
  2439                              <1> 	; 09/03/2015 (temporary code here)
  2440                              <1> 	;
  2441                              <1> 	; INPUT ->
  2442                              <1> 	; 	ESI = Logical disk description table address
  2443                              <1> 	; 	EBX = Memory page (buffer) address (physical!)
  2444                              <1> 	; 	EAX = Sector adress (offset address, logical sector number)
  2445                              <1> 	; 	ECX = Sector count
  2446                              <1> 	;
  2447                              <1> ;	retn
  2448                              <1> 
  2449                              <1> get_physical_addr:
  2450                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  2451                              <1> 	;	(temporary modifications)
  2452                              <1> 	;
  2453                              <1> 	; 26/03/2017
  2454                              <1> 	; 20/02/2017
  2455                              <1> 	; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  2456                              <1> 	; 18/10/2015
  2457                              <1> 	; 29/07/2015
  2458                              <1> 	; 20/07/2015
  2459                              <1> 	; 04/06/2015
  2460                              <1> 	; 20/05/2015
  2461                              <1> 	; 28/04/2015
  2462                              <1> 	; 18/04/2015
  2463                              <1> 	; Get physical address
  2464                              <1> 	;     (allocates a new page for user if it is not present)
  2465                              <1> 	;	
  2466                              <1> 	; (This subroutine is needed for mapping user's virtual 
  2467                              <1> 	; (buffer) address to physical address (of the buffer).)
  2468                              <1> 	; ('sys write', 'sys read' system calls...)
  2469                              <1> 	;
  2470                              <1> 	; INPUT ->
  2471                              <1> 	;	EBX = virtual address
  2472                              <1> 	;	u.pgdir = page directory (physical) address
  2473                              <1> 	;
  2474                              <1> 	; OUTPUT ->
  2475                              <1> 	;	EAX = physical address 
  2476                              <1> 	;	EBX = linear address	
  2477                              <1> 	;	EDX = physical address of the page frame
  2478                              <1> 	;	      (with attribute bits)
  2479                              <1> 	;	ECX = byte count within the page frame
  2480                              <1> 	;
  2481                              <1> 	; Modified Registers -> EAX, EBX, ECX, EDX
  2482                              <1> 	;
  2483 00005AB7 81C300004000        <1> 	add	ebx, CORE ; 18/10/2015
  2484                              <1> get_physical_addr_x: ; 27/05/2016
  2485 00005ABD A1[74010300]        <1> 	mov	eax, [u.pgdir]
  2486 00005AC2 E820FDFFFF          <1> 	call	get_pte
  2487                              <1> 		; EDX = Page table entry address (if CF=0)
  2488                              <1> 	        ;       Page directory entry address (if CF=1)
  2489                              <1> 		;       (Bit 0 value is 0 if PT is not present)
  2490                              <1> 		; EAX = Page table entry value (page address)
  2491                              <1> 		;	CF = 1 -> PDE not present or invalid ? 
  2492 00005AC7 731C                <1> 	jnc	short gpa_1
  2493                              <1> 	;
  2494 00005AC9 E807FCFFFF          <1> 	call	allocate_page
  2495 00005ACE 723F                <1> 	jc	short gpa_im_err  ; 'insufficient memory' error
  2496                              <1> gpa_0:
  2497 00005AD0 E871FCFFFF          <1> 	call 	clear_page
  2498                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  2499 00005AD5 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER ; 4+2+1 = 7
  2500                              <1> 			   ; lower 3 bits are used as U/S, R/W, P flags
  2501                              <1> 			   ; (user, writable, present page)	
  2502 00005AD7 8902                <1> 	mov	[edx], eax ; Let's put the new page directory entry here !
  2503 00005AD9 A1[74010300]        <1> 	mov	eax, [u.pgdir]	
  2504 00005ADE E804FDFFFF          <1> 	call	get_pte
  2505 00005AE3 722A                <1> 	jc	short gpa_im_err ; 'insufficient memory' error
  2506                              <1> gpa_1:
  2507                              <1> 	; EAX = PTE value, EDX = PTE address
  2508 00005AE5 A801                <1> 	test 	al, PTE_A_PRESENT
  2509 00005AE7 7516                <1> 	jnz	short gpa_3 ; 26/03/2017
  2510 00005AE9 09C0                <1> 	or	eax, eax
  2511 00005AEB 7446                <1> 	jz	short gpa_7  ; Allocate a new page
  2512                              <1> 
  2513                              <1> ; 17/04/2021 (TRDOS 386 v2.0.4)
  2514                              <1> ; ('reload_page' procedure call is disabled as temporary)
  2515 00005AED EB20                <1> 	jmp	short gpa_im_err  ; temporary !
  2516                              <1> 
  2517                              <1> 	; 20/07/2015
  2518                              <1> ;	push	ebp
  2519                              <1> ;	mov	ebp, ebx ; virtual (linear) address
  2520                              <1> ;	; reload swapped page
  2521                              <1> ;	call	reload_page ; 28/04/2015
  2522                              <1> ;	pop	ebp
  2523                              <1> ;	jc	short gpa_retn
  2524                              <1> gpa_2:
  2525                              <1> 	; 26/03/2017
  2526                              <1> 	; 20/02/2017
  2527                              <1> 	; If a page will contain a Signal Response Byte
  2528                              <1> 	; it must not be swapped out, because
  2529                              <1> 	; timer service or irq callback service
  2530                              <1> 	; will write a signal return/response byte 
  2531                              <1> 	; directly by using physical address of Signal
  2532                              <1> 	; Response Byte.(Even if process is not running,
  2533                              <1> 	; or it is running with swapped out pages.)
  2534                              <1> 	;
  2535                              <1> 	; 'no_page_swap' will be set by 'systimer' or
  2536                              <1> 	; 'syscalbac' sistem functions/calls. (*)
  2537                              <1> 	;
  2538 00005AEF 803D[1E890100]00    <1> 	cmp	byte [no_page_swap], 0
  2539 00005AF6 761D                <1> 	jna	short gpa_4 ; this page can be swapped out
  2540                              <1> 	; this page must not be swapped out
  2541                              <1> 	; but 'no_page_swap' must be reset here
  2542                              <1> 	; immediately for other callers (*)
  2543                              <1> 	; (otherwise, swap queue would not be long enough) 
  2544 00005AF8 E844000000          <1> 	call	gpa_8 ; 26/03/2017
  2545 00005AFD EB16                <1> 	jmp	short gpa_5
  2546                              <1> gpa_3: 
  2547                              <1> 	; 26/03/2017
  2548 00005AFF 803D[1E890100]00    <1> 	cmp	byte [no_page_swap], 0
  2549 00005B06 7611                <1> 	jna	short gpa_6 ; this page can be swapped out
  2550 00005B08 E834000000          <1> 	call	gpa_8
  2551 00005B0D EB0A                <1> 	jmp	short gpa_6
  2552                              <1> 
  2553                              <1> gpa_im_err:	
  2554 00005B0F B804000000          <1> 	mov	eax, ERR_MINOR_IM ; Insufficient memory (minor) error!
  2555                              <1> 				  ; Major error = 0 (No protection fault)	
  2556 00005B14 C3                  <1> 	retn
  2557                              <1> gpa_4:
  2558                              <1> ; 17/04/2021 (TRDOS 386 v2.0.4)
  2559                              <1> ; ('add_to_swap_queue' procedure call is disabled as temporary)
  2560                              <1> 
  2561                              <1> 	; 20/07/2015
  2562                              <1> 	; 20/05/2015
  2563                              <1> 	; add this page to swap queue
  2564                              <1> ;	push	eax 
  2565                              <1> ;	; EBX = Linear (CORE+virtual) address ; 20/02/2017 
  2566                              <1> ;	call 	add_to_swap_queue
  2567                              <1> ;	pop	eax
  2568                              <1> gpa_5:
  2569                              <1> 		; PTE address in EDX
  2570                              <1> 		; virtual address in EBX
  2571                              <1> 	; EAX = memory page address
  2572 00005B15 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_USER + PTE_A_WRITE
  2573                              <1> 				  ; present flag, bit 0 = 1
  2574                              <1> 				  ; user flag, bit 2 = 1	
  2575                              <1> 				  ; writable flag, bit 1 = 1
  2576 00005B17 8902                <1> 	mov	[edx], eax  ; Update PTE value
  2577                              <1> gpa_6:
  2578                              <1> 	; 18/10/2015
  2579 00005B19 89D9                <1> 	mov	ecx, ebx
  2580 00005B1B 81E1FF0F0000        <1> 	and	ecx, PAGE_OFF
  2581 00005B21 89C2                <1> 	mov 	edx, eax
  2582 00005B23 662500F0            <1> 	and	ax, PTE_A_CLEAR
  2583 00005B27 01C8                <1> 	add	eax, ecx
  2584 00005B29 F7D9                <1> 	neg	ecx ; 1 -> -1 (0FFFFFFFFh), 4095 (0FFFh) -> -4095
  2585 00005B2B 81C100100000        <1> 	add	ecx, PAGE_SIZE
  2586 00005B31 F8                  <1> 	clc
  2587                              <1> gpa_retn:
  2588 00005B32 C3                  <1> 	retn
  2589                              <1> gpa_7:	
  2590 00005B33 E89DFBFFFF          <1> 	call	allocate_page
  2591 00005B38 72D5                <1> 	jc	short gpa_im_err ; 'insufficient memory' error
  2592 00005B3A E807FCFFFF          <1> 	call	clear_page
  2593 00005B3F EBAE                <1> 	jmp	short gpa_2
  2594                              <1> 
  2595                              <1> gpa_8: ; 26/03/2017
  2596 00005B41 C605[1E890100]00    <1> 	mov	byte [no_page_swap], 0
  2597                              <1> 
  2598 00005B48 C3                  <1> 	retn	; 17/04/2021 (temporary)
  2599                              <1> 
  2600                              <1> ; 17/04/2021 (TRDOS 386 v2.0.4)
  2601                              <1> ; ('swap_queue_shift' procedure call is disabled as temporary)
  2602                              <1> ;	
  2603                              <1> ;	push	ebx
  2604                              <1> ;	push	eax ; 26/03/2017
  2605                              <1> ;       and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
  2606                              <1> ;	mov	bl, [u.uno] ; current process number
  2607                              <1> ;	call	swap_queue_shift ; drop from the queue if
  2608                              <1> ;				 ; it is already on the queue
  2609                              <1> ;	pop	eax ; 26/03/2017
  2610                              <1> ;	pop	ebx
  2611                              <1> ;
  2612                              <1> ;	retn
  2613                              <1> 
  2614                              <1> ; 17/04/2021
  2615                              <1> ; ('reload_page' procedure call is disabled as temporary)
  2616                              <1> 
  2617                              <1> reload_page:
  2618                              <1> 	; 20/07/2015
  2619                              <1> 	; 28/04/2015 (Retro UNIX 386 v1 - beginning)
  2620                              <1> 	;
  2621                              <1> 	; Reload (Restore) swapped page at memory
  2622                              <1> 	;
  2623                              <1> 	; INPUT -> 
  2624                              <1> 	;	EBP = Virtual (linear) memory address
  2625                              <1> 	;	EAX = PTE value (swap disk sector address)
  2626                              <1> 	;	(Swap disk sector address = bit 1 to bit 31 of EAX)	
  2627                              <1> 	; OUTPUT ->
  2628                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF RELOADED PAGE
  2629                              <1> 	;
  2630                              <1> 	;	CF = 1 and EAX = error code
  2631                              <1> 	;
  2632                              <1> 	; Modified Registers -> none (except EAX)
  2633                              <1> 	;
  2634                              <1> ;	shr	eax, 1   ; Convert PTE value to swap disk address 
  2635                              <1> ;	push	ebx      ;
  2636                              <1> ;	mov	ebx, eax ; Swap disk (offset) address	
  2637                              <1> ;	call	allocate_page
  2638                              <1> ;	jc	short rlp_im_err
  2639                              <1> ;	xchg 	eax, ebx	
  2640                              <1> ;	; EBX = Physical memory (page) address
  2641                              <1> ;	; EAX = Swap disk (offset) address
  2642                              <1> ;	; EBP = Virtual (linear) memory address
  2643                              <1> ;	call	swap_in
  2644                              <1> ;	jc	short rlp_swp_err  ; (swap disk/file read error)
  2645                              <1> ;	mov	eax, ebx	
  2646                              <1> ;rlp_retn:
  2647                              <1> ;	pop	ebx
  2648                              <1> ;	retn
  2649                              <1> ;	
  2650                              <1> ;rlp_im_err:	
  2651                              <1> ;	mov	eax, ERR_MINOR_IM ; Insufficient memory (minor) error!
  2652                              <1> ;				  ; Major error = 0 (No protection fault)	
  2653                              <1> ;	jmp	short rlp_retn
  2654                              <1> ;
  2655                              <1> ;rlp_swp_err:
  2656                              <1> ;	mov 	eax, SWP_DISK_READ_ERR ; Swap disk read error !
  2657                              <1> ;	jmp	short rlp_retn
  2658                              <1> 
  2659                              <1> copy_page_dir:
  2660                              <1> 	; 17/04/2021 (temporary modifications)
  2661                              <1> 	; 19/09/2015
  2662                              <1> 	; temporary - 07/09/2015
  2663                              <1> 	; 07/09/2015 (Retro UNIX 386 v1 - beginning)
  2664                              <1> 	;
  2665                              <1> 	; INPUT -> 
  2666                              <1> 	;	[u.pgdir] = PHYSICAL (real/flat) ADDRESS of the parent's
  2667                              <1> 	;		    page directory.
  2668                              <1> 	; OUTPUT ->
  2669                              <1> 	;	EAX =  PHYSICAL (real/flat) ADDRESS of the child's
  2670                              <1> 	;	       page directory.
  2671                              <1> 	;	(New page directory with new page table entries.)
  2672                              <1> 	;	(New page tables with read only copies of the parent's
  2673                              <1> 	;	pages.)
  2674                              <1> 	;	EAX = 0 -> Error (CF = 1)
  2675                              <1> 	;
  2676                              <1> 	; Modified Registers -> none (except EAX)
  2677                              <1> 	;
  2678 00005B49 E887FBFFFF          <1> 	call	allocate_page
  2679 00005B4E 723E                <1> 	jc	short cpd_err
  2680                              <1> 	;
  2681 00005B50 55                  <1> 	push	ebp ; 20/07/2015
  2682 00005B51 56                  <1> 	push	esi
  2683 00005B52 57                  <1> 	push	edi
  2684 00005B53 53                  <1> 	push	ebx
  2685 00005B54 51                  <1> 	push	ecx
  2686 00005B55 8B35[74010300]      <1> 	mov	esi, [u.pgdir]
  2687 00005B5B 89C7                <1> 	mov	edi, eax
  2688 00005B5D 50                  <1> 	push	eax ; save child's page directory address
  2689                              <1> 	; copy PDE 0 from the parent's page dir to the child's page dir
  2690                              <1> 	; (use same system space for all user page tables) 
  2691 00005B5E A5                  <1> 	movsd
  2692 00005B5F BD00004000          <1> 	mov	ebp, 1024*4096 ; pass the 1st 4MB (system space)
  2693 00005B64 B9FF030000          <1> 	mov	ecx, (PAGE_SIZE / 4) - 1 ; 1023
  2694                              <1> cpd_0:	
  2695 00005B69 AD                  <1> 	lodsd
  2696                              <1> 	;or	eax, eax
  2697                              <1>         ;jnz     short cpd_1
  2698 00005B6A A801                <1> 	test	al, PDE_A_PRESENT ;  bit 0 =  1
  2699 00005B6C 7508                <1> 	jnz	short cpd_1
  2700                              <1>  	; (virtual address at the end of the page table)	
  2701 00005B6E 81C500004000        <1> 	add	ebp, 1024*4096 ; page size * PTE count
  2702 00005B74 EB0F                <1> 	jmp	short cpd_2
  2703                              <1> cpd_1:	
  2704 00005B76 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear attribute bits
  2705 00005B7A 89C3                <1> 	mov	ebx, eax
  2706                              <1> 	; EBX = Parent's page table address
  2707 00005B7C E81F000000          <1> 	call	copy_page_table
  2708 00005B81 720C                <1> 	jc	short cpd_p_err
  2709                              <1> 	; EAX = Child's page table address
  2710 00005B83 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
  2711                              <1> 			 ; set bit 0, bit 1 and bit 2 to 1
  2712                              <1> 			 ; (present, writable, user)
  2713                              <1> cpd_2:
  2714 00005B85 AB                  <1> 	stosd
  2715 00005B86 E2E1                <1> 	loop	cpd_0
  2716                              <1> 	;
  2717 00005B88 58                  <1> 	pop	eax  ; restore child's page directory address
  2718                              <1> cpd_3:
  2719 00005B89 59                  <1> 	pop	ecx
  2720 00005B8A 5B                  <1> 	pop	ebx
  2721 00005B8B 5F                  <1> 	pop	edi
  2722 00005B8C 5E                  <1> 	pop	esi
  2723 00005B8D 5D                  <1> 	pop	ebp
  2724                              <1> cpd_err:
  2725 00005B8E C3                  <1> 	retn
  2726                              <1> cpd_p_err:
  2727                              <1> 	; release the allocated pages missing (recover free space)
  2728 00005B8F 58                  <1> 	pop	eax  ; the new page directory address (physical)
  2729 00005B90 8B1D[74010300]      <1> 	mov	ebx, [u.pgdir] ; parent's page directory address 
  2730 00005B96 E86AFCFFFF          <1> 	call 	deallocate_page_dir
  2731 00005B9B 29C0                <1> 	sub	eax, eax ; 0
  2732 00005B9D F9                  <1> 	stc
  2733 00005B9E EBE9                <1> 	jmp	short cpd_3	
  2734                              <1> 
  2735                              <1> copy_page_table:
  2736                              <1> 	; 17/04/2021 (temporary modifications)
  2737                              <1> 	; 19/09/2015
  2738                              <1> 	; temporary - 07/09/2015
  2739                              <1> 	; 07/09/2015 (Retro UNIX 386 v1 - beginning)
  2740                              <1> 	;
  2741                              <1> 	; INPUT -> 
  2742                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS of the parent's page table.
  2743                              <1> 	;	EBP = page table entry index (from 'copy_page_dir')
  2744                              <1> 	; OUTPUT ->
  2745                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS of the child's page table.
  2746                              <1> 	;	EBP = (recent) page table index (for 'add_to_swap_queue')	
  2747                              <1> 	;	CF = 1 -> error 
  2748                              <1> 	;
  2749                              <1> 	; Modified Registers -> EBP (except EAX)
  2750                              <1> 	;
  2751 00005BA0 E830FBFFFF          <1> 	call	allocate_page
  2752 00005BA5 7244                <1> 	jc	short cpt_err
  2753                              <1> 	;
  2754 00005BA7 50                  <1> 	push	eax ; *
  2755                              <1> 	;push 	ebx
  2756 00005BA8 56                  <1> 	push	esi
  2757 00005BA9 57                  <1> 	push	edi
  2758 00005BAA 52                  <1> 	push	edx
  2759 00005BAB 51                  <1> 	push	ecx
  2760                              <1> 	;
  2761 00005BAC 89DE                <1> 	mov	esi, ebx
  2762 00005BAE 89C7                <1> 	mov	edi, eax
  2763 00005BB0 89C2                <1> 	mov	edx, eax
  2764 00005BB2 81C200100000        <1> 	add	edx, PAGE_SIZE 	
  2765                              <1> cpt_0:
  2766 00005BB8 AD                  <1> 	lodsd
  2767 00005BB9 A801                <1> 	test	al, PTE_A_PRESENT ;  bit 0 = 1
  2768                              <1> 	;jnz	short cpt_1 (*)
  2769                              <1> 	; 17/04/2021 (temporary (*)
  2770                              <1> 	;and	eax, eax (*)
  2771 00005BBB 741E                <1> 	jz	short cpt_2  ; 17/04/2021
  2772                              <1> 	
  2773                              <1> ; 17/04/2021
  2774                              <1> ; ('reload_page' procedure call is disabled as temporary)
  2775                              <1> ;
  2776                              <1> ;	; ebp = virtual (linear) address of the memory page
  2777                              <1> ;	call	reload_page ; 28/04/2015
  2778                              <1> ;	jc	short cpt_p_err
  2779                              <1> cpt_1:
  2780 00005BBD 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  2781 00005BC1 89C1                <1> 	mov	ecx, eax
  2782                              <1> 	; Allocate a new page for the child process
  2783 00005BC3 E80DFBFFFF          <1> 	call	allocate_page
  2784 00005BC8 721C                <1> 	jc	short cpt_p_err
  2785 00005BCA 57                  <1> 	push	edi
  2786 00005BCB 56                  <1> 	push	esi
  2787 00005BCC 89CE                <1> 	mov	esi, ecx
  2788 00005BCE 89C7                <1> 	mov	edi, eax
  2789 00005BD0 B900040000          <1> 	mov	ecx, PAGE_SIZE/4
  2790 00005BD5 F3A5                <1> 	rep	movsd	; copy page (4096 bytes)
  2791 00005BD7 5E                  <1> 	pop	esi
  2792 00005BD8 5F                  <1> 	pop	edi
  2793                              <1> 	; 
  2794                              <1> 
  2795                              <1> ; 17/04/2021
  2796                              <1> ; ('add_to_swap_queue' procedure call is disabled as temporary)	
  2797                              <1> ;
  2798                              <1> ;	push	ebx
  2799                              <1> ;	push	eax
  2800                              <1> ;	mov	ebx, ebp
  2801                              <1> ;	; ebx = virtual address of the memory page
  2802                              <1> ;	call	add_to_swap_queue
  2803                              <1> ;	pop	eax
  2804                              <1> ;	pop	ebx
  2805                              <1> 	;
  2806                              <1> 	;or	ax, PTE_A_USER+PTE_A_PRESENT 
  2807 00005BD9 0C07                <1> 	or	al, PTE_A_USER+PTE_A_WRITE+PTE_A_PRESENT 
  2808                              <1> cpt_2:
  2809 00005BDB AB                  <1> 	stosd  ; EDI points to child's PTE  	 
  2810                              <1> 	;
  2811 00005BDC 81C500100000        <1> 	add	ebp, 4096 ; 20/07/2015 (next page)
  2812                              <1> 	;
  2813 00005BE2 39D7                <1> 	cmp	edi, edx
  2814 00005BE4 72D2                <1> 	jb	short cpt_0
  2815                              <1> cpt_p_err:
  2816 00005BE6 59                  <1> 	pop	ecx
  2817 00005BE7 5A                  <1> 	pop	edx
  2818 00005BE8 5F                  <1> 	pop	edi
  2819 00005BE9 5E                  <1> 	pop	esi
  2820                              <1> 	;pop	ebx
  2821 00005BEA 58                  <1> 	pop	eax ; *
  2822                              <1> cpt_err:
  2823 00005BEB C3                  <1> 	retn
  2824                              <1> 
  2825                              <1> allocate_memory_block:
  2826                              <1> 	; 01/05/2017
  2827                              <1> 	; 28/04/2017
  2828                              <1> 	; 25/04/2017
  2829                              <1> 	; 01/04/2016, 02/04/2016, 03/04/2016
  2830                              <1> 	; 13/03/2016, 14/03/2016
  2831                              <1> 	; 12/03/2016 (TRDOS 386 = TRDOS v2.0)
  2832                              <1> 	; Allocating contiguous memory pages (in the kernel's memory space)
  2833                              <1> 	;
  2834                              <1> 	; INPUT -> 
  2835                              <1> 	;	EAX = Beginning address (physical)
  2836                              <1> 	;	EAX = 0 -> Allocate memory block from the first proper aperture	
  2837                              <1> 	;	ECX = Number of bytes to be allocated
  2838                              <1> 	;
  2839                              <1> 	; OUTPUT ->
  2840                              <1> 	; 	1) cf = 0 -> successful
  2841                              <1> 	;	EAX = Beginning (physical) address of the allocated memory block
  2842                              <1> 	;	ECX = Number of allocated bytes (rounded up to page borders) 
  2843                              <1> 	;	2) cf = 1 -> unsuccessful
  2844                              <1> 	;	 2.1) If EAX > 0 -> 
  2845                              <1> 	;	      (Number of requested pages is more than # of free pages
  2846                              <1> 	;	       but contiguous free pages -the aperture- is not enough!)	   	
  2847                              <1> 	;	      EAX = Beginning address of available aperture
  2848                              <1> 	;		    (one of all aperture with max. aperture size/length)		
  2849                              <1> 	;	      ECX = Size of available aperture (memory block) in bytes
  2850                              <1> 	;	 2.2) If EAX = 0 -> Out of memory error 
  2851                              <1> 	;	            (number of free pages is less than requested number)
  2852                              <1> 	;	      ECX = Total number of free bytes (free pages * 4096) 
  2853                              <1> 	;		    (It is not number of contiguous free bytes)	
  2854                              <1> 	;
  2855                              <1> 	; (Modified Registers -> EAX, ECX)
  2856                              <1> 	;
  2857                              <1> 	; PURPOSE: Loading a file at memory for copying or running etc.
  2858                              <1> 	; If this procedure returns with cf is set, ECX contains maximum
  2859                              <1> 	; available space and EAX contains the beginning address of it.
  2860                              <1> 	; If EAX has zero, ECX contains total number of free bytes.
  2861                              <1> 	; If requested block has been successfully allocated (by rounding up to
  2862                              <1> 	; the last page border), it must be deallocated later by using
  2863                              <1> 	; 'deallocate_memory_block' procedure.    
  2864                              <1> 
  2865 00005BEC 52                  <1> 	push	edx ; *
  2866 00005BED BAFF0F0000          <1> 	mov	edx, PAGE_SIZE - 1   ; 4095
  2867 00005BF2 01D0                <1> 	add	eax, edx
  2868 00005BF4 01D1                <1> 	add	ecx, edx
  2869 00005BF6 C1E90C              <1> 	shr	ecx, PAGE_SHIFT	     ; 12
  2870                              <1> 
  2871                              <1> 	; ECX = number of contiguous pages to be allocated
  2872 00005BF9 8B15[90770100]      <1> 	mov	edx, [free_pages]
  2873                              <1> 	; 01/05/2017
  2874                              <1> 	;or	ecx, ecx
  2875                              <1> 	;jz	short amb3
  2876                              <1> 	; If ECX=0, set cf to 1 and return with max. available mem block size
  2877                              <1> 
  2878 00005BFF 39D1                <1> 	cmp	ecx, edx
  2879 00005C01 7760                <1> 	ja	short amb_3
  2880                              <1> 
  2881 00005C03 C1E80C              <1> 	shr	eax, PAGE_SHIFT      ; 12
  2882                              <1> 
  2883 00005C06 89C2                <1> 	mov	edx, eax 	     ; page number
  2884 00005C08 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  2885                              <1> 				     ; (1 allocation bit = 1 page)
  2886                              <1> 				     ; (1 allocation bytes = 8 pages)
  2887 00005C0B 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  2888                              <1> 				     ; (to get 32 bit position)	
  2889 00005C0E 53                  <1> 	push	ebx ; **
  2890                              <1> amb_0:
  2891 00005C0F 890D[40830100]      <1> 	mov	[mem_ipg_count], ecx ; initial (reset) value of page count
  2892 00005C15 890D[44830100]      <1> 	mov	[mem_pg_count], ecx
  2893 00005C1B 31C9                <1> 	xor	ecx, ecx ; 0
  2894 00005C1D 890D[48830100]      <1> 	mov	[mem_aperture], ecx ; 0
  2895 00005C23 890D[4C830100]      <1> 	mov	[mem_max_aperture], ecx ; 0
  2896                              <1> 	
  2897 00005C29 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table address.
  2898 00005C2E 3B15[94770100]      <1> 	cmp	edx, [next_page]     ; Is the beginning page address lower
  2899                              <1> 				     ; than the address in 'next_page' ?
  2900                              <1> 				     ; (the first/next free page of user space)		
  2901 00005C34 7208                <1> 	jb	short amb_1
  2902 00005C36 3B15[98770100]      <1> 	cmp 	edx, [last_page]     ; is the beginning page address higher
  2903                              <1> 				     ; than the address in 'last_page' ?
  2904                              <1> 				     ; (end of the memory)		
  2905 00005C3C 7606                <1> 	jna	short amb_2	     ; no	
  2906                              <1> amb_1:
  2907 00005C3E 8B15[94770100]      <1> 	mov	edx, [next_page]     ; M.A.T. offset (1 M.A.T. byte = 8 pages)
  2908                              <1> amb_2:
  2909 00005C44 01D3                <1> 	add	ebx, edx
  2910                              <1> 
  2911                              <1> 	; 28/04/2017
  2912                              <1> 	;xor	ecx, ecx
  2913 00005C46 0FBC0B              <1> 	bsf	ecx, [ebx]	     ; 0 to 31
  2914 00005C49 89D0                <1> 	mov	eax, edx
  2915 00005C4B C1E003              <1> 	shl	eax, 3		     ; *8	
  2916 00005C4E 01C8                <1> 	add	eax, ecx	     ; beginning page number
  2917                              <1> 
  2918 00005C50 A3[50830100]        <1> 	mov	[mem_pg_pos], eax    ; beginning page no (for curr. mem. aperture)
  2919 00005C55 A3[54830100]        <1>  	mov	[mem_max_pg_pos], eax ; beginning page no for max. mem. aperture
  2920                              <1> 
  2921 00005C5A 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only (0 to 31)
  2922                              <1> 				     ; (allocation bit position)	 
  2923 00005C5D 750E                <1> 	jnz	short amb_4	     ; 0
  2924 00005C5F B120                <1> 	mov	cl, 32
  2925 00005C61 EB4B                <1> 	jmp	short amb_10
  2926                              <1> 
  2927                              <1> amb_3:	; out_of_memory
  2928 00005C63 31C0                <1> 	xor	eax, eax ; 0
  2929 00005C65 89D1                <1> 	mov	ecx, edx ; free pages
  2930 00005C67 C1E10C              <1> 	shl	ecx, PAGE_SHIFT
  2931 00005C6A 5A                  <1> 	pop	edx ; *
  2932 00005C6B F9                  <1> 	stc
  2933 00005C6C C3                  <1> 	retn	
  2934                              <1> amb_4:
  2935 00005C6D 8B13                <1> 	mov	edx, [ebx]
  2936 00005C6F 88C1                <1> 	mov	cl, al ; 1 to 31
  2937 00005C71 D3EA                <1> 	shr	edx, cl
  2938 00005C73 89D0                <1> 	mov	eax, edx
  2939                              <1> amb_5:
  2940 00005C75 D1E8                <1> 	shr	eax, 1 ; (***)
  2941 00005C77 7317                <1> 	jnc	short amb_7
  2942 00005C79 FF05[48830100]      <1> 	inc	dword [mem_aperture]
  2943 00005C7F FF0D[44830100]      <1> 	dec	dword [mem_pg_count]
  2944 00005C85 747F                <1> 	jz	short amb_15
  2945                              <1> amb_6:
  2946                              <1> 	; 28/04/2017
  2947 00005C87 FEC1                <1> 	inc	cl
  2948 00005C89 80F920              <1> 	cmp	cl, 32
  2949 00005C8C 730D                <1> 	jnb	short amb_9
  2950 00005C8E EBE5                <1> 	jmp	short amb_5
  2951                              <1> amb_7:
  2952 00005C90 50                  <1> 	push	eax ; (***) allocation bits (in shifted status)
  2953 00005C91 E82A010000          <1> 	call	amb_26 ; set maximum memory aperture (free memory block size)
  2954 00005C96 58                  <1> 	pop	eax ; (***)
  2955 00005C97 EBEE                <1> 	jmp	short amb_6
  2956                              <1> amb_8:
  2957                              <1> 	; 28/04/2017
  2958 00005C99 B120                <1> 	mov	cl, 32
  2959                              <1> amb_9:
  2960 00005C9B 89DA                <1> 	mov	edx, ebx
  2961 00005C9D 81EA00001000        <1> 	sub	edx, MEM_ALLOC_TBL
  2962 00005CA3 3B15[98770100]      <1> 	cmp	edx, [last_page]
  2963 00005CA9 7336                <1> 	jnb	short amb_14 ; contiguous pages not enough
  2964 00005CAB 83C304              <1> 	add	ebx, 4
  2965                              <1> amb_10:
  2966 00005CAE 8B03                <1> 	mov	eax, [ebx]
  2967 00005CB0 21C0                <1> 	and 	eax, eax
  2968 00005CB2 7408                <1>         jz      short amb_11 ; there is not a free page bit in this alloc dword
  2969 00005CB4 40                  <1> 	inc	eax ; 0FFFFFFFFh -> 0
  2970 00005CB5 740C                <1> 	jz	short amb_12 ; all of bits are set (32 free pages)
  2971 00005CB7 48                  <1> 	dec	eax
  2972 00005CB8 28C9                <1> 	sub	cl, cl ; 0
  2973 00005CBA EBB9                <1> 	jmp	short amb_5
  2974                              <1> amb_11:
  2975 00005CBC E8FF000000          <1> 	call	amb_26 ; set maximum memory aperture (free memory block size)
  2976 00005CC1 EBD8                <1> 	jmp	short amb_9	
  2977                              <1> amb_12:
  2978 00005CC3 390D[44830100]      <1> 	cmp	[mem_pg_count], ecx ; 32
  2979 00005CC9 7306                <1> 	jnb	short amb_13
  2980 00005CCB 8B0D[44830100]      <1> 	mov	ecx, [mem_pg_count]
  2981                              <1> amb_13:
  2982 00005CD1 010D[48830100]      <1> 	add	[mem_aperture], ecx
  2983 00005CD7 290D[44830100]      <1> 	sub	[mem_pg_count], ecx
  2984 00005CDD 7627                <1> 	jna	short amb_15
  2985 00005CDF EBBA                <1> 	jmp	short amb_9 ; 01/05/2017
  2986                              <1> amb_14:
  2987 00005CE1 E8DA000000          <1> 	call	amb_26 ; 28/04/2017
  2988 00005CE6 A1[54830100]        <1> 	mov	eax, [mem_max_pg_pos] ; begin address of max. mem aperture	
  2989 00005CEB 8B0D[4C830100]      <1> 	mov	ecx, [mem_max_aperture] ; max. (largest) memory aperture
  2990 00005CF1 F9                  <1> 	stc
  2991 00005CF2 E9BE000000          <1>         jmp     amb_25
  2992                              <1> 
  2993                              <1> allocate_lfb_memory_block:
  2994                              <1> 	; 20/10/2023 - TRDOS 386 v2.0.7
  2995                              <1> 	; (short way to set the LFB page bits on the M.A.T.)
  2996                              <1> 	; called from 'allocate_lfb_pages_for_kernel' 
  2997 00005CF7 A3[50830100]        <1> 	mov	[mem_pg_pos], eax    ; LFB start/base address   	
  2998 00005CFC 890D[48830100]      <1> 	mov	[mem_aperture], ecx  ; number of LFB pages
  2999                              <1> 				     ; (!which overlapping main memory!)	
  3000 00005D02 52                  <1> 	push	edx ; *
  3001 00005D03 53                  <1> 	push	ebx ; **
  3002 00005D04 EB0B                <1> 	jmp	short amb_16
  3003                              <1> 
  3004                              <1> amb_15: ; OK !
  3005 00005D06 A1[50830100]        <1> 	mov	eax, [mem_pg_pos]    ; Beginning address as page number
  3006 00005D0B 8B0D[48830100]      <1> 	mov	ecx, [mem_aperture]  ; Free contiguous page count (>=1)
  3007                              <1> amb_16:
  3008                              <1> 	; allocate contiguous memory pages (via memory allocation table bits)
  3009 00005D11 89C2                <1> 	mov	edx, eax
  3010                              <1> 	; 25/04/2017
  3011 00005D13 C1EA03              <1> 	shr	edx, 3		 ; 8 pages in one allocation byte
  3012 00005D16 80E2FC              <1> 	and	dl, 0FCh	 ; clear lower 2 bits
  3013                              <1> 				 ; (for dword/32bit positioning)	
  3014                              <1> 
  3015 00005D19 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  3016 00005D1E 01D3                <1> 	add	ebx, edx
  3017 00005D20 83E01F              <1> 	and	eax, 1Fh ; 31
  3018                              <1> 	; 03/04/2016
  3019 00005D23 BA20000000          <1> 	mov	edx, 32
  3020 00005D28 28C2                <1> 	sub	dl, al
  3021 00005D2A 39CA                <1> 	cmp	edx, ecx	 ; ecx >= 1
  3022 00005D2C 7602                <1> 	jna	short amb_17
  3023 00005D2E 89CA                <1> 	mov	edx, ecx
  3024                              <1> amb_17:
  3025 00005D30 29D1                <1> 	sub	ecx, edx
  3026 00005D32 51                  <1> 	push	ecx ; ***
  3027 00005D33 89D1                <1> 	mov	ecx, edx
  3028                              <1> amb_18:		
  3029 00005D35 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
  3030                              <1> 				 ; is copied into the Carry Flag and then cleared
  3031                              <1> 				 ; in the destination.
  3032                              <1> 	; 20/10/2023
  3033                              <1> 	; (for LFB page allocation.. 
  3034                              <1> 	;  -here, to prevent using LFB pages for another allocation later-
  3035                              <1> 	;  /// the destination bit must be 0 -already- ..
  3036                              <1> 	;  so, following 'jnc' is not necessary but i am not removing it
  3037                              <1> 	;  for understanding why free page count is decreased here.) 
  3038                              <1> 	;   
  3039                              <1> 	;jnc	short amb_28 ; requested page is already allocated 
  3040                              <1> 
  3041 00005D38 FF0D[90770100]      <1> 	dec     dword [free_pages] ; 1 page has been allocated (X = X-1) 
  3042                              <1> ;amb_28:	; 20/10/2023
  3043 00005D3E 49                  <1> 	dec	ecx
  3044 00005D3F 7404                <1> 	jz	short amb_19
  3045 00005D41 FEC0                <1> 	inc	al
  3046 00005D43 EBF0                <1> 	jmp	short amb_18
  3047                              <1> amb_19:	
  3048 00005D45 59                  <1> 	pop	ecx ; ***
  3049 00005D46 21C9                <1> 	and	ecx, ecx ; 0 ?
  3050 00005D48 741E                <1> 	jz	short amb_22	
  3051                              <1> 	; 01/04/2016
  3052 00005D4A B020                <1> 	mov	al, 32
  3053                              <1> amb_20:
  3054 00005D4C 83C304              <1> 	add	ebx, 4
  3055 00005D4F 39C1                <1> 	cmp	ecx, eax ; 32
  3056 00005D51 7305                <1> 	jnb	short amb_21
  3057                              <1> 	; ECX < 32
  3058 00005D53 28C0                <1> 	sub	al, al ; 0
  3059 00005D55 50                  <1> 	push	eax ; 0 ***
  3060 00005D56 EBDD                <1> 	jmp	short amb_18
  3061                              <1> amb_21:
  3062 00005D58 2905[90770100]      <1> 	sub	[free_pages], eax   ; [free_pages] = [free_pages] - 32
  3063 00005D5E C70300000000        <1> 	mov	dword [ebx], 0	    ; reset 32 bits
  3064 00005D64 29C1                <1> 	sub	ecx, eax ; 32
  3065 00005D66 75E4                <1> 	jnz	short amb_20
  3066                              <1> amb_22:
  3067 00005D68 A1[50830100]        <1> 	mov	eax, [mem_pg_pos]   ; Beginning address as page number
  3068 00005D6D 8B0D[48830100]      <1> 	mov	ecx, [mem_aperture] ; Free contiguous page count
  3069                              <1> 	; [next_page] update
  3070 00005D73 89C2                <1> 	mov	edx, eax
  3071                              <1> 	; 03/04/2016
  3072 00005D75 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  3073                              <1> 				     ; (1 allocation bit = 1 page)
  3074                              <1> 				     ; (1 allocation bytes = 8 pages)
  3075 00005D78 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  3076                              <1> 				     ; (to get 32 bit position)	
  3077 00005D7B 3B15[94770100]      <1> 	cmp	edx, [next_page] ; first free page pointer offset
  3078 00005D81 7732                <1> 	ja	short amb_25
  3079 00005D83 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  3080 00005D88 833C1300            <1> 	cmp	dword [ebx+edx], 0
  3081 00005D8C 7721                <1> 	ja	short amb_24
  3082 00005D8E 89C2                <1> 	mov	edx, eax
  3083 00005D90 01CA                <1> 	add	edx, ecx
  3084 00005D92 C1EA03              <1> 	shr	edx, 3
  3085 00005D95 80E2FC              <1> 	and	dl, 0FCh
  3086                              <1> amb_23:
  3087 00005D98 833C1300            <1> 	cmp	dword [ebx+edx], 0
  3088 00005D9C 7711                <1> 	ja	short amb_24
  3089 00005D9E 83C204              <1> 	add	edx, 4
  3090 00005DA1 3B15[98770100]      <1> 	cmp	edx, [last_page]    ; last page pointer offset
  3091 00005DA7 76EF                <1> 	jna	short amb_23
  3092 00005DA9 8B15[9C770100]      <1> 	mov	edx, [first_page]   ; (for) beginning of user's space
  3093                              <1> amb_24:
  3094 00005DAF 8915[94770100]      <1> 	mov	[next_page], edx
  3095                              <1> amb_25:
  3096 00005DB5 9C                  <1> 	pushf
  3097 00005DB6 C1E00C              <1> 	shl	eax, PAGE_SHIFT	     ; convert to phy. address in bytes
  3098 00005DB9 C1E10C              <1> 	shl	ecx, PAGE_SHIFT	     ; convert to byte counts
  3099 00005DBC 9D                  <1> 	popf
  3100 00005DBD 5B                  <1> 	pop	ebx ; **
  3101 00005DBE 5A                  <1> 	pop	edx ; *
  3102 00005DBF C3                  <1> 	retn
  3103                              <1> 
  3104                              <1> amb_26:	; set maximum free memory aperture (free memory block size) 
  3105 00005DC0 89DA                <1> 	mov	edx, ebx ; current address
  3106 00005DC2 81EA00001000        <1> 	sub	edx, MEM_ALLOC_TBL ; MAT beginning address
  3107                              <1> 	; 02/04/2016 
  3108 00005DC8 C1E203              <1> 	shl	edx, 3 ; MAT byte offset * 8 = page number base
  3109 00005DCB 01CA                <1> 	add	edx, ecx ; current page number (ecx = 0 to 32)
  3110                              <1> 	;
  3111 00005DCD A1[48830100]        <1> 	mov	eax, [mem_aperture]
  3112 00005DD2 21C0                <1> 	and	eax, eax
  3113 00005DD4 7421                <1>         jz      short amb_27
  3114 00005DD6 C705[48830100]0000- <1>         mov     dword [mem_aperture], 0
  3114 00005DDE 0000                <1>
  3115 00005DE0 3B05[4C830100]      <1> 	cmp	eax, [mem_max_aperture]
  3116 00005DE6 760F                <1> 	jna	short amb_27
  3117 00005DE8 A3[4C830100]        <1> 	mov	[mem_max_aperture], eax
  3118                              <1> 	; 25/04/2017
  3119 00005DED A1[50830100]        <1> 	mov	eax, [mem_pg_pos]
  3120                              <1> 	; EAX = Beginning page number of the max. aperture 
  3121 00005DF2 A3[54830100]        <1> 	mov	[mem_max_pg_pos], eax
  3122                              <1> amb_27: 
  3123 00005DF7 8915[50830100]      <1> 	mov	[mem_pg_pos], edx ; current page
  3124                              <1> 
  3125 00005DFD A1[40830100]        <1> 	mov	eax, [mem_ipg_count] ; initial (reset) value of page count
  3126 00005E02 A3[44830100]        <1> 	mov	[mem_pg_count], eax
  3127                              <1> 
  3128 00005E07 C3                  <1> 	retn
  3129                              <1> 
  3130                              <1> deallocate_memory_block:
  3131                              <1> 	; 03/04/2016
  3132                              <1> 	; 14/03/2016 (TRDOS 386 = TRDOS v2.0)
  3133                              <1> 	; Deallocating contiguous memory pages (in the kernel's memory space)
  3134                              <1> 	;
  3135                              <1> 	; INPUT -> 
  3136                              <1> 	;	EAX = Beginning address (physical)
  3137                              <1> 	;	ECX = Number of bytes to be deallocated
  3138                              <1> 	;
  3139                              <1> 	; OUTPUT ->
  3140                              <1> 	;	Memory Allocation Table bits will be updated
  3141                              <1> 	;	[free_pages] will be changed (increased)
  3142                              <1> 	;
  3143                              <1> 	; (Modified Registers -> EAX, ECX)
  3144                              <1> 	;
  3145                              <1> 	; PURPOSE: Unloading/Freeing a file -or an allocated memory block- 
  3146                              <1> 	; at memory after copying, running, saving, reading, writing etc.
  3147                              <1> 	;
  3148                              <1> 
  3149 00005E08 52                  <1> 	push	edx ; *
  3150 00005E09 53                  <1> 	push	ebx ; **
  3151                              <1> 
  3152 00005E0A C1E80C              <1> 	shr	eax, PAGE_SHIFT	     ; 12
  3153 00005E0D C1E90C              <1> 	shr	ecx, PAGE_SHIFT	     ; 12
  3154                              <1> 
  3155                              <1> 	; EAX = Beginning page number
  3156                              <1> 	; ECX = Number of contiguous pages to be deallocated
  3157                              <1> damb_0:
  3158                              <1> 	; deallocate contiguous memory pages (via memory allocation table bits)
  3159 00005E10 89C2                <1> 	mov	edx, eax
  3160 00005E12 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  3161                              <1> 				     ; (1 allocation bit = 1 page)
  3162                              <1> 				     ; (1 allocation bytes = 8 pages)
  3163 00005E15 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  3164                              <1> 				     ; (to get 32 bit position)	
  3165 00005E18 3B15[94770100]      <1> 	cmp	edx, [next_page] ; next free page
  3166 00005E1E 7306                <1> 	jnb	short damb_1
  3167 00005E20 8915[94770100]      <1> 	mov	[next_page], edx
  3168                              <1> damb_1:
  3169 00005E26 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  3170 00005E2B 01D3                <1> 	add	ebx, edx
  3171 00005E2D 83E01F              <1> 	and	eax, 1Fh ; 31
  3172                              <1> 
  3173                              <1> 	; 03/04/2016
  3174 00005E30 BA20000000          <1> 	mov	edx, 32
  3175 00005E35 28C2                <1> 	sub	dl, al
  3176 00005E37 39CA                <1> 	cmp	edx, ecx
  3177 00005E39 7602                <1> 	jna	short damb_2
  3178 00005E3B 89CA                <1> 	mov	edx, ecx
  3179                              <1> damb_2:
  3180 00005E3D 29D1                <1> 	sub	ecx, edx
  3181 00005E3F 51                  <1> 	push	ecx ; ***
  3182 00005E40 89D1                <1> 	mov	ecx, edx
  3183                              <1> damb_3:		
  3184 00005E42 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate page
  3185                              <1> 				     ; set relevant bit to 1.
  3186                              <1> 				     ; set CF to the previous bit value	
  3187 00005E45 FF05[90770100]      <1> 	inc     dword [free_pages]   ; 1 page has been deallocated (X = X+1) 
  3188 00005E4B 49                  <1> 	dec	ecx
  3189 00005E4C 7404                <1> 	jz	short damb_4
  3190 00005E4E FEC0                <1> 	inc	al
  3191 00005E50 EBF0                <1> 	jmp	short damb_3
  3192                              <1> damb_4:	
  3193 00005E52 59                  <1> 	pop	ecx ; ***
  3194 00005E53 21C9                <1> 	and	ecx, ecx ; 0 ?
  3195 00005E55 741E                <1> 	jz	short damb_7
  3196                              <1> 	; 03/04/2016
  3197 00005E57 B020                <1> 	mov	al, 32
  3198                              <1> damb_5:
  3199 00005E59 83C304              <1> 	add	ebx, 4
  3200 00005E5C 39C1                <1> 	cmp	ecx, eax ; 32
  3201 00005E5E 7305                <1> 	jnb	short damb_6
  3202                              <1> 	; ECX < 32
  3203 00005E60 28C0                <1> 	sub	al, al ; 0
  3204 00005E62 50                  <1> 	push	eax ; 0 ***
  3205 00005E63 EBDD                <1> 	jmp	short damb_3
  3206                              <1> damb_6:
  3207 00005E65 0105[90770100]      <1> 	add	[free_pages], eax ; [free_pages] = [free_pages] + 32
  3208 00005E6B C703FFFFFFFF        <1> 	mov	dword [ebx], 0FFFFFFFFh ; set 32 bits
  3209 00005E71 29C1                <1> 	sub	ecx, eax ; 32
  3210 00005E73 75E4                <1> 	jnz	short damb_5
  3211                              <1> damb_7:
  3212 00005E75 5B                  <1> 	pop	ebx ; **
  3213 00005E76 5A                  <1> 	pop	edx ; *
  3214 00005E77 C3                  <1> 	retn
  3215                              <1> 
  3216                              <1> direct_memory_access:
  3217                              <1> 	; 20/10/2023
  3218                              <1> 	; 17/04/2021 (temporary modifications)
  3219                              <1> 	; 22/07/2017
  3220                              <1> 	; 12/05/2017
  3221                              <1> 	; 16/07/2016
  3222                              <1> 	; 12/07/2016 (TRDOS 386 = TRDOS v2.0)
  3223                              <1> 	; This processure will be called to map
  3224                              <1> 	; user's (ring 3) page tables to access phsical
  3225                              <1> 	; (flat/linear) memory addresses, directly (without
  3226                              <1> 	;  kernel's data transfer functions).
  3227                              <1> 	; 
  3228                              <1> 	; Purpose: Video memory access and shared memory access.
  3229                              <1> 	;
  3230                              <1> 	; INPUT -> 
  3231                              <1> 	;	EAX = Beginning address (physical).
  3232                              <1> 	;	EBX = User's buffer address ; 12/05/2017
  3233                              <1> 	;	ECX = Number of contiguous pages to be mapped.
  3234                              <1> 	; OUTPUT ->
  3235                              <1> 	;	User's page directory and pages tables
  3236                              <1> 	;	will be updated.
  3237                              <1> 	;	
  3238                              <1> 	;	If an old page table entry has valid page address, 
  3239                              <1> 	;	that page will be deallocated just before PTE will
  3240                              <1> 	;	be changed for direct (1 to 1) memory page access.
  3241                              <1> 	;
  3242                              <1> 	;	If old PTE value points to a swapped page,
  3243                              <1>         ;       that page (block) will be unlinked on swap disk. 
  3244                              <1> 	;
  3245                              <1> 	;	Newly allocated pages (except page tables) will not
  3246                              <1> 	;	be applied to Memory Allocation Table.
  3247                              <1> 	;	AVL bit 1 (PTE bit 10) of page table entry will be
  3248                              <1> 	;	used to indicate shared (direct) memory page; then,
  3249                              <1> 	;	this page will not be deallocated later during
  3250                              <1> 	;	process termination. (Memory Allocation Table and
  3251                              <1> 	;	free memory count will not be affected.
  3252                              <1> 	;	(Except deallocating page table's itself.)
  3253                              <1> 	;	
  3254                              <1> 	;      CF = 1 -> error (EAX = error code)
  3255                              <1> 	;      CF = 0 -> success (EAX = beginning address)
  3256                              <1> 	;
  3257                              <1> 	;; (Modified Registers -> none)
  3258                              <1> 	; Modified registers: ebp, edx, ecx, ebx, esi, edi	
  3259                              <1> 	;
  3260                              <1> 
  3261                              <1> 	;push	ebp
  3262                              <1> 	;push	ebx
  3263                              <1> 	;push	ecx
  3264                              <1> 	;push	edx
  3265 00005E78 662500F0            <1> 	and	ax, PTE_A_CLEAR ; clear page offset
  3266 00005E7C 50                  <1> 	push	eax
  3267                              <1> 	;and	ecx, ecx ; page count
  3268                              <1> 	;jz	dmem_acc_7  ; 'insufficient memory' error
  3269 00005E7D 89C5                <1> 	mov	ebp, eax
  3270 00005E7F 81C300004000        <1> 	add	ebx, CORE ; 12/05/2017
  3271                              <1> dmem_acc_0: 
  3272 00005E85 891D[EC8D0100]      <1> 	mov	[base_addr], ebx ; 12/05/2017
  3273 00005E8B A1[74010300]        <1> 	mov	eax, [u.pgdir] ; page dir address (physical)
  3274 00005E90 E852F9FFFF          <1> 	call	get_pte
  3275                              <1> 		; EDX = Page table entry address (if CF=0)
  3276                              <1> 	        ;       Page directory entry address (if CF=1)
  3277                              <1> 		;       (Bit 0 value is 0 if PT is not present)
  3278                              <1> 		; EAX = Page table entry value (page address)
  3279                              <1> 		;	CF = 1 -> PDE not present or invalid ? 	
  3280 00005E95 7321                <1> 	jnc	short dmem_acc_1
  3281                              <1> 	; 20/10/2023
  3282                              <1> 	; Allocate a page as a new page table
  3283 00005E97 E839F8FFFF          <1> 	call	allocate_page
  3284                              <1> 	;jc	dmem_acc_7  ; 'insufficient memory' error
  3285                              <1> 	; 17/04/2021
  3286 00005E9C 7215                <1> 	jc	short _dmem_acc_7
  3287                              <1> 	;
  3288 00005E9E E8A3F8FFFF          <1> 	call 	clear_page
  3289                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  3290 00005EA3 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER ; 4+2+1 = 7
  3291                              <1> 			   ; lower 3 bits are used as U/S, R/W, P flags
  3292                              <1> 			   ; (user, writable, present page)	
  3293 00005EA5 8902                <1> 	mov	[edx], eax ; Let's put the new page directory entry here !
  3294 00005EA7 A1[74010300]        <1> 	mov	eax, [u.pgdir]	
  3295 00005EAC E836F9FFFF          <1> 	call	get_pte
  3296                              <1>         ;jc	dmem_acc_7 ; 'insufficient memory' error
  3297                              <1> 	; 17/04/2021
  3298 00005EB1 7305                <1> 	jnc	short dmem_acc_1
  3299                              <1> _dmem_acc_7:
  3300 00005EB3 E985000000          <1> 	jmp	dmem_acc_7
  3301                              <1> dmem_acc_1:
  3302                              <1> 	; EAX = PTE value, EDX = PTE address
  3303 00005EB8 A801                <1> 	test 	al, PTE_A_PRESENT
  3304                              <1> 	;jnz	short dmem_acc_2   ; 17/04/2021 (*)
  3305                              <1> 	; 17/04/2021 (temporary)
  3306 00005EBA 745F                <1> 	jz	short short dmem_acc_6  ; ! temporary ! (*)	
  3307                              <1> 	; 20/10/2023
  3308                              <1> 	; If the page table entry is zero or invalid -not present-
  3309                              <1> 	; it will be directy allocated for the physical memory section
  3310                              <1> 	; without using the M.A.T. (Specially for LFB access -generally-
  3311                              <1> 	; is at the beyod of the physical main memory end.)
  3312                              <1> 	; (M.A.T bits are not used for direct memory access. To cancel
  3313                              <1> 	; direct memory access also is out of the M.A.T scope because
  3314                              <1> 	; direct accessed physical pages are marked as SHARED on their
  3315                              <1> 	; PTE. Shared pages are not dealloaced.)
  3316                              <1> 
  3317                              <1> ; 17/04/2021
  3318                              <1> ; (following code is disabled as temporary)
  3319                              <1> ;
  3320                              <1> ;	or	eax, eax
  3321                              <1> ;	jz	short dmem_acc_6   ; Change PTE
  3322                              <1> ;	shr	eax, 1		; swap disk block (8 sectors) address
  3323                              <1> ;	; unlink swap disk block
  3324                              <1> ;	call	unlink_swap_block
  3325                              <1> ;	jmp	short dmem_acc_6
  3326                              <1> 
  3327                              <1> dmem_acc_2:
  3328 00005EBC A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
  3329                              <1> 				  ; (must be 1)
  3330 00005EBE 7550                <1> 	jnz	short dmem_acc_4
  3331                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
  3332 00005EC0 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
  3333                              <1> 				   ; as child's page ?
  3334 00005EC4 7455                <1> 	jz	short dmem_acc_5 ; Change PTE but don't deallocate the page!
  3335                              <1> 
  3336                              <1> 	;push	edi
  3337                              <1> 	;push	esi
  3338                              <1> 
  3339 00005EC6 51                  <1> 	push	ecx
  3340                              <1> 	;push	ebx
  3341 00005EC7 8B1D[78010300]      <1> 	mov	ebx, [u.ppgdir] ; parent's page dir address (physical)
  3342                              <1> 	
  3343                              <1> 	; check the parent's PTE value is read only & same page or not.. 
  3344 00005ECD 89EF                <1> 	mov	edi, ebp
  3345 00005ECF C1EF16              <1> 	shr	edi, PAGE_D_SHIFT ; 22
  3346                              <1> 	; EDI = page directory entry index (0-1023)
  3347 00005ED2 89EE                <1> 	mov	esi, ebp
  3348 00005ED4 C1EE0C              <1> 	shr	esi, PAGE_SHIFT ; 12	
  3349 00005ED7 81E6FF030000        <1> 	and	esi, PTE_MASK
  3350                              <1> 	; ESI = page table entry index (0-1023)
  3351                              <1> 
  3352 00005EDD 66C1E702            <1> 	shl	di, 2 ; * 4
  3353 00005EE1 01FB                <1> 	add	ebx, edi ; PDE offset (for the parent)
  3354 00005EE3 8B0F                <1> 	mov	ecx, [edi]
  3355 00005EE5 F6C101              <1> 	test	cl, PDE_A_PRESENT ; present (valid) or not ?
  3356 00005EE8 7425                <1> 	jz	short dmem_acc_3	; parent process does not use this page
  3357 00005EEA 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  3358 00005EEF 66C1E602            <1> 	shl	si, 2 ; *4 
  3359 00005EF3 01CE                <1> 	add	esi, ecx ; PTE offset (for the parent)
  3360 00005EF5 8B1E                <1> 	mov	ebx, [esi]
  3361 00005EF7 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
  3362 00005EFA 7413                <1> 	jz	short dmem_acc_3	; parent process does not use this page
  3363 00005EFC 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
  3364 00005F00 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
  3365 00005F05 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
  3366 00005F07 7506                <1> 	jne	short dmem_acc_3	; not same page
  3367                              <1> 				; deallocate the child's page
  3368 00005F09 800E02              <1>         or      byte [esi], PTE_A_WRITE ; convert to writable page (parent)
  3369                              <1> 	;pop	ebx
  3370 00005F0C 59                  <1> 	pop	ecx
  3371 00005F0D EB0C                <1> 	jmp	short dmem_acc_5
  3372                              <1> dmem_acc_3:
  3373                              <1> 	;pop	ebx
  3374 00005F0F 59                  <1> 	pop	ecx
  3375                              <1> dmem_acc_4:	
  3376 00005F10 66A90004            <1> 	test	ax, PTE_SHARED ; shared or direct memory access indicator
  3377 00005F14 7505                <1> 	jnz	short dmem_acc_5   ; AVL bit 1 = 1, do not deallocate this page!
  3378                              <1> 	;
  3379                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3380 00005F16 E879F9FFFF          <1> 	call	deallocate_page
  3381                              <1> dmem_acc_5:
  3382                              <1> 	;pop	esi
  3383                              <1> 	;pop	edi
  3384                              <1> dmem_acc_6:
  3385 00005F1B 89E8                <1> 	mov	eax, ebp ; physical page (offset=0) address
  3386                              <1> 	; EAX = memory page address
  3387                              <1> 	; EDX = PTE entry address (physical)
  3388 00005F1D 660D0704            <1> 	or	ax, PTE_A_PRESENT+PTE_A_USER+PTE_A_WRITE+PTE_SHARED
  3389                              <1> 			; present flag, bit 0 = 1
  3390                              <1> 			; user flag, bit 2 = 1	
  3391                              <1> 			; writable flag, bit 1 = 1
  3392                              <1> 			; direct memory access flag, bit 10 = 1
  3393                              <1> 			; (This page must not be deallocated!)
  3394 00005F21 8902                <1> 	mov	[edx], eax  ; Update PTE value
  3395 00005F23 49                  <1> 	dec	ecx ; remain count of contiguous pages
  3396 00005F24 741E                <1> 	jz	short dmem_acc_8
  3397 00005F26 81C500100000        <1> 	add	ebp, PAGE_SIZE ; next physical page address
  3398                              <1> 	; 22/07/2017
  3399                              <1> 	;mov	eax, ebp
  3400                              <1> 	; 12/05/2017
  3401 00005F2C 8B1D[EC8D0100]      <1> 	mov	ebx, [base_addr] ; linear address (virtual+CORE)
  3402 00005F32 81C300100000        <1> 	add	ebx, PAGE_SIZE	; next linear address
  3403 00005F38 E948FFFFFF          <1>         jmp     dmem_acc_0
  3404                              <1> dmem_acc_7:  ; ERROR ! 
  3405 00005F3D C7042404000000      <1> 	mov	dword [esp], ERR_MINOR_IM 
  3406                              <1> 		; Insufficient memory (minor) error!
  3407                              <1> 		; Major error = 0 (No protection fault)	
  3408                              <1> 	; cf = 1
  3409                              <1> dmem_acc_8:
  3410 00005F44 58                  <1> 	pop	eax
  3411                              <1> 	;pop	edx
  3412                              <1> 	;pop	ecx
  3413                              <1> 	;pop	ebx
  3414                              <1> 	;pop	ebp
  3415 00005F45 C3                  <1> 	retn
  3416                              <1> 
  3417                              <1> deallocate_user_pages:
  3418                              <1> 	; 20/05/2017
  3419                              <1> 	; 15/05/2017
  3420                              <1> 	; 20/02/2017
  3421                              <1> 	; 19/02/2017 (TRDOS 386 = TRDOS v2.0)
  3422                              <1> 	;
  3423                              <1> 	; Deallocate virtually contiguous user pages (memory block)
  3424                              <1> 	; (caller: 'sysdalloc' system call)
  3425                              <1> 	;
  3426                              <1> 	; INPUT ->
  3427                              <1> 	;	EBX = VIRTUAL ADDRESS (beginning address)
  3428                              <1> 	;	ECX = byte count
  3429                              <1> 	;	[u.pgdir] = user's page directory
  3430                              <1> 	;	[u.ppdir] = parent's page directory
  3431                              <1> 	;
  3432                              <1> 	; OUTPUT ->
  3433                              <1> 	;    If CF = 0 	
  3434                              <1> 	;	EAX = Deallocated memory bytes
  3435                              <1> 	;	  (Even if shared or read only pages will not be
  3436                              <1> 	;	   deallocated on M.A.T., this byte count will be
  3437                              <1> 	;	   returned as virtually deallocated bytes; in fact
  3438                              <1> 	;	   virtually deallocated user pages * 4096.) 
  3439                              <1> 	;	EBX = Virtual address (as rounded up)
  3440                              <1> 	;    If CF = 1    	
  3441                              <1> 	;	EAX = 0 (there is not any deallocated pages)
  3442                              <1> 	;
  3443                              <1> 	; Note: Empty page tables will not be deallocated!!!
  3444                              <1> 	;     (they will be deallocated at process termination stage)
  3445                              <1> 	;
  3446                              <1> 	; Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP
  3447                              <1> 	;
  3448 00005F46 89DE                <1> 	mov	esi, ebx
  3449 00005F48 89F7                <1> 	mov	edi, esi
  3450 00005F4A 01CF                <1> 	add	edi, ecx
  3451 00005F4C 81C6FF0F0000        <1> 	add	esi, PAGE_SIZE - 1  ; 4095 (round up)	
  3452 00005F52 C1EE0C              <1> 	shr	esi, PAGE_SHIFT
  3453 00005F55 C1EF0C              <1> 	shr	edi, PAGE_SHIFT
  3454 00005F58 89F8                <1> 	mov	eax, edi ; end page
  3455 00005F5A 29F0                <1> 	sub	eax, esi ; end page - start page
  3456 00005F5C 0F86C8000000        <1> 	jna	da_u_pd_err  ; < 1
  3457 00005F62 89F3                <1> 	mov	ebx, esi
  3458 00005F64 C1E30C              <1> 	shl	ebx, PAGE_SHIFT ; virtual address (as rounded up)
  3459 00005F67 53                  <1> 	push	ebx ; *
  3460 00005F68 89C1                <1> 	mov	ecx, eax ; page count
  3461 00005F6A C1E00C              <1> 	shl	eax, PAGE_SHIFT ; byte count as adjusted
  3462 00005F6D 50                  <1> 	push	eax ; **
  3463 00005F6E 8B1D[74010300]      <1> 	mov	ebx, [u.pgdir] ; physical addr of user's page dir
  3464 00005F74 81C600040000        <1>  	add	esi, CORE/PAGE_SIZE 
  3465 00005F7A 89F7                <1> 	mov	edi, esi
  3466 00005F7C 81E7FF030000        <1> 	and	edi, PTE_MASK ; PTE entry in the page table
  3467 00005F82 57                  <1> 	push	edi ; *** ; PTE index (of page directory)
  3468 00005F83 C1EE0A              <1> 	shr	esi, PAGE_D_SHIFT - PAGE_SHIFT ; 22-12=10
  3469 00005F86 89F2                <1> 	mov	edx, esi 
  3470                              <1> 	; EDX = PDE index
  3471 00005F88 C1E602              <1> 	shl	esi, 2 ; convert PDE index to dword offset
  3472 00005F8B 01DE                <1> 	add	esi, ebx ; add page directory address
  3473                              <1> da_u_pd_1:
  3474 00005F8D AD                  <1> 	lodsd
  3475                              <1> 	;
  3476 00005F8E 89F5                <1> 	mov	ebp, esi ; 20/02/2017
  3477                              <1> 	; EBP = next PDE address
  3478                              <1> 	;
  3479 00005F90 A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
  3480 00005F92 0F8487000000        <1> 	jz	da_u_pd_3 ; 20/05/2017	
  3481 00005F98 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3482                              <1> 	; EAX = PHYSICAL (flat) ADDRESS OF THE PAGE TABLE
  3483 00005F9C 8B3C24              <1> 	mov	edi, [esp] ; ***
  3484                              <1> 	; EDI = PTE index (of complete page directory)
  3485                              <1> 	;and	edi, PTE_MASK ; PTE entry in the page table
  3486 00005F9F C1E702              <1> 	shl	edi, 2 ; convert PTE index to dword offset
  3487 00005FA2 89FE                <1> 	mov	esi, edi ; PTE offset in page table (0-4092)
  3488 00005FA4 01C6                <1> 	add	esi, eax ; now, esi points to requested PTE
  3489                              <1> da_u_pt_0:
  3490 00005FA6 AD                  <1> 	lodsd
  3491 00005FA7 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
  3492 00005FA9 7452                <1> 	jz	short da_u_pt_1
  3493                              <1> 	;
  3494 00005FAB A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
  3495                              <1> 				  ; (must be 1)
  3496 00005FAD 753C                <1> 	jnz	short da_u_pt_3
  3497                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
  3498 00005FAF 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
  3499                              <1> 				   ; as child's page ?
  3500 00005FB3 7441                <1> 	jz	short da_u_pt_4 ; Clear PTE but don't deallocate the page!
  3501                              <1> 	;
  3502                              <1> 	; check the parent's PTE value is read only & same page or not.. 
  3503                              <1> 	; EDX = page directory entry index (0-1023)
  3504 00005FB5 52                  <1> 	push	edx ; ****
  3505                              <1> 	; EDI = page table entry offset (0-4092)
  3506 00005FB6 8B1D[78010300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
  3507 00005FBC 66C1E202            <1> 	shl	dx, 2 ; *4 
  3508 00005FC0 01D3                <1> 	add	ebx, edx ; PDE address (for the parent)
  3509 00005FC2 8B13                <1> 	mov	edx, [ebx] ; page table address
  3510 00005FC4 F6C201              <1> 	test	dl, PDE_A_PRESENT ; present (valid) or not ?
  3511 00005FC7 7421                <1> 	jz	short da_u_pt_2	; parent process does not use this page
  3512 00005FC9 6681E200F0          <1> 	and	dx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  3513                              <1> 	; EDI = page table entry offset (0-4092)
  3514 00005FCE 01D7                <1> 	add	edi, edx	; PTE address (for the parent)
  3515 00005FD0 8B1F                <1> 	mov	ebx, [edi]
  3516 00005FD2 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
  3517 00005FD5 7413                <1> 	jz	short da_u_pt_2	; parent process does not use this page
  3518 00005FD7 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
  3519 00005FDB 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
  3520 00005FE0 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
  3521 00005FE2 7506                <1> 	jne	short da_u_pt_2	; not same page
  3522                              <1> 				; deallocate the child's page
  3523 00005FE4 800F02              <1>         or      byte [edi], PTE_A_WRITE ; convert to writable page (parent)
  3524 00005FE7 5A                  <1> 	pop	edx ; ****
  3525 00005FE8 EB0C                <1> 	jmp	short da_u_pt_4
  3526                              <1> 
  3527                              <1> ; 17/04/2021
  3528                              <1> ; ('da_u_pt_1' is disabled as temporary)
  3529                              <1> 
  3530                              <1> ;da_u_pt_1:
  3531                              <1> ;	or	eax, eax	; swapped page ?
  3532                              <1> ;	jz	short da_u_pt_5	; no
  3533                              <1> ;				; yes
  3534                              <1> ;	shr	eax, 1
  3535                              <1> ;	call	unlink_swap_block ; Deallocate swapped page block
  3536                              <1> ;				  ; on the swap disk (or in file)
  3537                              <1> ;	jmp	short da_u_pt_5
  3538                              <1> da_u_pt_2:
  3539 00005FEA 5A                  <1> 	pop	edx ; ****
  3540                              <1> da_u_pt_3:
  3541 00005FEB 66A90004            <1> 	test	ax, PTE_SHARED	; shared or direct memory access indicator
  3542 00005FEF 7505                <1> 	jnz	short da_u_pt_4	; AVL bit 1 = 1, do not deallocate this page!
  3543                              <1> 	;
  3544                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3545 00005FF1 E89EF8FFFF          <1> 	call	deallocate_page ; set the mem allocation bit of this page
  3546                              <1> da_u_pt_4:
  3547 00005FF6 C746FC00000000      <1> 	mov	dword [esi-4], 0 ; clear/reset PTE (child, dupl. as parent)
  3548                              <1> ; 17/04/2021 (temporary)
  3549                              <1> da_u_pt_1:
  3550                              <1> da_u_pt_5:
  3551                              <1> 	; 20/05/2017
  3552 00005FFD 58                  <1> 	pop	eax ; *** PTE index (of page directory)
  3553 00005FFE 49                  <1> 	dec	ecx ; remain page count
  3554 00005FFF 7426                <1> 	jz	short da_u_pd_4
  3555 00006001 40                  <1> 	inc	eax ; next PTE
  3556 00006002 6625FF03            <1> 	and	ax, PTE_MASK ; PTE entry index in the page table
  3557 00006006 50                  <1> 	push	eax ; *** (save again)
  3558                              <1> 	;mov	edi, eax
  3559                              <1> 	;and 	di, PTE_MASK
  3560                              <1> 	;cmp	edi, PAGE_SIZE / 4 ; 1024
  3561                              <1> 	;jnb	short da_u_pd_2
  3562 00006007 89C7                <1> 	mov	edi, eax
  3563 00006009 C1E702              <1> 	shl	edi, 2 ; convert index to dword offset
  3564                              <1> 	;test	ax, PTE_MASK ; 3FFh
  3565 0000600C 09C0                <1> 	or	eax, eax
  3566 0000600E 7596                <1> 	jnz	short da_u_pt_0 ; 1-1023
  3567                              <1> da_u_pd_2:
  3568 00006010 42                  <1> 	inc	edx
  3569                              <1> 	; 20/05/2017
  3570 00006011 6681E2FF03          <1> 	and	dx, PTE_MASK  ; 3FFh
  3571 00006016 740F                <1> 	jz	short da_u_pd_4  ; 0 (1024)
  3572                              <1> 	;cmp	edx, 1024
  3573                              <1> 	;jnb	short da_u_pd_4
  3574 00006018 89EE                <1> 	mov	esi, ebp ; 20/02/2017
  3575 0000601A E96EFFFFFF          <1> 	jmp	da_u_pd_1
  3576                              <1> da_u_pd_3:
  3577                              <1> 	; 15/05/2017 (empty page directory entry)
  3578 0000601F 81E900040000        <1> 	sub	ecx, 1024
  3579 00006025 77E9                <1> 	ja	short da_u_pd_2 ; 20/05/2017
  3580                              <1> da_u_pd_4:
  3581 00006027 58                  <1> 	pop	eax ; **
  3582 00006028 5B                  <1> 	pop	ebx ; *
  3583 00006029 C3                  <1> 	retn
  3584                              <1> 
  3585                              <1> da_u_pd_err:
  3586 0000602A 31C0                <1> 	xor	eax, eax
  3587 0000602C F9                  <1> 	stc	
  3588 0000602D C3                  <1> 	retn
  3589                              <1> 
  3590                              <1> allocate_user_pages:
  3591                              <1> 	; 20/05/2017
  3592                              <1> 	; 01/05/2017, 02/05/2017, 15/05/2017
  3593                              <1> 	; 04/03/2017
  3594                              <1> 	; 20/02/2017 (TRDOS 386 = TRDOS v2.0)
  3595                              <1> 	;
  3596                              <1> 	; Allocate physically contiguous user pages (memory block)
  3597                              <1> 	; (caller: 'sysalloc' system call)
  3598                              <1> 	;
  3599                              <1> 	; Note: This procedure does not alloc a page's itself
  3600                              <1> 	;	(page bits) on Memory Allocation Table.
  3601                              <1> 	;	(allocate_memory_block is needed before this proc)
  3602                              <1> 	;
  3603                              <1> 	; INPUT ->
  3604                              <1> 	;	EAX = PHYSICAL ADDRESS (beginning address)
  3605                              <1> 	;	EBX = VIRTUAL ADDRESS (beginning address)
  3606                              <1> 	;	ECX = byte count (>=4096)
  3607                              <1> 	;	[u.pgdir] = user's page directory
  3608                              <1> 	;	
  3609                              <1> 	;	Note: All addresses are (must be) already adjusted
  3610                              <1> 	;	to page	borders, otherwise, lower 12bits of addresses
  3611                              <1> 	;	and byte count would be truncated.
  3612                              <1> 	;
  3613                              <1> 	; OUTPUT ->
  3614                              <1> 	;	none
  3615                              <1> 	;
  3616                              <1> 	;	CF = 1 -> insufficient memory error
  3617                              <1> 	;
  3618                              <1> 	; Note: All pages will be allocated in physical page order 
  3619                              <1> 	;	from the beginning page address. 
  3620                              <1> 	;	* A new page table will be added to the page dir
  3621                              <1> 	;	  when the requested PDE is invalid.
  3622                              <1> 	;	* Those pages will not be added to swap queue
  3623                              <1> 	;	  because main purpose of this allocation is to
  3624                              <1> 	;	  set a direct memory access (DMA controller) buffer.
  3625                              <1> 	;	 (Swapping out a page in a DMA buffer would be wrong!)
  3626                              <1> 	;	* Previous content of page tables (PTEs) would be
  3627                              <1> 	;	  (should be) deallocated before entering this
  3628                              <1> 	;	  procedure. So, new page table entries (PTEs)
  3629                              <1> 	;	  directly will be written without checking
  3630                              <1> 	;	  their previous content.	
  3631                              <1> 	;	* Only solution to increase free memory by removing
  3632                              <1> 	;	  that non-swappable memory block is to terminate
  3633                              <1> 	;	  the process or to wait until the process will 
  3634                              <1> 	;	  deallocate that memory block as itself. ('sysdalloc')
  3635                              <1> 	;	  (No problem, if the process does not grab all of
  3636                              <1> 	;	  -very big amount of- free memory by using
  3637                              <1> 	;	  'sysalloc' system call!?)
  3638                              <1> 	;	  (Even if the process has grabbed all of free memory, 
  3639                              <1> 	;	  no problem if the process is not running in 
  3640                              <1> 	;	  multitasking mode. No problem in multitasking
  3641                              <1> 	;	  mode if there is not another process which is running
  3642                              <1> 	;	  or waiting or sleeping for an event as it's pages
  3643                              <1> 	;	  are swapped-out. But a new process can not start to
  3644                              <1> 	;	  run if all of free memory has beeen allocated 
  3645                              <1> 	;	  by running processes. Deallocation -'sysdalloc'- 
  3646                              <1> 	;	  or terminate a running process is needed 
  3647                              <1> 	;	  in order to run a new process.) 
  3648                              <1> 	;
  3649                              <1> 	; Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP
  3650                              <1> 	;
  3651                              <1> 
  3652                              <1> 	; 01/05/2017
  3653 0000602E 662500F0            <1> 	and	ax, ~PAGE_OFF
  3654 00006032 6681E300F0          <1> 	and	bx, ~PAGE_OFF
  3655                              <1> 	; 02/05/2017 
  3656 00006037 BD00F0FFFF          <1> 	mov	ebp, 0FFFFF000h ; 4 Giga Bytes - 4096 Bytes (for Stack)
  3657 0000603C C1E90C              <1> 	shr	ecx, PAGE_SHIFT ; page count
  3658 0000603F 83F901              <1> 	cmp	ecx, 1
  3659 00006042 7251                <1> 	jb	short a_u_im_retn
  3660 00006044 89C2                <1> 	mov	edx, eax
  3661 00006046 01CA                <1> 	add	edx, ecx
  3662 00006048 724B                <1> 	jc	short a_u_im_retn
  3663 0000604A 39D5                <1> 	cmp	ebp, edx
  3664 0000604C 7247                <1> 	jb	short a_u_im_retn
  3665 0000604E 89DA                <1> 	mov	edx, ebx
  3666 00006050 81C200004000        <1> 	add	edx, CORE
  3667 00006056 723D                <1> 	jc	short a_u_im_retn	
  3668 00006058 01CA                <1> 	add	edx, ecx
  3669 0000605A 7239                <1> 	jc	short a_u_im_retn
  3670 0000605C 39D5                <1> 	cmp	ebp, edx
  3671 0000605E 7235                <1> 	jb	short a_u_im_retn
  3672                              <1> 	;
  3673 00006060 89C5                <1> 	mov	ebp, eax ; physical address
  3674 00006062 89DE                <1> 	mov	esi, ebx
  3675 00006064 81C600004000        <1> 	add	esi, CORE ; start of user's memory (4M) 
  3676 0000606A C1EE0C              <1> 	shr	esi, PAGE_SHIFT ; higher 20 bits of the linear address
  3677                              <1> 	;shr	ecx, PAGE_SHIFT ; page count
  3678 0000606D 8B1D[74010300]      <1> 	mov	ebx, [u.pgdir] ; physical addr of user's page dir
  3679 00006073 89F7                <1> 	mov	edi, esi
  3680 00006075 81E7FF030000        <1> 	and	edi, PTE_MASK ; PTE entry index in the page table
  3681 0000607B 57                  <1> 	push	edi  ; * ; PTE index (in page directory)
  3682 0000607C C1EE0A              <1> 	shr	esi, PAGE_D_SHIFT - PAGE_SHIFT ; 22-12=10
  3683 0000607F 89F2                <1> 	mov	edx, esi 
  3684                              <1> 	; EDX = PDE index
  3685 00006081 C1E602              <1> 	shl	esi, 2 ; convert PDE index to dword offset
  3686 00006084 01DE                <1> 	add	esi, ebx ; add page directory address
  3687                              <1> a_u_pd_0:
  3688 00006086 AD                  <1> 	lodsd
  3689                              <1> 	;
  3690 00006087 89F3                <1> 	mov	ebx, esi ; next PDE address
  3691                              <1> 	;
  3692 00006089 A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
  3693 0000608B 7513                <1> 	jnz	short a_u_pd_2
  3694                              <1> 	;
  3695                              <1> 	; empty PDE (it does not point to valid page table address)
  3696 0000608D E843F6FFFF          <1> 	call	allocate_page  ; (allocate a new page table)
  3697 00006092 7302                <1> 	jnc	short a_u_pd_1 ; OK... now, we have a new page table.
  3698                              <1> 	; cf = 1
  3699                              <1> 	; There is not a free memory page to allocate a new page table !!!
  3700 00006094 5E                  <1> 	pop	esi ; *
  3701                              <1> a_u_im_retn:
  3702 00006095 C3                  <1> 	retn	; return to 'sysalloc' with 'insufficient memory' error
  3703                              <1> 	;
  3704                              <1> a_u_pd_1: ; clear the new page table content 
  3705                              <1> 	; EAX = Physical (base) address of the new page table
  3706 00006096 E8ABF6FFFF          <1> 	call	clear_page ; Clear page content
  3707                              <1> 	;
  3708 0000609B 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
  3709                              <1> 		 ; set bit 0, bit 1 and bit 2 to 1
  3710                              <1> 		 ; (present, writable, user)
  3711 0000609D 8946FC              <1> 	mov	[esi-4], eax
  3712                              <1> a_u_pd_2:
  3713 000060A0 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3714                              <1> 	; EAX = PHYSICAL (flat) ADDRESS OF THE PAGE TABLE
  3715 000060A4 8B3C24              <1> 	mov	edi, [esp] ; *
  3716                              <1> 	; EDI = PTE index (of page directory)
  3717                              <1> 	;and	edi, PTE_MASK ; PTE entry index in the page table	
  3718                              <1> 	; EBX = next PDE address
  3719 000060A7 89FE                <1> 	mov	esi, edi ; PTE index in page table (0-1023)
  3720 000060A9 C1E702              <1> 	shl	edi, 2 ; convert PTE index to dword offset
  3721 000060AC 01C7                <1> 	add	edi, eax ; now, edi points to requested PTE
  3722                              <1> a_u_pt_0:
  3723                              <1> 	; 02/05/2017
  3724 000060AE 8B07                <1> 	mov	eax, [edi]
  3725                              <1> 	;
  3726 000060B0 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
  3727 000060B2 7445                <1> 	jz	short a_u_pt_1
  3728                              <1> 	;
  3729 000060B4 A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
  3730                              <1> 				  ; (must be 1)
  3731 000060B6 7550                <1> 	jnz	short a_u_pt_3
  3732                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
  3733 000060B8 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
  3734                              <1> 				   ; as child's page ?
  3735 000060BC 7455                <1> 	jz	short a_u_pt_4	; Clear PTE but don't deallocate the page!
  3736                              <1> 	;
  3737                              <1> 	; check the parent's PTE value is read only & same page or not.. 
  3738                              <1> 	; EDX = page directory entry index (0-1023)
  3739 000060BE 52                  <1> 	push	edx ; **
  3740 000060BF 53                  <1> 	push	ebx ; ***
  3741                              <1> 	; ESI = page table entry index (0-1023)
  3742                              <1> 	;push	esi ; **** ; 20/05/2017
  3743 000060C0 8B1D[78010300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
  3744 000060C6 66C1E202            <1> 	shl	dx, 2 ; *4 
  3745 000060CA 01D3                <1> 	add	ebx, edx ; PTE address,0 (for the parent)
  3746 000060CC 8B13                <1> 	mov	edx, [ebx] ; page table address
  3747 000060CE F6C201              <1> 	test	dl, PDE_A_PRESENT ; present (valid) or not ?
  3748 000060D1 7433                <1> 	jz	short a_u_pt_2	; parent process does not use this page
  3749 000060D3 6681E200F0          <1> 	and	dx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  3750 000060D8 66C1E602            <1> 	shl	si, 2 ; *4
  3751                              <1> 	; ESI = page table entry offset (0-4092)
  3752 000060DC 01D6                <1> 	add	esi, edx	; PTE address (for the parent)
  3753 000060DE 8B1E                <1> 	mov	ebx, [esi]
  3754 000060E0 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
  3755 000060E3 7421                <1> 	jz	short a_u_pt_2	; parent process does not use this page
  3756 000060E5 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
  3757 000060E9 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
  3758 000060EE 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
  3759 000060F0 7514                <1> 	jne	short a_u_pt_2	; not same page
  3760                              <1> 				; deallocate the child's page
  3761 000060F2 800E02              <1>         or      byte [esi], PTE_A_WRITE ; convert to writable page (parent)
  3762                              <1> 	;pop	esi ; **** ; 20/05/2017
  3763 000060F5 5B                  <1> 	pop	ebx ; ***
  3764 000060F6 5A                  <1> 	pop	edx ; **
  3765 000060F7 EB1A                <1> 	jmp	short a_u_pt_4
  3766                              <1> a_u_pt_1:
  3767 000060F9 09C0                <1> 	or	eax, eax	; swapped page ?
  3768 000060FB 7416                <1> 	jz	short a_u_pt_4	; no
  3769                              <1> 				; yes
  3770 000060FD D1E8                <1> 	shr	eax, 1
  3771 000060FF E8B3F9FFFF          <1> 	call	unlink_swap_block ; Deallocate swapped page block
  3772                              <1> 				  ; on the swap disk (or in file)
  3773 00006104 EB0D                <1> 	jmp	short a_u_pt_4
  3774                              <1> a_u_pt_2:
  3775                              <1> 	;pop	esi ; **** ; 20/05/2017
  3776 00006106 5B                  <1> 	pop	ebx ; ***
  3777 00006107 5A                  <1> 	pop	edx ; **
  3778                              <1> a_u_pt_3:
  3779 00006108 66A90004            <1> 	test	ax, PTE_SHARED	; shared or direct memory access indicator
  3780 0000610C 7505                <1> 	jnz	short a_u_pt_4	; AVL bit 1 = 1, do not deallocate this page!
  3781                              <1> 	;
  3782                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3783 0000610E E881F7FFFF          <1> 	call	deallocate_page ; set the mem allocation bit of this page
  3784                              <1> 	;
  3785                              <1> a_u_pt_4:
  3786 00006113 89E8                <1> 	mov	eax, ebp ; physical address
  3787 00006115 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER ; 04/03/2017
  3788 00006117 AB                  <1> 	stosd
  3789 00006118 5E                  <1> 	pop	esi ; * ; 20/05/2017
  3790 00006119 49                  <1> 	dec	ecx ; remain page count
  3791 0000611A 7417                <1> 	jz	short a_u_pd_5
  3792 0000611C 81C500100000        <1> 	add	ebp, PAGE_SIZE
  3793 00006122 46                  <1> 	inc	esi ; next PTE (index)
  3794                              <1> 	; 20/05/2017
  3795                              <1> 	;cmp	esi, PAGE_SIZE/4 ; 1024
  3796                              <1> 	;jb	short a_u_pt_0
  3797 00006123 6681E6FF03          <1> 	and	si, PTE_MASK ; 3FFh (0 to 1023)
  3798 00006128 56                  <1> 	push	esi ; *
  3799 00006129 7583                <1> 	jnz	short a_u_pt_0 ; > 0 (<1024)
  3800                              <1> a_u_pd_3:
  3801 0000612B 42                  <1> 	inc	edx
  3802                              <1> ;	cmp	edx, 1024
  3803                              <1> ;	jnb	short a_u_pd_4 ; 02/05/2017 (error!, ecx > 0)
  3804 0000612C 89DE                <1> 	mov	esi, ebx ; the next PDE address
  3805 0000612E E953FFFFFF          <1> 	jmp	a_u_pd_0
  3806                              <1> a_u_pd_4:
  3807                              <1> 	; 02/05/2017
  3808                              <1> ;	stc
  3809                              <1> a_u_pd_5:
  3810                              <1> 	; 20/05/2017
  3811                              <1> 	;pop	edi ; *
  3812 00006133 C3                  <1> 	retn
  3813                              <1> 
  3814                              <1> allocate_lfb_pages_for_kernel:
  3815                              <1> 	; 20/10/2023 - TRDOS 386 v2.0.7
  3816                              <1> 	; (only the overlapped main memory pages will be allocated)
  3817                              <1> 	; ((if LFB base/start address is greater than -or equal to-
  3818                              <1> 	;      main memory size, this procedure is not called/used)) 
  3819                              <1> 	; 15/12/2020
  3820                              <1> 	; 14/12/2020 - TRDOS 386 v2.0.3
  3821                              <1> 	; Set kernel page tables for linear frame buffer 
  3822                              <1> 	;
  3823                              <1> 	; Input:
  3824                              <1> 	;	;[LFB_ADDR] = linear frame buffer base address
  3825                              <1> 	;	;[LFB_SIZE] = linear frame buffer size in bytes
  3826                              <1> 	;	; 20/10/2023
  3827                              <1> 	;	eax = Linear frame buffer base address as page num
  3828                              <1> 	;	      (eax < memory size)
  3829                              <1> 	;	esi = linear frame buffer base address
  3830                              <1> 	;	ecx = memory size in pages = [memory_size]
  3831                              <1> 	; Output:
  3832                              <1> 	;	none
  3833                              <1> 	;	cf = 1 -> error
  3834                              <1> 	;
  3835                              <1> 	; Modified registers: eax, ecx, edx, edi
  3836                              <1> 
  3837                              <1> 	; 20/10/2023
  3838                              <1> 	;mov	edi, [LFB_ADDR]
  3839                              <1> 	;mov	edx, [LFB_SIZE]
  3840                              <1> 
  3841                              <1> 	;;;
  3842                              <1> 	; 20/10/2023
  3843 00006134 89C7                <1> 	mov	edi, eax ; LFB base/start page number
  3844                              <1> 	;mov	ecx, [memory_size]
  3845 00006136 29C1                <1> 	sub	ecx, eax	
  3846                              <1> 
  3847                              <1> 	; ecx = number of pages to be set as (already) allocated 
  3848                              <1> 	;;;
  3849                              <1> 
  3850                              <1> 	; 20/10/2023
  3851 00006138 C1EF0A              <1> 	shr	edi, 10 ; convert page number to PDE entry number
  3852                              <1> 			; (1024 pages per page table -the shift
  3853                              <1> 			; result is a page table index number
  3854                              <1> 			; or page directory entry number <= 1023)
  3855                              <1> 	;shr	edi, 22	; convert address to page number
  3856                              <1> 			; and then convert it to PDE entry offset
  3857                              <1> 			; (1 PDE is for 4MB, 22 bit shift)
  3858                              <1> 
  3859 0000613B 66C1E702            <1> 	shl	di, 2	; * 4 to obtain the PDE offset
  3860                              <1> 
  3861                              <1> 	; 20/10/2023
  3862                              <1> 	;;add	edx, 4095
  3863                              <1> 	;shr	edx, 12	; convert LFB size to LFB page count
  3864                              <1> 	
  3865                              <1> 	;mov	ecx, edx ; * ; LFB page count
  3866                              <1> 	; 20/10/2023
  3867 0000613F 89CA                <1> 	mov	edx, ecx ; *
  3868                              <1> 			; 20/10/2023
  3869                              <1> 			; edx = page count (to be set as allocated)
  3870                              <1> 			; 	from the LFB start page
  3871                              <1> 			; (it may be <= linear frame buffer size) 
  3872                              <1> 
  3873 00006141 81C1FF030000        <1> 	add	ecx, 1023 ; page count + 1023
  3874 00006147 C1E90A              <1> 	shr	ecx, 10 ; convert to page directory entry count	
  3875                              <1> 			; (page table count)
  3876 0000614A 51                  <1> 	push	ecx ; **
  3877 0000614B C1E10C              <1> 	shl	ecx, 12 ; convert to byte count
  3878                              <1> 
  3879                              <1> 	; 20/10/2023
  3880                              <1> 	; (absolute allocation is needed instead of the first fit)
  3881                              <1> 	;xor	eax, eax ; first available pages
  3882                              <1> 	
  3883                              <1> 	; 20/10/2023
  3884                              <1> 	;mov	esi, [LFB_ADDR]
  3885 0000614E 89F0                <1> 	mov	eax, esi ; linear frame buffer's base/start address	
  3886                              <1> 
  3887                              <1> 	; allocate contiguous memory block for these kernel pages
  3888                              <1> 	
  3889                              <1> 	;call	allocate_memory_block
  3890                              <1> 	; 20/10/2023 
  3891                              <1> 	; (short way to set LFB page bits on the 'M.A.T.)
  3892 00006150 E8A2FBFFFF          <1> 	call	allocate_lfb_memory_block ; in 'allocate_memory_block'	
  3893                              <1> 
  3894                              <1> 	; eax = start address of (contiguous) memory block
  3895 00006155 59                  <1> 	pop	ecx ; ** ; PDE count
  3896 00006156 7301                <1> 	jnc	short a_lfb_k_1
  3897                              <1> 	; error (cf=1)
  3898 00006158 C3                  <1> 	retn
  3899                              <1> a_lfb_k_1:
  3900                              <1> 	; Allocate (new) page tables in kernel's page directory
  3901 00006159 51                  <1> 	push	ecx ; PDE (page table) count
  3902 0000615A 50                  <1> 	push	eax ; start address of contiguous memory pages
  3903                              <1> 		    ; (at page boundary)	
  3904                              <1> 	; edi = 1st page directory entry offset
  3905 0000615B 033D[88770100]      <1> 	add	edi, [k_page_dir] ; Kernel's Page Dir Address
  3906                              <1> a_lfb_k_2:
  3907 00006161 660D0304            <1> 	or	ax, PDE_A_PRESENT + PDE_A_WRITE + PDE_EXTERNAL
  3908                              <1> 				; supervisor + read&write + present 	
  3909                              <1> 				; + external memory block (LFB)
  3910 00006165 AB                  <1> 	stosd
  3911 00006166 0500100000          <1> 	add	eax, 4096
  3912 0000616B E2F4                <1> 	loop	a_lfb_k_2
  3913                              <1> 	
  3914 0000616D 5F                  <1> 	pop	edi ; start addr of contiguous memory pages
  3915 0000616E 59                  <1> 	pop	ecx ; page table (PDE) count
  3916                              <1> 
  3917                              <1> 	; Allocate pages in (new) kernel page tables
  3918                              <1> 	
  3919                              <1> 	; (Note: page tables are contiguous in pyhsical memory)
  3920 0000616F C1E10A              <1> 	shl	ecx, 10 ; * 1024, convert to (total) PTE count 
  3921                              <1> 	
  3922 00006172 A1[E00F0300]        <1> 	mov	eax, [LFB_ADDR]
  3923                              <1> 	; edx = LFB page count
  3924                              <1> 	;and	ax, ~4095  ; lw of LFB address is 0
  3925                              <1> a_lfb_k_3:	
  3926 00006177 660D0304            <1> 	or	ax, PTE_A_PRESENT + PTE_A_WRITE + PTE_EXTERNAL
  3927                              <1> 				; supervisor + read&write + present 	
  3928                              <1> 				; + external memory block (LFB)
  3929 0000617B AB                  <1> 	stosd
  3930 0000617C 4A                  <1> 	dec	edx
  3931 0000617D 7408                <1> 	jz	short a_lfb_k_4 ; LFB size has been completed (!?)
  3932 0000617F 0500100000          <1> 	add	eax, 4096	
  3933 00006184 E2F1                <1> 	loop	a_lfb_k_3
  3934                              <1> 
  3935 00006186 C3                  <1> 	retn
  3936                              <1> 	
  3937                              <1> a_lfb_k_4:
  3938                              <1> 	; clear PTEs for empty/free pages 
  3939                              <1> 	; 	(if there are after LFB !?)
  3940 00006187 31C0                <1> 	xor	eax, eax ; clear page table entry (empty)
  3941 00006189 F3AB                <1> 	rep	stosd
  3942 0000618B C3                  <1> 	retn
  3943                              <1> 
  3944                              <1> ;deallocate_lfb_pages_for_kernel:
  3945                              <1> 	; 15/12/2020
  3946                              <1> 	; 14/12/2020 - TRDOS 386 v2.0.3
  3947                              <1> 	; Reset/Release kernel page tables
  3948                              <1> 	;	 which are used for linear frame buffer 
  3949                              <1> 	; (this procedure will be called by kernel only)
  3950                              <1> 	;
  3951                              <1> 	; Input:
  3952                              <1> 	;	[LFB_ADDR] = linear frame buffer base address
  3953                              <1>  	;	[FFB_SIZE] = linear frame buffer size in bytes
  3954                              <1> 	; Output:
  3955                              <1> 	;	none
  3956                              <1> 	;
  3957                              <1> 	; Modified registers: eax, ecx, edi
  3958                              <1> 
  3959                              <1> 	;mov	edi, [LFB_ADDR]
  3960                              <1> 	;mov	ecx, [LFB_SIZE]
  3961                              <1> 	;
  3962                              <1> 	;shr	edi, 22	; convert address to page number
  3963                              <1> 	;		; and then convert it to PDE entry offset
  3964                              <1> 	;		; (1 PDE is for 4MB, 22 bit shift)
  3965                              <1> 	;
  3966                              <1> 	;shl	di, 2	; * 4 for offset 
  3967                              <1> 	;
  3968                              <1> 	;;add	ecx, 4095
  3969                              <1> 	;shr	ecx, 12	; convert LFB size to page count  
  3970                              <1> 	;
  3971                              <1> 	;add	ecx, 1023 ; page count + 1023
  3972                              <1> 	;shr	ecx, 10 ; convert to page directory entry count	
  3973                              <1> 	;		; (page table count)
  3974                              <1> 	;push	ecx ; *
  3975                              <1> 	;shl	ecx, 12 ; convert to byte count
  3976                              <1> 	;
  3977                              <1> 	;xor	eax, eax ; first available pages
  3978                              <1> 	;
  3979                              <1> 	;; deallocate contiguous memory block for kernel pages
  3980                              <1> 	;
  3981                              <1> 	;call	deallocate_memory_block
  3982                              <1> 	;
  3983                              <1> 	;pop	ecx ; * ; PDE count
  3984                              <1> 	;
  3985                              <1> 	;; Release/Free PDEs (page tables) in kernel's page dir
  3986                              <1> 	;; edi = 1st page directory entry offset
  3987                              <1> 	;add	edi, [k_page_dir] ; Kernel's Page Dir Address
  3988                              <1> 	;sub	eax, eax ; clear (also invalidate)
  3989                              <1> 	;rep	stosd
  3990                              <1> 	;
  3991                              <1> 	;retn
  3992                              <1> 
  3993                              <1> ; /// End Of MEMORY MANAGEMENT FUNCTIONS ///
  3994                              <1> 
  3995                              <1> ;; Data:
  3996                              <1> 
  3997                              <1> ; 09/03/2015
  3998                              <1> ;swpq_count: dw 0 ; count of pages on the swap que
  3999                              <1> ;swp_drv:    dd 0 ; logical drive description table address of the swap drive/disk
  4000                              <1> ;swpd_size:  dd 0 ; size of swap drive/disk (volume) in sectors (512 bytes). 		  				
  4001                              <1> ;swpd_free:  dd 0 ; free page blocks (4096 bytes) on swap disk/drive (logical)
  4002                              <1> ;swpd_next:  dd 0 ; next free page block
  4003                              <1> ;swpd_last:  dd 0 ; last swap page block
  3039                                  %include 'timer.s'   ; 17/01/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - timer.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 08/08/2022  (Previous: 18/04/2021)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 17/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ;
    15                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
    16                              <1> ; ****************************************************************************
    17                              <1> 
    18                              <1> ; TRDOS 386  (TRDOS v2.0) Kernel - TIMER & REAL TIME CLOCK (BIOS) FUNCTIONS
    19                              <1> 
    20                              <1> ; IBM PC-AT BIOS Source Code ('BIOS2.ASM')
    21                              <1> ; TITLE BIOS2 ---- 06/10/85 BIOS INTERRUPT ROUTINES
    22                              <1> 
    23                              <1> ;-------------------------------------------------------------------------------
    24                              <1> ;
    25                              <1> ; ///////// TIMER (& REAL TIME CLOCK) FUNCTIONS ///////////////
    26                              <1> 
    27                              <1> int1Ah:
    28                              <1> 	; 29/01/2016
    29                              <1> 	; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
    30 0000618C 9C                  <1> 	pushfd
    31 0000618D 0E                  <1> 	push 	cs
    32 0000618E E801000000          <1> 	call 	TIME_OF_DAY_1
    33 00006193 C3                  <1> 	retn
    34                              <1> 
    35                              <1> ;-------------------------------------------------------------------------------
    36                              <1> 
    37                              <1> ;--- INT 1A H -- (TIME OF DAY) --------------------------------------------------
    38                              <1> ;       THIS BIOS ROUTINE ALLOWS THE CLOCKS TO BE SET OR READ			:
    39                              <1> ;										:
    40                              <1> ; PARAMETERS:									:
    41                              <1> ;     (AH) = 00H  READ THE CURRENT SETTING AND RETURN WITH,			:
    42                              <1> ;                      (CX) = HIGH PORTION OF COUNT				:
    43                              <1> ;                      (DX) = LOW PORTION OF COUNT				:
    44                              <1> ;                      (AL) = 0 TIMER HAS NOT PASSED 24 HOURS SINCE LAST READ	:
    45                              <1> ;                             1 IF ON ANOTHER DAY. (RESET TO ZERO AFTER READ)	:
    46                              <1> ;										:
    47                              <1> ;     (AH) = 01H  SET THE CURRENT CLOCK USING,					:
    48                              <1> ;		     (CX) = HIGH PORTION OF COUNT				:
    49                              <1> ;		     (DX) = LOW PORTION OF COUNT.				:
    50                              <1> ;										:
    51                              <1> ;             NOTE: COUNTS OCCUR AT THE RATE OF 1193180/65536 COUNTS/SECOND	:
    52                              <1> ;                   (OR ABOUT 18.2 PER SECOND -- SEE EQUATES)			:
    53                              <1> ;										:
    54                              <1> ;     (AH) = 02H  READ THE REAL TIME CLOCK AND RETURN WITH,			:
    55                              <1> ;                      (CH) = HOURS IN BCD (00-23)				:
    56                              <1> ;                      (CL) = MINUTES IN BCD (00-59)				:
    57                              <1> ;                      (DH) = SECONDS IN BCD (00-59)				:
    58                              <1> ;                      (DL) = DAYLIGHT SAVINGS ENABLE (00-01)			:
    59                              <1> ;										:
    60                              <1> ;     (AH) = 03H  SET THE REAL TIME CLOCK USING,				:
    61                              <1> ;                     (CH) = HOURS IN BCD (00-23)				:
    62                              <1> ;                     (CL) = MINUTES IN BCD (00-59)				:
    63                              <1> ;                     (DH) = SECONDS IN BCD (00-59)				:
    64                              <1> ;                     (DL) = 01 IF DAYLIGHT SAVINGS ENABLE OPTION, ELSE 00.	:
    65                              <1> ;										:
    66                              <1> ;             NOTE: (DL) = 00 IF DAYLIGHT SAVINGS TIME ENABLE IS NOT ENABLED.	:
    67                              <1> ;                   (DL) = 01 ENABLES TWO SPECIAL UPDATES THE LAST SUNDAY IN	:
    68                              <1> ;	            APRIL   (1:59:59 --> 3:00:00 AM) AND THE LAST SUNDAY IN	:
    69                              <1> ;                   OCTOBER (1:59:59 --> 1:00:00 AM) THE FIRST TIME.		:
    70                              <1> ;										:
    71                              <1> ;     (AH) = 04H  READ THE DATE FROM THE REAL TIME CLOCK AND RETURN WITH,	:
    72                              <1> ;                      (CH) = CENTURY IN BCD (19 OR 20)				:
    73                              <1> ;                      (CL) = YEAR IN BCD (00-99)				:
    74                              <1> ;                      (DH) = MONTH IN BCD (01-12)				:
    75                              <1> ;                      (DL) = DAY IN BCD (01-31).				:
    76                              <1> ;										:
    77                              <1> ;     (AH) = 05H  SET THE DATE INTO THE REAL TIME CLOCK USING,			:
    78                              <1> ;                     (CH) = CENTURY IN BCD (19 OR 20)				:
    79                              <1> ;                     (CL) = YEAR IN BCD (00-99)				:
    80                              <1> ;                     (DH) = MONTH IN BCD (01-12)				:
    81                              <1> ;                     (DL) = DAY IN BCD (01-31).				:
    82                              <1> ;										:
    83                              <1> ;     (AH) = 06H  SET THE ALARM TO INTERRUPT AT SPECIFIED TIME,			:
    84                              <1> ;                     (CH) = HOURS IN BCD (00-23 (OR FFH))			:
    85                              <1> ;                     (CL) = MINUTES IN BCD (00-59 (OR FFH))			:
    86                              <1> ;                     (DH) = SECONDS IN BCD (00-59 (OR FFH))			:
    87                              <1> ;										:
    88                              <1> ;     (AH) = 07H  RESET THE ALARM INTERRUPT FUNCTION.				:
    89                              <1> ;										:
    90                              <1> ; NOTES: FOR ALL RETURNS CY= 0 FOR SUCCESSFUL OPERATION.			:
    91                              <1> ;        FOR (AH)= 2, 4, 6 - CARRY FLAG SET IF REAL TIME CLOCK NOT OPERATING.	:
    92                              <1> ;        FOR (AH)= 6 - CARRY FLAG SET IF ALARM ALREADY ENABLED. 		:
    93                              <1> ;        FOR THE ALARM FUNCTION (AH = 6) THE USER MUST SUPPLY A ROUTINE AND	:
    94                              <1> ;         INTERCEPT THE CORRECT ADDRESS IN THE VECTOR TABLE FOR INTERRUPT 4AH.	:
    95                              <1> ;         USE 0FFH FOR ANY "DO NOT CARE" POSITION FOR INTERVAL INTERRUPTS.	:
    96                              <1> ;        INTERRUPTS ARE DISABLED DURING DATA MODIFICATION. 			:
    97                              <1> ;        AH & AL ARE RETURNED MODIFIED AND NOT DEFINED EXCEPT WHERE INDICATED.	:
    98                              <1> ;--------------------------------------------------------------------------------
    99                              <1> 
   100                              <1> ; 29/07/2022
   101                              <1> ; 15/01/2017
   102                              <1> ; 14/01/2017
   103                              <1> ; 07/01/2017
   104                              <1> ; 02/01/2017
   105                              <1> ; 29/05/2016
   106                              <1> ; 29/01/2016
   107                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   108                              <1> 
   109                              <1> ; 29/05/2016
   110                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   111                              <1> int35h:  ; Date/Time functions
   112                              <1> 
   113                              <1> TIME_OF_DAY_1:
   114                              <1> 	; 07/08/5022
   115                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
   116                              <1> 	;sti				; INTERRUPTS BACK ON
   117                              <1> 	; 29/05/2016
   118 00006194 80642408FE          <1> 	and	byte [esp+8], 11111110b	; clear carry bit of eflags register
   119                              <1> 	;
   120 00006199 80FC08              <1> 	cmp	ah, (RTC_TBE-RTC_TB)/4	; CHECK IF COMMAND IN VALID RANGE (0-7)
   121 0000619C F5                  <1> 	cmc				; COMPLEMENT CARRY FOR ERROR EXIT
   122                              <1> 	; (*) jc short TIME_9		; EXIT WITH CARRY = 1 IF NOT VALID
   123 0000619D 721A                <1> 	jc	short _TIME_9 ; 29/05/2016
   124                              <1> 
   125 0000619F 1E                  <1> 	push	ds
   126 000061A0 56                  <1> 	push	esi
   127 000061A1 66BE1000            <1> 	mov	si, KDATA		; kernel data segment
   128 000061A5 8EDE                <1> 	mov	ds, si
   129                              <1> 
   130                              <1> 	;;15/01/2017
   131                              <1> 	; 14/01/2017
   132                              <1> 	; 02/01/2017
   133                              <1> 	;;mov	byte [intflg], 35h	; date & time interrupt 
   134                              <1> 	;sti
   135                              <1> 	;
   136 000061A7 C0E402              <1> 	shl	ah, 2			; convert function to dword offset
   137 000061AA 0FB6F4              <1> 	movzx	esi, ah			; PLACE INTO ADDRESSING REGISTER
   138                              <1> 	;cli				; NO INTERRUPTS DURING TIME FUNCTIONS
   139 000061AD FF96[BF610000]      <1> 	call	[esi+RTC_TB]		; VECTOR TO FUNCTION REQUESTED WITH CY=0
   140                              <1> 					; RETURN WITH CARRY FLAG SET FOR RESULT
   141                              <1> 	;sti				; INTERRUPTS BACK ON
   142 000061B3 B400                <1> 	mov	ah, 0			; CLEAR (AH) TO ZERO
   143 000061B5 5E                  <1> 	pop	esi			; RECOVER USERS REGISTER
   144 000061B6 1F                  <1> 	pop	ds			; RECOVER USERS SEGMENT SELECTOR
   145                              <1> 
   146                              <1> 	;;15/01/2017
   147                              <1> 	; 02/01/2017
   148                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
   149                              <1> 
   150                              <1> ;TIME_9:
   151                              <1> 					; RETURN WITH CY= 0 IF NO ERROR
   152                              <1> 	; (*) 29/05/2016
   153                              <1> 	; (*) retf 4 ; skip eflags on stack
   154 000061B7 7305                <1> 	jnc	short _TIME_10
   155                              <1> _TIME_9:
   156                              <1> 	; 29/05/2016 -set carry flag on stack-
   157                              <1> 	; [esp] = EIP
   158                              <1> 	; [esp+4] = CS
   159                              <1> 	; [esp+8] = E-FLAGS
   160 000061B9 804C240801          <1> 	or	byte [esp+8], 1	 ; set carry bit of eflags register
   161                              <1> 	; [esp+12] = ESP (user)
   162                              <1> 	; [esp+16] = SS (User)
   163                              <1> _TIME_10:
   164 000061BE CF                  <1> 	iretd
   165                              <1> 	
   166                              <1> 	; (*) 29/05/2016 - 'ref 4' intruction causes to stack fault
   167                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
   168                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
   169                              <1> 	; // RETF instruction:
   170                              <1> 	;
   171                              <1> 	; IF OperandMode=32 THEN
   172                              <1>  	;    Load CS:EIP from stack;
   173                              <1>  	;    Set CS RPL to CPL;
   174                              <1>  	;    Increment eSP by 8 plus the immediate offset if it exists;
   175                              <1>  	;    Load SS:eSP from stack;
   176                              <1>  	; ELSE (* OperandMode=16 *)
   177                              <1>  	;    Load CS:IP from stack;
   178                              <1>  	;    Set CS RPL to CPL;
   179                              <1>  	;    Increment eSP by 4 plus the immediate offset if it exists;
   180                              <1> 	;    Load SS:eSP from stack;
   181                              <1>  	; FI;
   182                              <1> 	;
   183                              <1> 	; //					
   184                              <1> 					; ROUTINE VECTOR TABLE (AH)=
   185                              <1> RTC_TB:
   186 000061BF [DF610000]          <1> 	dd	RTC_00			; 0 = READ CURRENT CLOCK COUNT
   187 000061C3 [F2610000]          <1> 	dd	RTC_10			; 1 = SET CLOCK COUNT
   188 000061C7 [00620000]          <1> 	dd	RTC_20			; 2 = READ THE REAL TIME CLOCK TIME
   189 000061CB [2E620000]          <1> 	dd	RTC_30			; 3 = SET REAL TIME CLOCK TIME
   190 000061CF [6B620000]          <1> 	dd	RTC_40			; 4 = READ THE REAL TIME CLOCK DATE
   191 000061D3 [91620000]          <1> 	dd	RTC_50			; 5 = SET REAL TIME CLOCK DATE
   192 000061D7 [F0620000]          <1> 	dd	RTC_60			; 6 = SET THE REAL TIME CLOCK ALARM
   193 000061DB [42630000]          <1> 	dd	RTC_70			; 7 = RESET ALARM
   194                              <1> 
   195                              <1> RTC_TBE	equ	$
   196                              <1> 
   197                              <1> RTC_00:				; READ TIME COUNT
   198 000061DF A0[0C780100]        <1> 	mov	al, [TIMER_OFL]		; GET THE OVERFLOW FLAG
   199 000061E4 C605[0C780100]00    <1> 	mov	byte [TIMER_OFL], 0	; AND THEN RESET THE OVERFLOW FLAG
   200 000061EB 8B0D[08780100]      <1>         mov     ecx, [TIMER_LH]         ; GET COUNT OF TIME
   201 000061F1 C3                  <1> 	retn
   202                              <1> 
   203                              <1> RTC_10:				; SET TIME COUNT
   204 000061F2 890D[08780100]      <1>         mov     [TIMER_LH], ecx         ; SET TIME COUNT
   205 000061F8 C605[0C780100]00    <1> 	mov	byte [TIMER_OFL], 0	; RESET OVERFLOW FLAG
   206 000061FF C3                  <1> 	retn				; RETURN WITH NO CARRY
   207                              <1> 
   208                              <1> RTC_20:				; GET RTC TIME
   209 00006200 E8C7010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   210 00006205 7226                <1> 	jc	short RTC_29		; EXIT IF ERROR (CY= 1)
   211                              <1> 
   212 00006207 B000                <1> 	mov	al, CMOS_SECONDS	; SET ADDRESS OF SECONDS
   213 00006209 E8F4010000          <1> 	call	CMOS_READ		; GET SECONDS
   214 0000620E 88C6                <1> 	mov	dh, al			; SAVE
   215 00006210 B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   216 00006212 E8EB010000          <1> 	call	CMOS_READ		; READ CURRENT VALUE OF DSE BIT
   217 00006217 2401                <1> 	and	al, 00000001b		; MASK FOR VALID DSE BIT
   218 00006219 88C2                <1> 	mov	dl, al			; SET [DL] TO ZERO FOR NO DSE BIT
   219 0000621B B002                <1> 	mov	al, CMOS_MINUTES	; SET ADDRESS OF MINUTES
   220 0000621D E8E0010000          <1> 	call	CMOS_READ		; GET MINUTES
   221 00006222 88C1                <1> 	mov	cl, al			; SAVE
   222 00006224 B004                <1>         mov     al, CMOS_HOURS          ; SET ADDRESS OF HOURS
   223                              <1> RTC_41:		; 29/07/2022
   224 00006226 E8D7010000          <1> 	call	CMOS_READ		; GET HOURS
   225 0000622B 88C5                <1> 	mov	ch, al			; SAVE
   226                              <1> 	; 29/07/2022
   227                              <1> 	;clc				; SET CY= 0
   228                              <1> RTC_29:
   229 0000622D C3                  <1> 	retn				; RETURN WITH RESULT IN CARRY FLAG
   230                              <1> 
   231                              <1> RTC_30:				; SET RTC TIME
   232 0000622E E899010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   233 00006233 7305                <1> 	jnc	short RTC_35		; GO AROUND IF CLOCK OPERATING
   234 00006235 E8AD010000          <1> 	call	RTC_STA			; ELSE TRY INITIALIZING CLOCK
   235                              <1> RTC_35:
   236 0000623A 88F4                <1> 	mov	ah, dh			; GET TIME BYTE - SECONDS
   237 0000623C B000                <1> 	mov	al, CMOS_SECONDS	; ADDRESS SECONDS
   238 0000623E E894000000          <1> 	call	CMOS_WRITE		; UPDATE SECONDS
   239 00006243 88CC                <1> 	mov	ah, cl			; GET TIME BYTE - MINUTES
   240 00006245 B002                <1> 	mov	al, CMOS_MINUTES	; ADDRESS MINUTES
   241 00006247 E88B000000          <1> 	call	CMOS_WRITE		; UPDATE MINUTES
   242 0000624C 88EC                <1> 	mov	ah, ch			; GET TIME BYTE - HOURS
   243 0000624E B004                <1> 	mov	al, CMOS_HOURS		; ADDRESS HOURS
   244 00006250 E882000000          <1> 	call	CMOS_WRITE		; UPDATE ADDRESS
   245                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   246                              <1> 	;mov	ah, al
   247 00006255 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
   248 00006259 E8A4010000          <1> 	call	CMOS_READ		; READ CURRENT TIME
   249 0000625E 2462                <1> 	and	al, 01100010b		; MASK FOR VALID BIT POSITIONS
   250 00006260 0C02                <1> 	or	al, 00000010b		; TURN ON 24 HOUR MODE
   251 00006262 80E201              <1> 	and	dl, 00000001b		; USE ONLY THE DSE BIT
   252 00006265 08D0                <1> 	or	al, dl			; GET DAY LIGHT SAVINGS TIME BIT (OSE)
   253 00006267 86E0                <1> 	xchg	ah, al			; PLACE IN WORK REGISTER AND GET ADDRESS
   254                              <1> 	;call	CMOS_WRITE		; SET NEW ALARM SITS
   255                              <1> 	;clc				; SET CY= 0
   256                              <1> 	;retn				; RETURN WITH CY= 0
   257                              <1> 	; 29/07/2022
   258 00006269 EB6C                <1> 	jmp	short CMOS_WRITE
   259                              <1> 
   260                              <1> RTC_40:				; GET RTC DATE
   261 0000626B E85C010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   262                              <1> 	;jc	short RTC_49		; EXIT IF ERROR (CY= 1)
   263                              <1> 	; 07/08/2022
   264 00006270 72BB                <1> 	jc	short RTC_29
   265                              <1> 
   266 00006272 B007                <1> 	mov	al, CMOS_DAY_MONTH	; ADDRESS DAY OF MONTH
   267 00006274 E889010000          <1> 	call	CMOS_READ		; READ DAY OF MONTH
   268 00006279 88C2                <1> 	mov	dl, al			; SAVE
   269 0000627B B008                <1> 	mov	al, CMOS_MONTH		; ADDRESS MONTH
   270 0000627D E880010000          <1> 	call	CMOS_READ		; READ MONTH
   271 00006282 88C6                <1> 	mov	dh, al			; SAVE
   272 00006284 B009                <1> 	mov	al, CMOS_YEAR		; ADDRESS YEAR
   273 00006286 E877010000          <1> 	call	CMOS_READ		; READ YEAR
   274 0000628B 88C1                <1> 	mov	cl, al			; SAVE
   275 0000628D B032                <1> 	mov	al, CMOS_CENTURY	; ADDRESS CENTURY LOCATION
   276                              <1> ; 29/07/2022
   277                              <1> ;	call	CMOS_READ		; GET CENTURY BYTE
   278                              <1> ;	mov	ch, al			; SAVE
   279                              <1> ;	; 29/07/2022
   280                              <1> ;	;clc				; SET CY=0
   281                              <1> ;RTC_49:
   282                              <1> ;	retn				; RETURN WITH RESULTS IN CARRY FLAG
   283                              <1> 
   284                              <1> 	; 29/07/2022
   285 0000628F EB95                <1> 	jmp	short RTC_41
   286                              <1> 
   287                              <1> 
   288                              <1> RTC_50:				; SET RTC DATE
   289 00006291 E836010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   290 00006296 7305                <1> 	jnc	short RTC_55		; GO AROUND IF NO ERROR
   291 00006298 E84A010000          <1> 	call	RTC_STA			; ELSE INITIALIZE CLOCK
   292                              <1> RTC_55:
   293 0000629D 66B80600            <1> 	mov	ax, CMOS_DAY_WEEK	; ADDRESS OF DAY OF WEEK BYTE
   294 000062A1 E831000000          <1> 	call	CMOS_WRITE		; LOAD ZEROS TO DAY OF WEEK
   295 000062A6 88D4                <1> 	mov	ah, dl			; GET DAY OF MONTH BYTE
   296 000062A8 B007                <1> 	mov	al, CMOS_DAY_MONTH	; ADDRESS DAY OF MONTH BYTE
   297 000062AA E828000000          <1> 	call	CMOS_WRITE		; WRITE OF DAY OF MONTH REGISTER
   298 000062AF 88F4                <1> 	mov	ah, dh			; GET MONTH
   299 000062B1 B008                <1> 	mov	al, CMOS_MONTH		; ADDRESS MONTH BYTE
   300 000062B3 E81F000000          <1> 	call	CMOS_WRITE		; WRITE MONTH REGISTER
   301 000062B8 88CC                <1> 	mov	ah, cl			; GET YEAR BYTE
   302 000062BA B009                <1> 	mov	al, CMOS_YEAR		; ADDRESS YEAR REGISTER
   303 000062BC E816000000          <1> 	call	CMOS_WRITE		; WRITE YEAR REGISTER
   304 000062C1 88EC                <1> 	mov	ah, ch			; GET CENTURY BYTE
   305 000062C3 B032                <1> 	mov	al, CMOS_CENTURY	; ADDRESS CENTURY BYTE
   306 000062C5 E80D000000          <1> 	call	CMOS_WRITE		; WRITE CENTURY LOCATION
   307                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   308                              <1> 	;mov	ah, al
   309 000062CA 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
   310 000062CE E82F010000          <1> 	call	CMOS_READ		; READ CURRENT SETTINGS
   311 000062D3 247F                <1> 	and	al, 07Fh		; CLEAR 'SET BIT'
   312 000062D5 86E0                <1> 	xchg	ah, al			; MOVE TO WORK REGISTER
   313                              <1> 	;call	CMOS_WRITE		; AND START CLOCK UPDATING
   314                              <1> 	;clc				; SET CY= 0
   315                              <1> 	;retn				; RETURN CY=0
   316                              <1> 	; 29/07/2022
   317                              <1> 	;jmp	short CMOS_WRITE
   318                              <1> 
   319                              <1> ;-------------------------------------------------------------------------------
   320                              <1> 
   321                              <1> ; 08/08/2022
   322                              <1> ; 29/07/2022 (TRDOS 386 v2.0.5)
   323                              <1> ; 18/04/2021 (TRDOS 386 v2.0.4)
   324                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   325                              <1> 
   326                              <1> ;--- CMOS_WRITE ----------------------------------------------------------------
   327                              <1> ;	WRITE BYTE TO CMOS SYSTEM CLOCK CONFIGURATION TABLE		       :
   328                              <1> ;									       :
   329                              <1> ; INPUT: (AL)=	CMOS TABLE ADDRESS TO BE WRITTEN TO			       :
   330                              <1> ;		BIT    7 = 0 FOR NMI ENABLED AND 1 FOR NMI DISABLED ON EXIT    :
   331                              <1> ;		BITS 6-0 = ADDRESS OF TABLE LOCATION TO WRITE		       :
   332                              <1> ;	 (AH)=	NEW VALUE TO BE PLACED IN THE ADDRESSED TABLE LOCATION	       :
   333                              <1> ;									       :
   334                              <1> ; OUTPUT:	VALUE IN (AH) PLACED IN LOCATION (AL) WITH NMI LEFT DISABLED   :
   335                              <1> ;		IF BIT 7 OF (AL) IS ON, DURING THE CMOS UPDATE BOTH NMI AND    :
   336                              <1> ;		NORMAL INTERRUPTS ARE DISABLED TO PROTECT CMOS DATA INTEGRITY. :
   337                              <1> ;		THE CMOS ADDRESS REGISTER IS POINTED TO A DEFAULT VALUE AND    :
   338                              <1> ;		THE INTERRUPT FLAG RESTORED TO THE ENTRY STATE ON RETURN.      :
   339                              <1> ;		ONLY THE CMOS LOCATION AND THE NMI STATE IS CHANGED.	       :
   340                              <1> ;-------------------------------------------------------------------------------
   341                              <1> 
   342                              <1> 	; 08/08/2022
   343                              <1> CMOS_WRITE:				; WRITE (AH) TO LOCATION (AL)
   344                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
   345                              <1> 	;pushf				; SAVE INTERRUPT ENABLE STATUS AND FLAGS
   346                              <1> 	;;push	ax			; SAVE WORK REGISTER VALUES
   347                              <1> 	; 18/04/2021
   348                              <1> 	;push	eax
   349 000062D7 D0C0                <1> 	rol	al, 1			; MOVE NMI BIT TO LOW POSITION
   350 000062D9 F9                  <1> 	stc				; FORCE NMI BIT ON IN CARRY FLAG
   351 000062DA D0D8                <1> 	rcr	al, 1			; HIGH BIT ON TO DISABLE NMI - OLD IN CY
   352 000062DC FA                  <1> 	cli				; DISABLE INTERRUPTS
   353 000062DD E670                <1> 	out	CMOS_PORT, al		; ADDRESS LOCATION AND DISABLE NMI
   354 000062DF 88E0                <1> 	mov	al, ah			; GET THE DATA BYTE TO WRITE
   355 000062E1 E671                <1> 	out	CMOS_DATA, al		; PLACE IN REQUESTED CMOS LOCATION
   356 000062E3 B01E                <1> 	mov	al, CMOS_SHUT_DOWN*2	; GET ADDRESS OF DEFAULT LOCATION
   357                              <1> 	;mov	al, CMOS_REG_D*2 	; GET ADDRESS OF DEFAULT LOCATION
   358 000062E5 D0D8                <1> 	rcr	al, 1			; PUT ORIGINAL NMI MASK BIT INTO ADDRESS
   359 000062E7 E670                <1> 	out	CMOS_PORT, al		; SET DEFAULT TO READ ONLY REGISTER
   360                              <1> 	;nop				; I/O DELAY
   361                              <1> 	; 29/07/2022
   362 000062E9 E6EB                <1> 	out	0EBh, al ; NEWIODELAY ; AWARD BIOS 1999, ATIME.ASM
   363 000062EB E471                <1> 	in	al, CMOS_DATA		; OPEN STANDBY LATCH
   364                              <1> 	;;pop	ax			; RESTORE WORK REGISTERS
   365                              <1> 	; 18/04/2021
   366                              <1> 	;pop	eax
   367                              <1> 	;popf
   368                              <1> 	; 29/07/2022
   369                              <1> 	;clc
   370                              <1> 	; 08/08/2022
   371 000062ED 30C0                <1> 	xor	al, al
   372 000062EF C3                  <1> 	retn
   373                              <1> 
   374                              <1> ;-------------------------------------------------------------------------------
   375                              <1> 
   376                              <1> RTC_60:				; SET RTC ALARM
   377 000062F0 B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM
   378 000062F2 E80B010000          <1> 	call	CMOS_READ		; READ ALARM REGISTER
   379 000062F7 A820                <1> 	test	al, 20h			; CHECK FOR ALARM ALREADY ENABLED
   380 000062F9 F9                  <1> 	stc				; SET CARRY IN CASE OF ERROR
   381 000062FA 7541                <1> 	jnz	short RTC_69		; ERROR EXIT IF ALARM SET
   382 000062FC E8CB000000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   383 00006301 7305                <1> 	jnc	short RTC_65		; SKIP INITIALIZATION IF NO ERROR
   384 00006303 E8DF000000          <1> 	call	RTC_STA			; ELSE INITIALIZE CLOCK
   385                              <1> RTC_65:	
   386 00006308 88F4                <1> 	mov	ah, dh			; GET SECONDS BYTE
   387 0000630A B001                <1> 	mov	al, CMOS_SEC_ALARM	; ADDRESS THE SECONDS ALARM REGISTER
   388 0000630C E8C6FFFFFF          <1> 	call	CMOS_WRITE		; INSERT SECONDS
   389 00006311 88CC                <1> 	mov	ah, cl			; GET MINUTES PARAMETER
   390 00006313 B003                <1> 	mov	al, CMOS_MIN_ALARM	; ADDRESS MINUTES ALARM REGISTER
   391 00006315 E8BDFFFFFF          <1> 	call	CMOS_WRITE		; INSERT MINUTES
   392 0000631A 88EC                <1> 	mov	ah, ch			; GET HOURS PARAMETER
   393 0000631C B005                <1> 	mov	al, CMOS_HR_ALARM	; ADDRESS HOUR ALARM REGISTER
   394 0000631E E8B4FFFFFF          <1> 	call	CMOS_WRITE		; INSERT HOURS
   395 00006323 E4A1                <1> 	in	al, INTB01		; READ SECOND INTERRUPT MASK REGISTER
   396 00006325 24FE                <1> 	and	al, 0FEh		; ENABLE ALARM TIMER BIT (CY= 0)
   397 00006327 E6A1                <1> 	out	INTB01, al		; WRITE UPDATED MASK
   398                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   399                              <1> 	;mov	ah, al
   400 00006329 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
   401 0000632D E8D0000000          <1> 	call	CMOS_READ		; READ CURRENT ALARM REGISTER
   402 00006332 247F                <1> 	and	al, 07Fh		; ENSURE SET BIT TURNED OFF
   403 00006334 0C20                <1> 	or	al, 20h			; TURN ON ALARM ENABLE
   404 00006336 86E0                <1> 	xchg	ah, al			; MOVE MASK TO OUTPUT REGISTER
   405 00006338 E89AFFFFFF          <1> 	call	CMOS_WRITE		; WRITE NEW ALARM MASK
   406                              <1> 	; 29/07/2022
   407                              <1> 	;clc				; SET CY= 0
   408                              <1> RTC_69:
   409 0000633D 66B80000            <1> 	mov	ax, 0			; CLEAR AX REGISTER
   410 00006341 C3                  <1> 	retn				; RETURN WITH RESULTS IN CARRY FLAC
   411                              <1> 
   412                              <1> RTC_70:				; RESET ALARM
   413                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   414                              <1> 	;mov	ah, al
   415 00006342 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257	; ADDRESS ALARM REGISTER (TO BOTH AH,AL)
   416 00006346 E8B7000000          <1> 	call	CMOS_READ		; READ ALARM REGISTER
   417 0000634B 2457                <1> 	and	al, 57h			; TURN OFF ALARM ENABLE
   418 0000634D 86E0                <1> 	xchg	ah, al			; SAVE DATA AND RECOVER ADDRESS
   419                              <1> 	;call	CMOS_WRITE		; RESTORE NEW VALUE
   420                              <1> 	;clc				; SET CY= 0
   421                              <1> 	;retn				; RETURN WITH NO CARRY
   422                              <1> 	; 29/07/2022
   423 0000634F EB86                <1> 	jmp	short CMOS_WRITE
   424                              <1> 
   425                              <1> ;-------------------------------------------------------------------------------
   426                              <1> 
   427                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   428                              <1> 
   429                              <1> ;--- HARDWARE INT 70 H -- ( IRQ LEVEL 8) ----------------------------------------
   430                              <1> ; ALARM INTERRUPT HANDLER (RTC)							:
   431                              <1> ;       THIS ROUTINE HANDLES THE PERIODIC AND ALARM INTERRUPTS FROM THE CMOS	:
   432                              <1> ;       TIMER. INPUT FREQUENCY IS 1.024 KHZ OR APPROXIMATELY 1024 INTERRUPTS	:
   433                              <1> ;       EVERY SECOND FOR THE PERIODIC INTERRUPT. FOR THE ALARM FUNCTION,	:
   434                              <1> ;       THE INTERRUPT WILL OCCUR AT THE DESIGNATED TIME.			:
   435                              <1> ;										:
   436                              <1> ;       INTERRUPTS ARE ENABLED WHEN THE EVENT OR ALARM FUNCTION IS ACTIVATED.	:
   437                              <1> ;       FOR THE EVENT INTERRUPT, THE HANDLER WILL DECREMENT THE WAIT COUNTER	:
   438                              <1> ;       AND WHEN IT EXPIRES WILL SET THE DESIGNATED LOCATION TO 80H. FOR	:
   439                              <1> ;       THE ALARM INTERRUPT. THE USER MUST PROVIDE A ROUTINE TO INTERCEPT	:
   440                              <1> ;       THE CORRECT ADDRESS FROM THE VECTOR TABLE INVOKED BY INTERRUPT 4AH	:
   441                              <1> ;       PRIOR TO SETTING THE REAL TIME CLOCK ALARM (INT 1AH, AH= 06H).		:
   442                              <1> ;--------------------------------------------------------------------------------
   443                              <1> 
   444                              <1> RTC_A_INT: ; 07/01/2017
   445                              <1> ;RTC_INT:				; ALARM INTERRUPT
   446 00006351 1E                  <1> 	push	ds			; LEAVE INTERRUPTS DISABLED
   447 00006352 50                  <1> 	push	eax			; SAVE REGISTERS
   448 00006353 57                  <1> 	push	edi
   449                              <1> RTC_I_1:				; CHECK FOR SECOND INTERRUPT
   450 00006354 66B88C8B            <1> 	mov	ax, 256*(CMOS_REG_B+NMI)+CMOS_REG_C+NMI ; ALARM AND STATUS
   451 00006358 E670                <1> 	out	CMOS_PORT, al		; WRITE ALARM FLAG MASK ADDRESS
   452 0000635A 90                  <1> 	nop				; I/O DELAY
   453 0000635B EB00                <1> 	jmp	short $+2
   454 0000635D E471                <1> 	in	al, CMOS_DATA		; READ AND RESET INTERRUPT REQUEST FLAGS
   455 0000635F A860                <1> 	test	al, 01100000b		; CHECK FOR EITHER INTERRUPT PENDING
   456 00006361 745B                <1> 	jz	short	RTC_I_9		; EXIT IF NOT A VALID RTC INTERRUPT
   457                              <1> 
   458 00006363 86E0                <1> 	xchg	ah, al			; SAVE FLAGS AND GET ENABLE ADDRESS
   459 00006365 E670                <1> 	out	CMOS_PORT, al		; WRITE ALARM ENABLE MASK ADDRESS
   460 00006367 90                  <1> 	nop				; I/O DELAY
   461 00006368 EB00                <1> 	jmp	short $+2	
   462 0000636A E471                <1> 	in	al, CMOS_DATA		; READ CURRENT ALARM ENABLE MASK
   463 0000636C 20E0                <1> 	and	al, ah			; ALLOW ONLY SOURCES THAT ARE ENABLED
   464 0000636E A840                <1> 	test	al, 01000000b		; CHECK FOR PERIODIC INTERRUPT
   465 00006370 7439                <1> 	jz	short RTC_I_5		; SKIP IF NOT A PERIODIC INTERRUPT
   466                              <1> 
   467                              <1> ;-----	DECREMENT WAIT COUNT BY INTERRUPT INTERVAL
   468                              <1> 
   469 00006372 66BF1000            <1> 	mov	di, KDATA		; kernel data segment
   470 00006376 8EDF                <1> 	mov	ds, di
   471                              <1> 	
   472 00006378 812D[00780100]D003- <1> 	sub	dword [RTC_LH], 976	; DECREMENT COUNT BY 1/1024
   472 00006380 0000                <1>
   473 00006382 7327                <1> 	jnc	short RTC_I_5		; SKIP TILL 32 BIT WORD LESS THAN ZERO
   474                              <1> 
   475                              <1> ;-----	TURN OFF PERIODIC INTERRUPT ENABLE
   476                              <1> 
   477                              <1> 	;push	ax			; SAVE INTERRUPT FLAG MASK
   478                              <1> 	; 18/04/2021
   479 00006384 50                  <1> 	push	eax
   480 00006385 66B88B8B            <1> 	mov	ax, 257*(CMOS_REG_B+NMI) ; INTERRUPT ENABLE REGISTER
   481 00006389 E670                <1> 	out	CMOS_PORT, al		; WRITE ADDRESS TO CMOS CLOCK
   482 0000638B 90                  <1> 	nop				; I/O DELAY
   483 0000638C EB00                <1> 	jmp	short $+2
   484 0000638E E471                <1> 	in	al, CMOS_DATA		; READ CURRENT ENABLES
   485 00006390 24BF                <1> 	and	al, 0BFh		; TURN OFF PIE
   486 00006392 86C4                <1> 	xchg	al, ah			; GET CMOS ADDRESS AND SAVE VALUE
   487 00006394 E670                <1> 	out	CMOS_PORT, al		; ADDRESS REGISTER B
   488 00006396 86C4                <1> 	xchg	al, ah			; GET NEW INTERRUPT ENABLE MASK
   489 00006398 E671                <1> 	out	CMOS_DATA, al		; SET MASK IN INTERRUPT ENABLE REGISTER
   490 0000639A C605[04780100]00    <1> 	mov	byte [RTC_WAIT_FLAG], 0	; SET FUNCTION ACTIVE FLAG OFF
   491 000063A1 8B3D[05780100]      <1> 	mov	edi, [USER_FLAG]	; SET UP (DS:DI) TO POINT TO USER FLAG
   492 000063A7 C60780              <1> 	mov	byte [edi], 80h		; TURN ON USERS FLAG
   493                              <1> 	;pop	ax			; GET INTERRUPT SOURCE BACK
   494                              <1> 	; 18/04/2021
   495 000063AA 58                  <1> 	pop	eax
   496                              <1> RTC_I_5:
   497 000063AB A820                <1> 	test	al, 00100000b		; TEST FOR ALARM INTERRUPT
   498 000063AD 740D                <1> 	jz	short RTC_I_7		; SKIP USER INTERRUPT CALL IF NOT ALARM
   499                              <1> 
   500 000063AF B00D                <1> 	mov	al, CMOS_REG_D		; POINT TO DEFAULT READ ONLY REGISTER
   501 000063B1 E670                <1> 	out	CMOS_PORT, al		; ENABLE NMI AND CMOS ADDRESS TO DEFAULT
   502 000063B3 FB                  <1> 	sti				; INTERRUPTS BACK ON NOW
   503 000063B4 52                  <1> 	push	edx
   504 000063B5 E88CBB0000          <1> 	call	INT4Ah			; TRANSFER TO USER ROUTINE
   505 000063BA 5A                  <1> 	pop	edx
   506 000063BB FA                  <1> 	cli				; BLOCK INTERRUPT FOR RETRY
   507                              <1> RTC_I_7:				; RESTART ROUTINE TO HANDLE DELAYED
   508 000063BC EB96                <1> 	jmp	short RTC_I_1		;  ENTRY AND SECOND EVENT BEFORE DONE
   509                              <1> 
   510                              <1> RTC_I_9:				; EXIT - NO PENDING INTERRUPTS
   511 000063BE B00D                <1> 	mov	al, CMOS_REG_D		; POINT TO DEFAULT READ ONLY REGISTER
   512 000063C0 E670                <1> 	out	CMOS_PORT, al		; ENABLE NMI AND CMOS ADDRESS TO DEFAULT
   513 000063C2 B020                <1> 	mov	al, EOI			; END OF INTERRUPT MASK TO 8259 - 2
   514 000063C4 E6A0                <1> 	out	INTB00, al		; TO 8259 - 2
   515 000063C6 E620                <1> 	out	INTA00,	al		; TO 8259 - 1
   516 000063C8 5F                  <1> 	pop	edi			; RESTORE REGISTERS
   517 000063C9 58                  <1> 	pop	eax
   518 000063CA 1F                  <1> 	pop	ds
   519 000063CB CF                  <1> 	iretd				; END OF INTERRUPT
   520                              <1> 
   521                              <1> ;-------------------------------------------------------------------------------
   522                              <1> 
   523                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
   524                              <1> 	; 22/08/2014 (Retro UNIX 386 v1)
   525                              <1> 	; IBM PC/AT BIOS source code ----- 10/06/85 (bios2.asm)
   526                              <1> UPD_IPR:				; WAIT TILL UPDATE NOT IN PROGRESS
   527 000063CC 51                  <1> 	push	ecx
   528                              <1> 
   529                              <1> 	; 29/05/2016
   530 000063CD B968110000          <1> 	mov	ecx, ((1984+244)*4)/2	; AWARD BIOS 1999, ATIME.ASM		
   531                              <1> 					; 'WAITCPU_CK_UD_STAT'
   532                              <1> 					; (244Us + 1984Us)
   533                              <1> 					; (assume each read takes
   534                              <1> 					;  2 microseconds).
   535                              <1> 	;mov	ecx, 65535		
   536                              <1> 		;mov cx, 800		; SET TIMEOUT LOOP COUNT (= 800)	
   537                              <1> UPD_10:
   538 000063D2 B00A                <1> 	mov	al, CMOS_REG_A		; ADDRESS STATUS REGISTER A
   539 000063D4 FA                  <1> 	cli				; NO TIMER INTERRUPTS DURING UPDATES
   540 000063D5 E828000000          <1> 	call	CMOS_READ		; READ UPDATE IN PROCESS FLAG
   541 000063DA A880                <1> 	test	al, 80h			; IF UIP BIT IS ON ( CANNOT READ TIME )
   542 000063DC 7406                <1> 	jz	short UPD_90		; EXIT WITH CY= 0 IF CAN READ CLOCK NOW
   543 000063DE FB                  <1> 	sti				; ALLOW INTERRUPTS WHILE WAITING
   544 000063DF E2F1                <1> 	loop	UPD_10			; LOOP TILL READY OR TIMEOUT
   545 000063E1 31C0                <1> 	xor	eax, eax ; xor ax, ax	; CLEAR RESULTS IF ERROR
   546 000063E3 F9                  <1> 	stc				; SET CARRY FOR ERROR
   547                              <1> UPD_90:
   548 000063E4 59                  <1> 	pop	ecx			; RESTORE CALLERS REGISTER
   549 000063E5 FA                  <1> 	cli				; INTERRUPTS OFF DURING SET
   550 000063E6 C3                  <1> 	retn				; RETURN WITH CY FLAG SET
   551                              <1> 
   552                              <1> 	; 18/04/2021
   553                              <1> RTC_STA:			; INITIALIZE REAL TIME CLOCK
   554                              <1> 	;mov	al, CMOS_REG_A		; ADDRESS REGISTER A AND LOAD DATA MASK		
   555                              <1> 	;mov	ah, 26h
   556 000063E7 66B80A26            <1> 	mov	ax, (26h*100h)+CMOS_REG_A
   557 000063EB E8E7FEFFFF          <1> 	call	CMOS_WRITE		; INITIALIZE STATUS REGISTER A
   558                              <1> 	;mov	al, CMOS_REG_B		; SET "SET BIT" FOR CLOCK INITIALIZATION	
   559                              <1> 	;mov	ah, 82h
   560 000063F0 66B80B82            <1> 	mov	ax, (82h*100h)+CMOS_REG_B
   561 000063F4 E8DEFEFFFF          <1> 	call	CMOS_WRITE		; AND 24 HOUR MODE TO REGISTER B
   562 000063F9 B00C                <1> 	mov	al, CMOS_REG_C		; ADDRESS REGISTER C
   563 000063FB E802000000          <1> 	call	CMOS_READ		; READ REGISTER C TO INITIALIZE
   564 00006400 B00D                <1> 	mov	al, CMOS_REG_D		; ADDRESS REGISTER D
   565                              <1> 	; 18/04/2021
   566                              <1> 	;call	CMOS_READ		; READ REGISTER D TO INITIALIZE
   567                              <1> 	;retn
   568                              <1> 	;jmp	short CMOS_READ ; 18/04/2021
   569                              <1> 
   570                              <1> ;-------------------------------------------------------------------------------
   571                              <1> 
   572                              <1> 	; 29/07/2022 - TRDOS 386 v2.0.5
   573                              <1> 	; 18/04/2021 - TRDOS 386 v2.0.4
   574                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0) 
   575                              <1> 	; 22/08/2014 (Retro UNIX 386 v1)
   576                              <1> 	; IBM PC/AT BIOS source code ----- 10/06/85 (test4.asm)
   577                              <1> 
   578                              <1> ;--- CMOS_READ -----------------------------------------------------------------
   579                              <1> ;		READ BYTE FROM CMOS_SYSTEM CLOCK CONFIGURATION TABLE	       :
   580                              <1> ;									       :
   581                              <1> ; INPUT: (AL)=	CMOS_TABLE ADDRESS TO BE READ				       :
   582                              <1> ;		BIT    7 = 0 FOR NMI ENABLED AND 1 FOR NMI DISABLED ON EXIT    :
   583                              <1> ;		BITS 6-0 = ADDRESS OF TABLE LOCATION TO READ		       :
   584                              <1> ;									       :
   585                              <1> ; OUTPUT: (AL)	VALUE AT LOCATION (AL) MOVED INTO (AL). IF BIT 7 OF (AL) WAS   :
   586                              <1> ;		ON THEN NMI LEFT DISABLED, DURING THE CMOS READ BOTH NMI AND   :
   587                              <1> ;		NORMAL INTERRUPTS ARE DISABLED TO PROTECT CMOS DATA INTEGRITY. :
   588                              <1> ;		THE CMOS ADDRESS REGISTER IS POINTED TO A DEFAULT VALUE AND    :
   589                              <1> ;		THE INTERRUPT FLAG RESTORED TO THE ENTRY STATE ON RETURN.      :
   590                              <1> ;		ONLY THE (AL) REGISTER AND THE NMI STATE IS CHANGED.	       :
   591                              <1> ;-------------------------------------------------------------------------------
   592                              <1> 
   593                              <1> CMOS_READ:
   594                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
   595                              <1> 	;pushf				; SAVE INTERRUPT ENABLE STATUS AND FLAGS
   596 00006402 D0C0                <1> 	rol	al, 1			; MOVE NMI BIT TO LOW POSITION
   597 00006404 F9                  <1> 	stc				; FORCE NMI BIT ON IN CARRY FLAG
   598 00006405 D0D8                <1> 	rcr	al, 1			; HIGH BIT ON TO DISABLE NMI - OLD IN CY
   599 00006407 FA                  <1> 	cli				; DISABLE INTERRUPTS
   600 00006408 E670                <1> 	out	CMOS_PORT, al		; ADDRESS LOCATION AND DISABLE NMI
   601                              <1> 	; 29/05/2016
   602                              <1> 	;nop				; I/O DELAY
   603 0000640A E6EB                <1> 	out	0EBh, al ; NEWIODELAY ; AWARD BIOS 1999, ATIME.ASM
   604                              <1> 	;
   605 0000640C E471                <1> 	in	al, CMOS_DATA		; READ THE REQUESTED CMOS LOCATION
   606                              <1> 	;push	ax	; SAVE (AH) REGISTER VALUE AND CMOS BYTE
   607                              <1> 	; 18/04/2021
   608 0000640E 50                  <1> 	push	eax
   609                              <1> 	; 15/03/2015 ; IBM PC/XT Model 286 BIOS source code 
   610                              <1> 		     ; ----- 10/06/85 (test4.asm)
   611 0000640F B01E                <1> 	mov	al, CMOS_SHUT_DOWN*2 	; GET ADDRESS OF DEFAULT LOCATION
   612                              <1> 	;mov	al, CMOS_REG_D*2 	; GET ADDRESS OF DEFAULT LOCATION
   613 00006411 D0D8                <1> 	rcr	al, 1			; PUT ORIGINAL NMI MASK BIT INTO ADDRESS
   614 00006413 E670                <1> 	out	CMOS_PORT, al		; SET DEFAULT TO READ ONLY REGISTER
   615                              <1> 	;pop	ax			; RESTORE (AH) AND (AL), CMOS BYTE
   616                              <1> 	; 18/04/2021
   617 00006415 58                  <1> 	pop	eax
   618                              <1> 	; 29/07/2022
   619                              <1> 	;popf
   620 00006416 F8                  <1> 	clc	; 29/07/2022	
   621 00006417 C3                  <1> 	retn				; RETURN WITH FLAGS RESTORED
   622                              <1> 
   623                              <1> ;-------------------------------------------------------------------------------
   624                              <1> 
   625                              <1> ; /// End Of TIMER FUNCTIONS ///
  3040                                  
  3041 00006418 90<rep 8h>              Align 16
  3042                                  
  3043                                  gdt:	; Global Descriptor Table
  3044                                  	; 02/12/2020
  3045                                  	; (30/07/2015, conforming cs)
  3046                                  	; (26/03/2015)
  3047                                  	; (24/03/2015, tss)
  3048                                  	; (19/03/2015)
  3049                                  	; (29/12/2013)
  3050                                  	;
  3051 00006420 0000000000000000        	dw 0, 0, 0, 0		; NULL descriptor
  3052                                  gdt_kcode:
  3053                                  	; 18/08/2014
  3054                                  			; 8h kernel code segment, base = 00000000h		
  3055                                  	;dw 0FFFFh, 0, 9E00h, 00CFh	; KCODE  ; 30/12/2016	 
  3056 00006428 FFFF0000009ACF00        	dw 0FFFFh, 0, 9A00h, 00CFh	; KCODE
  3057                                  gdt_kdata:
  3058                                  			; 10h kernel data segment, base = 00000000h	
  3059 00006430 FFFF00000092CF00        	dw 0FFFFh, 0, 9200h, 00CFh	; KDATA
  3060                                  gdt_ucode:
  3061                                  			; 1Bh user code segment, base address = 400000h ; CORE
  3062                                  	;dw 0FBFFh, 0, 0FE40h, 00CFh	; UCODE  ; 30/12/2016	
  3063 00006438 FFFB000040FACF00        	dw 0FBFFh, 0, 0FA40h, 00CFh	; UCODE
  3064                                  gdt_udata: 
  3065                                  			; 23h user data segment, base address = 400000h ; CORE
  3066 00006440 FFFB000040F2CF00        	dw 0FBFFh, 0, 0F240h, 00CFh	; UDATA
  3067                                  gdt_tss:
  3068                                  			; Task State Segment
  3069 00006448 6700                    	dw 0067h ; Limit = 103 ; (104-1, tss size = 104 byte, 
  3070                                  			       ;  no IO permission in ring 3)
  3071                                  gdt_tss0:
  3072 0000644A 0000                    	dw 0  ; TSS base address, bits 0-15 
  3073                                  gdt_tss1:
  3074 0000644C 00                      	db 0  ; TSS base address, bits 16-23 
  3075                                  	      		; 49h	
  3076 0000644D E9                      	db 11101001b ; 0E9h => P=1/DPL=11/0/1/0/B/1 --> B = Task is busy (1)
  3077 0000644E 00                      	db 0 ; G/0/0/AVL/LIMIT=0000 ; (Limit bits 16-19 = 0000) (G=0, 1 byte)
  3078                                  gdt_tss2:
  3079 0000644F 00                      	db 0  ; TSS base address, bits 24-31 
  3080                                  
  3081                                  	; 30/11/2020
  3082                                  	; 29/11/2020 - TRDOS v2.0.3
  3083                                  	; VESA VBE3 VIDE BIOS 32 BIT PMI SEGMENTS (16 bit segments)
  3084                                  			; 30h ; VBE3CS
  3085                                  _vbe3_CS:  ; vesa vbe3 bios uses this as code seg (same addr with _vbe3_DS)
  3086                                  	; limit = 65536, base addr = 0, P/DPL/1/Type/C/R/A = 9Ah, 16 bit
  3087 00006450 FFFF0000009A0000        	dw 0FFFFh, 0, 9A00h, 0 ; Note: base addr will be initialized
  3088                                  			; 38h ; VBE3BDS
  3089                                  _vbe3_BDS: ; vesa vbe3 bios uses this as equivalent of rombios data segment
  3090                                  	; limit = 1536, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  3091 00006458 FF05000000920000        	dw 05FFh, 0, 9200h, 0 ; Note: base addr will be initialized	
  3092                                  			; 40h ; VBE3A000 
  3093                                  _A0000Sel: ; VGA default video memory address
  3094                                  	; limit = 65536, base addr = 0A0000h, 16 bit
  3095 00006460 FFFF00000A920000        	dw 0FFFFh, 0, 920Ah, 0
  3096                                  			; 48h ; VBE3B000 
  3097                                  _B0000Sel: ; MDA (monochrome) video memory address
  3098                                  	; limit = 65536, base addr = 0B0000h, 16 bit
  3099 00006468 FFFF00000B920000        	dw 0FFFFh, 0, 920Bh, 0
  3100                                  			; 50h ; VBE3B800 
  3101                                  _B8000Sel: ; CGA video memory address
  3102                                  	; limit = 32768, base addr = 0B8000h, 16 bit
  3103 00006470 FF7F00800B920000        	dw 07FFFh, 8000h, 920Bh, 0
  3104                                  			; 58h ; VBE3DS 
  3105                                  _vbe3_DS: ; vesa vbe3 bios uses this as data seg (CodeSegSel in PMInfoBlock)
  3106                                  	; limit = 65536, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  3107 00006478 FFFF000000920000        	dw 0FFFFh, 0, 9200h, 0 ; Note: base addr will be initialized
  3108                                  			; 60h ; VBE3SS   
  3109                                  _vbe3_SS: ; kernel's stack segment but 16 bit version (same stack addr)
  3110                                  	; limit = 1024, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  3111 00006480 FF03000000920000        	dw 03FFh, 0, 9200h, 0 ; Note: base addr will be initialized
  3112                                  			; 68h ; VBE3ES 	
  3113                                  _vbe3_ES: ; extra 16 bit segment points to buffers in kernel's mem space
  3114                                  	; limit = 2048, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  3115 00006488 FF07000000920000        	dw 07FFh, 0, 9200h,0 ; Note: base addr will be initialized
  3116                                  			; 70h ; KODE16	
  3117                                  _16bit_CS: ; 16 bit code segment points to kernel's far return addr
  3118                                  	; limit = 16M, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  3119 00006490 FFFF0000009AFF00        	dw 0FFFFh, 0, 9A00h, 00FFh ; Note: base addr will be initialized
  3120                                  
  3121                                  gdt_end:
  3122                                  	;; 9Eh = 1001 1110b (GDT byte 5) P=1/DPL=00/1/TYPE=1110, 
  3123                                  					;; Type= 1 (code)/C=1/R=1/A=0
  3124                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
  3125                                  		; 1= Code C= Conforming, R= Readable, A = Accessed
  3126                                  
  3127                                  	;; 9Ah = 1001 1010b (GDT byte 5) P=1/DPL=00/1/TYPE=1010, 
  3128                                  					;; Type= 1 (code)/C=0/R=1/A=0
  3129                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
  3130                                  		; 1= Code C= non-Conforming, R= Readable, A = Accessed
  3131                                  
  3132                                  	;; 92h = 1001 0010b (GDT byte 5) P=1/DPL=00/1/TYPE=1010, 
  3133                                  					;; Type= 0 (data)/E=0/W=1/A=0
  3134                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
  3135                                  		; 0= Data E= Expansion direction (1= down, 0= up)
  3136                                  		; W= Writeable, A= Accessed
  3137                                  
  3138                                  	;; FEh = 1111 1110b (GDT byte 5) P=1/DPL=11/1/TYPE=1110, 
  3139                                  					;; Type= 1 (code)/C=1/R=1/A=0
  3140                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
  3141                                  		; 1= Code C= Conforming, R= Readable, A = Accessed
  3142                                  	
  3143                                  	;; FAh = 1111 1010b (GDT byte 5) P=1/DPL=11/1/TYPE=1010, 
  3144                                  					;; Type= 1 (code)/C=0/R=1/A=0
  3145                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
  3146                                  		; 1= Code C= non-Conforming, R= Readable, A = Accessed
  3147                                  
  3148                                  	;; F2h = 1111 0010b (GDT byte 5) P=1/DPL=11/1/TYPE=0010, 
  3149                                  					;; Type= 0 (data)/E=0/W=1/A=0
  3150                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
  3151                                  		; 0= Data E= Expansion direction (1= down, 0= up)
  3152                                  	
  3153                                  	;; CFh = 1100 1111b (GDT byte 6) G=1/B=1/0/AVL=0, Limit=1111b (3)
  3154                                  
  3155                                  		;; Limit = FFFFFh (=> FFFFFh+1= 100000h) // bits 0-15, 48-51 //
  3156                                  		;	 = 100000h * 1000h (G=1) = 4GB
  3157                                  		;; Limit = FFBFFh (=> FFBFFh+1= FFC00h) // bits 0-15, 48-51 //
  3158                                  		;	 = FFC00h * 1000h (G=1) = 4GB - 4MB
  3159                                  		; G= Granularity (1= 4KB), B= Big (32 bit), 
  3160                                  		; AVL= Available to programmers	
  3161                                  
  3162                                  gdtd:
  3163 00006498 7700                            dw gdt_end - gdt - 1    ; Limit (size)
  3164 0000649A [20640000]                      dd gdt			; Address of the GDT
  3165                                  
  3166                                  	; 20/08/2014
  3167                                  idtd:
  3168 0000649E 7F02                            dw idt_end - idt - 1    ; Limit (size)
  3169 000064A0 [A0740100]                      dd idt			; Address of the IDT
  3170                                  
  3171                                  ; 20/02/2017
  3172                                  ;;; 11/03/2015
  3173                                  %include 'diskdata.s'	; DISK (BIOS) DATA (initialized)
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - diskdata.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 06/08/2022 (Previous: 24/01/2016)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; diskdata.inc (11/03/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - DISKDATA.INC
    20                              <1> ; Last Modification: 11/03/2015
    21                              <1> ;	(Initialized Disk Parameters Data section for 'DISKIO.INC') 
    22                              <1> ;
    23                              <1> 
    24                              <1> ;----------------------------------------
    25                              <1> ;	80286 INTERRUPT LOCATIONS	:
    26                              <1> ;	REFERENCED BY POST & BIOS	:
    27                              <1> ;----------------------------------------
    28                              <1> 
    29 000064A4 [07650000]          <1> DISK_POINTER:	dd	MD_TBL6		; Pointer to Diskette Parameter Table
    30                              <1> 
    31                              <1> ; IBM PC-XT Model 286 source code ORGS.ASM (06/10/85) - 14/12/2014
    32                              <1> ;----------------------------------------------------------------
    33                              <1> ; DISK_BASE							:
    34                              <1> ;	THIS IS THE SET OF PARAMETERS REQUIRED FOR		:
    35                              <1> ;	DISKETTE OPERATION. THEY ARE POINTED AT BY THE		:
    36                              <1> ;	DATA VARIABLE @DISK_POINTER. TO MODIFY THE PARAMETERS,	:
    37                              <1> ;	BUILD ANOTHER PARAMETER BLOCK AND POINT AT IT		:
    38                              <1> ;----------------------------------------------------------------
    39                              <1> 
    40                              <1> ;DISK_BASE:	
    41                              <1> ;	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
    42                              <1> ;	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
    43                              <1> ;	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
    44                              <1> ;	DB	2		; 512 BYTES/SECTOR
    45                              <1> ;	;DB	15		; EOT (LAST SECTOR ON TRACK)
    46                              <1> ;	db	18		; (EOT for 1.44MB diskette)
    47                              <1> ;	DB	01BH		; GAP LENGTH
    48                              <1> ;	DB	0FFH		; DTL
    49                              <1> ;	;DB	054H		; GAP LENGTH FOR FORMAT
    50                              <1> ;	db	06ch		; (for 1.44MB dsikette)
    51                              <1> ;	DB	0F6H		; FILL BYTE FOR FORMAT
    52                              <1> ;	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
    53                              <1> ;	DB	8		; MOTOR START TIME (1/8 SECONDS)
    54                              <1> 
    55                              <1> ;----------------------------------------
    56                              <1> ;	ROM BIOS DATA AREAS		:
    57                              <1> ;----------------------------------------
    58                              <1> 
    59                              <1> ;DATA		SEGMENT AT 40H		; ADDRESS= 0040:0000
    60                              <1> 
    61                              <1> ;@EQUIP_FLAG	DW	?		; INSTALLED HARDWARE FLAGS
    62                              <1> 
    63                              <1> ;----------------------------------------
    64                              <1> ;	DISKETTE DATA AREAS		:
    65                              <1> ;----------------------------------------
    66                              <1> 
    67                              <1> ;@SEEK_STATUS	DB	?		; DRIVE RECALIBRATION STATUS
    68                              <1> ;					; BIT 3-0 = DRIVE 3-0 RECALIBRATION
    69                              <1> ;					; BEFORE NEXT SEEK IF BIT IS = 0
    70                              <1> ;@MOTOR_STATUS	DB	?		; MOTOR STATUS
    71                              <1> ;					; BIT 3-0 = DRIVE 3-0 CURRENTLY RUNNING
    72                              <1> ;					; BIT 7 = CURRENT OPERATION IS A WRITE
    73                              <1> ;@MOTOR_COUNT	DB	?		; TIME OUT COUNTER FOR MOTOR(S) TURN OFF
    74                              <1> ;@DSKETTE_STATUS DB	?		; RETURN CODE STATUS BYTE
    75                              <1> ;					; CMD_BLOCK  IN STACK FOR DISK OPERATION
    76                              <1> ;@NEC_STATUS	DB	7 DUP(?)	; STATUS BYTES FROM DISKETTE OPERATION
    77                              <1> 
    78                              <1> ;----------------------------------------
    79                              <1> ;	POST AND BIOS WORK DATA AREA	:
    80                              <1> ;----------------------------------------
    81                              <1> 
    82                              <1> ;@INTR_FLAG	DB	?		; FLAG INDICATING AN INTERRUPT HAPPENED
    83                              <1> 
    84                              <1> ;----------------------------------------
    85                              <1> ;	TIMER DATA AREA 		:
    86                              <1> ;----------------------------------------
    87                              <1> 
    88                              <1> ; 17/12/2014  (IRQ 0 - INT 08H)
    89                              <1> ;TIMER_LOW	equ	46Ch		; Timer ticks (counter)  @ 40h:006Ch
    90                              <1> ;TIMER_HIGH	equ	46Eh		; (18.2 timer ticks per second)
    91                              <1> ;TIMER_OFL	equ	470h		; Timer - 24 hours flag  @ 40h:0070h
    92                              <1> 
    93                              <1> ;----------------------------------------
    94                              <1> ;	ADDITIONAL MEDIA DATA		:
    95                              <1> ;----------------------------------------
    96                              <1> 
    97                              <1> ;@LASTRATE	DB	?		; LAST DISKETTE DATA RATE SELECTED
    98                              <1> ;@DSK_STATE	DB	?		; DRIVE 0 MEDIA STATE
    99                              <1> ;		DB	?		; DRIVE 1 MEDIA STATE
   100                              <1> ;		DB	?		; DRIVE 0 OPERATION START STATE
   101                              <1> ;		DB	?		; DRIVE 1 OPERATION START STATE
   102                              <1> ;@DSK_TRK	DB	?		; DRIVE 0 PRESENT CYLINDER
   103                              <1> ;		DB	?		; DRIVE 1 PRESENT CYLINDER
   104                              <1> 
   105                              <1> ;DATA		ENDS			; END OF BIOS DATA SEGMENT
   106                              <1> 
   107                              <1> ;--------------------------------------------------------
   108                              <1> ;	DRIVE TYPE TABLE				:
   109                              <1> ;--------------------------------------------------------
   110                              <1> 		; 16/02/2015 (unix386.s, 32 bit modifications)
   111                              <1> DR_TYPE:
   112 000064A8 01                  <1> 		DB	01		; DRIVE TYPE, MEDIA TABLE
   113                              <1>                 ;DW	MD_TBL1
   114 000064A9 [C6640000]          <1> 		dd	MD_TBL1
   115 000064AD 82                  <1> 		DB	02+BIT7ON
   116                              <1> 		;DW	MD_TBL2
   117 000064AE [D3640000]          <1>                 dd      MD_TBL2
   118 000064B2 02                  <1> DR_DEFAULT:	DB	02
   119                              <1>                 ;DW	MD_TBL3
   120 000064B3 [E0640000]          <1> 		dd      MD_TBL3
   121 000064B7 03                  <1> 		DB	03
   122                              <1>                 ;DW	MD_TBL4
   123 000064B8 [ED640000]          <1> 		dd      MD_TBL4
   124 000064BC 84                  <1> 		DB	04+BIT7ON
   125                              <1>                 ;DW	MD_TBL5
   126 000064BD [FA640000]          <1> 		dd      MD_TBL5
   127 000064C1 04                  <1> 		DB	04
   128                              <1>                 ;DW	MD_TBL6
   129 000064C2 [07650000]          <1> 		dd      MD_TBL6
   130                              <1> DR_TYPE_E       equ $                   ; END OF TABLE
   131                              <1> ;DR_CNT		EQU	(DR_TYPE_E-DR_TYPE)/3
   132                              <1> DR_CNT		equ	(DR_TYPE_E-DR_TYPE)/5
   133                              <1> ;--------------------------------------------------------
   134                              <1> ;	MEDIA/DRIVE PARAMETER TABLES			:
   135                              <1> ;--------------------------------------------------------
   136                              <1> ;--------------------------------------------------------
   137                              <1> ;	360 KB MEDIA IN 360 KB DRIVE			:
   138                              <1> ;--------------------------------------------------------
   139                              <1> MD_TBL1:        
   140 000064C6 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   141 000064C7 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   142 000064C8 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   143 000064C9 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   144 000064CA 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   145 000064CB 2A                  <1> 	DB	02AH		; GAP LENGTH
   146 000064CC FF                  <1> 	DB	0FFH		; DTL
   147 000064CD 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   148 000064CE F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   149 000064CF 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   150 000064D0 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   151 000064D1 27                  <1> 	DB	39		; MAX. TRACK NUMBER
   152 000064D2 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
   153                              <1> ;--------------------------------------------------------
   154                              <1> ;	360 KB MEDIA IN 1.2 MB DRIVE			:
   155                              <1> ;--------------------------------------------------------
   156                              <1> MD_TBL2:        
   157 000064D3 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   158 000064D4 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   159 000064D5 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   160 000064D6 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   161 000064D7 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   162 000064D8 2A                  <1> 	DB	02AH		; GAP LENGTH
   163 000064D9 FF                  <1> 	DB	0FFH		; DTL
   164 000064DA 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   165 000064DB F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   166 000064DC 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   167 000064DD 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   168 000064DE 27                  <1> 	DB	39		; MAX. TRACK NUMBER
   169 000064DF 40                  <1> 	DB	RATE_300	; DATA TRANSFER RATE
   170                              <1> ;--------------------------------------------------------
   171                              <1> ;	1.2 MB MEDIA IN 1.2 MB DRIVE			:
   172                              <1> ;--------------------------------------------------------
   173                              <1> MD_TBL3:
   174 000064E0 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   175 000064E1 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   176 000064E2 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   177 000064E3 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   178 000064E4 0F                  <1> 	DB	15		; EOT (LAST SECTOR ON TRACK)
   179 000064E5 1B                  <1> 	DB	01BH		; GAP LENGTH
   180 000064E6 FF                  <1> 	DB	0FFH		; DTL
   181 000064E7 54                  <1> 	DB	054H		; GAP LENGTH FOR FORMAT
   182 000064E8 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   183 000064E9 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   184 000064EA 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   185 000064EB 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   186 000064EC 00                  <1> 	DB	RATE_500	; DATA TRANSFER RATE
   187                              <1> ;--------------------------------------------------------
   188                              <1> ;	720 KB MEDIA IN 720 KB DRIVE			:
   189                              <1> ;--------------------------------------------------------
   190                              <1> MD_TBL4:
   191 000064ED DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   192 000064EE 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   193 000064EF 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   194 000064F0 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   195 000064F1 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   196 000064F2 2A                  <1> 	DB	02AH		; GAP LENGTH
   197 000064F3 FF                  <1> 	DB	0FFH		; DTL
   198 000064F4 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   199 000064F5 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   200 000064F6 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   201 000064F7 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   202 000064F8 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   203 000064F9 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
   204                              <1> ;--------------------------------------------------------
   205                              <1> ;	720 KB MEDIA IN 1.44 MB DRIVE			:
   206                              <1> ;--------------------------------------------------------
   207                              <1> MD_TBL5:
   208 000064FA DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   209 000064FB 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   210 000064FC 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   211 000064FD 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   212 000064FE 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   213 000064FF 2A                  <1> 	DB	02AH		; GAP LENGTH
   214 00006500 FF                  <1> 	DB	0FFH		; DTL
   215 00006501 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   216 00006502 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   217 00006503 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   218 00006504 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   219 00006505 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   220 00006506 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
   221                              <1> ;--------------------------------------------------------
   222                              <1> ;	1.44 MB MEDIA IN 1.44 MB DRIVE			:
   223                              <1> ;--------------------------------------------------------
   224                              <1> MD_TBL6:
   225 00006507 AF                  <1> 	DB	10101111B	; SRT=A, HD UNLOAD=0F - 1ST SPECIFY BYTE
   226 00006508 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   227 00006509 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   228 0000650A 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   229 0000650B 12                  <1> 	DB	18		; EOT (LAST SECTOR ON TRACK)
   230 0000650C 1B                  <1> 	DB	01BH		; GAP LENGTH
   231 0000650D FF                  <1> 	DB	0FFH		; DTL
   232 0000650E 6C                  <1> 	DB	06CH		; GAP LENGTH FOR FORMAT
   233 0000650F F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   234 00006510 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   235 00006511 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   236 00006512 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   237 00006513 00                  <1> 	DB	RATE_500	; DATA TRANSFER RATE
   238                              <1> 
   239                              <1> 
   240                              <1> ; << diskette.inc >>
   241                              <1> ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   242                              <1> ;
   243                              <1> ;----------------------------------------
   244                              <1> ;	ROM BIOS DATA AREAS		:
   245                              <1> ;----------------------------------------
   246                              <1> 
   247                              <1> ;DATA		SEGMENT AT 40H		; ADDRESS= 0040:0000
   248                              <1> 
   249                              <1> ;----------------------------------------
   250                              <1> ;	FIXED DISK DATA AREAS		:
   251                              <1> ;----------------------------------------
   252                              <1> 
   253                              <1> ;DISK_STATUS1:	DB	0		; FIXED DISK STATUS
   254                              <1> ;HF_NUM:	DB	0		; COUNT OF FIXED DISK DRIVES
   255                              <1> ;CONTROL_BYTE:	DB	0		; HEAD CONTROL BYTE
   256                              <1> ;@PORT_OFF	DB	?		; RESERVED (PORT OFFSET)
   257                              <1> 
   258                              <1> ;----------------------------------------
   259                              <1> ;	ADDITIONAL MEDIA DATA		:
   260                              <1> ;----------------------------------------
   261                              <1> 
   262                              <1> ;@LASTRATE	DB	?		; LAST DISKETTE DATA RATE SELECTED
   263                              <1> ;HF_STATUS	DB	0		; STATUS REGISTER
   264                              <1> ;HF_ERROR	DB	0		; ERROR REGISTER
   265                              <1> ;HF_INT_FLAG	DB	0		; FIXED DISK INTERRUPT FLAG
   266                              <1> ;HF_CNTRL	DB	0		; COMBO FIXED DISK/DISKETTE CARD BIT 0=1
   267                              <1> ;@DSK_STATE	DB	?		; DRIVE 0 MEDIA STATE
   268                              <1> ;		DB	?		; DRIVE 1 MEDIA STATE
   269                              <1> ;		DB	?		; DRIVE 0 OPERATION START STATE
   270                              <1> ;		DB	?		; DRIVE 1 OPERATION START STATE
   271                              <1> ;@DSK_TRK	DB	?		; DRIVE 0 PRESENT CYLINDER
   272                              <1> ;		DB	?		; DRIVE 1 PRESENT CYLINDER
   273                              <1> 
   274                              <1> ;DATA		ENDS			; END OF BIOS DATA SEGMENT
   275                              <1> ;
   276                              <1> ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   277                              <1> 
   278                              <1> ERR_TBL:
   279 00006514 E0                  <1> 	db	NO_ERR
   280 00006515 024001BB            <1> 	db	BAD_ADDR_MARK,BAD_SEEK,BAD_CMD,UNDEF_ERR
   281 00006519 04BB100A            <1> 	db	RECORD_NOT_FND,UNDEF_ERR,BAD_ECC,BAD_SECTOR
   282                              <1> 
   283                              <1> ; 06/08/2022
   284                              <1> ; 17/12/2014 (mov ax, [cfd])
   285                              <1> ; 11/12/2014
   286                              <1> ;cfd:		db	0		; current floppy drive (for GET_PARM)
   287                              <1> ; 17/12/2014				; instead of 'DISK_POINTER'
   288                              <1> ;pfd:		db	1		; previous floppy drive (for GET_PARM)
   289                              <1> 					; (initial value of 'pfd 
   290                              <1> 					; must be different then 'cfd' value
   291                              <1> 					; to force updating/initializing
   292                              <1> 					; current drive parameters) 
   293                              <1> ; 06/08/2022 - TRDOS 386 Kernel v2.0.5
   294                              <1> ; 11/07/2022 - Retro UNIX 386 v1.1 (Kernel v0.2.1.5)
   295 0000651D FF                  <1> pfd:		db	0FFh
   296                              <1> 
   297                              <1> align 2
   298                              <1> 
   299 0000651E F001                <1> HF_PORT:	dw 	1F0h  ; Default = 1F0h
   300                              <1> 			      ; (170h)
   301 00006520 F603                <1> HF_REG_PORT:	dw	3F6h  ; HF_PORT + 206h
   302                              <1> 
   303                              <1> ; 05/01/2015 
   304 00006522 00                  <1> hf_m_s:         db      0     ; (0 = Master, 1 = Slave)
   305                              <1> 
   306                              <1> ; *****************************************************************************
  3174                                  
  3175 00006523 90                      Align 2
  3176                                  
  3177                                  ; 04/11/2014 (Retro UNIX 386 v1)
  3178 00006524 0000                    mem_1m_1k:   dw 0  ; Number of contiguous KB between
  3179                                                       ; 1 and 16 MB, max. 3C00h = 15 MB.
  3180 00006526 0000                    mem_16m_64k: dw 0  ; Number of contiguous 64 KB blocks
  3181                                  		   ; between 16 MB and 4 GB.
  3182                                  
  3183                                  ; 12/11/2014 (Retro UNIX 386 v1)
  3184 00006528 00                      boot_drv:    db 0 ; boot drive number (physical)
  3185                                  ; 24/11/2014
  3186 00006529 00                      drv:	     db 0 
  3187 0000652A 00                      last_drv:    db 0 ; last hdd
  3188 0000652B 00                      hdc:         db 0  ; number of hard disk drives
  3189                                  		     ; (present/detected)
  3190                                  
  3191                                  ; 24/11/2014 (Retro UNIX 386 v1)
  3192                                  ; Physical drive type & flags
  3193 0000652C 00                      fd0_type:    db 0  ; floppy drive type
  3194 0000652D 00                      fd1_type:    db 0  ; 4 = 1.44 Mb, 80 track, 3.5" (18 spt)
  3195                                  		     ; 6 = 2.88 Mb, 80 track, 3.5" (36 spt)
  3196                                  		     ; 3 = 720 Kb, 80 track, 3.5" (9 spt)
  3197                                  		     ; 2 = 1.2 Mb, 80 track, 5.25" (15 spt)
  3198                                  		     ; 1 = 360 Kb, 40 track, 5.25" (9 spt)		
  3199 0000652E 00                      hd0_type:    db 0  ; EDD status for hd0 (bit 7 = present flag)
  3200 0000652F 00                      hd1_type:    db 0  ; EDD status for hd1 (bit 7 = present flag)
  3201 00006530 00                      hd2_type:    db 0  ; EDD status for hd2 (bit 7 = present flag)
  3202 00006531 00                      hd3_type:    db 0  ; EDD status for hd3 (bit 7 = present flag)
  3203                                  		     ; bit 0 - Fixed disk access subset supported
  3204                                  		     ; bit 1 - Drive locking and ejecting
  3205                                  		     ; bit 2 - Enhanced disk drive support
  3206                                  		     ; bit 3 = Reserved (64 bit EDD support)
  3207                                  		     ; (If bit 0 is '1' Retro UNIX 386 v1
  3208                                  		     ; will interpret it as 'LBA ready'!)
  3209                                  
  3210                                  ; 08/08/2022
  3211                                  ; (drv.cylinders, drv.spt, drv.spt will not be used now on)
  3212                                  ; ('diskio.inc')
  3213                                  ; ((spt and heads and cylinder counts will be taken from DPT))
  3214                                  
  3215                                  ;; 11/03/2015 - 10/07/2015
  3216                                  ;drv.cylinders: dw 0,0,0,0,0,0,0
  3217                                  ;drv.heads:     dw 0,0,0,0,0,0,0
  3218                                  ;drv.spt:       dw 0,0,0,0,0,0,0
  3219                                  ; 12/07/2022 - 11/03/2015
  3220 00006532 000000000000000000-     drv.size:      dd 0,0,0,0,0,0,0
  3220 0000653B 000000000000000000-
  3220 00006544 000000000000000000-
  3220 0000654D 00                 
  3221 0000654E 00000000000000          drv.status:    db 0,0,0,0,0,0,0
  3222 00006555 00000000000000          drv.error:     db 0,0,0,0,0,0,0
  3223                                  ;
  3224                                  
  3225                                  Align 2
  3226                                  
  3227                                  ;;; 11/03/2015
  3228                                  %include 'kybdata.s'	; KEYBOARD (BIOS) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - kybdata.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 24/07/2022 (Previous: 17/01/2016)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 17/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; kybdata.inc (11/03/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - KYBDATA.INC
    20                              <1> ; Last Modification: 11/03/2015
    21                              <1> ;		 (Data Section for 'KEYBOARD.INC')	
    22                              <1> ;
    23                              <1> ; ///////// KEYBOARD DATA ///////////////
    24                              <1> 
    25                              <1> ; 24/07/2022 - TRDOS 386 Kernel v2.0.5
    26                              <1> ; 05/12/2014
    27                              <1> ; 04/12/2014 (derived from pc-xt-286 bios source code -1986-) 
    28                              <1> ; 03/06/86  KEYBOARD BIOS
    29                              <1> 
    30                              <1> ;---------------------------------------------------------------------------------
    31                              <1> ;	KEY IDENTIFICATION SCAN TABLES
    32                              <1> ;---------------------------------------------------------------------------------
    33                              <1> 
    34                              <1> ;-----	TABLES FOR ALT CASE ------------
    35                              <1> ;-----	ALT-INPUT-TABLE 
    36 0000655C 524F50514B          <1> K30:	db	82,79,80,81,75
    37 00006561 4C4D474849          <1> 	db	76,77,71,72,73		; 10 NUMBER ON KEYPAD
    38                              <1> ;-----	SUPER-SHIFT-TABLE 
    39 00006566 101112131415        <1> 	db	16,17,18,19,20,21	; A-Z TYPEWRITER CHARS
    40 0000656C 161718191E1F        <1> 	db	22,23,24,25,30,31
    41 00006572 202122232425        <1> 	db	32,33,34,35,36,37
    42 00006578 262C2D2E2F30        <1> 	db	38,44,45,46,47,48
    43 0000657E 3132                <1> 	db	49,50
    44                              <1> 
    45                              <1> ;-----	TABLE OF SHIFT KEYS AND MASK VALUES
    46                              <1> ;-----	KEY_TABLE 
    47 00006580 52                  <1> _K6:    db      INS_KEY                 ; INSERT KEY
    48 00006581 3A4546381D          <1> 	db	CAPS_KEY,NUM_KEY,SCROLL_KEY,ALT_KEY,CTL_KEY
    49 00006586 2A36                <1>         db      LEFT_KEY,RIGHT_KEY
    50                              <1> _K6L    equ     $-_K6
    51                              <1> 
    52                              <1> ;-----	MASK_TABLE
    53 00006588 80                  <1> _K7:    db      INS_SHIFT               ; INSERT MODE SHIFT
    54 00006589 4020100804          <1> 	db	CAPS_SHIFT,NUM_SHIFT,SCROLL_SHIFT,ALT_SHIFT,CTL_SHIFT
    55 0000658E 0201                <1> 	db	LEFT_SHIFT,RIGHT_SHIFT
    56                              <1> 
    57                              <1> ;-----	TABLES FOR CTRL CASE		;---- CHARACTERS ------
    58 00006590 1BFF00FFFFFF        <1> _K8:	db	27,-1,0,-1,-1,-1	; Esc, 1, 2, 3, 4, 5
    59 00006596 1EFFFFFFFF1F        <1> 	db 	30,-1,-1,-1,-1,31	; 6, 7, 8, 9, 0, -
    60                              <1> 	;db	-1,127,-1,17,23,5	; =, Bksp, Tab, Q, W, E
    61 0000659C FF7F94111705        <1> 	db	-1,127,148,17,23,5 ; 24/07/2022
    62 000065A2 12141915090F        <1> 	db	18,20,25,21,9,15	; R, T, Y, U, I, O
    63 000065A8 101B1D0AFF01        <1> 	db	16,27,29,10,-1,1	; P, [, ], Enter, Ctrl, A
    64 000065AE 13040607080A        <1> 	db	19,4,6,7,8,10		; S, D, F, G, H, J
    65 000065B4 0B0CFFFFFFFF        <1> 	db	11,12,-1,-1,-1,-1	; K, L, :, ', `, LShift
    66 000065BA 1C1A18031602        <1> 	db	28,26,24,3,22,2		; Bkslash, Z, X, C, V, B
    67 000065C0 0E0DFFFFFFFF        <1> 	db	14,13,-1,-1,-1,-1	; N, M, ,, ., /, RShift
    68 000065C6 96FF20FF            <1> 	db	150,-1,' ',-1		; *, ALT, Spc, CL
    69                              <1> 	;				;----- FUNCTIONS ------		
    70 000065CA 5E5F60616263        <1> 	db 	94,95,96,97,98,99	; F1 - F6
    71 000065D0 64656667FFFF        <1> 	db	100,101,102,103,-1,-1	; F7 - F10, NL, SL
    72 000065D6 778D848E738F        <1> 	db	119,141,132,142,115,143	; Home, Up, PgUp, -, Left, Pad5
    73 000065DC 749075917692        <1> 	db 	116,144,117,145,118,146 ; Right, +, End, Down, PgDn, Ins
    74 000065E2 93FFFFFF898A        <1> 	db	147,-1,-1,-1,137,138	; Del, SysReq, Undef, WT, F11, F12
    75                              <1> 
    76                              <1> ;-----	TABLES FOR LOWER CASE ----------
    77 000065E8 1B3132333435363738- <1> K10:	db 	27,'1234567890-=',8,9
    77 000065F1 39302D3D0809        <1>
    78 000065F7 71776572747975696F- <1> 	db 	'qwertyuiop[]',13,-1,'asdfghjkl;',39
    78 00006600 705B5D0DFF61736466- <1>
    78 00006609 67686A6B6C3B27      <1>
    79 00006610 60FF5C7A786376626E- <1> 	db	96,-1,92,'zxcvbnm,./',-1,'*',-1,' ',-1
    79 00006619 6D2C2E2FFF2AFF20FF  <1>
    80                              <1> ;-----	LC TABLE SCAN
    81 00006622 3B3C3D3E3F          <1> 	db	59,60,61,62,63		; BASE STATE OF F1 - F10
    82 00006627 4041424344          <1> 	db	64,65,66,67,68
    83 0000662C FFFF                <1> 	db	-1,-1			; NL, SL
    84                              <1> 
    85                              <1> ;-----	KEYPAD TABLE
    86 0000662E 474849FF4BFF        <1> K15:	db	71,72,73,-1,75,-1	; BASE STATE OF KEYPAD KEYS
    87 00006634 4DFF4F50515253      <1> 	db	77,-1,79,80,81,82,83
    88 0000663B FFFF5C8586          <1> 	db	-1,-1,92,133,134	; SysRq, Undef, WT, F11, F12
    89                              <1> 
    90                              <1> ;-----	TABLES FOR UPPER CASE ----------
    91 00006640 1B21402324255E262A- <1> K11:	db 	27,'!@#$%',94,'&*()_+',8,0
    91 00006649 28295F2B0800        <1>
    92 0000664F 51574552545955494F- <1> 	db 	'QWERTYUIOP{}',13,-1,'ASDFGHJKL:"'
    92 00006658 507B7D0DFF41534446- <1>
    92 00006661 47484A4B4C3A22      <1>
    93 00006668 7EFF7C5A584356424E- <1> 	db	126,-1,'|ZXCVBNM<>?',-1,'*',-1,' ',-1
    93 00006671 4D3C3E3FFF2AFF20FF  <1>
    94                              <1> ;-----	UC TABLE SCAN
    95 0000667A 5455565758          <1> K12:	db	84,85,86,87,88		; SHIFTED STATE OF F1 - F10
    96 0000667F 595A5B5C5D          <1> 	db	89,90,91,92,93
    97 00006684 FFFF                <1> 	db	-1,-1			; NL, SL
    98                              <1> 
    99                              <1> ;-----	NUM STATE TABLE
   100 00006686 3738392D3435362B31- <1> K14:	db 	'789-456+1230.'		; NUMLOCK STATE OF KEYPAD KEYS
   100 0000668F 3233302E            <1>
   101                              <1> 	;
   102 00006693 FFFF7C8788          <1> 	db	-1,-1,124,135,136	; SysRq, Undef, WT, F11, F12
   103                              <1> 
   104                              <1> ; 26/08/2014
   105                              <1> ; Retro UNIX 8086 v1 - UNIX.ASM (03/03/2014)
   106                              <1> ; Derived from IBM "pc-at" 
   107                              <1> ; rombios source code (06/10/1985)
   108                              <1> ; 'dseg.inc'
   109                              <1> 
   110                              <1> ;---------------------------------------;
   111                              <1> ;	SYSTEM DATA AREA		;
   112                              <1> ;----------------------------------------
   113 00006698 00                  <1> BIOS_BREAK	db	0		; BIT 7=1 IF BREAK KEY HAS BEEN PRESSED
   114                              <1> 
   115                              <1> ;----------------------------------------
   116                              <1> ;	KEYBOARD DATA AREAS		;
   117                              <1> ;----------------------------------------
   118                              <1> 
   119 00006699 00                  <1> KB_FLAG		db	0		; KEYBOARD SHIFT STATE AND STATUS FLAGS
   120 0000669A 00                  <1> KB_FLAG_1	db	0		; SECOND BYTE OF KEYBOARD STATUS
   121 0000669B 00                  <1> KB_FLAG_2	db	0		; KEYBOARD LED FLAGS
   122 0000669C 00                  <1> KB_FLAG_3	db	0		; KEYBOARD MODE STATE AND TYPE FLAGS
   123 0000669D 00                  <1> ALT_INPUT	db	0		; STORAGE FOR ALTERNATE KEY PAD ENTRY
   124 0000669E [AE660000]          <1> BUFFER_START	dd	KB_BUFFER 	; OFFSET OF KEYBOARD BUFFER START
   125 000066A2 [CE660000]          <1> BUFFER_END	dd	KB_BUFFER + 32	; OFFSET OF END OF BUFFER
   126 000066A6 [AE660000]          <1> BUFFER_HEAD	dd	KB_BUFFER 	; POINTER TO HEAD OF KEYBOARD BUFFER
   127 000066AA [AE660000]          <1> BUFFER_TAIL	dd	KB_BUFFER 	; POINTER TO TAIL OF KEYBOARD BUFFER
   128                              <1> ; ------	HEAD = TAIL INDICATES THAT THE BUFFER IS EMPTY
   129 000066AE 0000<rep 10h>       <1> KB_BUFFER	times	16 dw 0		; ROOM FOR 16 SCAN CODE ENTRIES
   130                              <1> 
   131                              <1> ; /// End Of KEYBOARD DATA ///
  3229                                  %include 'vidata.s'	; VIDEO (BIOS) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.7 - vidata.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 17/10/2023 (Previous: 24/11/2020)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 16/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; vidata.inc (11/03/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - VIDATA.S
    20                              <1> ; Last Modification: 11/03/2015
    21                              <1> ;		    (Data section for 'VIDEO.INC')	
    22                              <1> ;
    23                              <1> ; ///////// VIDEO DATA ///////////////
    24                              <1> 
    25                              <1> ;----------------------------------------
    26                              <1> ;	VIDEO DISPLAY DATA AREA		;
    27                              <1> ;----------------------------------------
    28 000066CE 03                  <1> CRT_MODE:	db	3	; CURRENT DISPLAY MODE (TYPE)
    29 000066CF 29                  <1> CRT_MODE_SET:	db	29h	; CURRENT SETTING OF THE 3X8 REGISTER
    30                              <1> 				; (29h default setting for video mode 3)
    31                              <1> 				; Mode Select register Bits
    32                              <1> 				;   BIT 0 - 80x25 (1), 40x25 (0)
    33                              <1> 				;   BIT 1 - ALPHA (0), 320x200 GRAPHICS (1)
    34                              <1> 				;   BIT 2 - COLOR (0), BW (1)
    35                              <1> 				;   BIT 3 - Video Sig. ENABLE (1), DISABLE (0)
    36                              <1> 				;   BIT 4 - 640x200 B&W Graphics Mode (1)
    37                              <1> 				;   BIT 5 - ALPHA mode BLINKING (1)
    38                              <1> 				;   BIT 6, 7 - Not Used
    39                              <1> 
    40                              <1> ; Mode 0 - 2Ch = 101100b	; 40x25 text, 16 gray colors
    41                              <1> ; Mode 1 - 28h = 101000b	; 40x25 text, 16 fore colors, 8 back colors
    42                              <1> ; Mode 2 - 2Dh = 101101b	; 80x25 text, 16 gray colors	
    43                              <1> ; Mode 3 - 29h = 101001b	; 80x25 text, 16 fore color, 8 back color
    44                              <1> ; Mode 4 - 2Ah = 101010b	; 320x200 graphics, 4 colors
    45                              <1> ; Mode 5 - 2Eh = 101110b	; 320x200 graphics, 4 gray colors
    46                              <1> ; Mode 6 - 1Eh = 011110b	; 640x200 graphics, 2 colors
    47                              <1> ; Mode 7 - 29h = 101001b	; 80x25 text, black & white colors
    48                              <1> ; Mode & 37h = Video signal OFF
    49                              <1> 
    50                              <1> ; 24/06/2016
    51 000066D0 50                  <1> CRT_COLS:	db	80	; Number of columns
    52                              <1> 
    53                              <1> ; 01/07/2016
    54 000066D1 00                  <1> CRT_PALETTE:	db 	0	; Current palette setting
    55                              <1> 
    56                              <1> ; 03/07/2016
    57 000066D2 10                  <1> CHAR_HEIGHT:	db	16	; Default character height
    58 000066D3 60                  <1> VGA_VIDEO_CTL:	db	60h	; ROM BIOS DATA AREA Offset 87h
    59 000066D4 F9                  <1> VGA_SWITCHES:	db 	0F9h	; Feature Bit Switches (the basic screen)
    60 000066D5 51                  <1> VGA_MODESET_CTL: db	051h	; Basic mode set options (VGA video flags)
    61                              <1> 				; ROM BIOS DATA AREA Offset 89h
    62                              <1> 				; Bit 7, 4 : Mode
    63                              <1> 				;	  01 : 400-line mode
    64                              <1> 				; Bit 6	: Display switch enabled = 1			
    65                              <1> 				; Bit 5	: Reserved = 0
    66                              <1> 				; Bit 3	: Default palette loading 
    67                              <1> 				;	  disabled = 0
    68                              <1> 				; Bit 2 : Color monitor = 0
    69                              <1> 				; Bit 1 = Gray scale summing 
    70                              <1> 				;	  disabled = 0
    71                              <1> 				; Bit 0 = VGA active = 1
    72 000066D6 19                  <1> VGA_ROWS:	db	25
    73                              <1> 
    74                              <1> ; 16/01/2016
    75                              <1> chr_attrib:  ; Character color/attributes for video pages (0 to 7)
    76 000066D7 0707070707070707    <1> 	db	07h, 07h, 07h, 07h, 07h, 07h, 07h, 07h
    77                              <1> ; 30/01/2016
    78                              <1> vmode:
    79 000066DF 0303030303030303    <1> 	db	3,3,3,3,3,3,3,3 ; video modes for pseudo screens 
    80                              <1> 
    81                              <1> CURSOR_MODE: ; cursor start (ch) = 14, cursor end (cl) = 15
    82 000066E7 0F0E                <1> 	db	15, 14 ; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
    83                              <1> 
    84                              <1> ;align 4
    85                              <1> ;VGA_BASE: ; 26/07/2016
    86                              <1> ;	dd	 0B8000h  ; (Mode < 0Dh) or 0A0000h (mode >= 0Dh)
    87                              <1> 
    88 000066E9 90                  <1> align 2
    89                              <1> 
    90                              <1> vga_modes:
    91                              <1> 	; 25/07/2016
    92                              <1> 	; 09/07/2016
    93                              <1> 	; 03/07/2016
    94                              <1> 	; valid (implemented) video modes (>7, extension to IBM PC CGA modes)
    95 000066EA 0302010007040506    <1> 	db 	03h, 02h, 01h, 00h, 07h, 04h, 05h, 06h
    96                              <1> vga_g_modes: ; 31/07/2016
    97 000066F2 13F0126A0D0E1011    <1> 	db	13h, 0F0h, 12h, 6Ah, 0Dh, 0Eh, 10h, 11h
    98                              <1> vga_mode_count equ $ - vga_modes
    99                              <1> vga_g_mode_count equ $ - vga_g_modes
   100                              <1> 
   101                              <1> vga_mode_tbl_ptr:
   102                              <1> 	; 25/07/2016
   103 000066FA [5A670000]          <1> 	dd	vga_mode_03h
   104 000066FE [5A670000]          <1> 	dd	vga_mode_03h ; mode 02h -> mode 03h 
   105 00006702 [9A670000]          <1> 	dd	vga_mode_01h
   106 00006706 [9A670000]          <1> 	dd	vga_mode_01h ; mode 00h -> mode 01h
   107                              <1> 	;dd	vga_mode_07h
   108 0000670A [5A670000]          <1> 	dd	vga_mode_03h ; mode 07h -> mode 03h
   109 0000670E [DA670000]          <1> 	dd	vga_mode_04h
   110 00006712 [DA670000]          <1> 	dd	vga_mode_04h ; mode 05h -> mode 04h	
   111 00006716 [1A680000]          <1> 	dd	vga_mode_06h
   112 0000671A [5A680000]          <1> 	dd	vga_mode_13h
   113 0000671E [9A680000]          <1> 	dd	vga_mode_F0h
   114 00006722 [DA680000]          <1> 	dd	vga_mode_12h
   115 00006726 [1A690000]          <1> 	dd	vga_mode_6Ah
   116 0000672A [5A690000]          <1> 	dd	vga_mode_0Dh
   117 0000672E [9A690000]          <1> 	dd	vga_mode_0Eh
   118 00006732 [DA690000]          <1> 	dd	vga_mode_10h
   119 00006736 [1A6A0000]          <1> 	dd	vga_mode_11h	
   120                              <1> 
   121                              <1> vga_memmodel: 
   122                              <1> 	; 25/07/2016
   123                              <1> 	; 07/07/2016
   124                              <1> 	CTEXT	equ 0
   125                              <1> 	;MTEXT	equ 1
   126                              <1> 	MTEXT	equ 0 ; mode 07h -> mode 03h
   127                              <1> 	CGA	equ 2
   128                              <1> 	LINEAR8 equ 5
   129                              <1> 	PLANAR4	equ 4
   130                              <1> 	PLANAR1	equ 3
   131 0000673A 0000000000020202    <1> 	db	CTEXT, CTEXT, CTEXT, CTEXT, MTEXT, CGA, CGA, CGA
   132                              <1> vga_g_memmodel: ; 31/07/2016
   133 00006742 0504040404040403    <1> 	db	LINEAR8, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR1
   134                              <1> ;vga_pixbits:
   135                              <1> ;	; 25/07/2016
   136                              <1> ;	; 08/07/2016
   137                              <1> ;	db 	4, 4, 4, 4, 4, 2, 2, 1, 8, 4, 4, 4, 4, 4, 4, 1
   138                              <1> vga_dac_s:
   139 0000674A 020202020001010103- <1> 	db	2, 2, 2, 2, 0, 1, 1, 1, 3, 3, 2, 2, 1, 1, 2, 2  
   139 00006753 03020201010202      <1>
   140                              <1> 						; (vgatables.h, VGAMODES, dac) 
   141                              <1> 						; 17/11/2020
   142                              <1> vga_params:
   143                              <1> 	; 23/11/2020
   144                              <1> 	; 16/11/2020
   145                              <1> 	; 09/11/2020, 10/11/2020, 11/11/2020 (TRDOS 386 v2.0.3)
   146                              <1> 	; 25/07/2016 
   147                              <1> 	; 19/07/2016
   148                              <1> 	; 03/07/2016
   149                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
   150                              <1> 	; vgabios-0.7a (2011)
   151                              <1> 	; by the LGPL VGABios Developers Team (2001-2008)
   152                              <1> 	; 'vgatables.h'
   153                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
   154                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
   155                              <1> 
   156                              <1> 	; 09/11/2020
   157                              <1> 	; Block Structure of Video Parameter Table
   158                              <1> 	;
   159                              <1> 	; Offset	# Bytes		Contents
   160                              <1> 	;
   161                              <1> 	;  0		1		# columns
   162                              <1> 	;  1		1  		# rows - 1 
   163                              <1> 	;  2		1		Pixels/character
   164                              <1> 	;  3-4		2		Page length		
   165                              <1> 	;  5-8		4		Sequencer Registers
   166                              <1> 	;  9		1		Miscellaneous Register	
   167                              <1> 	;  10-34	25		CRTC Registers
   168                              <1> 	;  35-54	20		Attribute Registers
   169                              <1> 	;  55-63	9		Graphics Controller Registers
   170                              <1> 	;
   171                              <1> 	; Ref: Programmer's Guide to EGA, VGA, and Super VGA cards
   172                              <1> 	; (Richard F. Ferraro, 1994)  
   173                              <1> 
   174                              <1> 	;
   175                              <1> vga_mode_03h:  ; mode 03h, 80*25 text, CGA colors
   176                              <1> 	; 11/11/2020
   177 0000675A 5018100010          <1>  	db	80, 24, 16, 00h, 10h ; tw, th-1, ch, slength (5)
   178 0000675F 00030002            <1>  	db	00h, 03h, 00h, 02h ; sequ regs (4)
   179 00006763 67                  <1>  	db	67h	; misc reg (1)
   180 00006764 5F4F50825581BF1F    <1>  	db	5Fh, 4Fh, 50h, 82h, 55h, 81h, 0BFh, 1Fh
   181                              <1>  	; 09/11/2020
   182                              <1> 	;db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
   183 0000676C 004F                <1> 	db	00h, 4Fh
   184                              <1> vga_p_cm_pos equ $ - vga_mode_03h
   185 0000676E 0D0E00000000        <1> 	db	0Dh, 0Eh, 00h, 00h, 00h, 00h
   186 00006774 9C8E8F281F96B9A3    <1>  	db	9Ch, 8Eh, 8Fh, 28h, 1Fh, 96h, 0B9h, 0A3h
   187 0000677C FF                  <1> 	db	0FFh	; crtc_regs (25)
   188 0000677D 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   189 00006785 38393A3B3C3D3E3F    <1>  	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   190                              <1>  	; 17/10/2023
   191 0000678D 0C000F08            <1> 	db	0Ch, 00h, 0Fh, 08h  ; actl regs (20)
   192                              <1> 	;db	0Ch, 00h, 0Fh, 00h  ; 19/11/2020
   193 00006791 0000000000100E0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 0Fh, 0FFh ; grdc regs (9)
   194                              <1> 	; 09/11/2020
   195                              <1> 	;db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 00h, 0FFh ; grdc regs (9)
   196                              <1> vga_mode_01h:	; mode 01h, 40*25 text, CGA colors
   197 0000679A 2818100008          <1> 	db	40, 24, 16, 00h, 08h ; tw, th-1, ch, slength
   198 0000679F 08030002            <1> 	db	08h, 03h, 00h, 02h  ; sequ regs
   199 000067A3 67                  <1> 	db	67h	; misc reg
   200 000067A4 2D2728902BA0BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 0A0h, 0BFh, 1Fh
   201 000067AC 004F0D0E00000000    <1> 	db	00h, 4Fh, 0Dh, 0Eh, 00h, 00h, 00h, 00h
   202 000067B4 9C8E8F141F96B9A3    <1> 	db	9Ch, 8Eh, 8Fh, 14h, 1Fh, 96h, 0B9h, 0A3h
   203 000067BC FF                  <1> 	db	0FFh	; crtc_regs
   204 000067BD 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   205 000067C5 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   206                              <1>  	;db	0Ch, 00h, 0Fh, 08h  ; actl regs (20)
   207 000067CD 0C000F00            <1> 	db	0Ch, 00h, 0Fh, 00h  ; 19/11/2020
   208 000067D1 0000000000100E0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 0Fh, 0FFh ; grdc regs
   209                              <1> ;vga_mode_07h:	; mode 07h, 80*25 text, mono color
   210                              <1> ;	db	80, 24, 16, 00h, 10h  ; tw, th-1, ch, slength
   211                              <1> ;	db	00h, 03h, 00h, 02h ; sequ regs
   212                              <1> ;	db	66h	; misc reg
   213                              <1> ;	db	5Fh, 4Fh, 50h, 82h, 55h, 81h, 0BFh, 1Fh
   214                              <1> ;	db	00h, 4Fh, 0Dh, 0Eh, 00h, 00h, 00h, 00h
   215                              <1> ;	db	9Ch, 8Eh, 8Fh, 28h, 0Fh, 96h, 0B9h, 0A3h
   216                              <1> ;	db	0FFh	; crtc regs
   217                              <1> ;	db	00h, 08h, 08h, 08h, 08h, 08h, 08h, 08h
   218                              <1> ;	db	10h, 18h, 18h, 18h, 18h, 18h, 18h, 18h
   219                              <1> ;	db	0Eh, 00h, 0Fh, 08h  ; actl regs
   220                              <1> ;	db	00h, 00h, 00h, 00h, 00h, 10h, 0Ah, 0Fh, 0FFh ; grdc regs
   221                              <1> vga_mode_04h:	; 320*200 graphics, 4 colors, CGA
   222                              <1> 	; 11/11/2020
   223 000067DA 2818080040          <1> 	db	40, 24, 8, 00h, 40h ; tw, th-1, ch, slength
   224 000067DF 09030002            <1> 	db	09h, 03h, 00h, 02h ; sequ regs
   225 000067E3 63                  <1> 	db	63h	; misc reg
   226 000067E4 2D2728902B80BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 80h, 0BFh, 1Fh
   227 000067EC 00C1000000000000    <1> 	db	00h, 0C1h, 00h, 00h, 00h, 00h, 00h, 00h
   228 000067F4 9C8E8F140096B9A2    <1> 	db	9Ch, 8Eh, 8Fh, 14h, 00h, 96h, 0B9h, 0A2h
   229 000067FC FF                  <1> 	db	0FFh	; crtc_regs
   230 000067FD 0013151702040607    <1> 	db	00h, 13h, 15h, 17h, 02h, 04h, 06h, 07h
   231 00006805 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
   232 0000680D 01000300            <1> 	db	01h, 00h, 03h, 00h ; actl regs
   233 00006811 0000000000300F0FFF  <1> 	db 	00h, 00h, 00h, 00h, 00h, 30h, 0Fh, 0Fh, 0FFh ; grdc regs
   234                              <1> vga_mode_06h:	; 640*200 graphics, 2 colors, CGA
   235                              <1> 	; 11/11/2020
   236 0000681A 5018080040          <1> 	db	80, 24, 8, 00h, 40h   ;	tw, th-1, ch, slength
   237 0000681F 01010006            <1> 	db	01h, 01h, 00h, 06h ; sequ regs
   238 00006823 63                  <1> 	db	63h	; misc reg
   239 00006824 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
   240 0000682C 00C1000000000000    <1> 	db	00h, 0C1h, 00h, 00h, 00h, 00h, 00h, 00h
   241 00006834 9C8E8F280096B9C2    <1> 	db	9Ch, 8Eh, 8Fh, 28h, 00h, 96h, 0B9h, 0C2h
   242 0000683C FF                  <1> 	db	0FFh	; crtc regs
   243 0000683D 0017171717171717    <1> 	db	00h, 17h, 17h, 17h, 17h, 17h, 17h, 17h
   244 00006845 1717171717171717    <1> 	db	17h, 17h, 17h, 17h, 17h, 17h, 17h, 17h
   245 0000684D 01000100            <1> 	db	01h, 00h, 01, 00h  ; actl regs
   246 00006851 0000000000000D0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 0Dh, 0Fh, 0FFh ; grdc regs
   247                              <1> vga_mode_13h:  ; mode 13h, 300*200, 256 colors, linear
   248                              <1> 	; 11/11/2020
   249                              <1> 	;db 	40, 24, 8, 00h, 20h ; tw, th-1, ch, slength (5)
   250                              <1> 	; 23/11/2020 - 10/11/2020
   251 0000685A 28180800FA          <1> 	db 	40, 24, 8, 00h, 0FAh ; tw, th-1, ch, slength (5)
   252 0000685F 010F000E            <1> 	db	01h, 0Fh, 00h, 0Eh ; sequ regs (4)
   253 00006863 63                  <1> 	db	63h	; misc reg (1)
   254 00006864 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh 
   255 0000686C 0041000000000000    <1> 	db 	00h, 041h, 00h, 00h, 00h, 00h, 00h, 00h
   256 00006874 9C8E8F284096B9A3    <1> 	db	9Ch, 8Eh, 8Fh, 28h, 40h, 96h, 0B9h, 0A3h
   257                              <1> 	;db	9Ch, 0Eh, 8Fh, 28h, 40h, 96h, 0B9h, 0A3h ; 17/10/2023
   258 0000687C FF                  <1> 	db	0FFh	; crtc regs (25)
   259 0000687D 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   260 00006885 08090A0B0C0D0E0F    <1>  	db	08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 0Fh
   261 0000688D 41000F00            <1>  	db	41h, 00h, 0Fh, 00h  ; actl regs (20)
   262                              <1> 	; 10/11/2020
   263                              <1>  	;db	41h, 01h, 0Fh, 13h  ; actl regs (20) 
   264 00006891 000000000040050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 40h, 05h, 0Fh, 0FFh ; grdc regs (9)
   265                              <1> vga_mode_setl equ $ - vga_mode_13h  ; = 64
   266                              <1> vga_mode_F0h:  ; mode X ; 320*240, 256 colors, planar
   267 0000689A 2818080000          <1> 	db 	40, 24, 8, 00h, 00h ; tw, th-1, ch, slength
   268 0000689F 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   269 000068A3 E3                  <1> 	db	0E3h	; misc reg
   270 000068A4 5F4F508254800D3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Dh, 3Eh 
   271 000068AC 0041000000000000    <1>  	db 	00h, 41h, 00h, 00h, 00h, 00h, 00h, 00h
   272 000068B4 EAACDF2800E706E3    <1> 	db	0EAh, 0ACh, 0DFh, 28h, 00h, 0E7h, 06h, 0E3h
   273 000068BC FF                  <1> 	db	0FFh	; crtc regs (25)
   274 000068BD 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   275 000068C5 08090A0B0C0D0E0F    <1>  	db	08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 0Fh
   276 000068CD 41000F00            <1>  	db	41h, 00h, 0Fh, 00h  ; actl regs
   277 000068D1 000000000040050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 40h, 05h, 0Fh, 0FFh ; grdc regs
   278                              <1> vga_mode_12h:  ; mode 12h, 640*480, 16 colors, planar
   279                              <1> 	; 11/11/2020
   280                              <1>  	;db 	80, 29, 16, 0, 0 ; tw, th-1, ch, slength
   281                              <1> 	; 09/11/2020
   282 000068DA 501D1000A0          <1>  	db 	80, 29, 16, 00h, 0A0h ; tw, th-1, ch, slength
   283 000068DF 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   284 000068E3 E3                  <1> 	db 	0E3h	; misc reg
   285 000068E4 5F4F508254800B3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Bh, 3Eh
   286                              <1> 	; 09/11/2020
   287                              <1> 	;db	5Fh, 4Fh, 50h, 82h, 53h, 9Fh, 0Bh, 3Eh
   288 000068EC 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
   289 000068F4 EA8CDF2800E704E3    <1>  	db	0EAh, 8Ch, 0DFh, 28h, 00h, 0E7h, 04h, 0E3h
   290                              <1> 	; 09/11/2020
   291                              <1>  	;db	0E9h, 8Bh, 0DFh, 28h, 00h, 0E7h, 04h, 0E3h
   292 000068FC FF                  <1> 	db	0FFh	; crtc regs
   293 000068FD 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   294 00006905 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   295 0000690D 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   296 00006911 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   297                              <1> vga_mode_6Ah:  ; mode 6Ah, 800*600, 16 colors, planar
   298                              <1> 	; 11/11/2020
   299 0000691A 6424100000          <1>  	db 	100, 36, 16, 00h, 00h ; tw, th-1, ch, slength
   300 0000691F 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   301 00006923 E3                  <1> 	db 	0E3h	; misc reg
   302 00006924 7F6363836B1B72F0    <1> 	db	7Fh, 63h, 63h, 83h, 6Bh, 1Bh, 72h, 0F0h
   303 0000692C 0060000000000000    <1> 	db	00h, 60h, 00h, 00h, 00h, 00h, 00h, 00h
   304 00006934 598D5732005773E3    <1>  	db	59h, 8Dh, 57h, 32h, 00h, 57h, 73h, 0E3h
   305 0000693C FF                  <1> 	db	0FFh	; crtc regs
   306 0000693D 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   307 00006945 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   308 0000694D 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   309 00006951 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   310                              <1> vga_mode_0Dh:  ; mode 0Dh, 320*200, 16 colors, planar
   311 0000695A 2818080020          <1>  	db 	40, 24, 8, 00h, 20h ; tw, th-1, ch, slength
   312 0000695F 090F0006            <1> 	db	09h, 0Fh, 00h, 06h ; sequ regs
   313 00006963 63                  <1> 	db 	63h	; misc reg
   314 00006964 2D2728902B80BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 80h, 0BFh, 1Fh
   315 0000696C 00C0000000000000    <1> 	db	00h, 0C0h, 00h, 00h, 00h, 00h, 00h, 00h
   316 00006974 9C8E8F140096B9E3    <1>  	db	9Ch, 8Eh, 8Fh, 14h, 00h, 96h, 0B9h, 0E3h
   317 0000697C FF                  <1> 	db	0FFh	; crtc regs
   318 0000697D 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   319 00006985 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
   320 0000698D 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   321 00006991 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   322                              <1> vga_mode_0Eh:  ; mode 0Eh, 640*200, 16 colors, planar
   323 0000699A 5018080040          <1>  	db 	80, 24, 8, 00h, 40h ; tw, th-1, ch, slength
   324 0000699F 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   325 000069A3 63                  <1> 	db 	63h	; misc reg
   326 000069A4 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
   327 000069AC 00C0000000000000    <1> 	db	00h, 0C0h, 00h, 00h, 00h, 00h, 00h, 00h
   328 000069B4 9C8E8F280096B9E3    <1>  	db	9Ch, 8Eh, 8Fh, 28h, 00h, 96h, 0B9h, 0E3h
   329 000069BC FF                  <1> 	db	0FFh	; crtc regs
   330 000069BD 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   331 000069C5 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
   332 000069CD 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   333 000069D1 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   334                              <1> vga_mode_10h: ; mode 10h, 640*350, 16 colors, planar
   335 000069DA 50180E0080          <1>  	db 	80, 24, 14, 00h, 80h ; tw, th-1, ch, slength
   336 000069DF 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   337 000069E3 A3                  <1> 	db 	0A3h	; misc reg
   338 000069E4 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
   339 000069EC 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
   340 000069F4 83855D280F63BAE3    <1>  	db	83h, 85h, 5Dh, 28h, 0Fh, 63h, 0BAh, 0E3h
   341 000069FC FF                  <1> 	db	0FFh	; crtc regs
   342 000069FD 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   343 00006A05 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   344 00006A0D 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   345 00006A11 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   346                              <1> vga_mode_11h: ; mode 11h, 640*480, mono color, planar
   347                              <1>  	; 11/11/2020
   348 00006A1A 501D1000A0          <1> 	db 	80, 29, 16, 00h, 0A0h ; tw, th-1, ch, slength
   349 00006A1F 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   350 00006A23 E3                  <1> 	db 	0E3h	; misc reg
   351 00006A24 5F4F508254800B3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Bh, 3Eh
   352 00006A2C 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
   353 00006A34 EA8CDF2800E704C3    <1>  	db	0EAh, 8Ch, 0DFh, 28h, 00h, 0E7h, 04h, 0C3h ; 11/11/2020
   354 00006A3C FF                  <1> 	db	0FFh	; crtc regs
   355 00006A3D 003F003F003F003F    <1> 	db	00h, 3Fh, 00h, 3Fh, 00h, 3Fh, 00h, 3Fh
   356 00006A45 003F003F003F003F    <1> 	db	00h, 3Fh, 00h, 3Fh, 00h, 3Fh, 00h, 3Fh
   357 00006A4D 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   358 00006A51 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   359                              <1> end_of_vga_params:
   360                              <1> 
   361                              <1> ; /// End Of VIDEO DATA ///
   362                              <1> 
   363                              <1> ; 23/11/2020
   364                              <1> ; VBE 2 BOCHS/QEMU emulator extensions 
   365                              <1> ;	for TRDOS 386 v2 kernel (video bios)  
   366                              <1> 
   367                              <1> ; vbetables.h by Volker Rupper (02/01/2020)
   368                              <1> 
   369                              <1> b_vbe_modes:
   370                              <1> 	;/* standard VESA modes */	
   371 00006A5A 0001800290010800    <1> 	dw 100h,  640, 400,  8
   372 00006A62 01018002E0010800    <1> 	dw 101h,  640, 480,  8
   373 00006A6A 0301200358020800    <1> 	dw 103h,  800, 600,  8
   374 00006A72 0501000400030800    <1> 	dw 105h, 1024, 768,  8
   375 00006A7A 0E014001C8001000    <1> 	dw 10Eh,  320, 200, 16
   376 00006A82 0F014001C8001800    <1> 	dw 10Fh,  320, 200, 24
   377 00006A8A 11018002E0011000    <1> 	dw 111h,  640, 480, 16
   378 00006A92 12018002E0011800    <1> 	dw 112h,  640, 480, 24
   379 00006A9A 1401200358021000    <1> 	dw 114h,  800, 600, 16
   380 00006AA2 1501200358021800    <1> 	dw 115h,  800, 600, 24
   381 00006AAA 1701000400031000    <1> 	dw 117h, 1024, 768, 16
   382 00006AB2 1801000400031800    <1> 	dw 118h, 1024, 768, 24
   383                              <1> 
   384                              <1> ;/* BOCHS/PLEX86 'own' mode numbers */
   385 00006ABA 40014001C8002000    <1> 	dw 140h,  320,  200, 32
   386 00006AC2 4101800290012000    <1> 	dw 141h,  640,  400, 32
   387 00006ACA 42018002E0012000    <1> 	dw 142h,  640,  480, 32
   388 00006AD2 4301200358022000    <1> 	dw 143h,  800,  600, 32
   389 00006ADA 4401000400032000    <1> 	dw 144h, 1024,  768, 32
   390 00006AE2 46014001C8000800    <1> 	dw 146h,  320,  200,  8
   391 00006AEA 8D010005D0021000    <1> 	dw 18Dh, 1280,  720, 16
   392 00006AF2 8E010005D0021800    <1> 	dw 18Eh, 1280,  720, 24
   393 00006AFA 8F010005D0022000    <1> 	dw 18Fh, 1280,  720, 32
   394 00006B02 9001800738041000    <1> 	dw 190h, 1920, 1080, 16
   395 00006B0A 9101800738041800    <1> 	dw 191h, 1920, 1080, 24
   396 00006B12 9201800738042000    <1> 	dw 192h, 1920, 1080, 32
   397                              <1> 
   398                              <1> end_of_b_vbe_modes:
   399                              <1> 
   400                              <1> MA1 equ VBE_MODE_ATTRIBUTE_SUPPORTED
   401                              <1> MA2 equ VBE_MODE_ATTRIBUTE_EXTENDED_INFO_AVAILABLE
   402                              <1> MA3 equ VBE_MODE_ATTRIBUTE_COLOR_MODE
   403                              <1> MA4 equ VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE
   404                              <1> MA5 equ	VBE_MODE_ATTRIBUTE_GRAPHICS_MODE
   405                              <1> 
   406                              <1> MODE_ATTRIBUTES equ MA1|MA2|MA3|MA4|MA5
   407                              <1> 
   408                              <1> WA1 equ VBE_WINDOW_ATTRIBUTE_RELOCATABLE
   409                              <1> WA2 equ	VBE_WINDOW_ATTRIBUTE_READABLE
   410                              <1> WA3 equ VBE_WINDOW_ATTRIBUTE_WRITEABLE
   411                              <1> 
   412                              <1> WINA_ATTRIBUTES equ WA1|WA2|WA3
   413                              <1> 
   414                              <1> ; 24/11/2020
   415                              <1> 
   416                              <1> %if 0
   417                              <1> 
   418                              <1> MODE_INFO_LIST: 
   419                              <1> 
   420                              <1> ; 24/11/2020
   421                              <1> ; '%if 0' disables 24 mode info tables here, until %endif 
   422                              <1> ; ('set_mode_info_list' will set only 1 list for selected mode)
   423                              <1> ; (Purpose: To save about 1 KB kernel size by removing fixed data)
   424                              <1> 
   425                              <1> 			dw	0100h ; 640x400x8 
   426                              <1> ModeAttributes1: 	dw	MODE_ATTRIBUTES
   427                              <1> WinAAttributes1: 	db	WINA_ATTRIBUTES
   428                              <1> WinBAttributes1: 	db	0
   429                              <1> WinGranularity1: 	dw	VBE_DISPI_BANK_SIZE_KB
   430                              <1> WinSize1: 		dw	VBE_DISPI_BANK_SIZE_KB
   431                              <1> WinASegment1:		dw	VGAMEM_GRAPH
   432                              <1> WinBSegment1:		dw	0000h
   433                              <1> WinFuncPtr1:		dd	0
   434                              <1> BytesPerScanLine1: 	dw	640
   435                              <1> XResolution1:		dw	640
   436                              <1> YResolution1:		dw	400
   437                              <1> XCharSize1:		db	8
   438                              <1> YCharSize1:		db	16
   439                              <1> NumberOfPlanes1: 	db	1
   440                              <1> BitsPerPixel1:		db	8
   441                              <1> NumberOfBanks1:		db	4
   442                              <1> MemoryModel1:		db	VBE_MEMORYMODEL_PACKED_PIXEL
   443                              <1> BankSize1:		db	0
   444                              <1> NumberOfImagePages1: 	db	64
   445                              <1> Reserved_page1:		db	0
   446                              <1> RedMaskSize1:		db	0
   447                              <1> RedFieldPosition1: 	db	0
   448                              <1> GreenMaskSize1:		db	0
   449                              <1> GreenFieldPosition1: 	db	0
   450                              <1> BlueMaskSize1:		db	0
   451                              <1> BlueFieldPosition1: 	db	0
   452                              <1> RsvdMaskSize1: 		db	0
   453                              <1> RsvdFieldPosition1: 	db	0
   454                              <1> DirectColorModeInfo1: 	db	0
   455                              <1> PhysBasePtr1:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   456                              <1> OffScreenMemOffset1: 	dd	0
   457                              <1> OffScreenMemSize1: 	dw	0
   458                              <1> LinBytesPerScanLine1: 	dw	640
   459                              <1> BnkNumberOfPages1: 	db	0
   460                              <1> LinNumberOfPages1: 	db	0
   461                              <1> LinRedMaskSize1:	db	0
   462                              <1> LinRedFieldPosition1: 	db	0
   463                              <1> LinGreenMaskSize1: 	db	0
   464                              <1> LinGreenFieldPosition1: db	0
   465                              <1> LinBlueMaskSize1: 	db	0
   466                              <1> LinBlueFieldPosition1: 	db	0
   467                              <1> LinRsvdMaskSize1: 	db	0
   468                              <1> LinRsvdFieldPosition1: 	db	0
   469                              <1> MaxPixelClock1:		dd	0
   470                              <1> 
   471                              <1> 			dw	0101h ; 640x480x8
   472                              <1> ModeAttributes2: 	dw	MODE_ATTRIBUTES
   473                              <1> WinAAttributes2: 	db	WINA_ATTRIBUTES
   474                              <1> WinBAttributes2: 	db	0
   475                              <1> WinGranularity2: 	dw	VBE_DISPI_BANK_SIZE_KB
   476                              <1> WinSize2: 		dw	VBE_DISPI_BANK_SIZE_KB
   477                              <1> WinASegment2:		dw	VGAMEM_GRAPH
   478                              <1> WinBSegment2:		dw	0000h
   479                              <1> WinFuncPtr2:		dd	0
   480                              <1> BytesPerScanLine2:	dw	640
   481                              <1> XResolution2:		dw	640
   482                              <1> YResolution2:		dw	480
   483                              <1> XCharSize2:		db	8
   484                              <1> YCharSize2:		db	16
   485                              <1> NumberOfPlanes2:	db	1
   486                              <1> BitsPerPixel2:		db	8
   487                              <1> NumberOfBanks2:		db	5
   488                              <1> MemoryModel2:		db	VBE_MEMORYMODEL_PACKED_PIXEL
   489                              <1> BankSize2:		db	0
   490                              <1> NumberOfImagePages2:	db	53
   491                              <1> Reserved_page2:		db	0
   492                              <1> RedMaskSize2:		db	0
   493                              <1> RedFieldPosition2:	db	0
   494                              <1> GreenMaskSize2:		db	0
   495                              <1> GreenFieldPosition2:	db	0
   496                              <1> BlueMaskSize2:		db	0
   497                              <1> BlueFieldPosition2:	db	0
   498                              <1> RsvdMaskSize2:		db	0
   499                              <1> RsvdFieldPosition2:	db	0
   500                              <1> DirectColorModeInfo2:	db	0
   501                              <1> PhysBasePtr2:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   502                              <1> OffScreenMemOffset2:	dd	0
   503                              <1> OffScreenMemSize2:	dw	0
   504                              <1> LinBytesPerScanLine2:	dw	640
   505                              <1> BnkNumberOfPages2: 	db	0
   506                              <1> LinNumberOfPages2: 	db	0
   507                              <1> LinRedMaskSize2:	db	0
   508                              <1> LinRedFieldPosition2: 	db	0
   509                              <1> LinGreenMaskSize2: 	db	0
   510                              <1> LinGreenFieldPosition2: db	0
   511                              <1> LinBlueMaskSize2: 	db	0
   512                              <1> LinBlueFieldPosition2: 	db	0
   513                              <1> LinRsvdMaskSize2: 	db	0
   514                              <1> LinRsvdFieldPosition2: 	db	0
   515                              <1> MaxPixelClock2:		dd	0
   516                              <1> 			
   517                              <1> 			dw	0103h ; 800x600x8
   518                              <1> ModeAttributes3: 	dw	MODE_ATTRIBUTES
   519                              <1> WinAAttributes3: 	db	WINA_ATTRIBUTES
   520                              <1> WinBAttributes3: 	db	0
   521                              <1> WinGranularity3: 	dw	VBE_DISPI_BANK_SIZE_KB
   522                              <1> WinSize3: 		dw	VBE_DISPI_BANK_SIZE_KB
   523                              <1> WinASegment3:		dw	VGAMEM_GRAPH
   524                              <1> WinBSegment3:		dw	0000h
   525                              <1> WinFuncPtr3:		dd	0
   526                              <1> BytesPerScanLine3:	dw	800
   527                              <1> XResolution3:		dw	800
   528                              <1> YResolution3:		dw	600
   529                              <1> XCharSize3:		db	8
   530                              <1> YCharSize3:		db	16
   531                              <1> NumberOfPlanes3:	db	1
   532                              <1> BitsPerPixel3:		db	8
   533                              <1> NumberOfBanks3:		db	8
   534                              <1> MemoryModel3:		db	VBE_MEMORYMODEL_PACKED_PIXEL
   535                              <1> BankSize3:		db	0
   536                              <1> NumberOfImagePages3:	db	33
   537                              <1> Reserved_page3:		db	0
   538                              <1> RedMaskSize3:		db	0
   539                              <1> RedFieldPosition3:	db	0
   540                              <1> GreenMaskSize3:		db	0
   541                              <1> GreenFieldPosition3:	db	0
   542                              <1> BlueMaskSize3:		db	0
   543                              <1> BlueFieldPosition3:	db	0
   544                              <1> RsvdMaskSize3:		db	0
   545                              <1> RsvdFieldPosition3:	db	0
   546                              <1> DirectColorModeInfo3:	db	0
   547                              <1> PhysBasePtr3:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   548                              <1> OffScreenMemOffset3:	dd	0
   549                              <1> OffScreenMemSize3:	dw	0
   550                              <1> LinBytesPerScanLine3:	dw	800
   551                              <1> BnkNumberOfPages3: 	db	0
   552                              <1> LinNumberOfPages3: 	db	0
   553                              <1> LinRedMaskSize3:	db	0
   554                              <1> LinRedFieldPosition3: 	db	0
   555                              <1> LinGreenMaskSize3: 	db	0
   556                              <1> LinGreenFieldPosition: 	db	0
   557                              <1> LinBlueMaskSize: 	db	0
   558                              <1> LinBlueFieldPosition: 	db	0
   559                              <1> LinRsvdMaskSize: 	db	0
   560                              <1> LinRsvdFieldPosition: 	db	0
   561                              <1> MaxPixelClock:		dd	0
   562                              <1> 			
   563                              <1> 			dw	0105h ; 1024x768x8
   564                              <1> ModeAttributes4: 	dw	MODE_ATTRIBUTES
   565                              <1> WinAAttributes4: 	db	WINA_ATTRIBUTES
   566                              <1> WinBAttributes4: 	db	0
   567                              <1> WinGranularity4: 	dw	VBE_DISPI_BANK_SIZE_KB
   568                              <1> WinSize4: 		dw	VBE_DISPI_BANK_SIZE_KB
   569                              <1> WinASegment4:		dw	VGAMEM_GRAPH
   570                              <1> WinBSegment4:		dw	0000h
   571                              <1> WinFuncPtr4:		dd	0
   572                              <1> BytesPerScanLine4:	dw	1024
   573                              <1> XResolution4:		dw	1024
   574                              <1> YResolution4:		dw	768
   575                              <1> XCharSize4:		db	8
   576                              <1> YCharSize4:		db	16
   577                              <1> NumberOfPlanes4:	db	1
   578                              <1> BitsPerPixel4:		db	8
   579                              <1> NumberOfBanks4:		db	12
   580                              <1> MemoryModel4:		db	VBE_MEMORYMODEL_PACKED_PIXEL
   581                              <1> BankSize4:		db	0
   582                              <1> NumberOfImagePages4:	db	20
   583                              <1> Reserved_page4:		db	0
   584                              <1> RedMaskSize4:		db	0
   585                              <1> RedFieldPosition4:	db	0
   586                              <1> GreenMaskSize4:		db	0
   587                              <1> GreenFieldPosition4:	db	0
   588                              <1> BlueMaskSize4:		db	0
   589                              <1> BlueFieldPosition4:	db	0
   590                              <1> RsvdMaskSize4:		db	0
   591                              <1> RsvdFieldPosition4:	db	0
   592                              <1> DirectColorModeInfo4:	db	0
   593                              <1> PhysBasePtr4:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   594                              <1> OffScreenMemOffset4:	dd	0
   595                              <1> OffScreenMemSize4:	dw	0
   596                              <1> LinBytesPerScanLine4:	dw	1024
   597                              <1> BnkNumberOfPages4: 	db	0
   598                              <1> LinNumberOfPages4: 	db	0
   599                              <1> LinRedMaskSize4:	db	0
   600                              <1> LinRedFieldPosition4: 	db	0
   601                              <1> LinGreenMaskSize4: 	db	0
   602                              <1> LinGreenFieldPosition4: db	0
   603                              <1> LinBlueMaskSize4: 	db	0
   604                              <1> LinBlueFieldPosition4: 	db	0
   605                              <1> LinRsvdMaskSize4: 	db	0
   606                              <1> LinRsvdFieldPosition4: 	db	0
   607                              <1> MaxPixelClock4:		dd	0
   608                              <1> 
   609                              <1> 			dw	010Eh ; 320x200x16
   610                              <1> ModeAttributes5: 	dw	MODE_ATTRIBUTES
   611                              <1> WinAAttributes5: 	db	WINA_ATTRIBUTES
   612                              <1> WinBAttributes5: 	db	0
   613                              <1> WinGranularity5: 	dw	VBE_DISPI_BANK_SIZE_KB
   614                              <1> WinSize5: 		dw	VBE_DISPI_BANK_SIZE_KB
   615                              <1> WinASegment5:		dw	VGAMEM_GRAPH
   616                              <1> WinBSegment5:		dw	0000h
   617                              <1> WinFuncPtr5:		dd	0
   618                              <1> BytesPerScanLine5:	dw	640
   619                              <1> XResolution5:		dw	320
   620                              <1> YResolution5:		dw	200
   621                              <1> XCharSize5:		db	8
   622                              <1> YCharSize5:		db	16
   623                              <1> NumberOfPlanes5:	db	1
   624                              <1> BitsPerPixel5:		db	16
   625                              <1> NumberOfBanks5:		db	2
   626                              <1> MemoryModel5:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   627                              <1> BankSize5:		db	0
   628                              <1> NumberOfImagePages5:	db	130
   629                              <1> Reserved_page5:		db	0
   630                              <1> RedMaskSize5:		db	5
   631                              <1> RedFieldPosition5:	db	11
   632                              <1> GreenMaskSize5:		db	6
   633                              <1> GreenFieldPosition5:	db	5
   634                              <1> BlueMaskSize5:		db	5
   635                              <1> BlueFieldPosition5:	db	0
   636                              <1> RsvdMaskSize5:		db	0
   637                              <1> RsvdFieldPosition5:	db	0
   638                              <1> DirectColorModeInfo5:	db	0
   639                              <1> PhysBasePtr5:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   640                              <1> OffScreenMemOffset5:	dd	0
   641                              <1> OffScreenMemSize5:	dw	0
   642                              <1> LinBytesPerScanLine5:	dw	640
   643                              <1> BnkNumberOfPages5: 	db	0
   644                              <1> LinNumberOfPages5: 	db	0
   645                              <1> LinRedMaskSize5:	db	5
   646                              <1> LinRedFieldPosition5:	db	11
   647                              <1> LinGreenMaskSize5:	db	6
   648                              <1> LinGreenFieldPosition5:	db	5
   649                              <1> LinBlueMaskSize5:	db	5
   650                              <1> LinBlueFieldPosition5:	db	0
   651                              <1> LinRsvdMaskSize5:	db	0
   652                              <1> LinRsvdFieldPosition5:	db	0
   653                              <1> MaxPixelClock5:		dd	0
   654                              <1> 	
   655                              <1> 			dw	010Fh ; 320x200x24
   656                              <1> ModeAttributes6: 	dw	MODE_ATTRIBUTES
   657                              <1> WinAAttributes6: 	db	WINA_ATTRIBUTES
   658                              <1> WinBAttributes6: 	db	0
   659                              <1> WinGranularity6: 	dw	VBE_DISPI_BANK_SIZE_KB
   660                              <1> WinSize6: 		dw	VBE_DISPI_BANK_SIZE_KB
   661                              <1> WinASegment6:		dw	VGAMEM_GRAPH
   662                              <1> WinBSegment6:		dw	0000h
   663                              <1> WinFuncPtr6:		dd	0
   664                              <1> BytesPerScanLine6:	dw	960
   665                              <1> XResolution6:		dw	320
   666                              <1> YResolution6:		dw	200
   667                              <1> XCharSize6:		db	8
   668                              <1> YCharSize6:		db	16
   669                              <1> NumberOfPlanes6:	db	1
   670                              <1> BitsPerPixel6:		db	24
   671                              <1> NumberOfBanks6:		db	3
   672                              <1> MemoryModel6:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   673                              <1> BankSize6:		db	0
   674                              <1> NumberOfImagePages6:	db	86
   675                              <1> Reserved_page6:		db	0
   676                              <1> RedMaskSize6:		db	8
   677                              <1> RedFieldPosition6:	db	16
   678                              <1> GreenMaskSize6:		db	8
   679                              <1> GreenFieldPosition6:	db	8
   680                              <1> BlueMaskSize6:		db	8
   681                              <1> BlueFieldPosition6:	db	0
   682                              <1> RsvdMaskSize6:		db	0
   683                              <1> RsvdFieldPosition6:	db	0
   684                              <1> DirectColorModeInfo6:	db	0
   685                              <1> PhysBasePtr6:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   686                              <1> OffScreenMemOffset6:	dd	0
   687                              <1> OffScreenMemSize6:	dw	0
   688                              <1> LinBytesPerScanLine6:	dw	960
   689                              <1> BnkNumberOfPages6: 	db	0
   690                              <1> LinNumberOfPages6: 	db	0
   691                              <1> LinRedMaskSize6:	db	8
   692                              <1> LinRedFieldPosition6:	db	16
   693                              <1> LinGreenMaskSize6:	db	8
   694                              <1> LinGreenFieldPosition6:	db	8
   695                              <1> LinBlueMaskSize6:	db	8
   696                              <1> LinBlueFieldPosition6:	db	0
   697                              <1> LinRsvdMaskSize6:	db	0
   698                              <1> LinRsvdFieldPosition6:	db	0
   699                              <1> MaxPixelClock6:		dd	0
   700                              <1> 	
   701                              <1> 			dw	0111h ; 640x480x16
   702                              <1> ModeAttributes7: 	dw	MODE_ATTRIBUTES
   703                              <1> WinAAttributes7: 	db	WINA_ATTRIBUTES
   704                              <1> WinBAttributes7: 	db	0
   705                              <1> WinGranularity7: 	dw	VBE_DISPI_BANK_SIZE_KB
   706                              <1> WinSize7: 		dw	VBE_DISPI_BANK_SIZE_KB
   707                              <1> WinASegment7:		dw	VGAMEM_GRAPH
   708                              <1> WinBSegment7:		dw	0000h
   709                              <1> WinFuncPtr7:		dd	0
   710                              <1> BytesPerScanLine7:	dw	1280
   711                              <1> XResolution7:		dw	640
   712                              <1> YResolution7:		dw	480
   713                              <1> XCharSize7:		db	8
   714                              <1> YCharSize7:		db	16
   715                              <1> NumberOfPlanes7:	db	1
   716                              <1> BitsPerPixel7:		db	16
   717                              <1> NumberOfBanks7:		db	10
   718                              <1> MemoryModel7:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   719                              <1> BankSize7:		db	0
   720                              <1> NumberOfImagePages7:	db	26
   721                              <1> Reserved_page7:		db	0
   722                              <1> RedMaskSize7:		db	5
   723                              <1> RedFieldPosition7:	db	11
   724                              <1> GreenMaskSize7:		db	6
   725                              <1> GreenFieldPosition7:	db	5
   726                              <1> BlueMaskSize7:		db	5
   727                              <1> BlueFieldPosition7:	db	0
   728                              <1> RsvdMaskSize7:		db	0
   729                              <1> RsvdFieldPosition7:	db	0
   730                              <1> DirectColorModeInfo7:	db	0
   731                              <1> PhysBasePtr7:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
   732                              <1> OffScreenMemOffset7:	dd	0
   733                              <1> OffScreenMemSize7:	dw	0
   734                              <1> LinBytesPerScanLine7:	dw	1280
   735                              <1> BnkNumberOfPages7: 	db	0
   736                              <1> LinNumberOfPages7: 	db	0
   737                              <1> LinRedMaskSize7:	db	5
   738                              <1> LinRedFieldPosition7:	db	11
   739                              <1> LinGreenMaskSize7:	db	6
   740                              <1> LinGreenFieldPosition7:	db	5
   741                              <1> LinBlueMaskSize7:	db	5
   742                              <1> LinBlueFieldPosition7:	db	0
   743                              <1> LinRsvdMaskSize7:	db	0
   744                              <1> LinRsvdFieldPosition7:	db	0
   745                              <1> MaxPixelClock7:		dd	0
   746                              <1> 
   747                              <1> 			dw	0112h ; 640x480x24
   748                              <1> ModeAttributes8: 	dw	MODE_ATTRIBUTES
   749                              <1> WinAAttributes8: 	db	WINA_ATTRIBUTES
   750                              <1> WinBAttributes8: 	db	0
   751                              <1> WinGranularity8: 	dw	VBE_DISPI_BANK_SIZE_KB
   752                              <1> WinSize8: 		dw	VBE_DISPI_BANK_SIZE_KB
   753                              <1> WinASegment8:		dw	VGAMEM_GRAPH
   754                              <1> WinBSegment8:		dw	0000h
   755                              <1> WinFuncPtr8:		dd	0
   756                              <1> BytesPerScanLine8:	dw	1920
   757                              <1> XResolution8:		dw	640
   758                              <1> YResolution8:		dw	480
   759                              <1> XCharSize8:		db	8
   760                              <1> YCharSize8:		db	16
   761                              <1> NumberOfPlanes8:	db	1
   762                              <1> BitsPerPixel8:		db	24
   763                              <1> NumberOfBanks8:		db	15
   764                              <1> MemoryModel8:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   765                              <1> BankSize8:		db	0
   766                              <1> NumberOfImagePages8:	db	17
   767                              <1> Reserved_page8:		db	0
   768                              <1> RedMaskSize8:		db	8
   769                              <1> RedFieldPosition8:	db	16
   770                              <1> GreenMaskSize8:		db	8
   771                              <1> GreenFieldPosition8:	db	8
   772                              <1> BlueMaskSize8:		db	8
   773                              <1> BlueFieldPosition8:	db	0
   774                              <1> RsvdMaskSize8:		db	0
   775                              <1> RsvdFieldPosition8:	db	0
   776                              <1> DirectColorModeInfo8:	db	0
   777                              <1> PhysBasePtr8:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   778                              <1> OffScreenMemOffset8:	dd	0
   779                              <1> OffScreenMemSize8:	dw	0
   780                              <1> LinBytesPerScanLine8:	dw	1920
   781                              <1> BnkNumberOfPages8: 	db	0
   782                              <1> LinNumberOfPages8: 	db	0
   783                              <1> LinRedMaskSize8:	db	8
   784                              <1> LinRedFieldPosition8:	db	16
   785                              <1> LinGreenMaskSize8:	db	8
   786                              <1> LinGreenFieldPosition8:	db	8
   787                              <1> LinBlueMaskSize8:	db	8
   788                              <1> LinBlueFieldPosition8:	db	0
   789                              <1> LinRsvdMaskSize8:	db	0
   790                              <1> LinRsvdFieldPosition8:	db	0
   791                              <1> MaxPixelClock8:		dd	0
   792                              <1> 
   793                              <1> 			dw	0114h ; 800x600x16
   794                              <1> ModeAttributes9: 	dw	MODE_ATTRIBUTES
   795                              <1> WinAAttributes9: 	db	WINA_ATTRIBUTES
   796                              <1> WinBAttributes9: 	db	0
   797                              <1> WinGranularity9: 	dw	VBE_DISPI_BANK_SIZE_KB
   798                              <1> WinSize9: 		dw	VBE_DISPI_BANK_SIZE_KB
   799                              <1> WinASegment9:		dw	VGAMEM_GRAPH
   800                              <1> WinBSegment9:		dw	0000h
   801                              <1> WinFuncPtr9:		dd	0
   802                              <1> BytesPerScanLine9:	dw	1600
   803                              <1> XResolution9:		dw	800
   804                              <1> YResolution9:		dw	600
   805                              <1> XCharSize9:		db	8
   806                              <1> YCharSize9:		db	16
   807                              <1> NumberOfPlanes9:	db	1
   808                              <1> BitsPerPixel9:		db	16
   809                              <1> NumberOfBanks9:		db	15
   810                              <1> MemoryModel9:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   811                              <1> BankSize9:		db	0
   812                              <1> NumberOfImagePages9:	db	16
   813                              <1> Reserved_page9:		db	0
   814                              <1> RedMaskSize9:		db	5
   815                              <1> RedFieldPosition9:	db	11
   816                              <1> GreenMaskSize9:		db	6
   817                              <1> GreenFieldPosition9:	db	5
   818                              <1> BlueMaskSize9:		db	5
   819                              <1> BlueFieldPosition9:	db	0
   820                              <1> RsvdMaskSize9:		db	0
   821                              <1> RsvdFieldPosition9:	db	0
   822                              <1> DirectColorModeInfo9:	db	0
   823                              <1> PhysBasePtr9:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   824                              <1> OffScreenMemOffset9:	dd	0
   825                              <1> OffScreenMemSize9:	dw	0
   826                              <1> LinBytesPerScanLine9:	dw	1600
   827                              <1> BnkNumberOfPages9: 	db	0
   828                              <1> LinNumberOfPages9: 	db	0
   829                              <1> LinRedMaskSize9:	db	5
   830                              <1> LinRedFieldPosition9:	db	11
   831                              <1> LinGreenMaskSize9:	db	6
   832                              <1> LinGreenFieldPosition9:	db	5
   833                              <1> LinBlueMaskSize9:	db	5
   834                              <1> LinBlueFieldPosition9:	db	0
   835                              <1> LinRsvdMaskSize9:	db	0
   836                              <1> LinRsvdFieldPosition9:	db	0
   837                              <1> MaxPixelClock9:		dd	0
   838                              <1> 	
   839                              <1> 			dw	0115h ; 800x600x24
   840                              <1> ModeAttributes10: 	dw	MODE_ATTRIBUTES
   841                              <1> WinAAttributes10: 	db	WINA_ATTRIBUTES
   842                              <1> WinBAttributes10: 	db	0
   843                              <1> WinGranularity10: 	dw	VBE_DISPI_BANK_SIZE_KB
   844                              <1> WinSize10: 		dw	VBE_DISPI_BANK_SIZE_KB
   845                              <1> WinASegment10:		dw	VGAMEM_GRAPH
   846                              <1> WinBSegment10:		dw	0000h
   847                              <1> WinFuncPtr10:		dd	0
   848                              <1> BytesPerScanLine10:	dw	2400
   849                              <1> XResolution10:		dw	800
   850                              <1> YResolution10:		dw	600
   851                              <1> XCharSize10:		db	8
   852                              <1> YCharSize10:		db	16
   853                              <1> NumberOfPlanes10:	db	1
   854                              <1> BitsPerPixel10:		db	24
   855                              <1> NumberOfBanks10:	db	22
   856                              <1> MemoryModel10:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   857                              <1> BankSize10:		db	0
   858                              <1> NumberOfImagePages10:	db	10
   859                              <1> Reserved_page10:	db	0
   860                              <1> RedMaskSize10:		db	8
   861                              <1> RedFieldPosition10:	db	16
   862                              <1> GreenMaskSize10:	db	8
   863                              <1> GreenFieldPosition10:	db	8
   864                              <1> BlueMaskSize10:		db	8
   865                              <1> BlueFieldPosition10:	db	0
   866                              <1> RsvdMaskSize10:		db	0
   867                              <1> RsvdFieldPosition10:	db	0
   868                              <1> DirectColorModeInfo10:	db	0
   869                              <1> PhysBasePtr10:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   870                              <1> OffScreenMemOffset10:	dd	0
   871                              <1> OffScreenMemSize10:	dw	0
   872                              <1> LinBytesPerScanLine10:	dw	2400
   873                              <1> BnkNumberOfPages10: 	db	0
   874                              <1> LinNumberOfPages10: 	db	0
   875                              <1> LinRedMaskSize10:	db	8
   876                              <1> LinRedFieldPosition10:	db	16
   877                              <1> LinGreenMaskSize10:	db	8
   878                              <1> LinGreenFieldPosition10:db	8
   879                              <1> LinBlueMaskSize10:	db	8
   880                              <1> LinBlueFieldPosition10:	db	0
   881                              <1> LinRsvdMaskSize10:	db	0
   882                              <1> LinRsvdFieldPosition10:	db	0
   883                              <1> MaxPixelClock10:	dd	0
   884                              <1> 
   885                              <1> 			dw	0117h ; 1024x768x16
   886                              <1> ModeAttributes11: 	dw	MODE_ATTRIBUTES
   887                              <1> WinAAttributes11: 	db	WINA_ATTRIBUTES
   888                              <1> WinBAttributes11: 	db	0
   889                              <1> WinGranularity11: 	dw	VBE_DISPI_BANK_SIZE_KB
   890                              <1> WinSize11: 		dw	VBE_DISPI_BANK_SIZE_KB
   891                              <1> WinASegment11:		dw	VGAMEM_GRAPH
   892                              <1> WinBSegment11:		dw	0000h
   893                              <1> WinFuncPtr11:		dd	0
   894                              <1> BytesPerScanLine11:	dw	2048
   895                              <1> XResolution11:		dw	1024
   896                              <1> YResolution11:		dw	768
   897                              <1> XCharSize11:		db	8
   898                              <1> YCharSize11:		db	16
   899                              <1> NumberOfPlanes11:	db	1
   900                              <1> BitsPerPixel11:		db	16
   901                              <1> NumberOfBanks11:	db	24
   902                              <1> MemoryModel11:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   903                              <1> BankSize11:		db	0
   904                              <1> NumberOfImagePages11:	db	9
   905                              <1> Reserved_page11:	db	0
   906                              <1> RedMaskSize11:		db	5
   907                              <1> RedFieldPosition11:	db	11
   908                              <1> GreenMaskSize11:	db	6
   909                              <1> GreenFieldPosition11:	db	5
   910                              <1> BlueMaskSize11:		db	5
   911                              <1> BlueFieldPosition11:	db	0
   912                              <1> RsvdMaskSize11:		db	0
   913                              <1> RsvdFieldPosition11:	db	0
   914                              <1> DirectColorModeInfo11:	db	0
   915                              <1> PhysBasePtr11:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
   916                              <1> OffScreenMemOffset11:	dd	0
   917                              <1> OffScreenMemSize11:	dw	0
   918                              <1> LinBytesPerScanLine11:	dw	2048
   919                              <1> BnkNumberOfPages11: 	db	0
   920                              <1> LinNumberOfPages11: 	db	0
   921                              <1> LinRedMaskSize11:	db	5
   922                              <1> LinRedFieldPosition11:	db	11
   923                              <1> LinGreenMaskSize11:	db	6
   924                              <1> LinGreenFieldPosition11:db	5
   925                              <1> LinBlueMaskSize11:	db	5
   926                              <1> LinBlueFieldPosition11:	db	0
   927                              <1> LinRsvdMaskSize11:	db	0
   928                              <1> LinRsvdFieldPosition11:	db	0
   929                              <1> MaxPixelClock11:	dd	0
   930                              <1> 
   931                              <1> 			dw	0118h ; 1024x768x24
   932                              <1> ModeAttributes12: 	dw	MODE_ATTRIBUTES
   933                              <1> WinAAttributes12: 	db	WINA_ATTRIBUTES
   934                              <1> WinBAttributes12: 	db	0
   935                              <1> WinGranularity12: 	dw	VBE_DISPI_BANK_SIZE_KB
   936                              <1> WinSize12: 		dw	VBE_DISPI_BANK_SIZE_KB
   937                              <1> WinASegment12:		dw	VGAMEM_GRAPH
   938                              <1> WinBSegment12:		dw	0000h
   939                              <1> WinFuncPtr12:		dd	0
   940                              <1> BytesPerScanLine12:	dw	3072
   941                              <1> XResolution12:		dw	1024
   942                              <1> YResolution12:		dw	768
   943                              <1> XCharSize12:		db	8
   944                              <1> YCharSize12:		db	16
   945                              <1> NumberOfPlanes12:	db	1
   946                              <1> BitsPerPixel12:		db	24
   947                              <1> NumberOfBanks12:	db	36
   948                              <1> MemoryModel12:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   949                              <1> BankSize12:		db	0
   950                              <1> NumberOfImagePages12:	db	6
   951                              <1> Reserved_page12:	db	0
   952                              <1> RedMaskSize12:		db	8
   953                              <1> RedFieldPosition12:	db	16
   954                              <1> GreenMaskSize12:	db	8
   955                              <1> GreenFieldPosition12:	db	8
   956                              <1> BlueMaskSize12:		db	8
   957                              <1> BlueFieldPosition12:	db	0
   958                              <1> RsvdMaskSize12:		db	0
   959                              <1> RsvdFieldPosition12:	db	0
   960                              <1> DirectColorModeInfo12:	db	0
   961                              <1> PhysBasePtr12:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   962                              <1> OffScreenMemOffset12:	dd	0
   963                              <1> OffScreenMemSize12:	dw	0
   964                              <1> LinBytesPerScanLine12:	dw	3072
   965                              <1> BnkNumberOfPages12: 	db	0
   966                              <1> LinNumberOfPages12: 	db	0
   967                              <1> LinRedMaskSize12:	db	8
   968                              <1> LinRedFieldPosition12:	db	16
   969                              <1> LinGreenMaskSize12:	db	8
   970                              <1> LinGreenFieldPosition12:db	8
   971                              <1> LinBlueMaskSize12:	db	8
   972                              <1> LinBlueFieldPosition12:	db	0
   973                              <1> LinRsvdMaskSize12:	db	0
   974                              <1> LinRsvdFieldPosition12:	db	0
   975                              <1> MaxPixelClock12:	dd	0
   976                              <1> 
   977                              <1> 			dw	0140h ; 320x200x32
   978                              <1> ModeAttributes13: 	dw	MODE_ATTRIBUTES
   979                              <1> WinAAttributes13: 	db	WINA_ATTRIBUTES
   980                              <1> WinBAttributes13: 	db	0
   981                              <1> WinGranularity13: 	dw	VBE_DISPI_BANK_SIZE_KB
   982                              <1> WinSize13: 		dw	VBE_DISPI_BANK_SIZE_KB
   983                              <1> WinASegment13:		dw	VGAMEM_GRAPH
   984                              <1> WinBSegment13:		dw	0000h
   985                              <1> WinFuncPtr13:		dd	0
   986                              <1> BytesPerScanLine13:	dw	1280
   987                              <1> XResolution13:		dw	320
   988                              <1> YResolution13:		dw	200
   989                              <1> XCharSize13:		db	8
   990                              <1> YCharSize13:		db	16
   991                              <1> NumberOfPlanes13:	db	1
   992                              <1> BitsPerPixel13:		db	32
   993                              <1> NumberOfBanks13:	db	4
   994                              <1> MemoryModel13:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   995                              <1> BankSize13:		db	0
   996                              <1> NumberOfImagePages13:	db	64
   997                              <1> Reserved_page13:	db	0
   998                              <1> RedMaskSize13:		db	8
   999                              <1> RedFieldPosition13:	db	16
  1000                              <1> GreenMaskSize13:	db	8
  1001                              <1> GreenFieldPosition13:	db	8
  1002                              <1> BlueMaskSize13:		db	8
  1003                              <1> BlueFieldPosition13:	db	0
  1004                              <1> RsvdMaskSize13:		db	8
  1005                              <1> RsvdFieldPosition13:	db	24
  1006                              <1> DirectColorModeInfo13:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  1007                              <1> PhysBasePtr13:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1008                              <1> OffScreenMemOffset13:	dd	0
  1009                              <1> OffScreenMemSize13:	dw	0
  1010                              <1> LinBytesPerScanLine13:	dw	1280
  1011                              <1> BnkNumberOfPages13: 	db	0
  1012                              <1> LinNumberOfPages13: 	db	0
  1013                              <1> LinRedMaskSize13:	db	8
  1014                              <1> LinRedFieldPosition13:	db	16
  1015                              <1> LinGreenMaskSize13:	db	8
  1016                              <1> LinGreenFieldPosition13:db	8
  1017                              <1> LinBlueMaskSize13:	db	8
  1018                              <1> LinBlueFieldPosition13:	db	0
  1019                              <1> LinRsvdMaskSize13:	db	8
  1020                              <1> LinRsvdFieldPosition13:	db	24
  1021                              <1> MaxPixelClock13:	dd	0
  1022                              <1> 
  1023                              <1> 			dw	0141h ; 640x400x32
  1024                              <1> ModeAttributes14: 	dw	MODE_ATTRIBUTES
  1025                              <1> WinAAttributes14: 	db	WINA_ATTRIBUTES
  1026                              <1> WinBAttributes14: 	db	0
  1027                              <1> WinGranularity14: 	dw	VBE_DISPI_BANK_SIZE_KB
  1028                              <1> WinSize14: 		dw	VBE_DISPI_BANK_SIZE_KB
  1029                              <1> WinASegment14:		dw	VGAMEM_GRAPH
  1030                              <1> WinBSegment14:		dw	0000h
  1031                              <1> WinFuncPtr14:		dd	0
  1032                              <1> BytesPerScanLine14:	dw	2560
  1033                              <1> XResolution14:		dw	640
  1034                              <1> YResolution14:		dw	400
  1035                              <1> XCharSize14:		db	8
  1036                              <1> YCharSize14:		db	16
  1037                              <1> NumberOfPlanes14:	db	1
  1038                              <1> BitsPerPixel14:		db	32
  1039                              <1> NumberOfBanks14:	db	16
  1040                              <1> MemoryModel14:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1041                              <1> BankSize14:		db	0
  1042                              <1> NumberOfImagePages14:	db	15
  1043                              <1> Reserved_page14:	db	0
  1044                              <1> RedMaskSize14:		db	8
  1045                              <1> RedFieldPosition14:	db	16
  1046                              <1> GreenMaskSize14:	db	8
  1047                              <1> GreenFieldPosition14:	db	8
  1048                              <1> BlueMaskSize14:		db	8
  1049                              <1> BlueFieldPosition14:	db	0
  1050                              <1> RsvdMaskSize14:		db	8
  1051                              <1> RsvdFieldPosition14:	db	24
  1052                              <1> DirectColorModeInfo14:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  1053                              <1> PhysBasePtr14:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1054                              <1> OffScreenMemOffset14:	dd  	0
  1055                              <1> OffScreenMemSize14:	dw	0
  1056                              <1> LinBytesPerScanLine14:	dw	2560
  1057                              <1> BnkNumberOfPages14: 	db	0
  1058                              <1> LinNumberOfPages14: 	db	0
  1059                              <1> LinRedMaskSize14:	db	8
  1060                              <1> LinRedFieldPosition14:	db	16
  1061                              <1> LinGreenMaskSize14:	db	8
  1062                              <1> LinGreenFieldPosition14:db	8
  1063                              <1> LinBlueMaskSize14:	db	8
  1064                              <1> LinBlueFieldPosition14:	db	0
  1065                              <1> LinRsvdMaskSize14:	db	8
  1066                              <1> LinRsvdFieldPosition14:	db	24
  1067                              <1> MaxPixelClock14:	dd	0
  1068                              <1> 
  1069                              <1> 			dw	0142 ; 640x480x32
  1070                              <1> ModeAttributes15: 	dw	MODE_ATTRIBUTES
  1071                              <1> WinAAttributes15: 	db	WINA_ATTRIBUTES
  1072                              <1> WinBAttributes15: 	db	0
  1073                              <1> WinGranularity15: 	dw	VBE_DISPI_BANK_SIZE_KB
  1074                              <1> WinSize15: 		dw	VBE_DISPI_BANK_SIZE_KB
  1075                              <1> WinASegment15:		dw	VGAMEM_GRAPH
  1076                              <1> WinBSegment15:		dw	0000h
  1077                              <1> WinFuncPtr15:		dd	0
  1078                              <1> BytesPerScanLine15:	dw	2560
  1079                              <1> XResolution15:		dw	640
  1080                              <1> YResolution15:		dw	480
  1081                              <1> XCharSize15:		db	8
  1082                              <1> YCharSize15:		db	16
  1083                              <1> NumberOfPlanes15:	db	1
  1084                              <1> BitsPerPixel15:		db	32
  1085                              <1> NumberOfBanks15:	db	19
  1086                              <1> MemoryModel15:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1087                              <1> BankSize15:		db	0
  1088                              <1> NumberOfImagePages15:	db	12
  1089                              <1> Reserved_page15:	db	0
  1090                              <1> RedMaskSize15:		db	8
  1091                              <1> RedFieldPosition15:	db	16
  1092                              <1> GreenMaskSize15:	db	8
  1093                              <1> GreenFieldPosition15:	db	8
  1094                              <1> BlueMaskSize15:		db	8
  1095                              <1> BlueFieldPosition15:	db	0
  1096                              <1> RsvdMaskSize15:		db	8
  1097                              <1> RsvdFieldPosition15:	db	24
  1098                              <1> DirectColorModeInfo15:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE,
  1099                              <1> PhysBasePtr15:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
  1100                              <1> OffScreenMemOffset15:	dd	0
  1101                              <1> OffScreenMemSize15:	dw	0
  1102                              <1> LinBytesPerScanLine15:	dw	2560
  1103                              <1> BnkNumberOfPages15: 	db	0
  1104                              <1> LinNumberOfPages15: 	db	0
  1105                              <1> LinRedMaskSize15:	db	8
  1106                              <1> LinRedFieldPosition15:	db	16
  1107                              <1> LinGreenMaskSize15:	db	8
  1108                              <1> LinGreenFieldPosition15:db	8
  1109                              <1> LinBlueMaskSize15:	db	8
  1110                              <1> LinBlueFieldPosition15:	db	0
  1111                              <1> LinRsvdMaskSize15:	db	8
  1112                              <1> LinRsvdFieldPosition15:	db	24
  1113                              <1> MaxPixelClock15:	dd	0
  1114                              <1> 
  1115                              <1> 			dw	0143h ; 800x600x32
  1116                              <1> ModeAttributes16: 	dw	MODE_ATTRIBUTES
  1117                              <1> WinAAttributes16: 	db	WINA_ATTRIBUTES
  1118                              <1> WinBAttributes16: 	db	0
  1119                              <1> WinGranularity16: 	dw	VBE_DISPI_BANK_SIZE_KB
  1120                              <1> WinSize16: 		dw	VBE_DISPI_BANK_SIZE_KB
  1121                              <1> WinASegment16:		dw	VGAMEM_GRAPH
  1122                              <1> WinBSegment16:		dw	0000h
  1123                              <1> WinFuncPtr16:		dd	0
  1124                              <1> BytesPerScanLine16:	dw	3200
  1125                              <1> XResolution16:		dw	800
  1126                              <1> YResolution16:		dw	600
  1127                              <1> XCharSize16:		db	8
  1128                              <1> YCharSize16:		db	16
  1129                              <1> NumberOfPlanes16:	db	1
  1130                              <1> BitsPerPixel16:		db	32
  1131                              <1> NumberOfBanks16:	db	30
  1132                              <1> MemoryModel16:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1133                              <1> BankSize16:		db	0
  1134                              <1> NumberOfImagePages16:	db	7
  1135                              <1> Reserved_page16:	db	0
  1136                              <1> RedMaskSize16:		db	8
  1137                              <1> RedFieldPosition16:	db	16
  1138                              <1> GreenMaskSize16:	db	8
  1139                              <1> GreenFieldPosition16:	db	8
  1140                              <1> BlueMaskSize16:		db	8
  1141                              <1> BlueFieldPosition16:	db	0
  1142                              <1> RsvdMaskSize16:		db	8
  1143                              <1> RsvdFieldPosition16:	db	24
  1144                              <1> DirectColorModeInfo16:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE,
  1145                              <1> PhysBasePtr16:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
  1146                              <1> OffScreenMemOffset16:	dd	0
  1147                              <1> OffScreenMemSize16:	dw	0
  1148                              <1> LinBytesPerScanLine16:	dw	3200
  1149                              <1> BnkNumberOfPages16: 	db	0
  1150                              <1> LinNumberOfPages16: 	db	0
  1151                              <1> LinRedMaskSize16:	db	8
  1152                              <1> LinRedFieldPosition16:	db	16
  1153                              <1> LinGreenMaskSize16:	db	8
  1154                              <1> LinGreenFieldPosition16:db	8
  1155                              <1> LinBlueMaskSize16:	db	8
  1156                              <1> LinBlueFieldPosition16:	db	0
  1157                              <1> LinRsvdMaskSize16:	db	8
  1158                              <1> LinRsvdFieldPosition16:	db	24
  1159                              <1> MaxPixelClock16:	dd	0
  1160                              <1> 	
  1161                              <1> 			dw	0144h ; 1024x768x32
  1162                              <1> ModeAttributes17: 	dw	MODE_ATTRIBUTES
  1163                              <1> WinAAttributes17: 	db	WINA_ATTRIBUTES
  1164                              <1> WinBAttributes17: 	db	0
  1165                              <1> WinGranularity17: 	dw	VBE_DISPI_BANK_SIZE_KB
  1166                              <1> WinSize17: 		dw	VBE_DISPI_BANK_SIZE_KB
  1167                              <1> WinASegment17:		dw	VGAMEM_GRAPH
  1168                              <1> WinBSegment17:		dw	0000h
  1169                              <1> WinFuncPtr17:		dd	0
  1170                              <1> BytesPerScanLine17:	dw	4096
  1171                              <1> XResolution17:		dw	1024
  1172                              <1> YResolution17:		dw	768
  1173                              <1> XCharSize17:		db	8
  1174                              <1> YCharSize17:		db	16
  1175                              <1> NumberOfPlanes17:	db	1
  1176                              <1> BitsPerPixel17:		db	32
  1177                              <1> NumberOfBanks17:	db	48
  1178                              <1> MemoryModel17:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1179                              <1> BankSize17:		db	0
  1180                              <1> NumberOfImagePages17:	db	4
  1181                              <1> Reserved_page17:	db	0
  1182                              <1> RedMaskSize17:		db	8
  1183                              <1> RedFieldPosition17:	db	16
  1184                              <1> GreenMaskSize17:	db	8
  1185                              <1> GreenFieldPosition17:	db	8
  1186                              <1> BlueMaskSize17:		db	8
  1187                              <1> BlueFieldPosition17:	db	0
  1188                              <1> RsvdMaskSize17:		db	8
  1189                              <1> RsvdFieldPosition17:	db	24
  1190                              <1> DirectColorModeInfo17:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  1191                              <1> PhysBasePtr17:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1192                              <1> OffScreenMemOffset17:	dd	0
  1193                              <1> OffScreenMemSize17:	dw	0
  1194                              <1> LinBytesPerScanLine17:	dw	4096
  1195                              <1> BnkNumberOfPages17: 	db	0
  1196                              <1> LinNumberOfPages17: 	db	0
  1197                              <1> LinRedMaskSize17:	db	8
  1198                              <1> LinRedFieldPosition17:	db	16
  1199                              <1> LinGreenMaskSize17:	db	8
  1200                              <1> LinGreenFieldPosition17:db	8
  1201                              <1> LinBlueMaskSize17:	db	8
  1202                              <1> LinBlueFieldPosition17:	db	0
  1203                              <1> LinRsvdMaskSize17:	db	8
  1204                              <1> LinRsvdFieldPosition17:	db	24
  1205                              <1> MaxPixelClock17:	dd	0
  1206                              <1> 	
  1207                              <1> 			dw	0146h ; 320x200x8
  1208                              <1> ModeAttributes18: 	dw	MODE_ATTRIBUTES
  1209                              <1> WinAAttributes18: 	db	WINA_ATTRIBUTES
  1210                              <1> WinBAttributes18: 	db	0
  1211                              <1> WinGranularity18: 	dw	VBE_DISPI_BANK_SIZE_KB
  1212                              <1> WinSize18: 		dw	VBE_DISPI_BANK_SIZE_KB
  1213                              <1> WinASegment18:		dw	VGAMEM_GRAPH
  1214                              <1> WinBSegment18:		dw	0000h
  1215                              <1> WinFuncPtr18:		dd	0
  1216                              <1> BytesPerScanLine18:	dw	320
  1217                              <1> XResolution18:		dw	320
  1218                              <1> YResolution18:		dw	200
  1219                              <1> XCharSize18:		db	8
  1220                              <1> YCharSize18:		db	16
  1221                              <1> NumberOfPlanes18:	db	1
  1222                              <1> BitsPerPixel18:		db	8
  1223                              <1> NumberOfBanks18:	db	1
  1224                              <1> MemoryModel18:		db	VBE_MEMORYMODEL_PACKED_PIXEL
  1225                              <1> BankSize18:		db	0
  1226                              <1> NumberOfImagePages18:	db	255 ; 261 in vbetables.h (03/01/2020) !
  1227                              <1> Reserved_page18:	db	0
  1228                              <1> RedMaskSize18:		db	0
  1229                              <1> RedFieldPosition18:	db	0
  1230                              <1> GreenMaskSize18:	db	0
  1231                              <1> GreenFieldPosition18:	db	0
  1232                              <1> BlueMaskSize18:		db	0
  1233                              <1> BlueFieldPosition18:	db	0
  1234                              <1> RsvdMaskSize18:		db	0
  1235                              <1> RsvdFieldPosition18:	db	0
  1236                              <1> DirectColorModeInfo18:	db	0
  1237                              <1> PhysBasePtr18:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1238                              <1> OffScreenMemOffset18:	dd	0
  1239                              <1> OffScreenMemSize18:	dw	0
  1240                              <1> LinBytesPerScanLine18:	dw	320
  1241                              <1> BnkNumberOfPages18: 	db	0
  1242                              <1> LinNumberOfPages18: 	db	0
  1243                              <1> LinRedMaskSize18:	db	0
  1244                              <1> LinRedFieldPosition18: 	db	0
  1245                              <1> LinGreenMaskSize18: 	db	0
  1246                              <1> LinGreenFieldPosition18:db	0
  1247                              <1> LinBlueMaskSize18: 	db	0
  1248                              <1> LinBlueFieldPosition18: db	0
  1249                              <1> LinRsvdMaskSize18: 	db	0
  1250                              <1> LinRsvdFieldPosition18: db	0
  1251                              <1> MaxPixelClock18:	dd	0
  1252                              <1> 
  1253                              <1> 			dw	018Dh ; 1280x720x16
  1254                              <1> ModeAttributes19: 	dw	MODE_ATTRIBUTES
  1255                              <1> WinAAttributes19: 	db	WINA_ATTRIBUTES
  1256                              <1> WinBAttributes19: 	db	0
  1257                              <1> WinGranularity19: 	dw	VBE_DISPI_BANK_SIZE_KB
  1258                              <1> WinSize19: 		dw	VBE_DISPI_BANK_SIZE_KB
  1259                              <1> WinASegment19:		dw	VGAMEM_GRAPH
  1260                              <1> WinBSegment19:		dw	0000h
  1261                              <1> WinFuncPtr19:		dd	0
  1262                              <1> BytesPerScanLine19:	dw	2560
  1263                              <1> XResolution19:		dw	1280
  1264                              <1> YResolution19:		dw	720
  1265                              <1> XCharSize19:		db	8
  1266                              <1> YCharSize19:		db	16
  1267                              <1> NumberOfPlanes19:	db	1
  1268                              <1> BitsPerPixel19:		db	16
  1269                              <1> NumberOfBanks19:	db	29
  1270                              <1> MemoryModel19:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1271                              <1> BankSize19:		db	0
  1272                              <1> NumberOfImagePages19:	db	8
  1273                              <1> Reserved_page19:	db	0
  1274                              <1> RedMaskSize19:		db	5
  1275                              <1> RedFieldPosition19:	db	11
  1276                              <1> GreenMaskSize19:	db	6
  1277                              <1> GreenFieldPosition19:	db	5
  1278                              <1> BlueMaskSize19:		db	5
  1279                              <1> BlueFieldPosition19:	db	0
  1280                              <1> RsvdMaskSize19:		db	0
  1281                              <1> RsvdFieldPosition19:	db	0
  1282                              <1> DirectColorModeInfo19:	db	0
  1283                              <1> PhysBasePtr19:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1284                              <1> OffScreenMemOffset19:	dd	0
  1285                              <1> OffScreenMemSize19:	dw	0
  1286                              <1> LinBytesPerScanLine19:	dw	2560
  1287                              <1> BnkNumberOfPages19: 	db	0
  1288                              <1> LinNumberOfPages19: 	db	0
  1289                              <1> LinRedMaskSize19:	db	5
  1290                              <1> LinRedFieldPosition19:	db	11
  1291                              <1> LinGreenMaskSize19:	db	6
  1292                              <1> LinGreenFieldPosition19:db	5
  1293                              <1> LinBlueMaskSize19:	db	5
  1294                              <1> LinBlueFieldPosition19:	db	0
  1295                              <1> LinRsvdMaskSize19:	db	0
  1296                              <1> LinRsvdFieldPosition19:	db	0
  1297                              <1> MaxPixelClock19:	dd	0
  1298                              <1> 
  1299                              <1> 			dw	018Eh ; 1280x720x24
  1300                              <1> ModeAttributes20: 	dw	MODE_ATTRIBUTES
  1301                              <1> WinAAttributes20: 	db	WINA_ATTRIBUTES
  1302                              <1> WinBAttributes20: 	db	0
  1303                              <1> WinGranularity20: 	dw	VBE_DISPI_BANK_SIZE_KB
  1304                              <1> WinSize20: 		dw	VBE_DISPI_BANK_SIZE_KB
  1305                              <1> WinASegment20:		dw	VGAMEM_GRAPH
  1306                              <1> WinBSegment20:		dw	0000h
  1307                              <1> WinFuncPtr20:		dd	0
  1308                              <1> BytesPerScanLine20:	dw	3840
  1309                              <1> XResolution20:		dw	1280
  1310                              <1> YResolution20:		dw	720
  1311                              <1> XCharSize20:		db	8
  1312                              <1> YCharSize20:		db	16
  1313                              <1> NumberOfPlanes20:	db	1
  1314                              <1> BitsPerPixel20:		db	24
  1315                              <1> NumberOfBanks20:	db	43
  1316                              <1> MemoryModel20:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1317                              <1> BankSize20:		db	0
  1318                              <1> NumberOfImagePages20:	db	5
  1319                              <1> Reserved_page20:	db	0
  1320                              <1> RedMaskSize20:		db	8
  1321                              <1> RedFieldPosition20:	db	16
  1322                              <1> GreenMaskSize20:	db	8
  1323                              <1> GreenFieldPosition20:	db	8
  1324                              <1> BlueMaskSize20:		db	8
  1325                              <1> BlueFieldPosition20:	db	0
  1326                              <1> RsvdMaskSize20:		db	0
  1327                              <1> RsvdFieldPosition20:	db	0
  1328                              <1> DirectColorModeInfo20:	db	0
  1329                              <1> PhysBasePtr20:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1330                              <1> OffScreenMemOffset20:	dd	0
  1331                              <1> OffScreenMemSize20:	dw	0
  1332                              <1> LinBytesPerScanLine20:	dw	3840
  1333                              <1> BnkNumberOfPages20: 	db	0
  1334                              <1> LinNumberOfPages20: 	db	0
  1335                              <1> LinRedMaskSize20:	db	8
  1336                              <1> LinRedFieldPosition20:	db	16
  1337                              <1> LinGreenMaskSize20:	db	8
  1338                              <1> LinGreenFieldPosition20:db	8
  1339                              <1> LinBlueMaskSize20:	db	8
  1340                              <1> LinBlueFieldPosition20:	db	0
  1341                              <1> LinRsvdMaskSize20:	db	0
  1342                              <1> LinRsvdFieldPosition20:	db	0
  1343                              <1> MaxPixelClock20:	dd	0
  1344                              <1> 	
  1345                              <1> 			dw	018Fh ; 1280x720x32
  1346                              <1> ModeAttributes21: 	dw	MODE_ATTRIBUTES
  1347                              <1> WinAAttributes21: 	db	WINA_ATTRIBUTES
  1348                              <1> WinBAttributes21: 	db	0
  1349                              <1> WinGranularity21: 	dw	VBE_DISPI_BANK_SIZE_KB
  1350                              <1> WinSize21: 		dw	VBE_DISPI_BANK_SIZE_KB
  1351                              <1> WinASegment21:		dw	VGAMEM_GRAPH
  1352                              <1> WinBSegment21:		dw	0000h
  1353                              <1> WinFuncPtr21:		dd	0
  1354                              <1> BytesPerScanLine21:	dw	5120
  1355                              <1> XResolution21:		dw	1280
  1356                              <1> YResolution21:		dw	720
  1357                              <1> XCharSize21:		db	8
  1358                              <1> YCharSize21:		db	16
  1359                              <1> NumberOfPlanes21:	db	1
  1360                              <1> BitsPerPixel21:		db	32
  1361                              <1> NumberOfBanks21:	db	57
  1362                              <1> MemoryModel21:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1363                              <1> BankSize21:		db	0
  1364                              <1> NumberOfImagePages21:	db	3
  1365                              <1> Reserved_page21:	db	0
  1366                              <1> RedMaskSize21:		db	8
  1367                              <1> RedFieldPosition21:	db	16
  1368                              <1> GreenMaskSize21:	db	8
  1369                              <1> GreenFieldPosition21:	db	8
  1370                              <1> BlueMaskSize21:		db	8
  1371                              <1> BlueFieldPosition21:	db	0
  1372                              <1> RsvdMaskSize21:		db	8
  1373                              <1> RsvdFieldPosition21:	db	24
  1374                              <1> DirectColorModeInfo21:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  1375                              <1> PhysBasePtr21:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1376                              <1> OffScreenMemOffset21:	dd	0
  1377                              <1> OffScreenMemSize21:	dw	0
  1378                              <1> LinBytesPerScanLine21:	dw	5120
  1379                              <1> BnkNumberOfPages21: 	db	0
  1380                              <1> LinNumberOfPages21: 	db	0
  1381                              <1> LinRedMaskSize21:	db	8
  1382                              <1> LinRedFieldPosition21:	db	16
  1383                              <1> LinGreenMaskSize21:	db	8
  1384                              <1> LinGreenFieldPosition21:db	8
  1385                              <1> LinBlueMaskSize21:	db	8
  1386                              <1> LinBlueFieldPosition21:	db	0
  1387                              <1> LinRsvdMaskSize21:	db	8
  1388                              <1> LinRsvdFieldPosition21:	db	24
  1389                              <1> MaxPixelClock21:	dd	0
  1390                              <1> 			
  1391                              <1> 			dw	0190h ; 1920x1080x16
  1392                              <1> ModeAttributes22: 	dw	MODE_ATTRIBUTES
  1393                              <1> WinAAttributes22: 	db	WINA_ATTRIBUTES
  1394                              <1> WinBAttributes22: 	db	0
  1395                              <1> WinGranularity22: 	dw	VBE_DISPI_BANK_SIZE_KB
  1396                              <1> WinSize22: 		dw	VBE_DISPI_BANK_SIZE_KB
  1397                              <1> WinASegment22:		dw	VGAMEM_GRAPH
  1398                              <1> WinBSegment22:		dw	0000h
  1399                              <1> WinFuncPtr22:		dd	0
  1400                              <1> BytesPerScanLine22:	dw	3840
  1401                              <1> XResolution22:		dw	1920
  1402                              <1> YResolution22:		dw	1080
  1403                              <1> XCharSize22:		db	8
  1404                              <1> YCharSize22:		db	16
  1405                              <1> NumberOfPlanes22:	db	1
  1406                              <1> BitsPerPixel22:		db	16
  1407                              <1> NumberOfBanks22:	db	64
  1408                              <1> MemoryModel22:		db	VBE_MEMORYMODEL_DIRECT_COLOR,
  1409                              <1> BankSize22:		db	0
  1410                              <1> NumberOfImagePages22:	db	3
  1411                              <1> Reserved_page22:	db	0
  1412                              <1> RedMaskSize22:		db	5
  1413                              <1> RedFieldPosition22:	db	11
  1414                              <1> GreenMaskSize22:	db	6
  1415                              <1> GreenFieldPosition22:	db	5
  1416                              <1> BlueMaskSize22:		db	5
  1417                              <1> BlueFieldPosition22:	db	0
  1418                              <1> RsvdMaskSize22:		db	0
  1419                              <1> RsvdFieldPosition22:	db	0
  1420                              <1> DirectColorModeInfo22:	db	0
  1421                              <1> PhysBasePtr22:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1422                              <1> OffScreenMemOffset22:	dd	0
  1423                              <1> OffScreenMemSize22:	dw	0
  1424                              <1> LinBytesPerScanLine22:	dw	3840
  1425                              <1> BnkNumberOfPages22: 	db	0
  1426                              <1> LinNumberOfPages22: 	db	0
  1427                              <1> LinRedMaskSize22:	db	5
  1428                              <1> LinRedFieldPosition22:	db	11
  1429                              <1> LinGreenMaskSize22:	db	6
  1430                              <1> LinGreenFieldPosition22:db	5
  1431                              <1> LinBlueMaskSize22:	db	5
  1432                              <1> LinBlueFieldPosition22:	db	0
  1433                              <1> LinRsvdMaskSize22:	db	0
  1434                              <1> LinRsvdFieldPosition22:	db	0
  1435                              <1> MaxPixelClock22:	dd	0
  1436                              <1> 			
  1437                              <1> 			dw	0191h ; 1920x1080x24
  1438                              <1> ModeAttributes23: 	dw	MODE_ATTRIBUTES
  1439                              <1> WinAAttributes23: 	db	WINA_ATTRIBUTES
  1440                              <1> WinBAttributes23: 	db	0
  1441                              <1> WinGranularity23: 	dw	VBE_DISPI_BANK_SIZE_KB
  1442                              <1> WinSize23: 		dw	VBE_DISPI_BANK_SIZE_KB
  1443                              <1> WinASegment23:		dw	VGAMEM_GRAPH
  1444                              <1> WinBSegment23:		dw	0000h
  1445                              <1> WinFuncPtr23:		dd	0
  1446                              <1> BytesPerScanLine23:	dw	5760
  1447                              <1> XResolution23:		dw	1920
  1448                              <1> YResolution23:		dw	1080
  1449                              <1> XCharSize23:		db	8
  1450                              <1> YCharSize23:		db	16
  1451                              <1> NumberOfPlanes23:	db	1
  1452                              <1> BitsPerPixel23:		db	24
  1453                              <1> NumberOfBanks23:	db	95
  1454                              <1> MemoryModel23:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1455                              <1> BankSize23:		db	0
  1456                              <1> NumberOfImagePages23:	db	1
  1457                              <1> Reserved_page23:	db	0
  1458                              <1> RedMaskSize23:		db	8
  1459                              <1> RedFieldPosition23:	db	16
  1460                              <1> GreenMaskSize23:	db	8
  1461                              <1> GreenFieldPosition23:	db	8
  1462                              <1> BlueMaskSize23:		db	8
  1463                              <1> BlueFieldPosition23:	db	0
  1464                              <1> RsvdMaskSize23:		db	0
  1465                              <1> RsvdFieldPosition23:	db	0
  1466                              <1> DirectColorModeInfo23:	db	0
  1467                              <1> PhysBasePtr23:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1468                              <1> OffScreenMemOffset23:	dd	0
  1469                              <1> OffScreenMemSize23:	dw	0
  1470                              <1> LinBytesPerScanLine23:	dw	5760
  1471                              <1> BnkNumberOfPages23: 	db	0
  1472                              <1> LinNumberOfPages23: 	db	0
  1473                              <1> LinRedMaskSize23:	db	8
  1474                              <1> LinRedFieldPosition23:	db	16
  1475                              <1> LinGreenMaskSize23:	db	8
  1476                              <1> LinGreenFieldPosition23:db	8
  1477                              <1> LinBlueMaskSize23:	db	8
  1478                              <1> LinBlueFieldPosition23:	db	0
  1479                              <1> LinRsvdMaskSize23:	db	0
  1480                              <1> LinRsvdFieldPosition23:	db	0
  1481                              <1> MaxPixelClock23:	dd	0
  1482                              <1> 
  1483                              <1> 			dw	0192h ; 1920x1080x32
  1484                              <1> ModeAttributes24: 	dw	MODE_ATTRIBUTES
  1485                              <1> WinAAttributes24: 	db	WINA_ATTRIBUTES
  1486                              <1> WinBAttributes24: 	db	0
  1487                              <1> WinGranularity24: 	dw	VBE_DISPI_BANK_SIZE_KB
  1488                              <1> WinSize24: 		dw	VBE_DISPI_BANK_SIZE_KB
  1489                              <1> WinASegment24:		dw	VGAMEM_GRAPH
  1490                              <1> WinBSegment24:		dw	0000h
  1491                              <1> WinFuncPtr24:		dd	0
  1492                              <1> BytesPerScanLine24:	dw	7680
  1493                              <1> XResolution24:		dw	1920
  1494                              <1> YResolution24:		dw	1080
  1495                              <1> XCharSize24:		db	8
  1496                              <1> YCharSize24:		db	16
  1497                              <1> NumberOfPlanes24:	db	1
  1498                              <1> BitsPerPixel24:		db	32
  1499                              <1> NumberOfBanks24:	db	127
  1500                              <1> MemoryModel24:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1501                              <1> BankSize24:		db	0
  1502                              <1> NumberOfImagePages24:	db	1
  1503                              <1> Reserved_page24:	db	0
  1504                              <1> RedMaskSize24:		db	8
  1505                              <1> RedFieldPosition24:	db	16
  1506                              <1> GreenMaskSize24:	db	8
  1507                              <1> GreenFieldPosition24:	db	8
  1508                              <1> BlueMaskSize24:		db	8
  1509                              <1> BlueFieldPosition24:	db	0
  1510                              <1> RsvdMaskSize24:		db	8
  1511                              <1> RsvdFieldPosition24:	db	24
  1512                              <1> DirectColorModeInfo24:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  1513                              <1> PhysBasePtr24:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1514                              <1> OffScreenMemOffset24:	dd	0
  1515                              <1> OffScreenMemSize24:	dw	0
  1516                              <1> LinBytesPerScanLine24:	dw 	7680
  1517                              <1> BnkNumberOfPages24: 	db	0
  1518                              <1> LinNumberOfPages24: 	db	0
  1519                              <1> LinRedMaskSize24:	db	8
  1520                              <1> LinRedFieldPosition24:	db	16
  1521                              <1> LinGreenMaskSize24:	db	8
  1522                              <1> LinGreenFieldPosition24:db	8
  1523                              <1> LinBlueMaskSize24:	db	8
  1524                              <1> LinBlueFieldPosition24:	db	0
  1525                              <1> LinRsvdMaskSize24:	db	8
  1526                              <1> LinRsvdFieldPosition24:	db	24
  1527                              <1> MaxPixelClock24:	dd	0
  1528                              <1> 
  1529                              <1> VBE_VESA_MODE_END_OF_LIST: dw	0
  1530                              <1> 
  1531                              <1> %endif
  1532                              <1> 
  1533                              <1> ; 24/11/2020
  1534                              <1> 
  1535                              <1> direct_color_fields:
  1536                              <1> 	; 24/11/2020
  1537                              <1> 
  1538                              <1> ; (vbetables-gen.c)
  1539                              <1> ; // Direct Color fields 
  1540                              <1> ; (required for direct/6 and YUV/7 memory models)
  1541                              <1> ; switch(pm->depth) {
  1542                              <1>     
  1543                              <1> ;case 8:
  1544 00006B1A 00                  <1> r_size_8:  db 0
  1545 00006B1B 00                  <1> r_pos_8:   db 0
  1546 00006B1C 00                  <1> g_size_8:  db 0
  1547 00006B1D 00                  <1> g_pos_8:   db 0
  1548 00006B1E 00                  <1> b_size_8:  db 0
  1549 00006B1F 00                  <1> b_pos_8:   db 0
  1550 00006B20 00                  <1> a_size_8:  db 0
  1551 00006B21 00                  <1> a_pos_8:   db 0
  1552                              <1> 
  1553                              <1> ;case 16:
  1554 00006B22 05                  <1> r_size_16:  db 5
  1555 00006B23 0B                  <1> r_pos_16:   db 11
  1556 00006B24 06                  <1> g_size_16:  db 6
  1557 00006B25 05                  <1> g_pos_16:   db 5
  1558 00006B26 05                  <1> b_size_16:  db 5
  1559 00006B27 00                  <1> b_pos_16:   db 0
  1560 00006B28 00                  <1> a_size_16:  db 0
  1561 00006B29 00                  <1> a_pos_16:   db 0
  1562                              <1> 
  1563                              <1> ;case 24:
  1564 00006B2A 08                  <1> r_size_24:  db 8
  1565 00006B2B 10                  <1> r_pos_24:   db 16
  1566 00006B2C 08                  <1> g_size_24:  db 8
  1567 00006B2D 08                  <1> g_pos_24:   db 8
  1568 00006B2E 08                  <1> b_size_24:  db 8
  1569 00006B2F 00                  <1> b_pos_24:   db 0
  1570 00006B30 00                  <1> a_size_24:  db 0
  1571 00006B31 00                  <1> a_pos_24:   db 0
  1572                              <1> 
  1573                              <1> ;case 32:
  1574 00006B32 08                  <1> r_size_32:  db 8
  1575 00006B33 10                  <1> r_pos_32:   db 16
  1576 00006B34 08                  <1> g_size_32:  db 8
  1577 00006B35 08                  <1> g_pos_32:   db 8
  1578 00006B36 08                  <1> b_size_32:  db 8
  1579 00006B37 00                  <1> b_pos_32:   db 0
  1580 00006B38 08                  <1> a_size_32:  db 8
  1581 00006B39 18                  <1> a_pos_32:   db 24
  3230                                  ;%include 'diskdata.s'	; DISK (BIOS) DATA (initialized)
  3231                                  ;;;
  3232                                  
  3233                                  Align 2
  3234                                  
  3235                                  %include 'sysdefs.s' ; 24/01/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - SYSTEM DEFINITIONS : sysdefs.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 23/07/2022  (Previous: 31/12/2017)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    11                              <1> ; sysdefs.inc (14/11/2015)
    12                              <1> ; ****************************************************************************
    13                              <1> 
    14                              <1> ; Retro UNIX 386 v1 Kernel - SYSDEFS.INC
    15                              <1> ; Last Modification: 14/11/2015
    16                              <1> ;
    17                              <1> ; ///////// RETRO UNIX 386 V1 SYSTEM DEFINITIONS ///////////////
    18                              <1> ; (Modified from 
    19                              <1> ;	Retro UNIX 8086 v1 system definitions in 'UNIX.ASM', 01/09/2014)
    20                              <1> ; ((UNIX.ASM (RETRO UNIX 8086 V1 Kernel), 11/03/2013 - 01/09/2014))
    21                              <1> ; 	UNIX.ASM (MASM 6.11) --> SYSDEFS.INC (NASM 2.11)
    22                              <1> ; ----------------------------------------------------------------------------
    23                              <1> ;
    24                              <1> ; Derived from UNIX Operating System (v1.0 for PDP-11) 
    25                              <1> ; (Original) Source Code by Ken Thompson (1971-1972)
    26                              <1> ; <Bell Laboratories (17/3/1972)>
    27                              <1> ; <Preliminary Release of UNIX Implementation Document>
    28                              <1> ;
    29                              <1> ; ****************************************************************************
    30                              <1> 
    31                              <1> nproc 	equ	16  ; number of processes
    32                              <1> ;nfiles equ	50
    33                              <1> ntty	equ     8   ; 8+1 -> 8 (10/05/2013)
    34                              <1> nbuf	equ	4   ; 6 ;; 21/08/2015 - 'namei' buffer problem when nbuf > 4 	
    35                              <1> 		; NOTE: If fd0 super block buffer addres is beyond of the 1st
    36                              <1> 		; 32K, DMA r/w routine or someting else causes a jump to 
    37                              <1> 		; kernel panic routine (in 'alloc' routine, in u5.s)
    38                              <1> 		; because of invalid buffer content (r/w error). 
    39                              <1> 		; When all buffers are set before the end of the 1st 32k,
    40                              <1> 		; there is no problem!? (14/11/2015) 
    41                              <1> 
    42                              <1> ;csgmnt	equ	2000h	; 26/05/2013 (segment of process 1)
    43                              <1> ;core	equ 	0  	    ; 19/04/2013	
    44                              <1> ;ecore	equ	32768 - 64  ; 04/06/2013 (24/05/2013)
    45                              <1> 	; (if total size of argument list and arguments is 128 bytes)
    46                              <1> 	; maximum executable file size = 32768-(64+40+128-6) = 32530 bytes
    47                              <1> 	; maximum stack size = 40 bytes (+6 bytes for 'IRET' at 32570)	
    48                              <1> 	; initial value of user's stack pointer = 32768-64-128-2 = 32574
    49                              <1> 	; 	(sp=32768-args_space-2 at the beginning of execution)
    50                              <1> 	; argument list offset = 32768-64-128 = 32576 (if it is 128 bytes)
    51                              <1> 	; 'u' structure offset (for the '/core' dump file) = 32704
    52                              <1> 	; '/core' dump file size = 32768 bytes
    53                              <1>  
    54                              <1> ; 08/03/2014 
    55                              <1> ;sdsegmnt equ	6C0h  ; 256*16 bytes (swap data segment size for 16 processes)		 	 
    56                              <1> ; 19/04/2013 Retro UNIX 8086 v1 feaure only !
    57                              <1> ;;sdsegmnt equ 	740h  ; swap data segment (for user structures and registers)
    58                              <1> 
    59                              <1> ; 30/08/2013
    60                              <1> time_count equ 4 ; 10 --> 4 01/02/2014
    61                              <1> 
    62                              <1> ; 05/02/2014
    63                              <1> ; process status
    64                              <1> ;SFREE 	equ 0
    65                              <1> ;SRUN	equ 1
    66                              <1> ;SWAIT	equ 2
    67                              <1> ;SZOMB	equ 3
    68                              <1> ;SSLEEP	equ 4 ; Retro UNIX 8086 V1 extension (for sleep and wakeup)
    69                              <1> 
    70                              <1> ; 09/03/2015
    71                              <1> userdata equ 80000h ; user structure data address for current user ; temporary
    72                              <1> swap_queue equ 90000h - 2000h ; swap queue address ; temporary
    73                              <1> swap_alloc_table equ 0D0000h  ;  swap allocation table address ; temporary
    74                              <1> 
    75                              <1> ; 17/09/2015
    76                              <1> ESPACE equ 48 ; [u.usp] (at 'sysent') - [u.sp] value for error return
    77                              <1> 
    78                              <1> ; 31/12/2017
    79                              <1> ; 19/02/2017
    80                              <1> ; 15/10/2016
    81                              <1> ; 20/05/2016
    82                              <1> ; 19/05/2016
    83                              <1> ; 18/05/2016
    84                              <1> ; 29/04/2016 
    85                              <1> ; TRDOS 386 (TRDOS v2.0) system calls - temporary List 
    86                              <1> ; 14/07/2013 - 21/09/2015 (Retro UNIX 8086 & 386 system calls) 
    87                              <1> _ver 	equ 0 ; Get TRDOS version (v2.0)
    88                              <1> _exit 	equ 1
    89                              <1> _fork 	equ 2
    90                              <1> _read 	equ 3
    91                              <1> _write	equ 4
    92                              <1> _open	equ 5
    93                              <1> _close 	equ 6
    94                              <1> _wait 	equ 7
    95                              <1> _creat 	equ 8
    96                              <1> _rename	equ 9  ; TRDOS 386, Rename File (31/12/2017)	
    97                              <1> _delete	equ 10 ; TRDOS 386, Delete File (29/12/2017)
    98                              <1> _exec	equ 11
    99                              <1> _chdir	equ 12
   100                              <1> _time 	equ 13 ; TRDOS 386, Get Sys Date&Time (30/12/2017)
   101                              <1> _mkdir 	equ 14
   102                              <1> _chmod	equ 15 ; TRDOS 386, Change Attributes (30/12/2017) 
   103                              <1> _rmdir	equ 16 ; TRDOS 386, Remove Directory (29/12/2017)
   104                              <1> _break	equ 17
   105                              <1> _drive	equ 18 ; TRDOS 386, Get/Set Current Drv (30/12/2017) 
   106                              <1> _seek	equ 19
   107                              <1> _tell 	equ 20
   108                              <1> _mem	equ 21 ; TRDOS 386, Get Total&Free Mem (31/12/2017)
   109                              <1> _prompt	equ 22 ; TRDOS 386, Change Cmd Prompt (31/12/2017)
   110                              <1> _path	equ 23 ; TRDOS 386, Get/Set Run Path (31/12/2017)
   111                              <1> _env	equ 24 ; TRDOS 386, Get/Set Env Vars (31/12/2017)
   112                              <1> _stime	equ 25 ; TRDOS 386, Set Sys Date&Time (30/12/2017)
   113                              <1> _quit	equ 26	
   114                              <1> _intr	equ 27
   115                              <1> _dir	equ 28 ; TRDOS 386, Get Curr Drive&Dir (30/12/2017) 
   116                              <1> _emt 	equ 29
   117                              <1> _ldrvt 	equ 30 ; TRDOS 386, Get Logical DOS DDT (30/12/2017)
   118                              <1> _video  equ 31 ; TRDOS 386 Video Functions (16/05/2016)
   119                              <1> _audio	equ 32 ; TRDOS 386 Video Functions (16/05/2016)
   120                              <1> _timer	equ 33 ; TRDOS 386 Timer Functions (18/05/2016)
   121                              <1> _sleep	equ 34 ; Retro UNIX 8086 v1 feature only !
   122                              <1> _msg	equ 35 ; Retro UNIX 386 v1 feature only !
   123                              <1> _geterr	equ 36 ; Retro UNIX 386 v1 feature only !
   124                              <1> _fpsave equ 37 ; TRDOS 386 FPU state option (28/02/2017)
   125                              <1> _pri 	equ 38 ; change priority - TRDOS 386 (20/05/2016)
   126                              <1> _rele	equ 39 ; TRDOS 386 (19/05/2016)
   127                              <1> _fff	equ 40 ; Find First File - TRDOS 386 (15/10/2016)
   128                              <1> _fnf	equ 41 ; Find Next File - TRDOS 386 (15/10/2016)
   129                              <1> _alloc	equ 42 ; Allocate memory - TRDOS 386 (19/02/2017)
   130                              <1> 	       ; TRDOS 386 (19/02/2017) DMA buff fuctions		
   131                              <1> _dalloc equ 43 ; Deallocate mem - TRDOS 386 (19/02/2017)
   132                              <1> _calbac equ 44 ; Set IRQ callback - TRDOS 386 (20/02/2017)  				
   133                              <1> _dma	equ 45 ; DMA service - TRDOS 386 (20/08/2017)  
   134                              <1> 
   135                              <1> %macro sys 1-4
   136                              <1>     ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
   137                              <1>     ; 03/09/2015	
   138                              <1>     ; 13/04/2015
   139                              <1>     ; Retro UNIX 386 v1 system call.		
   140                              <1>     %if %0 >= 2   
   141                              <1>         mov ebx, %2
   142                              <1>         %if %0 >= 3    
   143                              <1>             mov ecx, %3
   144                              <1>             %if %0 = 4
   145                              <1>                mov edx, %4   
   146                              <1>             %endif
   147                              <1>         %endif
   148                              <1>     %endif
   149                              <1>     mov eax, %1
   150                              <1>     ;int 30h
   151                              <1>     int 40h ; TRDOS 386 (TRDOS v2.0)		   
   152                              <1> %endmacro
   153                              <1> 
   154                              <1> ; TRDOS 386 system calls, interrupt number
   155                              <1> ; 25/12/2016
   156                              <1> SYSCALL_INT_NUM   equ '40' ; '40h'
   157                              <1> 
   158                              <1> ; 13/05/2015 - ERROR CODES
   159                              <1> ERR_FILE_NOT_OPEN  equ 10 ; 'file not open !' error
   160                              <1> ERR_FILE_ACCESS    equ 11 ; 'permission denied !' error
   161                              <1> ; 14/05/2015
   162                              <1> ERR_DIR_ACCESS     equ 11 ; 'permission denied !' error
   163                              <1> ERR_FILE_NOT_FOUND equ 12 ; 'file not found !' error
   164                              <1> ERR_TOO_MANY_FILES equ 13 ; 'too many open files !' error
   165                              <1> ERR_DIR_EXISTS     equ 14 ; 'directory already exists !' error 	
   166                              <1> ; 16/05/2015		
   167                              <1> ERR_DRV_NOT_RDY    equ 15 ; 'drive not ready !' error
   168                              <1> ; 18/05/2015
   169                              <1> ERR_DEV_NOT_RDY    equ 15 ; 'device not ready !' error
   170                              <1> ERR_DEV_ACCESS     equ 11 ; 'permission denied !' error 
   171                              <1> ERR_DEV_NOT_OPEN   equ 10 ; 'device not open !' error	
   172                              <1> ; 07/06/2015
   173                              <1> ERR_FILE_EOF	   equ 16 ; 'end of file !' error
   174                              <1> ERR_DEV_VOL_SIZE   equ 16 ; 'out of volume !' error
   175                              <1> ; 09/06/2015
   176                              <1> ERR_DRV_READ	   equ 17 ; 'disk read error !'
   177                              <1> ERR_DRV_WRITE	   equ 18 ; 'disk write error !'
   178                              <1> ; 16/06/2015
   179                              <1> ERR_NOT_DIR	   equ 19 ; 'not a (valid) directory !' error
   180                              <1> ERR_FILE_SIZE	   equ 20 ; 'file size error !'	
   181                              <1> ; 22/06/2015
   182                              <1> ERR_NOT_SUPERUSER  equ 11 ; 'permission denied !' error
   183                              <1> ERR_NOT_OWNER      equ 11 ; 'permission denied !' error
   184                              <1> ERR_NOT_FILE       equ 11 ; 'permission denied !' error	
   185                              <1> ; 23/06/2015
   186                              <1> ERR_FILE_EXISTS    equ 14 ; 'file already exists !' error
   187                              <1> ERR_DRV_NOT_SAME   equ 21 ; 'not same drive !' error
   188                              <1> ERR_DIR_NOT_FOUND  equ 12 ; 'directory not found !' error
   189                              <1> ERR_NOT_EXECUTABLE equ 22 ; 'not executable file !' error
   190                              <1> ; 27/06/2015
   191                              <1> ERR_INV_PARAMETER  equ 23 ; 'invalid parameter !' error
   192                              <1> ERR_INV_DEV_NAME   equ 24 ; 'invalid device name !' error
   193                              <1> ; 29/06/2015
   194                              <1> ERR_TIME_OUT	   equ 25 ; 'time out !' error			
   195                              <1> ERR_DEV_NOT_RESP   equ 25 ; 'device not responding !' error
   196                              <1> ; 10/10/2016
   197                              <1> ERR_INV_FILE_NAME  equ 26 ; 'invalid file name !' error
   198                              <1> ERR_INV_FLAGS	   equ 23 ; 'invalid flags !' error
   199                              <1> ; For code compatibility with previous version of TRDOS (2011)
   200                              <1> ; (Temporary error codes for current TRDOS 386 -2016- version) 
   201                              <1> ERR_NO_MORE_FILES  equ 12 ; 'no more files !' error
   202                              <1> ERR_PATH_NOT_FOUND equ  3 ; 'path not found !' error 
   203                              <1> 			  ; 'dir not found !' ; TRDOS 8086
   204                              <1> ERR_NOT_FOUND:	   equ  2 ; 'file not found !' ; TRDOS 8086
   205                              <1> ERR_DISK_SPACE	   equ 39 ; 'out of volume !' TRDOS 8086
   206                              <1> 			  ; 'insufficient disk space !' ; 27h
   207                              <1> ERR_DISK_WRITE	   equ 30 ; 'disk write protected !' ; 16/10/2016
   208                              <1> ERR_ACCESS_DENIED  equ  5 ; 'access denied !' ; TRDOS 8086 	
   209                              <1> ; 28/02/2017
   210                              <1> ERR_PERM_DENIED	   equ 11 ; 'permission denied !' error  	
   211                              <1> ; 18/05/2016
   212                              <1> ERR_MISC	   equ 27 ; miscellaneous/other errors
   213                              <1> ; 15/10/2016
   214                              <1> ; TRDOS 8086 -> TRDOS 386 (0Bh -> 28)
   215                              <1> ERR_INV_FORMAT	   equ 28 ; 'invalid format !' error
   216                              <1> ; TRDOS 8086 -> TRDOS 386 (0Dh -> 29)
   217                              <1> ERR_INV_DATA	   equ 29 ; 'invalid data !' error
   218                              <1> ; TRDOS 8086 -> TRDOS 386 (0Eh -> 20)
   219                              <1> ERR_ZERO_LENGTH	   equ 20  ; 'zero length !' error 	
   220                              <1> ; TRDOS 8086 -> TRDOS 386 (15h -> 17, 1Dh -> 18, 1Eh -> 17) 	
   221                              <1> ERR_DRV_NR_READ	   equ 17 ; 'drive not ready or read error !'
   222                              <1> ERR_DRV_NR_WRITE   equ 18 ; 'drive not ready or write error !'		
   223                              <1> ; 15/10/2016
   224                              <1> ERR_INV_PATH_NAME  equ 19 ; 'bad path name !' error
   225                              <1> ERR_BAD_CMD_ARG	   equ  1 ; 'bad command argument !' ; TRDOS 8086
   226                              <1> ERR_INV_FNUMBER	   equ  1 ; 'invalid function number !' ; TRDOS 8086
   227                              <1> ERR_BIG_FILE	   equ  8 ; 'big file & out of memory ! ; TRDOS 8086 	
   228                              <1> ERR_BIG_DATA	   equ  8 ; 'big data & out of memory ! ; TRDOS 8086
   229                              <1> ERR_CLUSTER	   equ 35 ; 'cluster not available !' ; TRDOS 8086
   230                              <1> ERR_OUT_OF_MEMORY  equ  4 ; 'out of memory !'
   231                              <1> 			  ; 'insufficient memory !'
   232                              <1> ERR_P_VIOLATION	   equ	6 ; 'protection violation !'
   233                              <1> ERR_PAGE_FAULT	   equ 224 ;'page fault !' ;0E0h						 
   234                              <1> ERR_SWP_DISK_READ  	   equ 40
   235                              <1> ERR_SWP_DISK_NOT_PRESENT   equ 41
   236                              <1> ERR_SWP_SECTOR_NOT_PRESENT equ 42
   237                              <1> ERR_SWP_NO_FREE_SPACE      equ 43
   238                              <1> ERR_SWP_DISK_WRITE         equ 44
   239                              <1> ERR_SWP_NO_PAGE_TO_SWAP    equ 45
   240                              <1> ; 10/04/2017
   241                              <1> ERR_BUFFER	   equ 46  ; 'buffer error !'
   242                              <1> ; 28/08/2017 (20/08/2017)
   243                              <1> ERR_DMA		   equ -1  ; DMA buffer (allocation/misc.) error!
   244                              <1> 
   245                              <1> ; 26/08/2015
   246                              <1> ; 24/07/2015
   247                              <1> ; 24/06/2015
   248                              <1> MAX_ARG_LEN	   equ 256 ; max. length of sys exec arguments
   249                              <1> ; 01/07/2015
   250                              <1> MAX_MSG_LEN	   equ 255 ; max. msg length for 'sysmsg'
   251                              <1> ;	
   252                              <1> ; 06/10/2016
   253                              <1> ;OPENFILES	   equ 10  ; max. number of open files (system)
   254                              <1> ; 23/07/2022
   255                              <1> OPENFILES	   equ 32  ; max. number of open files (system)
   256                              <1> ; 07/10/2016
   257                              <1> ;NUMOFDEVICES	   equ 20  ; max. num of available devices (sys)
   258                              <1> 			 		
  3236                                  %include 'trdosk0.s' ; 04/01/2016 
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - DEFINITIONS : trdosk0.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 29/02/2016
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 04/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; TRDOS2.ASM (09/11/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; TRDOS2.ASM (c) 2004-2011 Erdogan TAN [ 17/01/2004 ] Last Update: 09/11/2011
    14                              <1> ;
    15                              <1> ; Masterboot / Partition Table at Beginning+1BEh
    16                              <1> ptBootable       equ 0
    17                              <1> ptBeginHead      equ 1
    18                              <1> ptBeginSector    equ 2
    19                              <1> ptBeginCylinder  equ 3
    20                              <1> ptFileSystemID   equ 4
    21                              <1> ptEndHead        equ 5
    22                              <1> ptEndSector      equ 6
    23                              <1> ptEndCylinder    equ 7
    24                              <1> ptStartSector    equ 8
    25                              <1> ptSectors        equ 12
    26                              <1> 
    27                              <1> ; Boot Sector Parameters at 7C00h
    28                              <1> DataArea1     equ -4
    29                              <1> DataArea2     equ -2
    30                              <1> BootStart     equ 0h
    31                              <1> OemName       equ 03h
    32                              <1> BytesPerSec   equ 0Bh
    33                              <1> SecPerClust   equ 0Dh
    34                              <1> ResSectors    equ 0Eh
    35                              <1> FATs          equ 10h
    36                              <1> RootDirEnts   equ 11h
    37                              <1> Sectors       equ 13h
    38                              <1> Media         equ 15h
    39                              <1> FATSecs       equ 16h
    40                              <1> SecPerTrack   equ 18h
    41                              <1> Heads         equ 1Ah 
    42                              <1> Hidden1       equ 1Ch
    43                              <1> Hidden2       equ 1Eh
    44                              <1> HugeSec1      equ 20h
    45                              <1> HugeSec2      equ 22h
    46                              <1> DriveNumber   equ 24h
    47                              <1> Reserved1     equ 25h
    48                              <1> bootsignature equ 26h                 
    49                              <1> VolumeID      equ 27h
    50                              <1> VolumeLabel   equ 2Bh
    51                              <1> FileSysType   equ 36h          
    52                              <1> Reserved2     equ 3Eh                           ; Starting cluster of P2000
    53                              <1> 
    54                              <1> ; FAT32 BPB Structure
    55                              <1> FAT32_FAT_Size equ 36
    56                              <1> FAT32_RootFClust equ 44
    57                              <1> FAT32_FSInfoSec equ 48
    58                              <1> FAT32_DrvNum equ 64
    59                              <1> FAT32_BootSig equ 66
    60                              <1> FAT32_VolID equ 67
    61                              <1> FAT32_VolLab equ 71
    62                              <1> FAT32_FilSysType equ 82
    63                              <1> 
    64                              <1> ; BIOS Disk Parameters
    65                              <1> DPDiskNumber  equ 0h
    66                              <1> DPDType       equ 1h
    67                              <1> DPReturn      equ 2h
    68                              <1> DPHeads       equ 3h
    69                              <1> DPCylinders   equ 4h
    70                              <1> DPSecPerTrack equ 6h
    71                              <1> DPDisks       equ 7h
    72                              <1> DPTableOff    equ 8h
    73                              <1> DPTableSeg    equ 0Ah
    74                              <1> DPNumOfSecs   equ 0Ch
    75                              <1> 
    76                              <1> ; BIOS INT 13h Extensions (LBA extensions)
    77                              <1> ; Just After DP Data (DPDiskNumber+)
    78                              <1> DAP_PacketSize equ 10h  ; If extensions present, this byte will be >=10h
    79                              <1> DAP_Reserved1 equ 11h   ; Reserved Byte 
    80                              <1> DAP_NumOfBlocks equ 12h ; Value of this byte must be 0 to 127
    81                              <1> DAP_Reserved2 equ 13h   ; Reserved Byte
    82                              <1> DAP_Destination equ 14h ; Address of Transfer Buffer as SEGMENT:OFFSET
    83                              <1> DAP_LBA_Address equ 18h ; LBA=(C1*H0+H1)*S0+S1-1
    84                              <1>                         ; C1= Selected Cylinder Number
    85                              <1>                         ; H0= Number Of Heads (Maximum Head Number + 1)
    86                              <1>                         ; H1= Selected Head Number
    87                              <1>                         ; S0= Maximum Sector Number
    88                              <1>                         ; S1= Selected Sector Number
    89                              <1>                         ; QUAD WORD
    90                              <1> ; DAP_Flat_Destination equ 20h ; 64 bit address, if value in 4h is FFFF:FFFFh
    91                              <1>                              ; QUAD WORD (Also, value in 0h must be 18h) 
    92                              <1>                              ; TR-DOS will not use 64 bit Flat Address
    93                              <1> 
    94                              <1> ; INT 13h Function 48h "Get Enhanced Disk Drive Parameters"
    95                              <1> ; Just After DP Data (DPDiskNumber+)
    96                              <1> GetDParams_48h equ 20h ; Word. Data Length, must be 26 (1Ah) for short data.
    97                              <1> GDP_48h_InfoFlag equ 22h ; Word
    98                              <1> ; Bit 1 = 1 -> The geometry returned in bytes 4-15 is valid.
    99                              <1> GDP_48h_NumOfPCyls equ 24h ; Double Word. Number physical cylinders.
   100                              <1> GDP_48h_NumOfPHeads equ 28h ; Double Word. Number of physical heads.
   101                              <1> GDP_48h_NumOfPSpT equ 2Ch ; Double word. Num of physical sectors per track.
   102                              <1> GDP_48h_LBA_Sectors equ 30h ; 8 bytes. Number of physical/LBA sectors.
   103                              <1> GDP_48h_BytesPerSec equ 38h ; Word. Number of bytes in a sector.
   104                              <1> 
   105                              <1> ; TR-DOS Standalone Program Extensions to the DiskParams Block
   106                              <1> ; Just After DP Data (DPDiskNumber+)
   107                              <1> TRDP_CurrentSector equ 3Ah  ; DX:AX (LBA)
   108                              <1> TRDP_SectorCount equ 3Eh    ; CX (or Counter)
   109                              <1> 
   110                              <1> 
   111                              <1> ; DOS Logical Disks
   112                              <1> LD_Name equ 0
   113                              <1> LD_DiskType equ 1
   114                              <1> LD_PhyDrvNo equ 2
   115                              <1> LD_FATType equ 3
   116                              <1> LD_FSType equ 4
   117                              <1> LD_LBAYes equ 5
   118                              <1> LD_BPB equ 6
   119                              <1> LD_FATBegin equ 96
   120                              <1> LD_ROOTBegin equ 100
   121                              <1> LD_DATABegin equ 104
   122                              <1> LD_StartSector equ 108
   123                              <1> LD_TotalSectors equ 112
   124                              <1> LD_FreeSectors equ 116
   125                              <1> LD_Clusters equ 120
   126                              <1> LD_PartitionEntry equ 124
   127                              <1> LD_DParamEntry equ 125
   128                              <1> LD_MediaChanged equ 126
   129                              <1> LD_CDirLevel equ 127
   130                              <1> LD_CurrentDirectory equ 128
   131                              <1> 
   132                              <1> ; Singlix FS Extensions to DOS Logical Disks
   133                              <1> ; 03/01/2010 (LD_BPB compatibility for CHS r/w)
   134                              <1> 
   135                              <1> LD_FS_Name equ 0
   136                              <1> LD_FS_DiskType equ 1
   137                              <1> LD_FS_PhyDrvNo equ 2
   138                              <1> LD_FS_FATType equ 3
   139                              <1> LD_FS_FSType equ 4
   140                              <1> LD_FS_LBAYes equ 5
   141                              <1> LD_FS_BPB equ 6
   142                              <1> LD_FS_MediaAttrib equ 6
   143                              <1> LD_FS_VersionMajor equ 7
   144                              <1> LD_FS_RootDirD equ 8
   145                              <1> LD_FS_MATLocation equ 12
   146                              <1> LD_FS_Reserved1 equ 16 ;1 reserved byte
   147                              <1> LD_FS_BytesPerSec equ 17 ; LD_BPB + 0Bh
   148                              <1> LD_FS_Reserved2 equ 19 ;2 reserved byte
   149                              <1> LD_FS_DATLocation equ 20
   150                              <1> LD_FS_DATSectors equ 24
   151                              <1> LD_FS_Reserved3 equ 28 ;3 reserved word
   152                              <1> LD_FS_SecPerTrack equ 30 ; LD_BPB + 18h
   153                              <1> LD_FS_NumHeads equ 32    ; LD_BPB + 1Ah
   154                              <1> LD_FS_UnDelDirD equ 34
   155                              <1> LD_FS_Reserved4 equ 38 ;4 reserved word
   156                              <1> LD_FS_VolumeSerial equ 40
   157                              <1> LD_FS_VolumeName equ 44
   158                              <1> LD_FS_BeginSector equ 108
   159                              <1> LD_FS_VolumeSize equ 112
   160                              <1> LD_FS_FreeSectors equ 116
   161                              <1> LD_FS_FirstFreeSector equ 120
   162                              <1> LD_FS_PartitionEntry equ 124
   163                              <1> LD_FS_DParamEntry equ 125
   164                              <1> LD_FS_MediaChanged equ 126
   165                              <1> LD_FS_CDirLevel equ 127
   166                              <1> LD_FS_CDIR_Converted equ 128
   167                              <1> 
   168                              <1> ; Valid FAT Types
   169                              <1> FS_FAT12 equ 1
   170                              <1> FS_FAT16_CHS equ 2
   171                              <1> FS_FAT32_CHS equ 3
   172                              <1> FS_FAT16_LBA equ 4
   173                              <1> FS_FAT32_LBA equ 5
   174                              <1> 
   175                              <1> ; Cursor Location
   176                              <1> CCCpointer equ  0450h   ; BIOS data, current cursor column
   177                              <1> ; FAT Clusters EOC sign
   178                              <1> FAT12EOC equ 0FFFh
   179                              <1> FAT16EOC equ 0FFFFh
   180                              <1> ;FAT32EOC equ 0FFFFFFFh ; It is not direct usable for 8086 code
   181                              <1> ; BAD Cluster
   182                              <1> FAT12BADC equ 0FF7h
   183                              <1> FAT16BADC equ 0FFF7h
   184                              <1> ;FAT32BADC equ 0FFFFFF7h ; It is not direct usable for 8086 code
   185                              <1> ; MS-DOS FAT16 FS (Maximum Possible) Last Cluster Number= 0FFF6h 
   186                              <1> 
   187                              <1> ; TRFS
   188                              <1> 
   189                              <1> bs_FS_JmpBoot equ 0 ; jmp short bsBootCode
   190                              <1>                 ; db 0EBh, db 3Fh, db 90h
   191                              <1> bs_FS_Identifier equ 3  ; db 'FS', db 0
   192                              <1> bs_FS_BytesPerSec equ 6 ; dw 512
   193                              <1> bs_FS_MediaAttrib equ 8 ; db 3
   194                              <1> bs_FS_PartitionID equ 9 ; db 0A1h
   195                              <1> bs_FS_VersionMaj equ 10 ; db 01h
   196                              <1> bs_FS_VersionMin equ 11 ; db 0
   197                              <1> bs_FS_BeginSector equ 12   ; dd 0 
   198                              <1> bs_FS_VolumeSize equ 16 ; dd 2880
   199                              <1> bs_FS_StartupFD equ 20 ; dd 0
   200                              <1> bs_FS_MATLocation equ 24 ; dd 1
   201                              <1> bs_FS_RootDirD equ 28 ; dd 8
   202                              <1> bs_FS_SystemConfFD equ 32 ; dd 0
   203                              <1> bs_FS_SwapFD equ 36 ; dd 0
   204                              <1> bs_FS_UnDelDirD equ 40 ; dd 0
   205                              <1> bs_FS_DriveNumber equ 44 ; db 0
   206                              <1> bs_FS_LBA_Ready equ 45 ; db 0
   207                              <1> bs_FS_MagicWord equ 46 
   208                              <1> bs_FS_SecPerTrack equ 46 ; db 0A1h
   209                              <1> bs_FS_Heads equ 47 ; db 01h 
   210                              <1> bs_FS_OperationSys equ 48 ; db "TR-SINGLIX v1.0b"
   211                              <1> bs_FS_Terminator equ 64 ; db 0
   212                              <1> bs_FS_BootCode equ 65 
   213                              <1> 
   214                              <1> FS_MAT_DATLocation equ 12
   215                              <1> FS_MAT_DATScount equ 16
   216                              <1> FS_MAT_FreeSectors equ 20
   217                              <1> FS_MAT_FirstFreeSector equ 24
   218                              <1> FS_RDT_VolumeSerialNo equ 28
   219                              <1> FS_RDT_VolumeName equ 64
   220                              <1> 
   221                              <1> ; FAT12 + FAT16 + FAT32
   222                              <1> BS_JmpBoot equ 0
   223                              <1> BS_OEMName equ 3
   224                              <1> BPB_BytsPerSec equ 11
   225                              <1> BPB_SecPerClust equ 13
   226                              <1> BPB_RsvdSecCnt equ 14
   227                              <1> BPB_NumFATs equ 16
   228                              <1> BPB_RootEntCnt equ 17
   229                              <1> BPB_TotalSec16 equ 19
   230                              <1> BPB_Media equ 21
   231                              <1> BPB_FATSz16 equ 22
   232                              <1> BPB_SecPerTrk equ 24
   233                              <1> BPB_NumHeads equ 26
   234                              <1> BPB_HiddSec equ 28
   235                              <1> BPB_TotalSec32 equ 32
   236                              <1> 
   237                              <1> ; FAT12 and FAT16 only
   238                              <1> BS_DrvNum equ 36
   239                              <1> BS_Reserved1 equ 37
   240                              <1> BS_BootSig equ 38
   241                              <1> BS_VolID equ 39
   242                              <1> BS_VolLab equ 43
   243                              <1> BS_FilSysType equ 54 ; 8 bytes
   244                              <1> BS_BootCode equ 62
   245                              <1> 
   246                              <1> ; FAT32 only
   247                              <1> BPB_FATSz32 equ 36 ; FAT32, 4 bytes
   248                              <1> BPB_ExtFlags equ 40 ; FAT32, 2 bytes
   249                              <1> BPB_FSVer equ 42 ; FAT32, 2 bytes
   250                              <1> BPB_RootClus equ 44 ; FAT32, 4 bytes
   251                              <1> BPB_FSInfo equ 48 ; FAT 32, 2 bytes 
   252                              <1> BPB_BkBootSec equ 50 ; FAT32, 2 bytes
   253                              <1> BPB_Reserved equ 52 ; FAT32, 12 bytes
   254                              <1> BS_FAT32_DrvNum equ 64 ; FAT32, 1 byte
   255                              <1> BS_FAT32_Reserved1 equ 65 ; FAT32, 1 byte
   256                              <1> BS_FAT32_BootSig equ 66 ; FAT32, 1 byte
   257                              <1> BS_FAT32_VolID equ 67 ; FAT32, 4 bytes
   258                              <1> BS_FAT32_VolLab equ 71 ; FAT32, 11 bytes
   259                              <1> BS_FAT32_FilSysType equ 82 ; FAT32, 8 bytes
   260                              <1> BS_FAT32_BootCode equ 90
   261                              <1> 
   262                              <1> ; 29/02/2016
   263                              <1> ;(FAT32 Free Cluster Count & First Free Cluster values)
   264                              <1> ;[BPB_Reserved] = Free Cluster Count (offset 52)
   265                              <1> ;[BPB_Reserved+4] = First Free Cluster (offset 56)
   266                              <1> 
   267                              <1> BS_Validation equ 510
   268                              <1> 
   269                              <1> ; 15/02/2016
   270                              <1> ; FILE.ASM - 09/10/2011
   271                              <1> ; Directory Entry Structure
   272                              <1> ; 29/10/2009 (According to Microsoft FAT32 File System Specification)
   273                              <1> DirEntry_Name equ 0
   274                              <1> DirEntry_Attr equ 11
   275                              <1> DirEntry_NTRes equ 12
   276                              <1> DirEntry_CrtTimeTenth equ 13
   277                              <1> DirEntry_CrtTime equ 14
   278                              <1> DirEntry_CrtDate equ 16
   279                              <1> DirEntry_LastAccDate equ 18
   280                              <1> DirEntry_FstClusHI equ 20
   281                              <1> DirEntry_WrtTime equ 22
   282                              <1> DirEntry_WrtDate equ 24
   283                              <1> DirEntry_FstClusLO equ 26
   284                              <1> DirEntry_FileSize equ 28
  3237                                  %include 'trdosk1.s' ; 04/01/2016 
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - SYS INIT : trdosk1.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 25/07/2022 (Previous: 18/04/2021)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 04/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; TRDOS2.ASM (09/11/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; TRDOS2.ASM (c) 2004-2011 Erdogan TAN [ 17/01/2004 ] Last Update: 09/11/2011
    14                              <1> ;
    15                              <1> 
    16                              <1> sys_init:
    17                              <1> 	; 18/04/2021 (TRDOS 386 v2.0.4) 
    18                              <1> 	; 20/01/2018  (v2.0.1)
    19                              <1> 	; 23/01/2017  (v2.0.0)
    20                              <1> 	; 07/05/2016
    21                              <1> 	; 02/05/2016
    22                              <1> 	; 24/04/2016
    23                              <1> 	; 14/04/2016
    24                              <1> 	; 13/04/2016
    25                              <1> 	; 30/03/2016
    26                              <1> 	; 24/01/2016
    27                              <1> 	; 06/01/2016
    28                              <1> 	; 04/01/2016 (TRDOS 386 v2.0 - Beginning)
    29                              <1> 
    30                              <1> 	; 23/01/2017 - reset timer frequency (to 18.2Hz)
    31 00006B3A B036                <1> 	mov	al, 00110110b ; 36h
    32 00006B3C E643                <1>  	out	43h, al
    33 00006B3E 31C0                <1> 	xor	eax, eax  ; sub	al, al ; 0
    34 00006B40 E640                <1> 	out	40h, al ; LB
    35 00006B42 E640                <1> 	out	40h, al ; HB
    36                              <1>  	; 
    37                              <1> 	; 30/03/2016
    38                              <1> 	; Clear Logical DOS Disk Description Tables Area
    39                              <1> 	;xor	eax, eax
    40 00006B44 BF00010900          <1> 	mov	edi, Logical_DOSDisks
    41 00006B49 B980060000          <1> 	mov	ecx, 6656/4 ; 26*256 = 6656 bytes
    42 00006B4E F3AB                <1> 	rep	stosd ; 1664 times 4 bytes
    43                              <1> 
    44 00006B50 B83F3A2F00          <1> 	mov	eax, '?:/'
    45 00006B55 A3[4B780100]        <1> 	mov	[Current_Dir_Drv], eax
    46                              <1> 
    47                              <1> 	; Logical DRV INIT (only for hard disks)
    48 00006B5A E8F1030000          <1> 	call 	ldrv_init  ; trdosk2.s
    49                              <1> 	
    50                              <1> 	; When floppy_drv_init call is disabled
    51                              <1> 	; media changed sign is needed
    52                              <1> 	; for proper drive initialization
    53                              <1>         
    54 00006B5F BE00010900          <1> 	mov 	esi, Logical_DOSDisks
    55 00006B64 B001                <1> 	mov 	al, 1 ; Initialization sign (invalid_fd_parameter)
    56 00006B66 83C67E              <1> 	add 	esi, LD_MediaChanged ; Media Change Status = 1 (init needed)
    57 00006B69 8806                <1> 	mov 	[esi], al ; A:
    58 00006B6B 81C600010000        <1> 	add 	esi, 100h 
    59 00006B71 8806                <1> 	mov 	[esi], al ; B: 
    60                              <1>            
    61                              <1> _current_drive_bootdisk:
    62 00006B73 8A15[28650000]      <1> 	mov 	dl, [boot_drv] ; physical drive number
    63 00006B79 80FAFF              <1> 	cmp 	dl, 0FFh
    64 00006B7C 740A                <1> 	je 	short _last_dos_diskno_check
    65                              <1> _boot_drive_check:
    66 00006B7E 80FA80              <1> 	cmp 	dl, 80h
    67 00006B81 7218                <1> 	jb 	short _current_drive_a
    68 00006B83 80EA7E              <1> 	sub 	dl, 7Eh ; C = 2 , D = 3
    69 00006B86 EB13                <1> 	jmp 	short _current_drive_a 
    70                              <1> 
    71                              <1> _last_dos_diskno_check:
    72 00006B88 8A15[91300100]      <1> 	mov 	dl, [Last_DOS_DiskNo]
    73 00006B8E 80FA02              <1> 	cmp 	dl, 2
    74 00006B91 7706                <1> 	ja 	short _current_drive_c
    75 00006B93 7406                <1> 	je 	short _current_drive_a
    76 00006B95 30D2                <1> 	xor 	dl, dl ; A:
    77 00006B97 EB02                <1> 	jmp 	short _current_drive_a
    78                              <1> 
    79                              <1> _current_drive_c:
    80 00006B99 B202                <1> 	mov 	dl, 2 ; C:
    81                              <1> 
    82                              <1> _current_drive_a:
    83 00006B9B 8815[29650000]      <1> 	mov	[drv], dl
    84 00006BA1 BE[93300100]        <1>         mov     esi, msg_CRLF_temp
    85 00006BA6 E8AF000000          <1> 	call 	print_msg
    86                              <1> 
    87 00006BAB 8A15[29650000]      <1> 	mov	dl, [drv]
    88                              <1> _default_drive_c:
    89 00006BB1 E8DC0B0000          <1> 	call 	change_current_drive
    90 00006BB6 731C                <1> 	jnc 	short _start_mainprog
    91                              <1> 
    92                              <1> _drv_not_ready_error: 
    93 00006BB8 BE[56330100]        <1> 	mov 	esi, msgl_drv_not_ready
    94 00006BBD E898000000          <1> 	call 	print_msg
    95                              <1>         ;jmp	_end_of_mainprog
    96                              <1> 
    97                              <1> 	; 20/01/2018
    98 00006BC2 B202                <1> 	mov	dl, 2
    99 00006BC4 3815[29650000]      <1> 	cmp	[drv], dl
   100 00006BCA 736C                <1> 	jnb	short _end_of_mainprog
   101 00006BCC 8815[29650000]      <1> 	mov	[drv], dl
   102 00006BD2 EBDD                <1> 	jmp	short _default_drive_c
   103                              <1> 
   104                              <1> _start_mainprog:
   105                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   106                              <1> 	; 18/04/2021 (TRDOS 386 v2.0.4 - Beginning) 
   107                              <1> 	; 07/01/2017
   108                              <1> 	; 07/05/2016
   109                              <1> 	; 02/05/2016
   110                              <1> 	; 24/04/2016 (TRDOS 386 v2)
   111                              <1> 	; Retro UNIX 386 v1, 'sys_init' (u0.s)
   112                              <1> 	; 23/06/2015
   113                              <1> 
   114                              <1> 	; 02/05/2016
   115                              <1> 	; 24/04/2016
   116                              <1> 	;mov	ax, 1
   117                              <1> 	; 18/04/2021 - TRDOS 386 v2.0.4
   118 00006BD4 31C0                <1> 	xor	eax, eax
   119 00006BD6 FEC0                <1> 	inc	al  ; eax = 1
   120 00006BD8 A2[6D010300]        <1> 	mov	[u.uno], al
   121 00006BDD 66A3[04010300]      <1> 	mov	[mpid], ax
   122 00006BE3 66A3[00000300]      <1> 	mov	[p.pid], ax
   123 00006BE9 A2[60000300]        <1> 	mov	[p.stat], al
   124 00006BEE C605[64010300]04    <1> 	mov	byte [u.quant], time_count  ; 07/01/2017
   125                              <1> 	;
   126 00006BF5 A1[88770100]        <1> 	mov	eax, [k_page_dir]
   127 00006BFA A3[74010300]        <1> 	mov	[u.pgdir], eax ; reset
   128                              <1> 	;
   129 00006BFF E8D1EAFFFF          <1> 	call	allocate_page
   130                              <1> 	;jc	panic
   131                              <1> 	; 25/07/2022
   132 00006C04 7305                <1> 	jnc	short _start_mainprog_1
   133 00006C06 E9AE000000          <1> 	jmp	panic
   134                              <1> 
   135                              <1> _start_mainprog_1:
   136 00006C0B A3[70010300]        <1> 	mov	[u.upage], eax ; user structure page	
   137 00006C10 A3[70000300]        <1> 	mov	[p.upage], eax
   138 00006C15 E82CEBFFFF          <1> 	call	clear_page
   139                              <1> 	;
   140                              <1> 	; 24/08/2015
   141 00006C1A FE0D[10010300]      <1> 	dec 	byte [sysflg] ; FFh = ready for system call
   142                              <1> 			      ; 0 = executing a system call
   143                              <1> 	; 13/04/2016
   144                              <1> 	; Clear Environment Variables Page/Area
   145 00006C20 BF00300900          <1> 	mov	edi, Env_Page ; 93000h
   146 00006C25 B980000000          <1> 	mov	ecx, Env_Page_Size / 4	; 512/4  (4096/4)				 	  		 	  
   147 00006C2A 31C0                <1> 	xor	eax, eax
   148 00006C2C F3AB                <1> 	rep	stosd
   149                              <1> 
   150                              <1> 	; 14/04/2016
   151 00006C2E E810330000          <1>  	call	mainprog_startup_configuration
   152                              <1> 
   153 00006C33 E8970C0000          <1>         call    dos_prompt
   154                              <1>               
   155                              <1> _end_of_mainprog:
   156 00006C38 BE[93300100]        <1>         mov     esi, msg_CRLF_temp
   157 00006C3D E818000000          <1> 	call 	print_msg
   158 00006C42 BE[99300100]        <1> 	mov 	esi, mainprog_Version
   159 00006C47 E80E000000          <1> 	call 	print_msg
   160                              <1> 	; 24/01/2016
   161 00006C4C 28E4                <1> 	sub	ah, ah
   162 00006C4E E8B5A2FFFF          <1> 	call	int16h ; call getch
   163 00006C53 E943A7FFFF          <1> 	jmp	cpu_reset
   164                              <1> 
   165 00006C58 EBFE                <1> infinitiveloop: jmp short infinitiveloop
   166                              <1> 
   167                              <1> print_msg:
   168                              <1> 	; 13/05/2016
   169                              <1> 	; 04/01/2016
   170                              <1> 	; 01/07/2015
   171                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
   172                              <1> 	; 07/03/2014 (Retro UNIX 8086 v1)
   173                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI, EDI)
   174                              <1> 	;
   175 00006C5A 8A3D[B6770100]      <1> 	mov	bh, [ACTIVE_PAGE] ; 04/01/2016 (ptty)
   176                              <1> 	;mov	bl, 07h ; Black background, light gray forecolor
   177                              <1> 
   178 00006C60 AC                  <1> 	lodsb
   179                              <1> pmsg1:
   180 00006C61 56                  <1> 	push 	esi
   181                              <1> 	;mov	bh, [ACTIVE_PAGE] ; 04/01/2016 (ptty)
   182 00006C62 B307                <1> 	mov	bl, 07h ; Black background, light gray forecolor
   183 00006C64 E8EFB5FFFF          <1> 	call 	_write_tty
   184 00006C69 5E                  <1> 	pop	esi
   185 00006C6A AC                  <1> 	lodsb
   186 00006C6B 20C0                <1> 	and 	al, al
   187 00006C6D 75F2                <1> 	jnz 	short pmsg1
   188 00006C6F C3                  <1> 	retn
   189                              <1> 
   190                              <1> clear_screen:
   191                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   192                              <1> 	; 06/12/2020 
   193                              <1> 	; 03/12/2020 (TRDOS 386 v2.0.3)
   194                              <1> 	; 13/05/2016
   195                              <1> 	; 30/01/2016
   196                              <1> 	; 24/01/2016
   197                              <1> 	; 04/01/2016
   198 00006C70 0FB61D[B6770100]    <1> 	movzx	ebx, byte [ACTIVE_PAGE] ; video page number (0 to 7)
   199                              <1> 	; 25/07/2022
   200                              <1> 	;sub	al, al
   201                              <1> 	; al = 0
   202 00006C77 8AA3[DF660000]      <1> 	mov 	ah, [ebx+vmode] ; default = 03h (80x25 text)
   203 00006C7D 80FC04              <1> 	cmp	ah, 4
   204 00006C80 7205                <1> 	jb	short cls1
   205 00006C82 80FC07              <1> 	cmp	ah, 7
   206 00006C85 752B                <1> 	jne	short vga_clear
   207                              <1> cls1:
   208                              <1> 	;mov	bh, bl
   209                              <1> 	;mov	bl, 7
   210 00006C87 3A25[CE660000]      <1> 	cmp	ah, [CRT_MODE] ; current video mode ? 
   211 00006C8D 740D                <1> 	je	short cls2 ; yes (current video mode = 3)
   212                              <1> 	;;call	set_mode_3 ; set video mode to 3 (& clear screen)
   213                              <1> 	;;retn
   214                              <1> 	; 06/12/2020
   215                              <1> 	;cmp	byte [pmi32], 0
   216                              <1> 	; 25/07/2022
   217 00006C8F 383D[D00F0300]      <1> 	cmp	[pmi32], bh ; 0
   218 00006C95 771B                <1> 	ja	short vga_clear 	
   219 00006C97 E9C6B5FFFF          <1> 	jmp	set_mode_3
   220                              <1> cls2:
   221 00006C9C 88DF                <1> 	mov	bh, bl ; video page (0 to 7)
   222 00006C9E B307                <1> 	mov	bl, 07h ; attribute to be used on blanked line
   223                              <1> 	; 25/07/2022
   224                              <1> 	;sub 	al, al ; 0 = entire window
   225                              <1> 	;xor 	cx, cx
   226                              <1> 	; 25/07/2022
   227                              <1> 	; al = 0
   228 00006CA0 31C9                <1> 	xor	ecx, ecx
   229 00006CA2 66BA4F18            <1> 	mov 	dx, 184Fh
   230 00006CA6 E8FFB2FFFF          <1> 	call	_scroll_up ; 24/01/2016
   231                              <1> 	;
   232                              <1> 	;mov	bh, [ACTIVE_PAGE] ; video page number (0 to 7)
   233                              <1> 	;xor 	dx, dx
   234                              <1> 	; 25/07/2022
   235 00006CAB 31D2                <1> 	xor	edx, edx
   236                              <1> 	;call	_set_cpos ; 24/01/2016 
   237                              <1> 	;;retn
   238                              <1> 	; 03/12/2020
   239 00006CAD E93EB6FFFF          <1> 	jmp	_set_cpos ; returns to the caller of this proc
   240                              <1> ;cls3:
   241                              <1> ;	retn
   242                              <1> 
   243                              <1> 	; 06/12/2020
   244                              <1> vga_clear:
   245                              <1> 	; 03/12/2020
   246                              <1> 	; set mode by using _int10h
   247                              <1> 	; (also clears screen)
   248                              <1> 	;mov	al, ah
   249                              <1> 	;sub	ah, ah  ; set current video mode
   250                              <1> 	; 25/07/2022
   251 00006CB2 86E0                <1> 	xchg	ah, al
   252                              <1> 	; ah = 0
   253                              <1> 	; al = video mode
   254                              <1> 	;call	_int10h ; simulates int 10h in TRDOS 386 kernel
   255                              <1> 	;jmp	short cls3
   256 00006CB4 E957AAFFFF          <1> 	jmp	_int10h ; returns to the caller of this proc
   257                              <1> 
   258                              <1> panic:
   259                              <1> 	; 13/05/2016 (TRDOS 386 = TRDOS v2)
   260                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
   261                              <1> 	; 07/03/2014 (Retro UNIX 8086 v1)
   262 00006CB9 BE[433B0100]        <1> 	mov 	esi, panic_msg
   263 00006CBE E897FFFFFF          <1> 	call 	print_msg
   264                              <1> key_to_reboot:
   265                              <1>         ; 24/01/2016
   266 00006CC3 28E4                <1>         sub     ah, ah
   267 00006CC5 E83EA2FFFF          <1>         call    int16h	; call getch
   268                              <1>         ; wait for a character from the current tty
   269                              <1> 	;
   270 00006CCA B00A                <1> 	mov	al, 0Ah
   271 00006CCC 8A3D[B6770100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
   272 00006CD2 B307                <1> 	mov	bl, 07h ; Black background, 
   273                              <1> 			; light gray forecolor
   274 00006CD4 E87FB5FFFF          <1> 	call 	_write_tty
   275 00006CD9 E9BDA6FFFF          <1> 	jmp	cpu_reset 
   276                              <1> 
   277                              <1> ctrlbrk:
   278                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   279                              <1> 	; 12/11/2015
   280                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
   281                              <1> 	; 06/12/2013 (Retro UNIX 8086 v1)
   282                              <1> 	;
   283                              <1> 	; INT 1Bh (control+break) handler		
   284                              <1> 	;
   285                              <1>       	; Retro Unix 8086 v1 feature only!
   286                              <1>       	;
   287                              <1> 	
   288                              <1> 	; 25/07/2022
   289 00006CDE 52                  <1> 	push	edx
   290 00006CDF 31D2                <1> 	xor	edx, edx
   291                              <1> 	;cmp 	word [u.intr], 0
   292 00006CE1 663915[68010300]    <1> 	cmp	[u.intr], dx ; 0
   293 00006CE8 763D                <1> 	jna 	short cbrk4
   294                              <1> cbrk0:
   295                              <1> 	; 12/11/2015
   296                              <1> 	; 06/12/2013
   297                              <1> 	;cmp 	word [u.quit], 0
   298 00006CEA 663915[6A010300]    <1> 	cmp	[u.quit], dx ; 0 ; 25/07/2022
   299 00006CF1 7434                <1> 	jz	short cbrk4
   300                              <1> 	
   301                              <1> 	; 20/09/2013	
   302                              <1> 	;push 	ax
   303 00006CF3 50                  <1> 	push	eax ; 25/07/2022
   304 00006CF4 A0[B6770100]        <1> 	mov	al, [ptty]
   305                              <1> 	
   306                              <1> 	; 12/11/2015
   307                              <1> 	;
   308                              <1> 	; ctrl+break (EOT, CTRL+D) from serial port
   309                              <1> 	; or ctrl+break from console (pseudo) tty
   310                              <1> 	; (!redirection!)
   311                              <1> 	
   312 00006CF9 3C08                <1> 	cmp	al, 8 ; serial port tty nums > 7
   313 00006CFB 720E                <1>         jb      short cbrk1 ; console (pseudo) tty
   314                              <1> 		
   315                              <1> 	; Serial port interrupt handler sets [ptty]
   316                              <1> 	; to the port's tty number (as temporary).
   317                              <1> 	;
   318                              <1> 	; If active process is using a stdin or 
   319                              <1> 	; stdout redirection (by the shell),
   320                              <1>         ; console tty keyboard must be available
   321                              <1> 	; to terminate running process,
   322                              <1> 	; in order to prevent a deadlock. 
   323                              <1> 
   324                              <1> 	; 25/07/2022
   325                              <1> 	;push	edx
   326                              <1> 	;movzx	edx, byte [u.uno]
   327 00006CFD 8A15[6D010300]      <1> 	mov	dl, [u.uno]
   328 00006D03 3A82[3F000300]      <1> 	cmp     al, [edx+p.ttyc-1] ; console tty (rw)
   329                              <1> 	;pop	edx
   330 00006D09 7412                <1> 	je	short cbrk2
   331                              <1> cbrk1:
   332 00006D0B FEC0                <1> 	inc 	al  ; [u.ttyp] : 1 based tty number
   333                              <1> 	; 06/12/2013
   334 00006D0D 3A05[50010300]      <1> 	cmp	al, [u.ttyp]   ; recent open tty (r)
   335 00006D13 7408                <1> 	je	short cbrk2	
   336 00006D15 3A05[51010300]      <1>         cmp     al, [u.ttyp+1] ; recent open tty (w)
   337 00006D1B 7509                <1> 	jne	short cbrk3	
   338                              <1> cbrk2:
   339                              <1> 	;; 06/12/2013
   340                              <1> 	;mov	ax, [u.quit]
   341                              <1> 	;and	ax, ax
   342                              <1> 	;jz	short cbrk3
   343                              <1> 	
   344                              <1> 	;xor	ax, ax ; 0
   345                              <1> 	;dec	ax
   346                              <1> 	; 0FFFFh = 'ctrl+brk' keystroke
   347                              <1> 	; 25/07/2022
   348 00006D1D 31C0                <1> 	xor	eax, eax ; 0
   349 00006D1F 48                  <1> 	dec	eax ; -1 ; 0FFFFFFFFh
   350 00006D20 66A3[6A010300]      <1> 	mov	[u.quit], ax
   351                              <1> cbrk3:
   352                              <1> 	;pop	ax
   353 00006D26 58                  <1> 	pop	eax ; 25/07/2022
   354                              <1> cbrk4:
   355                              <1> 	; 25/07/2022
   356 00006D27 5A                  <1> 	pop	edx
   357 00006D28 C3                  <1> 	retn
   358                              <1> 
   359                              <1> ; 31/12/2017
   360                              <1> ; TRDOS 386 - 30/12/2017
   361                              <1> %define get_rtc_date RTC_40
   362                              <1> %define get_rtc_time RTC_20
   363                              <1> %define	set_rtc_date RTC_50
   364                              <1> %define set_rtc_time RTC_30	
   365                              <1> get_rtc_date_time:
   366                              <1> ; Retro UNIX 8086 v1 - UNIX.ASM (01/09/2014)
   367                              <1> ;epoch:
   368                              <1> 	; 18/04/2021 (TRDOS 386 v2.0.3)
   369                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0)
   370                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
   371                              <1> 	; 09/04/2013 (Retro UNIX 8086 v1 - UNIX.ASM)
   372                              <1> 	; 'epoch' procedure prototype: 
   373                              <1> 	; 	            UNIXCOPY.ASM, 10/03/2013
   374                              <1> 	; 14/11/2012
   375                              <1> 	; unixboot.asm (boot file configuration)
   376                              <1> 	; version of "epoch" procedure in "unixproc.asm"
   377                              <1> 	; 21/7/2012
   378                              <1> 	; 15/7/2012
   379                              <1> 	; 14/7/2012		
   380                              <1> 	; Erdogan Tan - RETRO UNIX v0.1
   381                              <1> 	; compute current date and time as UNIX Epoch/Time
   382                              <1> 	; UNIX Epoch: seconds since 1/1/1970 00:00:00
   383                              <1> 	;
   384                              <1>         ;  ((Modified registers: EAX, EDX, ECX, EBX))  
   385                              <1> 	;
   386                              <1> 
   387                              <1> 	; 18/04/2021
   388                              <1> 	; INPUT:
   389                              <1> 	;	none (real time clock)
   390                              <1> 	; OUTPUT:
   391                              <1> 	;	eax = unix epoch time value
   392                              <1> 	;	    (seconds since 1/1/1970 00:00:00)
   393                              <1> 
   394 00006D29 E8D2F4FFFF          <1> 	call 	get_rtc_time		; Return Current Time
   395                              <1>         ;xchg 	ch, cl ; 18/04/2021
   396 00006D2E 66890D[56740100]    <1>         mov 	[hour], cx    ; BCD, cl = minute, ch = hour
   397                              <1>         ;xchg 	dh, dl ; 18/04/2021
   398                              <1> 	;mov 	[second], dx  ; BCD, dh = second, dl = dse
   399                              <1> 	; 18/04/2021
   400 00006D35 8835[5A740100]      <1> 	mov	[second], dh  ; second
   401                              <1> 	;
   402 00006D3B E82BF5FFFF          <1>         call 	get_rtc_date		; Return Current Date
   403                              <1>         ;xchg 	ch, cl ; 18/04/2021
   404 00006D40 66890D[50740100]    <1>         mov 	[year], cx    ; BCD, cl = year, ch = century
   405                              <1>         ;xchg 	dh, dl ; 18/04/2021
   406 00006D47 668915[52740100]    <1>         mov 	[month], dx   ; BCD, dl = day, dh = month
   407                              <1> 	;
   408                              <1> 	;mov 	al, [hour]    ; Hour
   409                              <1>         ; 18/04/2021
   410 00006D4E A0[57740100]        <1> 	mov	al, [hour+1]  ; Hour
   411                              <1> 	   	; AL <-- BCD number
   412 00006D53 D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
   413                              <1> 					; AH = AL / 10h
   414                              <1> 					; AL = AL MOD 10h
   415 00006D55 D50A                <1>         aad 	; AX= AH*10+AL
   416                              <1> 	;mov 	[hour], al
   417                              <1> 	;mov 	al, [hour+1]  ; Minute
   418 00006D57 8605[56740100]      <1> 	xchg	al, [hour]    ; [hour] = hour, al = minute
   419                              <1> 	   	; AL <-- BCD number
   420 00006D5D D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
   421                              <1> 					; AH = AL / 10h
   422                              <1> 					; AL = AL MOD 10h
   423 00006D5F D50A                <1>         aad 	; AX= AH*10+AL
   424 00006D61 A2[58740100]        <1> 	mov 	[minute], al
   425 00006D66 A0[5A740100]        <1> 	mov 	al, [second]  ; Second
   426                              <1> 	   	; AL <-- BCD number
   427 00006D6B D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
   428                              <1> 					; AH = AL / 10h
   429                              <1> 					; AL = AL MOD 10h
   430 00006D6D D50A                <1>         aad 	; AX= AH*10+AL
   431 00006D6F A2[5A740100]        <1> 	mov 	[second], al
   432 00006D74 66A1[50740100]      <1> 	mov 	ax, [year]    ; Year (century)
   433                              <1> 	; 18/04/2021
   434                              <1> 	;push 	eax ; puhs ax
   435                              <1> 	;mov	al, ah ; century ; 18/04/2021
   436                              <1> 	   	; AL <-- BCD number
   437 00006D7A D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
   438                              <1> 					; AH = AL / 10h
   439                              <1> 					; AL = AL MOD 10h
   440 00006D7C D50A                <1>         aad 	; AX= AH*10+AL
   441                              <1> 	;mov 	ah, 100
   442                              <1> 	;mul 	ah
   443                              <1> 	;mov 	[year], ax
   444                              <1> 	; 18/04/2021
   445                              <1> 	; ax = al = year (0 to 99)
   446 00006D7E 668705[50740100]    <1> 	xchg	ax, [year]    ; [year+1] = century -> ah
   447                              <1> 	;pop	eax ; pop ax
   448 00006D85 88E0                <1> 	mov	al, ah  ; century
   449                              <1> 	   	; AL <-- BCD number
   450 00006D87 D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
   451                              <1> 					; AH = AL / 10h
   452                              <1> 					; AL = AL MOD 10h
   453 00006D89 D50A                <1>         aad 	; AX= AH*10+AL
   454                              <1> 	; 18/04/2021
   455 00006D8B B464                <1> 	mov	ah, 100	      ; 100*(century byte of year)
   456 00006D8D F6E4                <1> 	mul	ah
   457                              <1> 	;
   458 00006D8F 660105[50740100]    <1> 	add 	[year], ax
   459                              <1> 	;mov 	al, [month]   ; Month
   460                              <1> 	; 18/04/2021
   461 00006D96 A0[53740100]        <1> 	mov	al, [month+1] ; Month
   462                              <1> 	   	; AL <-- BCD number
   463 00006D9B D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
   464                              <1> 					; AH = AL / 10h
   465                              <1> 					; AL = AL MOD 10h
   466 00006D9D D50A                <1>         aad 	; AX= AH*10+AL
   467                              <1> 	;mov 	[month], al	
   468                              <1>         ;mov	al, [month+1] ; Day
   469                              <1> 	; 18/04/2021
   470 00006D9F 8605[52740100]      <1> 	xchg	al, [month]   ; [month] = month, al = day
   471                              <1> 	   	; AL <-- BCD number
   472 00006DA5 D410                <1>         db 	0D4h, 10h		; Undocumented inst. AAM
   473                              <1> 					; AH = AL / 10h
   474                              <1> 					; AL = AL MOD 10h
   475 00006DA7 D50A                <1>         aad 	; AX= AH*10+AL
   476 00006DA9 A2[54740100]        <1>         mov     [day], al
   477                              <1> 	
   478 00006DAE C3                  <1> 	retn	; 30/12/2017
   479                              <1> 
   480                              <1> epoch:
   481 00006DAF E875FFFFFF          <1> 	call	get_rtc_date_time ; TRDOS 386 - 30/12/2017
   482                              <1> 
   483                              <1> convert_to_epoch:
   484                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   485                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0)
   486                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit modification)
   487                              <1> 	; 09/04/2013 (Retro UNIX 8086 v1)
   488                              <1> 	;
   489                              <1> 	; ((Modified registers: EAX, EDX, EBX)) 
   490                              <1> 	;
   491                              <1> 	; Derived from DALLAS Semiconductor
   492                              <1> 	; Application Note 31 (DS1602/DS1603)
   493                              <1> 	; 6 May 1998
   494 00006DB4 29C0                <1> 	sub 	eax, eax
   495 00006DB6 66A1[50740100]      <1> 	mov 	ax, [year]
   496 00006DBC 662DB207            <1> 	sub 	ax, 1970
   497 00006DC0 BA6D010000          <1> 	mov 	edx, 365
   498 00006DC5 F7E2                <1> 	mul 	edx
   499 00006DC7 31DB                <1> 	xor 	ebx, ebx
   500 00006DC9 8A1D[52740100]      <1> 	mov 	bl, [month]
   501 00006DCF FECB                <1> 	dec 	bl
   502 00006DD1 D0E3                <1> 	shl 	bl, 1
   503                              <1> 	;sub	edx, edx
   504 00006DD3 668B93[5C740100]    <1> 	mov 	dx, [EBX+DMonth]
   505 00006DDA 8A1D[54740100]      <1>         mov     bl, [day]
   506 00006DE0 FECB                <1> 	dec 	bl
   507 00006DE2 01D0                <1> 	add 	eax, edx
   508 00006DE4 01D8                <1> 	add 	eax, ebx
   509                              <1> 			; EAX = days since 1/1/1970
   510 00006DE6 668B15[50740100]    <1> 	mov 	dx, [year]
   511 00006DED 6681EAB107          <1> 	sub 	dx, 1969
   512                              <1> 	;shr 	dx, 1
   513                              <1> 	;shr 	dx, 1
   514                              <1> 	; 25/07/2022
   515 00006DF2 C1EA02              <1> 	shr	edx, 2		
   516                              <1> 		; (year-1969)/4
   517 00006DF5 01D0                <1> 	add 	eax, edx
   518                              <1> 			; + leap days since 1/1/1970
   519 00006DF7 803D[52740100]02    <1> 	cmp 	byte [month], 2	; if past february
   520 00006DFE 760E                <1> 	jna 	short cte1
   521 00006E00 668B15[50740100]    <1> 	mov 	dx, [year]
   522 00006E07 6683E203            <1> 	and 	dx, 3 ; year mod 4
   523 00006E0B 7501                <1> 	jnz 	short cte1		
   524                              <1> 			; and if leap year
   525                              <1> 	;add 	eax, 1 	; add this year's leap day (february 29)
   526                              <1> 	; 25/07/2022
   527 00006E0D 40                  <1> 	inc	eax
   528                              <1> cte1: 			; compute seconds since 1/1/1970
   529 00006E0E BA18000000          <1> 	mov 	edx, 24
   530 00006E13 F7E2                <1> 	mul	edx
   531 00006E15 8A15[56740100]      <1> 	mov 	dl, [hour]
   532 00006E1B 01D0                <1> 	add 	eax, edx
   533                              <1> 		; EAX = hours since 1/1/1970 00:00:00
   534                              <1> 	;mov	ebx, 60
   535 00006E1D B33C                <1> 	mov	bl, 60
   536 00006E1F F7E3                <1> 	mul	ebx
   537 00006E21 8A15[58740100]      <1> 	mov 	dl, [minute]
   538 00006E27 01D0                <1> 	add 	eax, edx
   539                              <1> 		; EAX = minutes since 1/1/1970 00:00:00
   540                              <1> 	;mov 	ebx, 60
   541 00006E29 F7E3                <1> 	mul	ebx
   542 00006E2B 8A15[5A740100]      <1> 	mov 	dl, [second]
   543 00006E31 01D0                <1> 	add 	eax, edx
   544                              <1>  		; EAX -> seconds since 1/1/1970 00:00:00
   545 00006E33 C3                  <1> 	retn
   546                              <1> 
   547                              <1> ;set_date_time:
   548                              <1> convert_from_epoch:
   549                              <1> 	; 25/07/2022 (v2.0.5)
   550                              <1> 	; 18/04/2021 (v2.0.4)
   551                              <1> 	; 31/12/2017 (v2.0.0)
   552                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0)
   553                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
   554                              <1> 	; 20/06/2013 (Retro UNIX 8086 v1)
   555                              <1> 	; 'convert_from_epoch' procedure prototype: 
   556                              <1> 	; 	            UNIXCOPY.ASM, 10/03/2013
   557                              <1> 	;
   558                              <1> 	; ((Modified registers: EAX, EDX, ECX, EBX))	
   559                              <1> 	;
   560                              <1> 	; Derived from DALLAS Semiconductor
   561                              <1> 	; Application Note 31 (DS1602/DS1603)
   562                              <1> 	; 6 May 1998
   563                              <1> 	;
   564                              <1> 	; INPUT:
   565                              <1> 	; EAX = Unix (Epoch) Time
   566                              <1> 	;
   567 00006E34 31D2                <1> 	xor 	edx, edx
   568                              <1> 	;mov 	ecx, 60
   569                              <1> 	; 25/07/2022
   570 00006E36 29C9                <1> 	sub	ecx, ecx
   571 00006E38 B13C                <1> 	mov	cl, 60
   572 00006E3A F7F1                <1> 	div	ecx
   573                              <1> 	;mov 	[imin], eax   ; whole minutes
   574                              <1> 			  ; since 1/1/1970
   575 00006E3C 668915[5A740100]    <1> 	mov 	[second], dx  ; leftover seconds
   576 00006E43 29D2                <1> 	sub 	edx, edx
   577 00006E45 F7F1                <1> 	div	ecx
   578                              <1> 	;mov 	[ihrs], eax   ; whole hours
   579                              <1> 	;		      ; since 1/1/1970
   580 00006E47 668915[58740100]    <1> 	mov 	[minute], dx  ; leftover minutes
   581 00006E4E 31D2                <1> 	xor	edx, edx
   582                              <1> 	;mov 	cx, 24
   583 00006E50 B118                <1> 	mov 	cl, 24
   584 00006E52 F7F1                <1> 	div	ecx
   585                              <1> 	;mov 	[iday], ax   ; whole days
   586                              <1> 			     ; since 1/1/1970
   587 00006E54 668915[56740100]    <1> 	mov 	[hour], dx   ; leftover hours
   588 00006E5B 05DB020000          <1> 	add 	eax, 365+366 ; whole day since
   589                              <1> 			     ; 1/1/1968 	
   590                              <1> 	;mov 	[iday], ax
   591 00006E60 50                  <1> 	push 	eax
   592 00006E61 29D2                <1> 	sub	edx, edx
   593                              <1> 	;mov 	ecx, (4*365)+1 ; 4 years = 1461 days
   594                              <1> 	; 25/07/2022
   595 00006E63 66B9B505            <1> 	mov	cx, (4*365)+1
   596 00006E67 F7F1                <1> 	div	ecx
   597 00006E69 59                  <1> 	pop 	ecx
   598                              <1> 	;mov 	[lday], ax   ; count of quadyrs (4 years)
   599                              <1> 	;push 	dx
   600                              <1> 	; 18/04/2021
   601 00006E6A 52                  <1> 	push	edx
   602                              <1> 	;mov 	[qday], dx   ; days since quadyr began
   603 00006E6B 6683FA3C            <1> 	cmp 	dx, 31+29    ; if past feb 29 then
   604 00006E6F F5                  <1> 	cmc		     ; add this quadyr's leap day
   605 00006E70 83D000              <1> 	adc 	eax, 0	     ; to # of qadyrs (leap days)
   606                              <1> 	;mov 	[lday], ax   ; since 1968			  
   607                              <1> 	;mov 	cx, [iday]
   608 00006E73 91                  <1> 	xchg 	ecx, eax     ; ECX = lday, EAX = iday		  
   609 00006E74 29C8                <1> 	sub 	eax, ecx     ; iday - lday
   610                              <1> 	;mov 	ecx, 365
   611                              <1> 	; 25/07/2022
   612 00006E76 66B96D01            <1> 	mov	cx, 365
   613 00006E7A 31D2                <1> 	xor	edx, edx
   614                              <1> 	; EAX = iday-lday, EDX = 0
   615 00006E7C F7F1                <1> 	div	ecx
   616                              <1> 	;mov 	[iyrs], ax   ; whole years since 1968
   617                              <1> 	;jday = iday - (iyrs*365) - lday
   618                              <1> 	;mov	[jday], dx   ; days since 1/1 of current year
   619                              <1> 	;add	eax, 1968
   620 00006E7E 6605B007            <1> 	add 	ax, 1968     ; compute year
   621 00006E82 66A3[50740100]      <1> 	mov 	[year], ax
   622                              <1> 	;mov 	cx, dx
   623                              <1> 	; 25/07/2022
   624 00006E88 89D1                <1> 	mov	ecx, edx
   625                              <1> 	;;mov 	dx, [qday]
   626                              <1> 	;pop 	dx
   627                              <1> 	; 18/04/2021
   628 00006E8A 5A                  <1> 	pop	edx
   629 00006E8B 6681FA6D01          <1> 	cmp 	dx, 365	     ; if qday <= 365 and qday >= 60	
   630 00006E90 7708                <1> 	ja 	short cfe1   ; jday = jday +1
   631 00006E92 6683FA3C            <1> 	cmp 	dx, 60       ; if past 2/29 and leap year then
   632 00006E96 F5                  <1>         cmc		     ; add a leap day to the # of whole
   633                              <1> 	;adc 	cx, 0        ; days since 1/1 of current year
   634                              <1> 	; 25/07/2022
   635 00006E97 83D100              <1> 	adc	ecx, 0
   636                              <1> cfe1:			
   637                              <1> 	;mov 	[jday], cx
   638                              <1> 	;mov 	bx, 12       ; estimate month
   639                              <1> 	; 18/04/2021
   640 00006E9A 29DB                <1> 	sub	ebx, ebx
   641 00006E9C B30C                <1> 	mov	bl, 12
   642 00006E9E 66BA6E01            <1> 	mov 	dx, 366      ; mday, max. days since 1/1 is 365
   643 00006EA2 6683E003            <1> 	and 	ax, 11b      ; year mod 4 (and dx, 3) 
   644                              <1> cfe2:	; Month calculation  ; 0 to 11  (11 to 0)	
   645                              <1> 	;cmp 	cx, dx       ; mday = # of days passed from 1/1
   646                              <1> 	; 25/07/2022
   647 00006EA6 39D1                <1> 	cmp	ecx, edx 
   648 00006EA8 731B                <1> 	jnb 	short cfe3
   649                              <1> 	;dec 	bx           ; month = month - 1
   650                              <1> 	;shl 	bx, 1
   651                              <1> 	; 18/04/2021
   652 00006EAA FECB                <1> 	dec	bl
   653 00006EAC D0E3                <1> 	shl	bl, 1 
   654 00006EAE 668B93[5C740100]    <1> 	mov 	dx, [EBX+DMonth] ; # elapsed days at 1st of month
   655                              <1> 	; 18/04/2021
   656                              <1> 	;shr 	bx, 1        ; bx = month - 1 (0 to 11)
   657 00006EB5 D0EB                <1> 	shr	bl, 1
   658                              <1> 	;cmp	bx, 1        ; if month > 2 and year mod 4  = 0	
   659 00006EB7 80FB01              <1> 	cmp	bl, 1
   660 00006EBA 76EA                <1> 	jna 	short cfe2   ; then mday = mday + 1
   661 00006EBC 76E8                <1> 	jna 	short cfe2   ; then mday = mday + 1
   662 00006EBE 08C0                <1> 	or 	al, al       ; if past 2/29 and leap year then
   663 00006EC0 75E4                <1> 	jnz 	short cfe2   ; add leap day (to mday)
   664                              <1> 	;inc 	dx           ; mday = mday + 1
   665                              <1> 	; 25/07/2022
   666 00006EC2 42                  <1> 	inc	edx
   667 00006EC3 EBE1                <1> 	jmp 	short cfe2
   668                              <1> cfe3:
   669                              <1> 	;inc 	bx	     ; -> bx = month, 1 to 12
   670                              <1> 	; 18/04/2021
   671 00006EC5 FEC3                <1> 	inc	bl
   672 00006EC7 66891D[52740100]    <1> 	mov 	[month], bx
   673                              <1> 	;sub 	cx, dx	     ; day = jday - mday + 1	
   674                              <1> 	; 25/07/2022
   675 00006ECE 29D1                <1> 	sub	ecx, edx
   676                              <1> 	;inc 	cx 			  
   677                              <1> 	; 18/04/2021
   678 00006ED0 FEC1                <1> 	inc	cl
   679                              <1> 	;mov 	[day], cx
   680 00006ED2 880D[54740100]      <1> 	mov	[day], cl	
   681                              <1> 
   682                              <1> 	; eax, ebx, ecx, edx is changed at return
   683                              <1> 	; output ->
   684                              <1> 	; [year], [month], [day], [hour], [minute], [second]
   685                              <1> 
   686 00006ED8 C3                  <1> 	retn	; 31/12/2017 (TRDOS 386)
   687                              <1> 
   688                              <1> set_rtc_date_time:
   689                              <1> 	; 31/12/2017 (v2.0.0)
   690                              <1> 	; 30/12/2017 (TRDOS 386)
   691                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
   692                              <1> 	; 20/06/2013 (Retro UNIX 8086 v1)
   693 00006ED9 E80F000000          <1> 	call	set_date_bcd
   694                              <1> 	; Set real-time clock date
   695 00006EDE E8AEF3FFFF          <1> 	call	set_rtc_date ; RTC_50
   696                              <1> 	; Set real-time clock time
   697 00006EE3 E832000000          <1> 	call	set_time_bcd
   698 00006EE8 E941F3FFFF          <1> 	jmp	set_rtc_time ; RTC_30	
   699                              <1> 
   700                              <1> ; 31/12/2017
   701                              <1> set_date_bcd:
   702 00006EED A0[51740100]        <1>         mov     al, [year+1]
   703 00006EF2 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   704 00006EF4 D510                <1> 	db 	0D5h, 10h    ; Undocumented inst. AAD
   705                              <1> 			     ; AL = AH * 10h + AL
   706 00006EF6 88C5                <1> 	mov 	ch, al ; century (BCD)
   707 00006EF8 A0[50740100]        <1> 	mov 	al, [year]
   708 00006EFD D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   709 00006EFF D510                <1> 	db 	0D5h, 10h    ; Undocumented inst. AAD
   710                              <1> 			     ; AL = AH * 10h + AL
   711 00006F01 88C1                <1> 	mov 	cl, al ; year (BCD)
   712 00006F03 A0[52740100]        <1>         mov 	al, [month]
   713 00006F08 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   714 00006F0A D510                <1> 	db 	0D5h, 10h    ; Undocumented inst. AAD
   715                              <1> 			     ; AL = AH * 10h + AL
   716 00006F0C 88C6                <1> 	mov 	dh, al ; month (BCD)
   717 00006F0E A0[54740100]        <1> 	mov 	al, [day]
   718 00006F13 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   719 00006F15 D510                <1> 	db 	0D5h, 10h    ; Undocumented inst. AAD
   720                              <1> 			     ; AL = AH * 10h + AL
   721                              <1> 	; 18/04/2021
   722 00006F17 88C2                <1> 	mov 	dl, al ; day (BCD)
   723 00006F19 C3                  <1> 	retn	; 30/12/2017
   724                              <1> 
   725                              <1> ; 31/12/2017
   726                              <1> set_time_bcd:
   727                              <1>         ; Read real-time clock time 
   728                              <1> 	; (get day light saving time bit status)
   729 00006F1A FA                  <1>  	cli
   730 00006F1B E8ACF4FFFF          <1> 	call	UPD_IPR 		; CHECK FOR UPDATE IN PROCESS
   731                              <1> 	; cf = 1 -> al = 0
   732 00006F20 7207                <1>         jc      short stime1
   733 00006F22 B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   734 00006F24 E8D9F4FFFF          <1> 	call	CMOS_READ		; READ CURRENT VALUE OF DSE BIT
   735                              <1> stime1:
   736 00006F29 FB                  <1> 	sti
   737 00006F2A 2401                <1> 	and	al, 00000001b		; MASK FOR VALID DSE BIT
   738 00006F2C 88C2                <1> 	mov	dl, al			; SET [DL] TO ZERO FOR NO DSE BIT
   739                              <1> 	; DL = 1 or 0 (day light saving time)
   740                              <1> 	;	
   741 00006F2E A0[56740100]        <1> 	mov 	al, [hour]
   742 00006F33 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   743 00006F35 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
   744                              <1> 			     ; AL = AH * 10h + AL
   745 00006F37 88C5                <1> 	mov 	ch, al ; hour (BCD)
   746 00006F39 A0[58740100]        <1>         mov     al, [minute]
   747 00006F3E D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   748 00006F40 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
   749                              <1> 			     ; AL = AH * 10h + AL
   750 00006F42 88C1                <1> 	mov 	cl, al       ; minute (BCD)
   751 00006F44 A0[5A740100]        <1>         mov     al, [second]
   752 00006F49 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   753 00006F4B D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
   754                              <1> 			     ; AL = AH * 10h + AL
   755 00006F4D 88C6                <1> 	mov 	dh, al	     ; second (BCD)
   756 00006F4F C3                  <1> 	retn	; 30/12/2017
  3238                                  %include 'trdosk2.s' ; 04/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.6) - DRV INIT : trdosk2.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 29/08/2023 (Previous: 30/07/2022)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 04/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.14 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; TRDOS2.ASM (09/11/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; DRV_INIT.ASM (c) 2009-2011 Erdogan TAN  [26/09/2009] Last Update: 07/08/2011
    14                              <1> ;
    15                              <1> 
    16                              <1> ldrv_init: ; Logical Drive Initialization
    17                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
    18                              <1> 	; 30/08/2020
    19                              <1> 	; 25/08/2020
    20                              <1> 	; 11/08/2020 - 13/08/2020
    21                              <1> 	; 17/07/2020 - 20/07/2020
    22                              <1> 	; 14/07/2020 - 15/07/2020
    23                              <1> 	; 30/01/2018
    24                              <1> 	; 27/12/2017
    25                              <1> 	; 12/02/2016
    26                              <1> 	; 06/01/2016
    27                              <1> 	;  	('diskinit.inc', 'diskio.inc' integration)
    28                              <1> 	; 04/01/2016 (TRDOS 386 = TRDOS v2.0)
    29                              <1> 	; 07/08/2011
    30                              <1> 	; 20/09/2009
    31                              <1> 	; 2005
    32                              <1> 
    33                              <1> 	; 15/07/2020
    34                              <1> 	;movzx	ecx, byte [HF_NUM] ; number of fixed disks
    35                              <1> 	;cmp	cl, 1
    36                              <1> 	;jnb	short load_hd_partition_tables
    37                              <1> 
    38 00006F50 A0[20780100]        <1> 	mov	al, [HF_NUM] ; number of fixed disks
    39 00006F55 20C0                <1> 	and 	al, al
    40 00006F57 7501                <1> 	jnz	short load_hd_partition_tables
    41                              <1> 
    42                              <1> 	; no any hard disks
    43 00006F59 C3                  <1> 	retn			
    44                              <1> 
    45                              <1> load_hd_partition_tables:
    46                              <1> 	;mov	esi, [HDPM_TBL_VEC] ; primary master disk FDPT
    47                              <1> 	; 15/07/2020
    48 00006F5A BE[24780100]        <1> 	mov	esi, HDPM_TBL_VEC
    49 00006F5F BF[4A7C0100]        <1> 	mov 	edi, PTable_hd0
    50 00006F64 B280                <1> 	mov 	dl, 80h
    51                              <1> 	; 15/07/2020
    52 00006F66 A2[2B650000]        <1> 	mov	[hdc], al
    53                              <1> 	;xor	ecx, ecx ; 0
    54                              <1> load_next_hd_partition_table:
    55                              <1> 	; 20/07/2020
    56 00006F6B 31C9                <1> 	xor	ecx, ecx ; 0
    57                              <1> 	;push	ecx
    58 00006F6D 57                  <1> 	push	edi ; *
    59                              <1> 	;push	esi ; FDPT (+ DPTE) address
    60                              <1> 	; 15/07/2020
    61 00006F6E AD                  <1> 	lodsd
    62 00006F6F 56                  <1> 	push	esi ; ** ; next FDPT (+ DPTE) address ptr
    63                              <1> 	
    64                              <1> 	;mov	al, [esi+20] ; DPTE offset 4
    65                              <1> 	;and	al, 40h ;  LBA bit (bit 6)
    66                              <1> 	;;shr	al, 6
    67                              <1> 	;mov 	[HD_LBA_yes], al
    68                              <1> 	
    69                              <1> 	; 15/07/2020
    70 00006F70 8A4814              <1> 	mov	cl, [eax+20]
    71 00006F73 80E140              <1> 	and	cl, 40h
    72 00006F76 880D[4E7D0100]      <1> 	mov	[HD_LBA_yes], cl
    73                              <1> 	
    74 00006F7C E83F040000          <1> 	call	load_masterboot
    75                              <1> 	;jc	short pass_pt_this_hard_disk
    76                              <1> 	; 13/08/2020
    77                              <1> 	;jc	pass_pt_this_hard_disk
    78                              <1> 	; 25/07/2022
    79 00006F81 7305                <1> 	jnc	short load_mbr_ok
    80 00006F83 E98A000000          <1> 	jmp	pass_pt_this_hard_disk
    81                              <1> 
    82                              <1> load_mbr_ok:
    83 00006F88 BB[087C0100]        <1> 	mov	ebx, PartitionTable
    84 00006F8D 89DE                <1> 	mov	esi, ebx
    85                              <1> 	;mov	ecx, 16
    86 00006F8F B110                <1> 	mov	cl, 16
    87 00006F91 F3A5                <1> 	rep 	movsd
    88 00006F93 89DE                <1> 	mov 	esi, ebx 
    89                              <1> 	;mov 	byte [hdc], 4 ; 4 - partition index
    90                              <1> 	; 15/07/2020
    91 00006F95 C605[4F7D0100]04    <1> 	mov	byte [PP_Counter], 4
    92                              <1> loc_validate_hdp_partition:
    93                              <1> 	;cmp 	byte [esi+ptFileSystemID], 0
    94                              <1> 	;jna	short loc_validate_next_hdp_partition2
    95                              <1> 	; 13/08/2020
    96 00006F9C 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
    97 00006F9F 20C0                <1> 	and	al, al
    98 00006FA1 7457                <1> 	jz	short loc_validate_next_hdp_partition2
    99                              <1> 
   100 00006FA3 56                  <1> 	push	esi ; *** ; Masterboot partition table offset
   101 00006FA4 52                  <1> 	push	edx ; **** ; dl = Physical drive number
   102                              <1> 
   103                              <1> 	; 13/08/2020
   104 00006FA5 3C05                <1> 	cmp	al, 05h  ; Extended partition CHS
   105 00006FA7 7404                <1>  	je	short loc_set_ep_counter
   106 00006FA9 3C0F                <1> 	cmp	al, 0Fh  ; Extended partition LBA
   107 00006FAB 7511                <1>  	jne	short loc_validate_next_hdp_partition0
   108                              <1> 	
   109                              <1> 	;;inc	byte [PP_Counter]
   110                              <1> 	; 15/07/2020
   111                              <1> 	;inc 	byte [EP_Counter] ; disk has valid partition(s)
   112                              <1> 
   113                              <1> loc_set_ep_counter:
   114                              <1> 	; 13/08/2020
   115 00006FAD 803D[507D0100]80    <1> 	cmp	byte [EP_Counter], 80h
   116 00006FB4 7342                <1> 	jnb	short loc_validate_next_hdp_partition1
   117                              <1> 
   118 00006FB6 8815[507D0100]      <1> 	mov	byte [EP_Counter], dl ; disk drv has extd. part.
   119                              <1> 
   120 00006FBC EB3A                <1> 	jmp	short loc_validate_next_hdp_partition1
   121                              <1> 
   122                              <1> loc_validate_next_hdp_partition0:
   123 00006FBE 31FF                <1> 	xor	edi, edi ; 0  
   124                              <1> 	; Input -> ESI = PartitionTable offset
   125                              <1> 	; DL = Hard disk drive number 
   126                              <1> 	; EDI = 0 -> Primary Partition
   127                              <1> 	; EDI > 0 -> Extended Partition's Start Sector   
   128 00006FC0 E887010000          <1> 	call 	validate_hd_fat_partition
   129 00006FC5 730E                <1> 	jnc 	short loc_set_valid_hdp_partition_entry
   130                              <1> 
   131                              <1> 	;pop	edx
   132                              <1> 	;push	edx
   133 00006FC7 8B1424              <1> 	mov	edx, [esp]  ; ****
   134 00006FCA 8B742404            <1> 	mov	esi, [esp+4] ; *** ; 30/01/2018
   135 00006FCE E8CC020000          <1> 	call	validate_hd_fs_partition
   136 00006FD3 7223                <1> 	jc	short loc_validate_next_hdp_partition1
   137                              <1> loc_set_valid_hdp_partition_entry:
   138 00006FD5 8A0D[91300100]      <1> 	mov 	cl, [Last_DOS_DiskNo] 
   139 00006FDB 80C141              <1> 	add 	cl, 'A'
   140                              <1> 	; ESI = Logical dos drive description table address
   141 00006FDE 880E                <1> 	mov	[esi+LD_Name], cl
   142                              <1> 	; 15/07/2020
   143 00006FE0 8A4602              <1> 	mov	al, [esi+LD_PhyDrvNo] ; Physical drive number
   144                              <1> 	;mov	al, [esp] ; ****
   145 00006FE3 2C7F                <1> 	sub	al, 7Fh
   146                              <1> 		; AL = 1 to 4	
   147 00006FE5 C0E002              <1> 	shl	al, 2 ; AL = 4 to 16
   148                              <1> 
   149 00006FE8 8A15[4F7D0100]      <1> 	mov	dl, [PP_Counter]
   150                              <1> 
   151                              <1> 	;sub	al, [PP_Counter]
   152 00006FEE 28D0                <1> 	sub	al, dl ; [PP_Counter] ; 4 - partition index
   153                              <1> 
   154                              <1> 	; AL = Partition entry/index, 0 based
   155                              <1> 	;  0 -> hd 0, Partition Table offset = 0
   156                              <1> 	; 15 -> hd 3, Partition Table offset = 3
   157                              <1> 
   158                              <1> 	;mov	[esi+LD_PartitionEntry], al 
   159                              <1> 	
   160                              <1> 	; 15/07/2020
   161 00006FF0 B404                <1> 	mov	ah, 4
   162                              <1> 	;sub	ah, [PP_Counter]
   163 00006FF2 28D4                <1> 	sub	ah, dl
   164                              <1> 
   165                              <1> 	; AH = Primary partition index, 0 to 3 ; pt entry
   166                              <1> 	;		(4 to 7 for logical disk partitions)
   167                              <1> 
   168                              <1> 	;mov 	[esi+LD_DParamEntry], ah 
   169 00006FF4 6689467C            <1> 	mov 	[esi+LD_PartitionEntry], ax
   170                              <1> 
   171                              <1> loc_validate_next_hdp_partition1:
   172 00006FF8 5A                  <1> 	pop 	edx ; **** ; dl = Physical drive number 
   173 00006FF9 5E                  <1> 	pop	esi ; *** ; Masterboot partition table offset
   174                              <1> 
   175                              <1> loc_validate_next_hdp_partition2:
   176                              <1> 	; ESI = PartitionTable offset
   177                              <1> 	; DL = Hard/Fixed disk drive number
   178                              <1> 	
   179                              <1> 	;dec	byte [hdc] ; 4 - partition index
   180                              <1> 	;jz	short pass_pt_this_hard_disk
   181                              <1> 	; 15/07/2020
   182 00006FFA FE0D[4F7D0100]      <1> 	dec	byte [PP_Counter] ; 4 - partition index
   183 00007000 7410                <1> 	jz	short pass_pt_this_hard_disk
   184                              <1> 	
   185 00007002 83C610              <1> 	add	esi, 16 ; 10h
   186 00007005 EB95                <1> 	jmp	short loc_validate_hdp_partition
   187                              <1> 
   188                              <1> loc_not_any_extd_partitions:
   189                              <1> 	; 15/07/2020
   190 00007007 C3                  <1> 	retn	
   191                              <1> 
   192                              <1> loc_next_hd_partition_table:
   193 00007008 FEC2                <1> 	inc	dl
   194                              <1> 	; 15/07/2020
   195                              <1> 	;add	esi, 32 ; next FDPT address
   196 0000700A 83C740              <1> 	add	edi, 64 ; next partition table destination
   197 0000700D E959FFFFFF          <1>         jmp     load_next_hd_partition_table
   198                              <1> 
   199                              <1> pass_pt_this_hard_disk:
   200                              <1> 	;pop	esi ; FDPT (+ DPTE) address
   201                              <1> 	; 15/07/2020
   202 00007012 5E                  <1> 	pop	esi ; ** ; next FDPT (+ DPTE) address ptr
   203 00007013 5F                  <1> 	pop	edi ; * ; Ptable_hd?
   204                              <1> 	;pop	ecx
   205                              <1> 	;loop	loc_next_hd_partition_table
   206 00007014 FE0D[2B650000]      <1> 	dec	byte [hdc]
   207 0000701A 75EC                <1> 	jnz	short loc_next_hd_partition_table
   208                              <1> 
   209                              <1> 	;cmp	byte [PP_Counter], 1
   210                              <1> 	;jnb	short load_extended_dos_partitions
   211                              <1> 	;; Empty partition table
   212                              <1> 	;retn
   213                              <1> 
   214                              <1> 	; 11/08/2020
   215                              <1> 	; 17/07/2020
   216                              <1> check_extended_partitions:
   217                              <1> 	; 15/07/2020
   218                              <1> 	;cmp	byte [EP_Counter], 0
   219                              <1> 	;jna	short loc_not_any_extd_partitions
   220                              <1> 	; 13/08/2020
   221 0000701C A0[507D0100]        <1> 	mov	al, [EP_Counter] ; 1st disk drv has extd partition
   222 00007021 08C0                <1> 	or	al, al ; 0 ?
   223 00007023 74E2                <1> 	jz	short loc_not_any_extd_partitions
   224                              <1> 
   225                              <1> load_extended_dos_partitions:
   226                              <1> 	;mov	byte [hdc], 80h
   227                              <1> 	; 13/08/2020
   228 00007025 A2[2B650000]        <1> 	mov	byte [hdc], al ; 1st disk drv has extd partition
   229                              <1> 	; 25/08/2020
   230 0000702A 2C80                <1> 	sub	al, 80h
   231 0000702C 740E                <1> 	jz	short loc_set_ext_ptable_hd0
   232 0000702E C0E006              <1> 	shl	al, 6 ; * 64
   233 00007031 0FB6F0              <1> 	movzx	esi, al
   234 00007034 81C6[4A7C0100]      <1> 	add	esi, PTable_hd0
   235 0000703A EB05                <1> 	jmp 	short next_hd_extd_partition
   236                              <1> 
   237                              <1> 	; 25/08/2020
   238                              <1> loc_set_ext_ptable_hd0:
   239 0000703C BE[4A7C0100]        <1> 	mov	esi, PTable_hd0
   240                              <1> 
   241                              <1> next_hd_extd_partition:
   242                              <1> 	; 17/07/2020
   243                              <1> 	;mov 	byte [EP_Counter], 0 ; Reset for each physical disk
   244                              <1> 	; 13/08/2020
   245                              <1> 	;mov	byte [LD_Counter], 0 ; Reset logical drive index
   246 00007041 66C705[507D0100]00- <1> 	mov 	word [EP_Counter], 0 ; Reset EP index and LD index	
   246 00007049 00                  <1>
   247                              <1> 
   248 0000704A 56                  <1> 	push	esi ; **** ; PTable_hd? offset
   249                              <1> 	
   250 0000704B C605[4F7D0100]04    <1> 	mov 	byte [PP_Counter], 4 
   251                              <1> 				; set for each extd partition table
   252                              <1> 	;;mov	ecx, 4
   253                              <1> 	;mov	cl, 4
   254 00007052 8A15[2B650000]      <1> 	mov	dl, [hdc]
   255                              <1> hd_check_fs_id_05h:
   256 00007058 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
   257 0000705B 3C05                <1> 	cmp	al, 05h ; Is it an extended dos partition ?
   258 0000705D 7411                <1> 	je	short loc_set_ep_start_sector ; yes
   259                              <1> hd_check_fs_id_0Fh:
   260 0000705F 3C0F                <1> 	cmp	al, 0Fh ; Is it an extended win4 (LBA mode) partition ?
   261 00007061 740D                <1> 	je	short loc_set_ep_start_sector ; yes
   262                              <1> 
   263                              <1> continue_to_check_ep:
   264                              <1> 	;add	esi, 16
   265                              <1> 	;loop	hd_check_fs_id_05h
   266                              <1> 	; 15/07/2020
   267                              <1> 	;dec	cl
   268                              <1> 	;jz	short continue_check_ep_next_disk
   269 00007063 FE0D[4F7D0100]      <1> 	dec	byte [PP_Counter] ; 4 --> 0
   270 00007069 742D                <1> 	jz	short continue_check_ep_next_disk
   271 0000706B 83C610              <1> 	add	esi, 16
   272 0000706E EBE8                <1> 	jmp	short hd_check_fs_id_05h
   273                              <1> 
   274                              <1> loc_set_ep_start_sector:
   275                              <1> 	; dl = [hdc] ; Drive number
   276                              <1> 	; 15/07/2020
   277 00007070 8B4E08              <1> 	mov	ecx, [esi+ptStartSector]
   278                              <1> 	; 30/08/2020
   279 00007073 890D[527D0100]      <1> 	mov	[MBR_EP_StartSector], ecx 
   280                              <1> 	; 20/07/2020
   281                              <1> loc_validate_hde_partition_next:
   282 00007079 890D[567D0100]      <1> 	mov	[EP_StartSector], ecx ; Extended partition's start sector
   283 0000707F BB[4A7A0100]        <1>         mov	ebx, MasterBootBuff
   284 00007084 803D[4E7D0100]01    <1> 	cmp	byte [HD_LBA_yes], 1 ; LBA ready = Yes
   285 0000708B 7227                <1> 	jb	short loc_hd_load_ep_05h ; cf = 1 ; 20/07/2020 
   286                              <1> 	; 11/08/2020
   287                              <1> 	; (BugFix for extended partition type 05h beyond CHS limit)
   288                              <1> 	; (Infact if extended partition starts at the beyond of CHS limit,
   289                              <1> 	;  it's partition ID must be 0Fh but they/somebodies had used 05h.)
   290                              <1> 	;cmp	al, 05h
   291                              <1> 	;je	short loc_hd_load_ep_05h
   292                              <1> loc_hd_load_ep_0Fh:
   293                              <1> 	; 04/01/2016
   294                              <1> 	;push	ecx
   295                              <1> 	; 15/07/2020
   296                              <1> 	;mov	ecx, [esi+ptStartSector] ; sector number
   297                              <1> 	;mov	ebx, MasterBootBuff ; buffer address
   298                              <1> 	; LBA read/write (with private LBA function) 
   299                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
   300                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
   301                              <1> 	;mov	ah, 1Bh ; LBA read
   302                              <1> 	;mov	al, 1 ; sector count
   303 0000708D 66B8011B            <1> 	mov	ax, 1B01h
   304 00007091 E8E1DEFFFF          <1> 	call	int13h
   305                              <1> 	;pop	ecx
   306                              <1> 	;jnc	short loc_hd_move_ep_table
   307                              <1> 	; 15/07/2020
   308 00007096 732E                <1> 	jnc	short loc_validate_hde_partition
   309                              <1> 
   310                              <1> continue_check_ep_next_disk:
   311                              <1> 	; 15/07/2020
   312                              <1> 	;pop	edi ; PTable_ep?
   313 00007098 5E                  <1> 	pop	esi ; **** ; PTable_hd?
   314 00007099 A0[20780100]        <1> 	mov	al, [HF_NUM] ; number of hard disks
   315 0000709E 047F                <1> 	add	al, 7Fh
   316 000070A0 3805[2B650000]      <1> 	cmp	[hdc], al
   317 000070A6 730B                <1> 	jnb	short loc_validating_hd_partitions_ok
   318 000070A8 83C640              <1> 	add	esi, 64
   319                              <1> 	; 15/07/2020
   320                              <1> 	;add	edi, 64
   321 000070AB FE05[2B650000]      <1> 	inc	byte [hdc]
   322 000070B1 EB8E                <1> 	jmp	short next_hd_extd_partition
   323                              <1> 
   324                              <1> loc_validating_hd_partitions_ok:
   325                              <1> 	; 15/07/2020
   326                              <1> 	;mov	al, [Last_DOS_DiskNo]
   327                              <1> loc_drv_init_retn:
   328 000070B3 C3                  <1> 	retn
   329                              <1> 	
   330                              <1> loc_hd_load_ep_05h:
   331                              <1> 	; 20/07/2020 ('diskio.s', int13h, cf = 1 -> bugfix)
   332                              <1> 	;clc    ; (Bug: int13h would not clear carry flag bit, 
   333                              <1> 	;	; even if there would not be an error)
   334                              <1> 	;	; ((Fix: now, int13h procedure clears carry flag
   335                              <1> 	;	;  at the entrance of it.. 20/07/2020))
   336                              <1> 	; 15/07/2020
   337                              <1> 	;push	ecx 
   338 000070B4 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
   339 000070B7 668B4E02            <1>         mov     cx, [esi+ptBeginSector]
   340 000070BB 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
   341                              <1> 	;mov	ebx, MasterBootBuff
   342 000070BF E8B3DEFFFF          <1> 	call	int13h ; 20/07/2020
   343                              <1> 		       ; 'diskio.s' modification, 'clc'
   344                              <1> 	;pop	ecx  
   345 000070C4 72D2                <1> 	jc	short continue_check_ep_next_disk
   346                              <1> 	; 15/07/2020
   347                              <1> 	;jmp	short loc_validate_hde_partition
   348                              <1> 
   349                              <1> 	; 15/07/2020
   350                              <1> ;loc_hd_move_ep_table:
   351                              <1> 	;;pop	edi
   352                              <1> 	;;push	edi  ; PTable_ep?
   353                              <1> 	;mov	edi, [esp]        
   354                              <1>         ;mov	esi, PartitionTable ; Extended
   355                              <1> 	;mov	ebx, esi
   356                              <1> 	;;mov	ecx, 16
   357                              <1> 	;mov	cl, 16
   358                              <1>        	;rep	movsd
   359                              <1> 	;mov	esi, ebx 
   360                              <1> ;loc_set_hde_sub_partition_count:
   361                              <1> 	;mov	byte [PP_Counter], 4
   362                              <1> 	;mov	byte [EP_Counter], 0
   363                              <1> 
   364                              <1> loc_validate_hde_partition:
   365                              <1> 	; 13/08/2020
   366                              <1> 	; 15/07/2020
   367                              <1> 	;mov	byte [PP_Counter], 4
   368 000070C6 BE[087C0100]        <1> 	mov	esi, PartitionTable ; (in MasterBootBuff)
   369                              <1> 	; 13/08/2020
   370                              <1> 	;jmp	short get_minidisk_partition_entry
   371                              <1> 
   372                              <1> ;get_minidisk_partition_entry:
   373                              <1> ;	; 20/07/2020
   374                              <1> ;	cmp	byte [esi+ptFileSystemID], 0
   375                              <1> ;	ja	short loc_validate_minidisk_partition
   376                              <1> ;	; 13/08/2020
   377                              <1> ;	jmp	short continue_check_ep_next_disk
   378                              <1> 
   379                              <1> ;	; 11/08/2020
   380                              <1> ;get_minidisk_partition_entry_next:
   381                              <1> ;	; 13/08/2020
   382                              <1> ;	;dec 	byte [PP_Counter]
   383                              <1> ;	;jz	short continue_check_ep_next_disk
   384                              <1> ;	; 20/07/2020
   385                              <1> ;;get_minidisk_partition_entry_next:
   386                              <1> ;	; 13/08/2020
   387                              <1> ;	cmp	esi, PartitionTable+64 
   388                              <1> ;	jnb	short continue_check_ep_next_disk
   389                              <1> ;	
   390                              <1> ;	add 	esi, 16 ; 10h
   391                              <1> ;	;jmp	short get_minidisk_partition_entry
   392                              <1> 
   393                              <1> 	; 13/08/2020
   394                              <1> get_minidisk_partition_entry:
   395                              <1> 	; 20/07/2020
   396 000070CB 807E0400            <1> 	cmp	byte [esi+ptFileSystemID], 0
   397 000070CF 76C7                <1> 	jna	short continue_check_ep_next_disk ; 13/08/2020
   398                              <1> 
   399                              <1> loc_validate_minidisk_partition:
   400                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   401                              <1> 	; 13/08/2020
   402                              <1> 	; 20/07/2020
   403                              <1> 	;push	esi ; *** ; Extended partition table offset
   404                              <1> 
   405                              <1> 	; 13/08/2020
   406 000070D1 FE05[507D0100]      <1> 	inc	byte [EP_Counter] ; current (sub partition) index 
   407                              <1> 				  ; in current extended partition
   408                              <1> 
   409 000070D7 BF[567D0100]        <1> 	mov	edi, EP_StartSector
   410                              <1> 
   411                              <1> 	; Input -> ESI = PartitionTable offset
   412                              <1> 	; DL = Hard disk drive number   
   413                              <1> 	; EDI = Extended partition start sector pointer
   414 000070DC E86B000000          <1> 	call	validate_hd_fat_partition
   415                              <1> 	;pop	ecx ; *
   416 000070E1 7308                <1> 	jnc	short loc_set_valid_hde_partition_entry
   417                              <1> 			 ; jump down to deep !!!
   418                              <1> 
   419                              <1> 	;pop	esi ; *** ; Extended partition table offset
   420                              <1> 	; 13/08/2020
   421                              <1> 	;mov	esi, PartitionTable
   422                              <1> 
   423                              <1> 	; 11/08/2020
   424                              <1> 	; ESI = Extended partition table offset
   425 000070E3 8A15[2B650000]      <1> 	mov	dl, [hdc]
   426                              <1> 
   427                              <1> 	;; DL = Hard disk drive number
   428                              <1> 	;dec	byte [PP_Counter]
   429                              <1> 	;jz	short continue_check_ep_next_disk
   430                              <1> 	;add 	esi, 16 ; 10h
   431                              <1> 	;mov	dl, [hdc]
   432                              <1> 	;jmp	short get_minidisk_partition_entry
   433                              <1> 
   434                              <1> 	; 11/08/2020
   435                              <1> 	;jmp	short get_minidisk_partition_entry_next
   436                              <1> 
   437                              <1> 	; 23/08/2020
   438 000070E9 EB3E                <1> 	jmp	short validate_next_minidisk_partition_ok
   439                              <1> 
   440                              <1> 	; 17/07/2020
   441                              <1> 	;; jumping down to deep levels !!!
   442                              <1> 	; ((That is a pitty microsoft preferred ep table chain
   443                              <1> 	; instead of a single table as mbr partition table!?))
   444                              <1> 
   445                              <1> loc_set_valid_hde_partition_entry:
   446                              <1> 	; 15/07/2020
   447 000070EB A0[2B650000]        <1> 	mov	al, [hdc] ; Hard disk drive number (>=80h)
   448 000070F0 88C2                <1> 	mov	dl, al ; mov dl, [hdc]
   449 000070F2 2C7F                <1> 	sub	al, 7Fh
   450                              <1> 		    ; 1 to 4	
   451 000070F4 C0E002              <1> 	shl	al, 2 ; 4 to 16
   452 000070F7 2A05[4F7D0100]      <1> 	sub	al, [PP_Counter] ; al - (4 - partition index)
   453                              <1> 			; (disk number * 4) + partition index
   454                              <1> 	
   455                              <1> 	; AL = Partition entry/index, 0 based
   456                              <1>         ;  0 -> hd 0, Partition Table offset = 0
   457                              <1>         ; 15 -> hd 3, Partition Table offset = 3
   458                              <1> 
   459                              <1> 	;mov	ah, 4 ; Logical dos partition (>= 4)
   460                              <1> 	;add	ah, [EP_Counter]
   461                              <1> 		; Logical disk partition index = 4 to 7
   462                              <1> 		; (Primary disk partition index = 0 to 3)
   463                              <1> 
   464                              <1> 	; 13/08/2020
   465 000070FD 8A25[517D0100]      <1> 	mov	ah, [LD_Counter] ; Logical drive index number
   466                              <1> 				; (in current extended partition)
   467 00007103 80C404              <1> 	add	ah, 4 ; 4 to 7
   468                              <1> 	
   469                              <1> 	; 15/07/2020
   470                              <1> 	; CX -> AX
   471                              <1> 	;; 06/01/2016 (TRDOS v2.0)
   472                              <1> 	;; BUGFIX *
   473                              <1> 	;;mov	[esi+LD_PartitionEntry], cl 
   474                              <1> 	;;mov	[esi+LD_DParamEntry], ch 
   475                              <1> 	;mov	[esi+LD_PartitionEntry], cx 
   476 00007106 6689467C            <1> 	mov	[esi+LD_PartitionEntry], ax 	
   477                              <1> 
   478 0000710A 8A0D[91300100]      <1> 	mov	cl, [Last_DOS_DiskNo] 
   479 00007110 80C141              <1> 	add	cl, 'A'
   480 00007113 880E                <1> 	mov	[esi+LD_Name], cl
   481                              <1> 
   482                              <1> 	; 17/07/2020
   483                              <1> 	;cmp	cl, 'Z'
   484                              <1> 	;jb	short logical_drive_count_ok_for_next
   485                              <1> 	;pop	esi ; ***
   486                              <1> 	;pop	esi ; ****
   487                              <1> 	;retn
   488                              <1> 
   489                              <1> ;logical_drive_count_ok_for_next:
   490                              <1> 
   491                              <1> 	;; 15/07/2020
   492                              <1> 	;inc	byte [EP_Counter]
   493                              <1> 	; 13/08/2020
   494 00007115 FE05[517D0100]      <1> 	inc	byte [LD_Counter]	
   495                              <1> 
   496                              <1> 	;mov	dl, [hdc]
   497                              <1> 
   498                              <1> 	; 17/07/2020
   499                              <1> 	;; Now, 
   500                              <1> 	;; we are swimming in deep of an extended partition !!!
   501                              <1> 	; (! sub or chained extended partition tables !)
   502                              <1> 	; ((Logical dos partitions in extended partition were called
   503                              <1> 	;  as 'mini disk partition' in msdos 6.0 source code.))
   504                              <1> 
   505                              <1> validate_next_minidisk_partition:
   506                              <1> 	; 13/08/2020
   507                              <1> 	;pop	esi ; *** ; Extended partition table offset
   508                              <1> 
   509                              <1> 	; 17/07/2020
   510                              <1> 	;cmp	byte [EP_Counter], 4
   511                              <1> 	; 13/08/2020
   512 0000711B 803D[517D0100]04    <1> 	cmp	byte [LD_Counter], 4 ; maximum 4 logical disks
   513                              <1> 				     ; per extended partition
   514                              <1> 	;jnb	continue_check_ep_next_disk
   515                              <1> 	; 25/07/2022
   516 00007122 7205                <1> 	jb	short validate_next_minidisk_partition_ok
   517 00007124 E96FFFFFFF          <1> 	jmp	continue_check_ep_next_disk	
   518                              <1> 
   519                              <1> validate_next_minidisk_partition_ok:
   520                              <1> 	; 13/08/2020
   521                              <1> 	;dec	byte [PP_Counter] ; 4 --> 0
   522                              <1> 	;jz	continue_check_ep_next_disk
   523                              <1> 	
   524                              <1> 	;cmp	esi, PartitionTable+64 
   525                              <1> 	;jnb	continue_check_ep_next_disk
   526                              <1> 
   527                              <1> 	;add	esi, 16
   528                              <1> 	; 13/08/2020
   529 00007129 BE[187C0100]        <1> 	mov	esi, PartitionTable+16
   530                              <1> 
   531                              <1> 	; 20/07/2020
   532 0000712E 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
   533                              <1> 
   534                              <1> 	; 20/07/2020
   535 00007131 3C05                <1> 	cmp	al, 05h ; Is it an extended dos partition ?
   536 00007133 7409                <1> 	je	short loc_minidisk_next_ep_lba_chs ; 17/07/2020
   537 00007135 3C0F                <1> 	cmp	al, 0Fh ; Is it an extended win4 (LBA mode) partition ?
   538                              <1> 	;jne	continue_check_ep_next_disk ; AL must be 0 here
   539                              <1> 					; (when it is not 05h or 0Fh)
   540                              <1> 					; If AL is not ZERO -> EP Bug!
   541                              <1> 					; (!Microsoft DOS convention!)
   542                              <1> 	; 25/07/2022
   543 00007137 7405                <1> 	je	short loc_minidisk_next_ep_lba_chs
   544 00007139 E95AFFFFFF          <1> 	jmp	continue_check_ep_next_disk	
   545                              <1> 
   546                              <1> loc_minidisk_next_ep_lba_chs:
   547                              <1> 	; 17/07/2020
   548 0000713E 8B4E08              <1> 	mov	ecx, [esi+ptStartSector] ; relative start sector number
   549                              <1> 	;add	ecx, [EP_StartSector]
   550                              <1> 	; 30/08/2020	
   551 00007141 030D[527D0100]      <1> 	add	ecx, [MBR_EP_StartSector] 
   552                              <1> 	; 20/07/2020
   553 00007147 E92DFFFFFF          <1> 	jmp	loc_validate_hde_partition_next
   554                              <1> 
   555                              <1> validate_hd_fat_partition:
   556                              <1> 	; 17/07/2020
   557                              <1> 	; 15/07/2020
   558                              <1> 	;	(optimization)
   559                              <1> 	; 14/07/2020
   560                              <1> 	;	(fat16 -big- partition search bugfix)
   561                              <1> 	; 27/12/2017
   562                              <1> 	; 12/02/2016
   563                              <1> 	; 07/01/2016 (TRDOS 386 = TRDOS v2.0)
   564                              <1> 	; 07/08/2011
   565                              <1> 	; 23/07/2011
   566                              <1> 	; Input
   567                              <1> 	;   DL = Hard/Fixed Disk Drive Number
   568                              <1> 	;   ESI = PartitionTable offset
   569                              <1> 	;   EDI = Extend. Part. Start Sector Pointer
   570                              <1> 	;   EDI = 0 -> Primary Partition 
   571                              <1> 	;   byte [Last_DOS_DiskNo]
   572                              <1>  	; Output
   573                              <1> 	;  cf=0 -> Validated
   574                              <1> 	;   ESI = Logical dos drv desc. table
   575                              <1> 	;   EBX = FAT boot sector buffer
   576                              <1> 	;   byte [Last_DOS_DiskNo]
   577                              <1> 	;  cf=1 -> Not a valid FAT partition
   578                              <1> 	; EAX, EDX, ECX, EDI -> changed 
   579                              <1> 	
   580                              <1> 	;mov 	esi, PartitionTable
   581 0000714C 8A6604              <1> 	mov 	ah, [esi+ptFileSystemID]
   582 0000714F B002                <1> 	mov	al, 2 ; 27/12/2017
   583 00007151 80FC06              <1> 	cmp 	ah, 06h ; FAT16 CHS partition (>=32MB)
   584                              <1> 	; 12/02/2016
   585                              <1> 	;;jb	short loc_not_a_valid_fat_partition2
   586                              <1>  	;jnb	short vhdp_FAT16_32
   587                              <1> 	; 14/07/2020 (BugFix)
   588 00007154 7711                <1> 	ja	short vhdp_FAT16_32
   589 00007156 7425                <1> 	je	short loc_set_valid_hd_partition_params
   590                              <1> 
   591                              <1> vhdp_FAT12_16:
   592                              <1> 	; 27/12/2017
   593 00007158 FEC8                <1> 	dec	al ; mov al, 1
   594 0000715A 38C4                <1> 	cmp	ah, al ; 1 ; FAT12 partition
   595 0000715C 741F                <1> 	je	short loc_set_valid_hd_partition_params
   596                              <1> 	;
   597 0000715E FEC0                <1> 	inc	al ; mov al, 2
   598 00007160 80FC04              <1> 	cmp	ah, 04h ; FAT16 CHS partition (< 32MB)
   599 00007163 7418                <1> 	je	short loc_set_valid_hd_partition_params
   600                              <1> 	
   601                              <1> 	; 15/07/2020
   602                              <1> 	; (ah = 05h, 02h or 03h)
   603                              <1> loc_not_a_valid_fat_partition1:
   604 00007165 F9                  <1> 	stc
   605                              <1> 	; cf=1
   606 00007166 C3                  <1> 	retn
   607                              <1> 
   608                              <1> vhdp_FAT16_32:
   609                              <1> 	; 15/07/2020
   610                              <1> 	;mov	al, 3
   611 00007167 FEC0                <1> 	inc	al
   612 00007169 80FC0C              <1> 	cmp	ah, 0Ch ; FAT32 LBA partition
   613 0000716C 740F                <1> 	je	short loc_set_valid_hd_partition_params
   614 0000716E 7706                <1> 	ja	short vhdp_check_FAT16_lba
   615                              <1> 
   616                              <1> vhdp_check_FAT32_chs:
   617 00007170 80FC0B              <1> 	cmp	ah, 0Bh ; FAT32 CHS partition 
   618 00007173 7408                <1> 	je	short loc_set_valid_hd_partition_params
   619                              <1> 	;jne	short loc_not_a_valid_fat_partition1
   620                              <1> 
   621                              <1> 	;stc
   622                              <1> loc_not_a_valid_fat_partition2:
   623 00007175 C3                  <1> 	retn
   624                              <1> 
   625                              <1> vhdp_check_FAT16_lba:
   626 00007176 80FC0E              <1> 	cmp	ah, 0Eh ; FAT16 LBA partition
   627 00007179 75EA                <1> 	jne	short loc_not_a_valid_fat_partition1
   628                              <1> 
   629                              <1> 	;mov	al, 2
   630 0000717B FEC8                <1> 	dec	al
   631                              <1> 
   632                              <1> loc_set_valid_hd_partition_params:
   633                              <1> 	; 30/07/2022
   634                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   635                              <1> 	; 15/07/2020
   636                              <1> 	;inc 	byte [Last_DOS_DiskNo] ; > 1
   637                              <1> 	;
   638 0000717D 31DB                <1> 	xor	ebx, ebx
   639 0000717F 8A3D[91300100]      <1> 	mov	bh, [Last_DOS_DiskNo] ; * 256	
   640 00007185 FEC7                <1> 	inc	bh ; 15/07/2020
   641 00007187 81C300010900        <1> 	add	ebx, Logical_DOSDisks
   642                              <1> 	;
   643 0000718D C6430102            <1> 	mov	byte [ebx+LD_DiskType], 2
   644 00007191 885302              <1> 	mov	byte [ebx+LD_PhyDrvNo], dl
   645                              <1> 	;mov	byte [ebx+LD_FATType], al ; 2 or 3
   646                              <1> 	;mov	byte [ebx+LD_FSType], ah ; 06h, 0Eh, 0Bh, 0Ch
   647 00007194 66894303            <1> 	mov	word [ebx+LD_FATType], ax
   648                              <1> 	;
   649 00007198 8B4E08              <1> 	mov	ecx, [esi+ptStartSector]
   650 0000719B 09FF                <1> 	or	edi, edi 
   651 0000719D 7402                <1> 	jz	short pass_hd_FAT_ep_start_sector_adding
   652                              <1> loc_add_hd_FAT_ep_start_sector:
   653                              <1> 	; 17/07/2020
   654 0000719F 030F                <1> 	add	ecx, [edi]
   655                              <1> pass_hd_FAT_ep_start_sector_adding:
   656 000071A1 894B6C              <1> 	mov	[ebx+LD_StartSector], ecx
   657                              <1> loc_hd_FAT_logical_drv_init:
   658 000071A4 89DD                <1> 	mov	ebp, ebx
   659                              <1> 	;mov	dl, [ebx+LD_PhyDrvNo]
   660 000071A6 A0[4E7D0100]        <1> 	mov	al, [HD_LBA_yes] ; 07/01/2016
   661 000071AB 884305              <1> 	mov	[ebx+LD_LBAYes], al
   662 000071AE BB[5A7D0100]        <1> 	mov	ebx, DOSBootSectorBuff ; buffer address
   663 000071B3 08C0                <1> 	or	al, al
   664 000071B5 740C                <1> 	jz	short loc_hd_FAT_drv_init_load_bs_chs
   665                              <1> loc_hd_FAT_drv_init_load_bs_lba:
   666                              <1> 	; DL = Physical drive number
   667                              <1>    	;mov	ecx, [esi+ptStartSector] ; sector number
   668                              <1> 	;mov	ebx, DOSBootSectorBuff ; buffer address
   669                              <1> 	; LBA read/write (with private LBA function) 
   670                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
   671                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
   672 000071B7 B41B                <1> 	mov	ah, 1Bh ; LBA read
   673 000071B9 B001                <1> 	mov	al, 1 ; sector count
   674 000071BB E8B7DDFFFF          <1> 	call	int13h
   675 000071C0 7313                <1> 	jnc	short loc_hd_drv_FAT_boot_validation
   676                              <1> loc_not_a_valid_fat_partition3:
   677 000071C2 C3                  <1> 	retn
   678                              <1> loc_hd_FAT_drv_init_load_bs_chs:
   679 000071C3 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
   680 000071C6 668B4E02            <1> 	mov	cx, [esi+ptBeginSector]
   681 000071CA 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
   682                              <1> 	;mov	ebx, DOSBootSectorBuff
   683 000071CE E8A4DDFFFF          <1> 	call	int13h
   684 000071D3 72ED                <1> 	jc	short loc_not_a_valid_fat_partition3
   685                              <1> loc_hd_drv_FAT_boot_validation:
   686                              <1> 	;mov	esi, DOSBootSectorBuff
   687 000071D5 89DE                <1> 	mov	esi, ebx
   688 000071D7 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
   689 000071E0 7514                <1> 	jne	short loc_not_a_valid_fat_partition4
   690 000071E2 807E15F8            <1> 	cmp	byte [esi+BPB_Media], 0F8h
   691 000071E6 750E                <1> 	jne	short loc_not_a_valid_fat_partition4
   692                              <1> 
   693                              <1> 	; 25/07/2022
   694 000071E8 31C9                <1> 	xor	ecx, ecx
   695                              <1> 
   696                              <1> 	; 27/12/2017
   697 000071EA 807D0303            <1> 	cmp	byte [ebp+LD_FATType], 3
   698 000071EE 7508                <1> 	jne	short loc_hd_FAT16_BPB
   699                              <1> 
   700                              <1> loc_hd_drv_FAT32_boot_validation:
   701 000071F0 807E4229            <1> 	cmp	byte [esi+BS_FAT32_BootSig], 29h
   702 000071F4 7413                <1> 	je	short loc_hd_FAT32_BPB
   703                              <1> 
   704                              <1> loc_not_a_valid_fat_partition4:
   705 000071F6 F9                  <1> 	stc
   706 000071F7 C3                  <1> 	retn
   707                              <1> 
   708                              <1> loc_hd_FAT16_BPB:
   709 000071F8 807E2629            <1> 	cmp	byte [esi+BS_BootSig], 29h
   710 000071FC 75F8                <1> 	jne	short loc_not_a_valid_fat_partition4
   711                              <1> 
   712 000071FE 66837E1600          <1> 	cmp	word [esi+BPB_FATSz16], 0
   713 00007203 7604                <1> 	jna	short loc_hd_big_FAT16_BPB
   714                              <1> 	;mov	ecx, 32
   715                              <1> 	; 25/07/2022
   716 00007205 B120                <1> 	mov	cl, 32
   717                              <1> 	; ecx = 32
   718 00007207 EB02                <1> 	jmp	short loc_hd_move_FAT_BPB
   719                              <1> 
   720                              <1> loc_hd_FAT32_BPB:
   721                              <1> 	;cmp	word [esi+BPB_FATSz16], 0
   722                              <1> 	;ja	short loc_not_a_valid_fat_partition4
   723                              <1> loc_hd_big_FAT16_BPB:
   724                              <1> 	;mov	ecx, 45
   725                              <1> 	; 25/07/2022
   726 00007209 B12D                <1> 	mov	cl, 45
   727                              <1> 	; ecx = 45
   728                              <1> loc_hd_move_FAT_BPB:
   729 0000720B 89EF                <1> 	mov 	edi, ebp
   730                              <1> 	;mov	esi, ebx ; Boot sector
   731 0000720D 57                  <1> 	push	edi
   732 0000720E 83C706              <1> 	add	edi, LD_BPB
   733 00007211 F366A5              <1> 	rep	movsw 
   734 00007214 5E                  <1> 	pop	esi
   735 00007215 0FB74614            <1> 	movzx	eax, word [esi+LD_BPB+BPB_RsvdSecCnt]
   736 00007219 03466C              <1> 	add	eax, [esi+LD_StartSector]
   737 0000721C 894660              <1> 	mov	[esi+LD_FATBegin], eax
   738 0000721F 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3
   739 00007223 7223                <1> 	jb	short loc_set_FAT16_RootDirLoc
   740                              <1> loc_set_FAT32_RootDirLoc:
   741 00007225 8B462A              <1> 	mov	eax, [esi+LD_BPB+BPB_FATSz32]
   742 00007228 0FB65E16            <1>         movzx	ebx, byte [esi+LD_BPB+BPB_NumFATs]
   743 0000722C F7E3                <1> 	mul	ebx
   744 0000722E 034660              <1> 	add	eax, [esi+LD_FATBegin]
   745                              <1> loc_set_FAT32_data_begin:
   746 00007231 894668              <1> 	mov	[esi+LD_DATABegin], eax
   747 00007234 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
   748                              <1> 	; If Root Directory Cluster <> 2 then
   749                              <1> 	; change the beginning sector value 
   750                              <1> 	; of the root dir by adding sector offset.
   751 00007237 8B4632              <1> 	mov	eax, [esi+LD_BPB+BPB_RootClus]
   752                              <1> 	;sub	eax, 2
   753                              <1> 	; 30/07/2022
   754 0000723A 48                  <1> 	dec	eax ; 2 -> 1
   755 0000723B 48                  <1> 	dec	eax ; 1 -> 0
   756 0000723C 7433                <1> 	jz	short short loc_set_32bit_FAT_total_sectors  
   757                              <1> 	;movzx	ebx, byte [esi+LD_BPB+BPB_SecPerClust]
   758 0000723E 8A5E13              <1> 	mov	bl, [esi+LD_BPB+BPB_SecPerClust] 
   759 00007241 F7E3                <1> 	mul	ebx
   760 00007243 014664              <1> 	add	[esi+LD_ROOTBegin], eax
   761 00007246 EB29                <1> 	jmp	short loc_set_32bit_FAT_total_sectors
   762                              <1> 	;
   763                              <1> loc_set_FAT16_RootDirLoc:
   764 00007248 0FB64616            <1> 	movzx	eax, byte [esi+LD_BPB+BPB_NumFATs]
   765 0000724C 0FB7561C            <1> 	movzx	edx, word [esi+LD_BPB+BPB_FATSz16]
   766 00007250 F7E2                <1> 	mul	edx
   767 00007252 034660              <1> 	add	eax, [esi+LD_FATBegin]  
   768 00007255 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
   769                              <1> loc_set_FAT16_data_begin:
   770 00007258 894668              <1> 	mov	[esi+LD_DATABegin], eax 
   771                              <1> 	;mov	eax, 20h  ; Size of a directory entry
   772                              <1> 	;;movzx	edx, word [esi+LD_BPB+BPB_RootEntCnt]
   773                              <1>         ;mov	dx, [esi+LD_BPB+BPB_RootEntCnt]
   774                              <1>         ;mul	edx
   775                              <1> 	;;mov	ecx, 511
   776                              <1> 	;mov	cx, 511
   777                              <1> 	;add	eax, ecx
   778                              <1> 	;inc	ecx ; 512
   779                              <1> 	;div	ecx
   780                              <1> 	; 14/07/2020
   781 0000725B 0FB74617            <1> 	movzx	eax, word [esi+LD_BPB+BPB_RootEntCnt]
   782 0000725F 6683C00F            <1> 	add	ax, 15
   783                              <1> 	;shr	ax, 4 ; / 16 ; (16 entries per sector)
   784                              <1> 	; 25/07/2022
   785 00007263 C1E804              <1> 	shr	eax, 4
   786 00007266 014668              <1> 	add	[esi+LD_DATABegin], eax
   787                              <1> 	;movzx	eax, word [esi+LD_BPB+BPB_TotalSec16]
   788 00007269 668B4619            <1> 	mov	ax, [esi+LD_BPB+BPB_TotalSec16]
   789                              <1> 	;test	ax, ax
   790                              <1> 	; 25/07/2022
   791 0000726D 85C0                <1> 	test	eax, eax
   792                              <1> 	;jz	short loc_set_32bit_FAT_total_sectors
   793                              <1> ;loc_set_16bit_FAT_total_sectors:
   794                              <1> 	;mov	[esi+LD_TotalSectors], eax
   795                              <1> 	;jmp	short loc_set_hd_FAT_cluster_count
   796                              <1> 	; 14/07/2020
   797 0000726F 7503                <1> 	jnz	short loc_set_hd_FAT_cluster_count
   798                              <1> loc_set_32bit_FAT_total_sectors:
   799 00007271 8B4626              <1> 	mov	eax, [esi+LD_BPB+BPB_TotalSec32]
   800                              <1> 	;mov	[esi+LD_TotalSectors], eax
   801                              <1> loc_set_hd_FAT_cluster_count:
   802 00007274 894670              <1> 	mov	[esi+LD_TotalSectors], eax ; 14/07/2020
   803 00007277 8B5668              <1> 	mov	edx, [esi+LD_DATABegin]
   804 0000727A 2B566C              <1> 	sub	edx, [esi+LD_StartSector]
   805 0000727D 29D0                <1> 	sub	eax, edx
   806 0000727F 31D2                <1> 	xor	edx, edx ; 0
   807 00007281 0FB64E13            <1>         movzx   ecx, byte [esi+LD_BPB+BPB_SecPerClust]
   808 00007285 F7F1                <1>         div	ecx 
   809 00007287 894678              <1> 	mov	[esi+LD_Clusters], eax
   810                              <1> 	; Maximum Valid Cluster Number= EAX +1
   811                              <1> 	; with 2 reserved clusters= EAX +2
   812                              <1> loc_set_hd_FAT_fs_free_sectors:
   813                              <1> 	;mov	dword [esi+LD_FreeSectors], 0
   814 0000728A E852010000          <1> 	call	get_free_FAT_sectors
   815 0000728F 720D                <1> 	jc	short loc_validate_hd_FAT_partition_retn
   816 00007291 894674              <1> 	mov	[esi+LD_FreeSectors], eax
   817 00007294 C6467E06            <1> 	mov	byte [esi+LD_MediaChanged], 6  ; Volume Name Reset
   818                              <1> 
   819                              <1> 	; 15/07/2020
   820 00007298 FE05[91300100]      <1> 	inc 	byte [Last_DOS_DiskNo] ; > 1
   821                              <1> 
   822                              <1> 	;mov	cl, [Last_DOS_DiskNo] 
   823                              <1> 	;add	cl, 'A'
   824                              <1> 	;mov	[esi+LD_FS_Name], cl
   825                              <1> 
   826                              <1> loc_validate_hd_FAT_partition_retn:         
   827 0000729E C3                  <1> 	retn
   828                              <1> 
   829                              <1> validate_hd_fs_partition:
   830                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   831                              <1> 	; 03/02/2018
   832                              <1> 	; 09/12/2017
   833                              <1> 	; 13/02/2016
   834                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
   835                              <1> 	; 29/01/2011
   836                              <1> 	; 23/07/2011
   837                              <1> 	; Input
   838                              <1> 	;   DL = Hard/Fixed Disk Drive Number
   839                              <1> 	;   ESI = PartitionTable offset
   840                              <1> 	;   byte [Last_DOS_DiskNo]
   841                              <1> 	; Output
   842                              <1> 	;  cf=0 -> Validated
   843                              <1> 	;   ESI = Logical dos drv desc. table
   844                              <1> 	;   EBX = Singlix FS boot sector buffer
   845                              <1> 	;   byte [Last_DOS_DiskNo]
   846                              <1> 	;  cf=1 -> Not a valid 'Singlix FS' partition
   847                              <1> 	; EAX, EDX, ECX, EDI -> changed 
   848                              <1> 
   849                              <1> 	;mov	esi, PartitionTable
   850 0000729F 8A6604              <1> 	mov	ah, [esi+ptFileSystemID]
   851 000072A2 80FCA1              <1> 	cmp	ah, 0A1h ; SINGLIX FS1 (trfs1) partition
   852 000072A5 7549                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   853                              <1> loc_set_valid_hd_fs_partition_params:
   854 000072A7 FE05[91300100]      <1> 	inc	byte [Last_DOS_DiskNo] ; > 1
   855 000072AD 30C0                <1> 	xor	al, al ; mov al, 0
   856                              <1> 	;mov	[drv], dl
   857 000072AF 29DB                <1> 	sub	ebx, ebx ; 0
   858 000072B1 8A3D[91300100]      <1> 	mov	bh, [Last_DOS_DiskNo] 
   859 000072B7 81C300010900        <1> 	add	ebx, Logical_DOSDisks
   860 000072BD C6430102            <1> 	mov	byte [ebx+LD_DiskType], 2
   861 000072C1 885302              <1> 	mov	[ebx+LD_PhyDrvNo], dl
   862                              <1> 	;mov	[ebx+LD_FATType], al ; 0
   863                              <1> 	;mov	[ebx+LD_FSType], ah
   864 000072C4 66894303            <1> 	mov	[ebx+LD_FATType], ax
   865                              <1> 	;mov	eax, [esi+ptStartSector]
   866                              <1> 	;mov	[ebx+LD_StartSector], eax
   867                              <1> loc_hd_fs_logical_drv_init:
   868 000072C8 89DD                <1> 	mov	ebp, ebx ; 10/01/2016
   869                              <1> 	;mov	dl, [ebx+LD_PhyDrvNo]
   870 000072CA A0[4E7D0100]        <1> 	mov	al, [HD_LBA_yes] ; 10/01/2016
   871 000072CF 884305              <1> 	mov	[ebx+LD_LBAYes], al
   872 000072D2 89DE                <1> 	mov	esi, ebx
   873 000072D4 BB[5A7D0100]        <1> 	mov	ebx, DOSBootSectorBuff ; buffer address
   874 000072D9 08C0                <1> 	or	al, al
   875 000072DB 7515                <1> 	jnz	short loc_hd_fs_drv_init_load_bs_lba
   876                              <1> loc_hd_fs_drv_init_load_bs_chs:
   877 000072DD 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
   878 000072E0 668B4E02            <1> 	mov	cx, [esi+ptBeginSector]
   879 000072E4 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
   880                              <1> 	;mov	ebx, DOSBootSectorBuff
   881 000072E8 E88ADCFFFF          <1> 	call	int13h
   882 000072ED 7311                <1> 	jnc	short loc_hd_drv_fs_boot_validation
   883                              <1> loc_validate_hd_fs_partition_err_retn:
   884 000072EF C3                  <1> 	retn
   885                              <1> loc_validate_hd_fs_partition_stc_retn:
   886 000072F0 F9                  <1> 	stc
   887 000072F1 C3                  <1> 	retn
   888                              <1> loc_hd_fs_drv_init_load_bs_lba:
   889                              <1> 	; DL = Physical drive number
   890                              <1> 	;mov	esi, ebx
   891 000072F2 8B4E08              <1>    	mov	ecx, [esi+ptStartSector] ; sector number
   892                              <1> 	;mov	ebx, DOSBootSectorBuff ; buffer address
   893                              <1> 	; LBA read/write (with private LBA function) 
   894                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
   895                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
   896 000072F5 B41B                <1> 	mov	ah, 1Bh ; LBA read
   897 000072F7 B001                <1> 	mov	al, 1 ; sector count
   898 000072F9 E879DCFFFF          <1> 	call	int13h
   899 000072FE 72EF                <1> 	jc	short loc_validate_hd_fs_partition_err_retn
   900                              <1> loc_hd_drv_fs_boot_validation:
   901                              <1> 	;mov	esi, DOSBootSectorBuff
   902 00007300 89DE                <1> 	mov	esi, ebx ; Boot sector buffer
   903 00007302 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
   904 0000730B 75E3                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   905                              <1>         ;
   906                              <1> 	;Singlix FS Extensions to TR-DOS (7/6/2009) 
   907 0000730D 66817E034653        <1> 	cmp	word [esi+bs_FS_Identifier], 'FS' ; 03/02/2018
   908 00007313 75DB                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   909                              <1>         ;'A1h' check is not necessary
   910                              <1> 	;  if 'FS' check is passed as OK/Yes.
   911 00007315 807E09A1            <1> 	cmp	byte [esi+bs_FS_PartitionID], 0A1h
   912 00007319 75D5                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   913                              <1> 	;
   914 0000731B 89EF                <1> 	mov	edi, ebp ; 10/01/2016
   915                              <1> 	;
   916 0000731D 8A462D              <1> 	mov	al, byte [esi+bs_FS_LBA_Ready]
   917 00007320 884705              <1> 	mov	[edi+LD_FS_LBAYes], al
   918                              <1> 	;
   919                              <1> 	; 03/01/2010 CHS -> DOS FAT/BPB compatibility fix
   920 00007323 8A4608              <1> 	mov	al, [esi+bs_FS_MediaAttrib]
   921 00007326 884706              <1> 	mov	byte [edi+LD_FS_MediaAttrib], al
   922                              <1> 	;
   923 00007329 8A460A              <1> 	mov	al, [esi+bs_FS_VersionMaj]
   924 0000732C 884707              <1> 	mov	[edi+LD_FS_VersionMajor], al
   925                              <1> 	;
   926 0000732F 668B4606            <1> 	mov	ax, [esi+bs_FS_BytesPerSec]
   927 00007333 66894711            <1> 	mov	[edi+LD_FS_BytesPerSec], ax
   928 00007337 8A462E              <1> 	mov	al, [esi+bs_FS_SecPerTrack]
   929 0000733A 30E4                <1> 	xor	ah, ah ; 09/12/2017
   930 0000733C 6689471E            <1> 	mov	[edi+LD_FS_SecPerTrack], ax
   931 00007340 8A462F              <1> 	mov	al, [esi+bs_FS_Heads]
   932 00007343 66894720            <1> 	mov	[edi+LD_FS_NumHeads], ax
   933                              <1> 	;
   934 00007347 8B4628              <1> 	mov	eax, [esi+bs_FS_UnDelDirD]
   935 0000734A 894722              <1> 	mov	[edi+LD_FS_UnDelDirD], eax
   936 0000734D 8B5618              <1> 	mov	edx, [esi+bs_FS_MATLocation]
   937 00007350 89570C              <1> 	mov	[edi+LD_FS_MATLocation], edx
   938 00007353 8B461C              <1> 	mov	eax, [esi+bs_FS_RootDirD]
   939 00007356 894708              <1> 	mov	[edi+LD_FS_RootDirD], eax
   940 00007359 8B460C              <1> 	mov	eax, [esi+bs_FS_BeginSector]
   941 0000735C 89476C              <1> 	mov	[edi+LD_FS_BeginSector], eax
   942 0000735F 8B4710              <1> 	mov	eax, [edi+bs_FS_VolumeSize]
   943 00007362 894770              <1> 	mov	[edi+LD_FS_VolumeSize], eax
   944                              <1> 	;
   945 00007365 89D0                <1> 	mov	eax, edx ; [edi+LD_FS_MATLocation]
   946 00007367 03476C              <1> 	add	eax, [edi+LD_FS_BeginSector]
   947 0000736A 89FE                <1> 	mov	esi, edi
   948                              <1> mread_hd_fs_MAT_sector:
   949                              <1>         ;mov	ebx, DOSBootSectorBuff
   950                              <1> 	;mov	ecx, 1
   951                              <1> 	; 25/07/2022
   952 0000736C 29C9                <1> 	sub	ecx, ecx
   953 0000736E FEC1                <1> 	inc	cl
   954                              <1> 	; ecx = 1	
   955 00007370 E8E0A90000          <1> 	call	disk_read
   956 00007375 7248                <1> 	jc	short loc_validate_hd_fs_partition_retn
   957                              <1> 	; EDI will not be changed
   958 00007377 89DE                <1> 	mov	esi, ebx
   959                              <1> use_hdfs_mat_sector_params:
   960 00007379 8B460C              <1> 	mov	eax, [esi+FS_MAT_DATLocation]
   961 0000737C 894714              <1> 	mov	[edi+LD_FS_DATLocation], eax
   962 0000737F 8B4610              <1> 	mov	eax, [esi+FS_MAT_DATScount]
   963 00007382 894718              <1> 	mov	[edi+LD_FS_DATSectors], eax
   964 00007385 8B4614              <1> 	mov	eax, [esi+FS_MAT_FreeSectors]
   965 00007388 894774              <1>         mov     [edi+LD_FS_FreeSectors], eax
   966 0000738B 8B4618              <1> 	mov	eax, [esi+FS_MAT_FirstFreeSector]
   967 0000738E 894778              <1> 	mov	[edi+LD_FS_FirstFreeSector], eax
   968 00007391 8B4708              <1> 	mov	eax, [edi+LD_FS_RootDirD]
   969 00007394 03476C              <1> 	add	eax, [edi+LD_FS_BeginSector]
   970 00007397 89FE                <1> 	mov	esi, edi   
   971                              <1> read_hd_fs_RDT_sector:
   972 00007399 BB[5A7D0100]        <1> 	mov	ebx, DOSBootSectorBuff
   973                              <1> 	;mov	ecx, 1
   974 0000739E B101                <1> 	mov	cl, 1
   975 000073A0 E8B0A90000          <1> 	call	disk_read
   976 000073A5 7218                <1> 	jc	short loc_validate_hd_fs_partition_retn
   977                              <1> 	; EDI will not be changed
   978 000073A7 89DE                <1> 	mov	esi, ebx
   979                              <1> use_hdfs_RDT_sector_params:
   980 000073A9 8B461C              <1> 	mov	eax, [esi+FS_RDT_VolumeSerialNo]
   981 000073AC 894728              <1> 	mov	[edi+LD_FS_VolumeSerial], eax
   982 000073AF 57                  <1> 	push	edi
   983                              <1> 	;mov	ecx, 16
   984 000073B0 B110                <1> 	mov	cl, 16
   985 000073B2 83C640              <1> 	add	esi, FS_RDT_VolumeName
   986 000073B5 83C72C              <1> 	add	edi, LD_FS_VolumeName
   987 000073B8 F3A5                <1> 	rep	movsd ; 64 bytes
   988 000073BA 5E                  <1> 	pop	esi
   989                              <1> 		; Volume Name Reset
   990 000073BB C6467E06            <1>         mov     byte [esi+LD_FS_MediaChanged], 6
   991                              <1> 	;
   992                              <1>         ;mov	cl, [Last_DOS_DiskNo] 
   993                              <1> 	;add	cl, 'A'
   994                              <1> 	;mov	[esi+LD_FS_Name], cl
   995                              <1> 
   996                              <1> loc_validate_hd_fs_partition_retn:
   997 000073BF C3                  <1> 	retn
   998                              <1> 
   999                              <1> load_masterboot:
  1000                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  1001                              <1> 	; 14/07/2020 (Reset function has been removed)
  1002                              <1> 	;
  1003                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1004                              <1> 	; 2005 - 2011
  1005                              <1> 	; input -> DL = drive number
  1006                              <1> ;	mov	ah, 0Dh ; Alternate disk reset
  1007                              <1> ;	call	int13h
  1008                              <1> ;	jnc	short pass_reset_error
  1009                              <1> ;harddisk_error:
  1010                              <1> ;  	retn
  1011                              <1> ;pass_reset_error:
  1012 000073C0 BB[4A7A0100]        <1> 	mov	ebx, MasterBootBuff
  1013                              <1> 	;mov	ax, 0201h
  1014                              <1> 	;mov	cx, 1
  1015                              <1> 	; 25/07/2022
  1016                              <1> 	;xor	ecx, ecx
  1017                              <1> 	;inc	cl
  1018 000073C5 B101                <1> 	mov	cl, 1
  1019                              <1> 	; ecx = 1
  1020 000073C7 89C8                <1> 	mov	eax, ecx ; ch = cylinder = 0
  1021 000073C9 B402                <1> 	mov	ah, 2  ; chs read
  1022                              <1> 	; eax = 0201h
  1023 000073CB 30F6                <1> 	xor	dh, dh ; head = 0
  1024 000073CD E8A5DBFFFF          <1> 	call	int13h
  1025 000073D2 720C                <1> 	jc	short harddisk_error
  1026                              <1> 	;
  1027 000073D4 66813D[487C0100]55- <1> 	cmp	word [MBIDCode], 0AA55h
  1027 000073DC AA                  <1>
  1028 000073DD 7401                <1> 	je	short load_masterboot_ok
  1029 000073DF F9                  <1> 	stc
  1030                              <1> harddisk_error:
  1031                              <1> load_masterboot_ok:
  1032 000073E0 C3                  <1> 	retn
  1033                              <1> 
  1034                              <1> get_free_FAT_sectors:
  1035                              <1> 	; 29/08/2023
  1036                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  1037                              <1> 	; 21/12/2017
  1038                              <1> 	; 29/02/2016
  1039                              <1> 	; 13/02/2016
  1040                              <1> 	; 04/02/2016
  1041                              <1> 	; 07/01/2016 (TRDOS 386 = TRDOS v2.0)
  1042                              <1> 	; 11/07/2010
  1043                              <1> 	; 21/06/2009
  1044                              <1> 	; INPUT: ESI = Logical DOS Drive Description Table address
  1045                              <1> 	; OUTPUT: STC => Error
  1046                              <1>         ;	cf = 0 and EAX = Free FAT sectors
  1047                              <1> 	; Also, related parameters and FAT buffer will be reset and updated
  1048                              <1> 
  1049 000073E1 31C0                <1> 	xor	eax, eax
  1050                              <1> 	;mov	[esi+LD_FreeSectors], eax ; Reset
  1051                              <1> 	
  1052 000073E3 807E0302            <1>         cmp     byte [esi+LD_FATType], 2
  1053 000073E7 7653                <1> 	jna	short loc_gfc_get_fat_free_clusters
  1054                              <1> 
  1055                              <1> 	; 29/02/2016
  1056 000073E9 48                  <1> 	dec	eax ; 0FFFFFFFFh
  1057 000073EA 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count (reset)
  1058 000073ED 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First Free Cluster (reset)
  1059 000073F0 40                  <1> 	inc	eax ; 0
  1060                              <1> 	;
  1061 000073F1 668B4636            <1> 	mov	ax, [esi+LD_BPB+BPB_FSInfo]
  1062 000073F5 03466C              <1> 	add	eax, [esi+LD_StartSector]
  1063                              <1> 
  1064 000073F8 BB[5A7D0100]        <1> 	mov	ebx, DOSBootSectorBuff
  1065                              <1> 	;mov	ecx, 1
  1066                              <1> 	; 25/07/2022
  1067 000073FD 31C9                <1> 	xor	ecx, ecx
  1068 000073FF FEC1                <1> 	inc	cl
  1069                              <1> 	; ecx = 1
  1070 00007401 E84FA90000          <1>  	call	disk_read
  1071 00007406 7301                <1> 	jnc	short loc_gfc_check_fsinfo_signs
  1072                              <1> retn_gfc_get_fsinfo_sec:
  1073 00007408 C3                  <1> 	retn
  1074                              <1> 
  1075                              <1> loc_gfc_check_fsinfo_signs:
  1076 00007409 BB[5A7D0100]        <1> 	mov 	ebx, DOSBootSectorBuff ; 13/02/2016
  1077 0000740E 813B52526141        <1>         cmp     dword [ebx], 41615252h
  1078 00007414 7524                <1> 	jne	short retn_gfc_get_fsinfo_stc
  1079                              <1> 	;add	ebx, 484
  1080                              <1> 	;cmp	dword [ebx], 61417272h
  1081 00007416 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
  1081 0000741F 61                  <1>
  1082 00007420 7518                <1> 	jne	short retn_gfc_get_fsinfo_stc
  1083                              <1> 	;add	ebx, 4
  1084                              <1> 	;mov	eax, [ebx]
  1085 00007422 8B83E8010000        <1> 	mov	eax, [ebx+488]
  1086                              <1> 	; 29/02/2016
  1087 00007428 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count
  1088 0000742B 8B93EC010000        <1> 	mov	edx, [ebx+492] 
  1089                              <1> 	; 29/08/2023 (BugFix)
  1090 00007431 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx ; First Free Cluster
  1091                              <1> 	; 21/12/2017
  1092 00007434 89C3                <1> 	mov	ebx, eax ; (initial value = 0FFFFFFFFh)
  1093 00007436 43                  <1> 	inc	ebx ; 0FFFFFFFFh -> 0  
  1094 00007437 7513                <1> 	jnz	short short retn_from_get_free_fat32_clusters
  1095 00007439 C3                  <1> 	retn
  1096                              <1> 
  1097                              <1> retn_gfc_get_fsinfo_stc:
  1098 0000743A F9                  <1> 	stc
  1099 0000743B C3                  <1> 	retn
  1100                              <1> 
  1101                              <1> loc_gfc_get_fat_free_clusters:
  1102                              <1> 	;mov	eax, 2
  1103 0000743C B002                <1> 	mov	al, 2
  1104                              <1> 	;mov	[FAT_CurrentCluster], eax
  1105                              <1> loc_gfc_loop_get_next_cluster:
  1106 0000743E E8744D0000          <1> 	call	get_next_cluster
  1107 00007443 730E                <1> 	jnc	short loc_gfc_free_fat_clusters_cont
  1108 00007445 21C0                <1> 	and	eax, eax
  1109 00007447 7411                <1> 	jz	short loc_gfc_pass_inc_free_cluster_count
  1110                              <1>  
  1111                              <1> retn_from_get_free_fat_clusters:
  1112 00007449 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors] ; Free clusters !
  1113                              <1> retn_from_get_free_fat32_clusters:
  1114 0000744C 0FB65E13            <1>         movzx	ebx, byte [esi+LD_BPB+BPB_SecPerClust]
  1115 00007450 F7E3                <1>       	mul	ebx
  1116                              <1> 	;mov	[esi+LD_FreeSectors], eax ; Free sectors
  1117                              <1> retn_get_free_sectors_calc:
  1118 00007452 C3                  <1> 	retn
  1119                              <1> 
  1120                              <1> loc_gfc_free_fat_clusters_cont:
  1121 00007453 09C0                <1> 	or	eax, eax
  1122 00007455 7503                <1> 	jnz	short loc_gfc_pass_inc_free_cluster_count
  1123 00007457 FF4674              <1> 	inc	dword [esi+LD_FreeSectors] ; Free clusters !
  1124                              <1>    
  1125                              <1> loc_gfc_pass_inc_free_cluster_count:
  1126                              <1> 	;mov	eax, [FAT_CurrentCluster]
  1127 0000745A 89C8                <1> 	mov	eax, ecx ; [FAT_CurrentCluster]
  1128 0000745C 3B4678              <1> 	cmp	eax, [esi+LD_Clusters]
  1129 0000745F 77E8                <1> 	ja	short retn_from_get_free_fat_clusters
  1130 00007461 40                  <1> 	inc	eax
  1131                              <1> 	;mov	[FAT_CurrentCluster], eax
  1132 00007462 EBDA                <1> 	jmp	short loc_gfc_loop_get_next_cluster
  1133                              <1> 
  1134                              <1> floppy_drv_init:
  1135                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  1136                              <1> 	; 09/12/2017
  1137                              <1> 	; 06/07/2016
  1138                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1139                              <1> 	; 24/07/2011
  1140                              <1> 	; 04/07/2009
  1141                              <1> 	; INPUT ->
  1142                              <1> 	;	DL = Drive number (0,1)
  1143                              <1> 	; OUTPUT ->
  1144                              <1> 	;	BL = drive name
  1145                              <1> 	;	BH = drive number
  1146                              <1> 	;	ESI = Logical DOS drv description table
  1147                              <1> 	;	EAX = Volume serial number
  1148                              <1>  
  1149 00007464 BE[2C650000]        <1> 	mov	esi, fd0_type ; 10/01/2016
  1150 00007469 BF00010900          <1> 	mov	edi, Logical_DOSDisks
  1151 0000746E 08D2                <1> 	or	dl, dl
  1152 00007470 7407                <1> 	jz	short loc_drv_init_fd0_fd1
  1153 00007472 81C700010000        <1> 	add	edi, 100h
  1154 00007478 46                  <1> 	inc	esi ; fd1_type ; 10/01/2016
  1155                              <1> loc_drv_init_fd0_fd1:
  1156 00007479 C6477E00            <1> 	mov	byte [edi+LD_MediaChanged], 0
  1157 0000747D 803E01              <1> 	cmp	byte [esi], 1 ; type (>0 if it is existing) 
  1158                              <1> 		; 4 = 1.44 MB, 80 track, 3 1/2"
  1159 00007480 7221                <1> 	jb	short read_fd_boot_sector_retn
  1160 00007482 885702              <1> 	mov	[edi+LD_PhyDrvNo], dl
  1161                              <1> read_fd_boot_sector:
  1162 00007485 30F6                <1> 	xor	dh, dh
  1163 00007487 B904000000          <1> 	mov	ecx, 4 ; Retry Count
  1164                              <1> read_fd_boot_sector_again:
  1165 0000748C 51                  <1> 	push 	ecx
  1166                              <1> 	;mov	cx, 1
  1167 0000748D B101                <1> 	mov	cl, 1
  1168 0000748F 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
  1169 00007493 BB[5A7D0100]        <1> 	mov	ebx, DOSBootSectorBuff
  1170 00007498 E8DADAFFFF          <1> 	call	int13h
  1171 0000749D 59                  <1> 	pop	ecx
  1172 0000749E 7304                <1> 	jnc	short use_fd_boot_sector_params
  1173 000074A0 E2EA                <1> 	loop	read_fd_boot_sector_again
  1174                              <1> 
  1175                              <1> read_fd_boot_sector_stc_retn:
  1176 000074A2 F9                  <1> 	stc
  1177                              <1> read_fd_boot_sector_retn:
  1178 000074A3 C3                  <1> 	retn
  1179                              <1> 
  1180                              <1> use_fd_boot_sector_params:
  1181                              <1> 	;mov	esi, DOSBootSectorBuff
  1182 000074A4 89DE                <1> 	mov	esi, ebx
  1183 000074A6 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
  1184 000074AF 75F1                <1> 	jne	short read_fd_boot_sector_stc_retn
  1185 000074B1 66817E035346        <1>         cmp     word [esi+bs_FS_Identifier], 'SF'
  1186                              <1> 	;jne	use_fd_fatfs_boot_sector_params
  1187                              <1> 	; 25/07/2022
  1188 000074B7 7405                <1> 	je	short use_fdfs_boot_sector_params
  1189 000074B9 E9A1000000          <1> 	jmp	use_fd_fatfs_boot_sector_params	
  1190                              <1> use_fdfs_boot_sector_params:
  1191 000074BE 8A462D              <1> 	mov	al, [esi+bs_FS_LBA_Ready]
  1192 000074C1 884705              <1> 	mov	[edi+LD_FS_LBAYes], al
  1193                              <1> 	;
  1194                              <1> 	; 03/01/2010 CHS -> DOS FAT/BPB compatibility fix
  1195 000074C4 8A4608              <1> 	mov	al, [esi+bs_FS_MediaAttrib]
  1196 000074C7 884706              <1> 	mov	[edi+LD_FS_MediaAttrib], al
  1197                              <1> 	;
  1198 000074CA 8A460A              <1>         mov	al, [esi+bs_FS_VersionMaj]
  1199 000074CD 884707              <1> 	mov	byte [edi+LD_FS_VersionMajor], al
  1200 000074D0 668B4606            <1> 	mov	ax, [esi+bs_FS_BytesPerSec]
  1201 000074D4 66894711            <1> 	mov	[edi+LD_FS_BytesPerSec], ax
  1202 000074D8 8A462E              <1> 	mov	al, [esi+bs_FS_SecPerTrack]
  1203 000074DB 28E4                <1> 	sub	ah, ah ; 09/12/2017
  1204 000074DD 6689471E            <1> 	mov	[edi+LD_FS_SecPerTrack], ax
  1205 000074E1 8A462F              <1> 	mov	al, [esi+bs_FS_Heads]
  1206 000074E4 66894720            <1> 	mov	[edi+LD_FS_NumHeads], ax
  1207                              <1> 	;
  1208 000074E8 8B4628              <1> 	mov	eax, [esi+bs_FS_UnDelDirD]
  1209 000074EB 894722              <1> 	mov	[edi+LD_FS_UnDelDirD], eax
  1210 000074EE 8B4618              <1> 	mov	eax, [esi+bs_FS_MATLocation]
  1211 000074F1 89470C              <1> 	mov	[edi+LD_FS_MATLocation], eax
  1212 000074F4 8B461C              <1> 	mov	eax, [esi+bs_FS_RootDirD]
  1213 000074F7 894708              <1> 	mov	[edi+LD_FS_RootDirD], eax
  1214 000074FA 8B460C              <1> 	mov	eax, [esi+bs_FS_BeginSector]
  1215 000074FD 89476C              <1> 	mov	[edi+LD_FS_BeginSector], eax
  1216 00007500 8B4610              <1> 	mov	eax, [esi+bs_FS_VolumeSize]
  1217 00007503 894770              <1> 	mov	[edi+LD_FS_VolumeSize], eax
  1218                              <1> 	;		
  1219 00007506 89FE                <1> 	mov	esi, edi
  1220 00007508 8B460C              <1>  	mov	eax, [esi+LD_FS_MATLocation]
  1221                              <1> 	;add	eax, [edi+LD_FS_BeginSector]
  1222                              <1> read_fd_MAT_sector_again:
  1223                              <1> 	;mov	ebx, DOSBootSectorBuff
  1224                              <1> 	;mov	ecx, 1
  1225 0000750B B101                <1> 	mov	cl, 1
  1226 0000750D E849A80000          <1> 	call	chs_read
  1227 00007512 89DE                <1> 	mov	esi, ebx
  1228                              <1> 	;jnc	short use_fdfs_mat_sector_params
  1229                              <1> 	;jmp	short read_fd_boot_sector_retn
  1230                              <1> 	;retn
  1231                              <1> 	; 25/07/2022
  1232 00007514 7248                <1> 	jc	short read_fd_RDT_sector_retn
  1233                              <1> use_fdfs_mat_sector_params:
  1234 00007516 8B460C              <1> 	mov	eax, [esi+FS_MAT_DATLocation]
  1235 00007519 894714              <1> 	mov	[edi+LD_FS_DATLocation], eax
  1236 0000751C 8B4610              <1> 	mov	eax, [esi+FS_MAT_DATScount]
  1237 0000751F 894718              <1> 	mov	[edi+LD_FS_DATSectors], eax
  1238 00007522 8B4714              <1> 	mov	eax, [edi+FS_MAT_FreeSectors]
  1239 00007525 894774              <1> 	mov	[edi+LD_FS_FreeSectors], eax
  1240 00007528 8B4618              <1> 	mov	eax, [esi+FS_MAT_FirstFreeSector]
  1241 0000752B 894778              <1> 	mov	[edi+LD_FS_FirstFreeSector], eax
  1242                              <1> 	;
  1243 0000752E 89FE                <1> 	mov	esi, edi
  1244 00007530 8B4608              <1>  	mov	eax, [esi+LD_FS_RootDirD]
  1245                              <1> read_fd_RDT_sector_again:
  1246                              <1> 	;mov	ebx, DOSBootSectorBuff
  1247                              <1> 	;mov	cx, 1
  1248 00007533 B101                <1> 	mov	cl, 1
  1249 00007535 E821A80000          <1> 	call	chs_read
  1250 0000753A 89DE                <1> 	mov	esi, ebx
  1251 0000753C 7220                <1> 	jc	short read_fd_RDT_sector_retn
  1252                              <1> use_fdfs_RDT_sector_params:
  1253 0000753E 8B461C              <1> 	mov	eax, [esi+FS_RDT_VolumeSerialNo]
  1254 00007541 894728              <1> 	mov	[edi+LD_FS_VolumeSerial], eax
  1255 00007544 57                  <1> 	push	edi
  1256                              <1> 	;mov	ecx, 16
  1257 00007545 B110                <1> 	mov	cl, 16	
  1258 00007547 83C640              <1> 	add	esi, FS_RDT_VolumeName
  1259 0000754A 83C72C              <1> 	add	edi, LD_FS_VolumeName
  1260 0000754D F3A5                <1> 	rep	movsd ; 64 bytes
  1261 0000754F 5E                  <1> 	pop	esi
  1262 00007550 C6460300            <1> 	mov	byte [esi+LD_FATType], 0
  1263 00007554 C64604A1            <1> 	mov	byte [esi+LD_FSType], 0A1h  
  1264 00007558 E9A2000000          <1>         jmp     loc_cont_use_fd_boot_sector_params
  1265                              <1> 
  1266                              <1> read_fd_RDT_sector_stc_retn:
  1267 0000755D F9                  <1> 	stc
  1268                              <1> read_fd_RDT_sector_retn:
  1269 0000755E C3                  <1> 	retn
  1270                              <1> 
  1271                              <1> use_fd_fatfs_boot_sector_params:
  1272 0000755F 807E2629            <1> 	cmp	byte [esi+BS_BootSig], 29h
  1273 00007563 75F8                <1> 	jne	short read_fd_RDT_sector_stc_retn
  1274 00007565 807E15F0            <1> 	cmp	byte [esi+BPB_Media], 0F0h
  1275 00007569 72F3                <1> 	jb	short read_fd_RDT_sector_retn
  1276 0000756B 57                  <1> 	push	edi
  1277 0000756C 83C706              <1> 	add	edi, LD_BPB
  1278                              <1> 	;mov	ecx, 16
  1279 0000756F B110                <1> 	mov	cl, 16
  1280 00007571 F3A5                <1> 	rep	movsd ; 64 bytes 
  1281 00007573 5E                  <1> 	pop	esi
  1282 00007574 31C0                <1> 	xor	eax, eax
  1283 00007576 89466C              <1> 	mov	[esi+LD_StartSector], eax ; 0
  1284 00007579 668B461C            <1> 	mov	ax, [esi+LD_BPB+BPB_FATSz16]
  1285 0000757D 8A4E16              <1> 	mov	cl, [esi+LD_BPB+BPB_NumFATs] 
  1286 00007580 F7E1                <1>   	mul	ecx
  1287                              <1> 	; edx = 0 !
  1288 00007582 668B5614            <1> 	mov	dx, [esi+LD_BPB+BPB_RsvdSecCnt]
  1289 00007586 66895660            <1> 	mov	[esi+LD_FATBegin], dx
  1290                              <1> 	; 25/07/2022
  1291 0000758A 01D0                <1> 	add	eax, edx
  1292                              <1> 	;add	ax, dx
  1293 0000758C 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
  1294 0000758F 894668              <1> 	mov	[esi+LD_DATABegin], eax 
  1295 00007592 668B5617            <1> 	mov	dx, [esi+LD_BPB+BPB_RootEntCnt]
  1296                              <1> 	;;shl	edx, 5 ; * 32 (Size of a directory entry)
  1297                              <1> 	;shl	dx, 5
  1298                              <1> 	;;add	edx, 511
  1299                              <1> 	;add	dx, 511
  1300                              <1> 	;;shr	edx, 9 ; edx = ((edx*32)+511) / 512
  1301                              <1> 	;shr	dx, 9
  1302 00007596 6683C20F            <1> 	add	dx, 15 ; 06/07/2016 (+(512/32)-1)
  1303                              <1> 	;shr	dx, 4 ; / 16 (==16 entries per sector)
  1304                              <1> 	; 25/07/2022
  1305 0000759A C1EA04              <1> 	shr	edx, 4
  1306 0000759D 015668              <1> 	add 	[esi+LD_DATABegin], edx ; + rd sectors
  1307                              <1> 	;movzx	eax, word [esi+LD_BPB+BPB_TotalSec16]
  1308 000075A0 668B4619            <1> 	mov	ax, [esi+LD_BPB+BPB_TotalSec16]
  1309 000075A4 894670              <1> 	mov	[esi+LD_TotalSectors], eax
  1310 000075A7 2B4668              <1> 	sub	eax, [esi+LD_DATABegin]
  1311                              <1>   	;movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust]
  1312 000075AA 8A4E13              <1> 	mov	cl, [esi+LD_BPB+BPB_SecPerClust]  
  1313 000075AD 80F901              <1> 	cmp	cl, 1
  1314 000075B0 7604                <1> 	jna	short save_fd_fatfs_cluster_count
  1315                              <1> 	; 25/07/2022
  1316 000075B2 29D2                <1> 	sub	edx, edx
  1317                              <1> 	;sub	dx, dx ; 0
  1318                              <1> 	;sub	dl, dl ; 06/07/2016
  1319 000075B4 F7F1                <1> 	div	ecx
  1320                              <1> save_fd_fatfs_cluster_count:
  1321 000075B6 894678              <1> 	mov	[esi+LD_Clusters], eax
  1322                              <1> 
  1323                              <1>       ; Maximum Valid Cluster Number = EAX +1
  1324                              <1>       ; with 2 reserved clusters= EAX +2
  1325                              <1>  
  1326                              <1> reset_FAT_buffer_decriptors:
  1327 000075B9 29C0                <1> 	sub	eax, eax ; 0  
  1328 000075BB A2[5E7F0100]        <1> 	mov	[FAT_BuffValidData], al ; 0
  1329 000075C0 A2[5F7F0100]        <1> 	mov	[FAT_BuffDrvName], al ; 0
  1330 000075C5 A3[627F0100]        <1> 	mov	[FAT_BuffSector], eax ; 0
  1331                              <1> 
  1332                              <1> read_fd_FAT_sectors:
  1333 000075CA BB001C0900          <1>   	mov	ebx, FAT_Buffer
  1334 000075CF 668B4614            <1> 	mov	ax, [esi+LD_BPB+BPB_RsvdSecCnt]
  1335                              <1> 	;mov	ecx, 3
  1336 000075D3 B103                <1> 	mov	cl, 3 ; 3 sectors
  1337 000075D5 E881A70000          <1> 	call	chs_read
  1338 000075DA 7240                <1> 	jc	short read_fd_FAT_sectors_retn
  1339                              <1> use_fd_FAT_sectors:
  1340 000075DC 8A4602              <1> 	mov	al, [esi+LD_PhyDrvNo]
  1341 000075DF 0441                <1> 	add	al, 'A' 
  1342 000075E1 A2[5F7F0100]        <1> 	mov	[FAT_BuffDrvName], al 
  1343 000075E6 C605[5E7F0100]01    <1>  	mov	byte [FAT_BuffValidData], 1
  1344 000075ED E82B000000          <1> 	call	fd_init_calculate_free_clusters
  1345 000075F2 7228                <1> 	jc	short read_fd_FAT_sectors_retn
  1346                              <1>   
  1347                              <1> loc_use_fd_boot_sector_params_FAT:
  1348 000075F4 C6460301            <1> 	mov	byte [esi+LD_FATType], 1 ; FAT 12
  1349 000075F8 C6460401            <1> 	mov	byte [esi+LD_FSType], 1
  1350 000075FC 8B462D              <1>         mov     eax, [esi+LD_BPB+VolumeID]
  1351                              <1> loc_cont_use_fd_boot_sector_params:
  1352 000075FF 8A7E02              <1> 	mov	bh, [esi+LD_PhyDrvNo]
  1353 00007602 887E7D              <1> 	mov	[esi+LD_DParamEntry], bh
  1354 00007605 88FB                <1> 	mov	bl, bh
  1355 00007607 80C341              <1> 	add	bl, 'A'
  1356 0000760A 881E                <1> 	mov	byte [esi+LD_Name], bl
  1357 0000760C C6460101            <1> 	mov	byte [esi+LD_DiskType], 1
  1358 00007610 C6460500            <1> 	mov	byte [esi+LD_LBAYes], 0
  1359 00007614 C6467C00            <1> 	mov	byte [esi+LD_PartitionEntry], 0
  1360 00007618 C6467E06            <1> 	mov	byte [esi+LD_MediaChanged], 6 ; Volume Name Reset
  1361                              <1> 
  1362                              <1> read_fd_FAT_sectors_retn:
  1363 0000761C C3                  <1> 	retn   
  1364                              <1> 
  1365                              <1> fd_init_calculate_free_clusters:
  1366                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  1367                              <1> 	; 09/12/2017
  1368                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1369                              <1> 	; 04/07/2009
  1370                              <1> 	; INPUT ->
  1371                              <1> 	;     ESI = Logical DOS drive description table address
  1372                              <1> 	; OUTPUT ->
  1373                              <1> 	;    [ESI+LD_FreeSectors] will be set
  1374                              <1> 	
  1375 0000761D 29C0                <1> 	sub	eax, eax
  1376 0000761F 894674              <1> 	mov	[esi+LD_FreeSectors], eax ; 0
  1377 00007622 B002                <1> 	mov	al, 2 ; eax = 2
  1378                              <1> 
  1379                              <1> fd_init_loop_get_next_cluster:
  1380 00007624 E828000000          <1> 	call	fd_init_get_next_cluster
  1381 00007629 7225                <1> 	jc	short fd_init_calculate_free_clusters_retn
  1382                              <1> 
  1383                              <1> fd_init_free_fat_clusters:
  1384                              <1> 	;cmp 	eax, 0
  1385                              <1> 	;ja	short fd_init_pass_inc_free_cluster_count
  1386                              <1> 	;and	eax, eax
  1387                              <1> 	;jnz	short fd_init_pass_inc_free_cluster_count
  1388                              <1> 	;and	ax, ax
  1389 0000762B 21C0                <1> 	and	eax, eax ; 25/07/2022
  1390 0000762D 7503                <1> 	jnz	short fd_init_pass_inc_free_cluster_count
  1391                              <1> 	; 25/07/2022
  1392 0000762F FF4674              <1> 	inc	dword [esi+LD_FreeSectors]
  1393                              <1>         ;inc	word [esi+LD_FreeSectors]
  1394                              <1>     
  1395                              <1> fd_init_pass_inc_free_cluster_count:
  1396                              <1>   	; 25/07/2022
  1397 00007632 A1[5A7F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
  1398                              <1> 	;mov	ax, [FAT_CurrentCluster]
  1399 00007637 3B4678              <1> 	cmp	eax, [esi+LD_Clusters]
  1400                              <1> 	;cmp	ax, [esi+LD_Clusters]
  1401 0000763A 7703                <1> 	ja	short short retn_from_fd_init_calculate_free_clusters
  1402 0000763C 40                  <1> 	inc	eax
  1403                              <1> 	;inc	ax
  1404 0000763D EBE5                <1> 	jmp	short fd_init_loop_get_next_cluster
  1405                              <1> 
  1406                              <1> retn_from_fd_init_calculate_free_clusters:
  1407                              <1> 	; 25/07/2022
  1408                              <1> 	;xor	eax, eax
  1409 0000763F 30E4                <1> 	xor	ah, ah
  1410 00007641 8A4613              <1>   	mov	al, [esi+LD_BPB+BPB_SecPerClust]
  1411 00007644 3C01                <1>   	cmp	al, 1
  1412 00007646 7608                <1> 	jna	short fd_init_calculate_free_clusters_retn
  1413                              <1> 	;;movzx	eax, al
  1414                              <1> 	;xor	ah, ah ; 09/12/2017
  1415                              <1> 	; 25/07/2022
  1416 00007648 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  1417                              <1> 	;mov	cx, [esi+LD_FreeSectors] ; Count of free clusters
  1418 0000764B F7E1                <1>   	mul	ecx
  1419                              <1> 	;mul	cx
  1420 0000764D 894674              <1> 	mov	[esi+LD_FreeSectors], eax
  1421                              <1> 	;mov	[esi+LD_FreeSectors], ax
  1422                              <1> fd_init_calculate_free_clusters_retn:
  1423 00007650 C3                  <1> 	retn
  1424                              <1> 
  1425                              <1> fd_init_get_next_cluster:
  1426                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  1427                              <1> 	; 04/02/2016
  1428                              <1> 	; 02/02/2016
  1429                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1430                              <1> 	; 04/07/2009
  1431                              <1> 	; INPUT ->
  1432                              <1> 	;    EAX = Current cluster
  1433                              <1> 	;    ESI = Logical DOS drive description table address
  1434                              <1> 	;    EDX = 0
  1435                              <1> 	; OUTPUT ->
  1436                              <1> 	;    EAX = Next cluster
  1437                              <1> 
  1438 00007651 A3[5A7F0100]        <1> 	mov	[FAT_CurrentCluster], eax
  1439                              <1> fd_init_get_next_cluster_readnext:
  1440 00007656 29D2                <1> 	sub	edx, edx ; 0
  1441 00007658 BB00040000          <1>   	mov	ebx, 1024 ; 400h
  1442 0000765D F7F3                <1>   	div	ebx
  1443                              <1>   	; EAX = Count of 3 FAT sectors
  1444                              <1>   	; EDX = Buffer entry index
  1445 0000765F 89C1                <1> 	mov	ecx, eax
  1446                              <1> 	;mov	eax, 3
  1447 00007661 B003                <1> 	mov	al, 3
  1448 00007663 F7E2                <1> 	mul	edx ; Multiply by 3
  1449                              <1> 	;shr	ax, 1 ; Divide by 2
  1450                              <1> 	; 25/07/2022
  1451 00007665 D1E8                <1> 	shr	eax, 1
  1452 00007667 89C3                <1> 	mov	ebx, eax ; Buffer byte offset
  1453 00007669 81C3001C0900        <1> 	add	ebx, FAT_Buffer
  1454 0000766F 89C8                <1> 	mov	eax, ecx
  1455                              <1> 	;mov	edx, 3
  1456 00007671 66BA0300            <1> 	mov	dx, 3
  1457 00007675 F7E2                <1> 	mul	edx 
  1458                              <1>   	; EAX = FAT Beginning Sector
  1459                              <1> 	; EDX = 0
  1460 00007677 8A0E                <1> 	mov	cl, [esi+LD_Name]
  1461                              <1> 	;cmp	byte [FAT_BuffValidData], 0
  1462                              <1> 	;jna	short fd_init_load_FAT_sectors0
  1463 00007679 3A0D[5F7F0100]      <1> 	cmp	cl, [FAT_BuffDrvName]
  1464 0000767F 751D                <1> 	jne	short fd_init_load_FAT_sectors0
  1465 00007681 3B05[627F0100]      <1> 	cmp	eax, [FAT_BuffSector]
  1466 00007687 751B                <1> 	jne	short fd_init_load_FAT_sectors1
  1467                              <1> 	; 25/07/2022
  1468 00007689 A1[5A7F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
  1469                              <1> 	;mov	al, [FAT_CurrentCluster]
  1470 0000768E D1E8                <1> 	shr	eax, 1
  1471                              <1> 	;shr	al, 1
  1472 00007690 668B03              <1> 	mov	ax, [ebx]
  1473 00007693 7305                <1>   	jnc	short fd_init_gnc_even
  1474                              <1> 	;shr	ax, 4
  1475                              <1> 	; 25/04/2022
  1476 00007695 C1E804              <1> 	shr	eax, 4
  1477                              <1> fd_init_gnc_clc_retn:
  1478 00007698 F8                  <1> 	clc
  1479 00007699 C3                  <1> 	retn
  1480                              <1> 
  1481                              <1> fd_init_gnc_even:
  1482 0000769A 80E40F              <1> 	and	ah, 0Fh
  1483 0000769D C3                  <1> 	retn
  1484                              <1> 
  1485                              <1> fd_init_load_FAT_sectors0:
  1486 0000769E 880D[5F7F0100]      <1> 	mov 	[FAT_BuffDrvName], cl
  1487                              <1> fd_init_load_FAT_sectors1:
  1488 000076A4 C605[5E7F0100]00    <1> 	mov	byte [FAT_BuffValidData], 0
  1489 000076AB A3[627F0100]        <1> 	mov	[FAT_BuffSector], eax
  1490 000076B0 034660              <1> 	add	eax, [esi+LD_FATBegin]
  1491 000076B3 BB001C0900          <1>  	mov	ebx, FAT_Buffer
  1492                              <1> 	;movzx	ecx, word [esi+LD_BPB+BPB_FATSz16]
  1493 000076B8 668B4E1C            <1> 	mov	cx, [esi+LD_BPB+BPB_FATSz16]
  1494                              <1> 	;sub	cx, [FAT_BuffSector]
  1495                              <1>         ; 25/07/2022
  1496 000076BC 2B0D[627F0100]      <1> 	sub	ecx, [FAT_BuffSector] 
  1497                              <1> 	;sub	edx, edx
  1498 000076C2 B203                <1> 	mov	dl, 3
  1499                              <1> 	; edx = 3 
  1500                              <1> 	;;cmp	ecx, 3
  1501                              <1> 	;cmp	cx, 3
  1502 000076C4 39D1                <1> 	cmp	ecx, edx ; 3
  1503 000076C6 7602                <1> 	jna	short fdinit_pass_fix_sector_count_3
  1504                              <1> 	;;mov	ecx, 3
  1505                              <1> 	;mov	ecx, 3
  1506 000076C8 89D1                <1> 	mov	ecx, edx ; 3
  1507                              <1> fdinit_pass_fix_sector_count_3:  
  1508 000076CA E88CA60000          <1> 	call	chs_read
  1509 000076CF 730D                <1> 	jnc	short fd_init_FAT_sectors_no_load_error
  1510 000076D1 C605[5E7F0100]00    <1> 	mov	byte [FAT_BuffValidData], 0
  1511                              <1> 		; Drv not ready or read Error !
  1512 000076D8 B80F000000          <1> 	mov	eax, ERR_DRV_NOT_RDY ; 15
  1513                              <1> 	;xor	edx, edx
  1514 000076DD C3                  <1> 	retn
  1515                              <1> 
  1516                              <1> fd_init_FAT_sectors_no_load_error:
  1517 000076DE C605[5E7F0100]01    <1> 	mov	byte [FAT_BuffValidData], 1
  1518 000076E5 A1[5A7F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
  1519 000076EA E967FFFFFF          <1>         jmp     fd_init_get_next_cluster_readnext
  1520                              <1> 
  1521                              <1> get_FAT_volume_name:
  1522                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  1523                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1524                              <1> 	; 12/09/2009
  1525                              <1> 	; INPUT ->
  1526                              <1> 	;	BH = Logical DOS drive number (0,1,2,3,4 ...)
  1527                              <1> 	;       BL = 0
  1528                              <1> 	; OUTPUT ->
  1529                              <1> 	;	CF = 0 -> ESI = Volume name address
  1530                              <1> 	; 	CF = 1 -> Root volume name not found
  1531                              <1> 
  1532                              <1> 	;mov 	ah, 0FFh
  1533                              <1> 	;mov 	al, [Last_Dos_DiskNo]
  1534                              <1> 	;cmp 	al, bh
  1535                              <1> 	;jb     short loc_gfvn_dir_load_err
  1536                              <1> 
  1537 000076EF 89DE                <1> 	mov	esi, ebx
  1538 000076F1 81E600FF0000        <1> 	and	esi, 0FF00h ; esi = bh
  1539 000076F7 81C600010900        <1> 	add	esi, Logical_DOSDisks
  1540 000076FD 8A06                <1> 	mov     al, [esi+LD_Name]
  1541 000076FF 8A6603              <1> 	mov     ah, [esi+LD_FATType]
  1542 00007702 80FC01              <1> 	cmp     ah, 1
  1543 00007705 7210                <1> 	jb    	short loc_gfvn_dir_load_err
  1544 00007707 3C41                <1> 	cmp 	al, 'A'
  1545 00007709 720C                <1> 	jb      short loc_gfvn_dir_load_err
  1546 0000770B 80FC02              <1> 	cmp 	ah, 2 
  1547 0000770E 7708                <1> 	ja      short get_FAT32_root_cluster
  1548                              <1> 	
  1549 00007710 E8E04B0000          <1> 	call    load_FAT_root_directory
  1550 00007715 730B                <1> 	jnc     short loc_get_volume_name
  1551                              <1> 
  1552                              <1> loc_gfvn_dir_load_err:
  1553                              <1> loc_get_volume_name_retn: ; 29/08/2023
  1554 00007717 C3                  <1> 	retn
  1555                              <1> 
  1556                              <1> get_FAT32_root_cluster:
  1557 00007718 8B4632              <1> 	mov	eax, [esi+LD_BPB+BPB_RootClus]
  1558 0000771B E8534C0000          <1> 	call    load_FAT_sub_directory
  1559 00007720 72F5                <1> 	jc	short loc_get_volume_name_retn
  1560                              <1> 
  1561                              <1> loc_get_volume_name:
  1562 00007722 BE00000800          <1>         mov     esi, Directory_Buffer
  1563                              <1> 	;xor	cx, cx ; 0
  1564                              <1> 	; 25/07/2022
  1565 00007727 31C9                <1> 	xor	ecx, ecx ; 0
  1566                              <1> check_root_volume_name:
  1567 00007729 8A06                <1> 	mov	al, [esi]
  1568 0000772B 08C0                <1> 	or      al, al
  1569 0000772D 74E8                <1> 	jz      short loc_get_volume_name_retn
  1570 0000772F 807E0B08            <1> 	cmp     byte [esi+0Bh], 08h
  1571 00007733 74E2                <1> 	je      short loc_get_volume_name_retn
  1572 00007735 663B0D[747F0100]    <1> 	cmp     cx, [DirBuff_LastEntry]
  1573 0000773C 7306                <1> 	jnb     short pass_check_root_volume_name
  1574                              <1> 	;inc	cx
  1575                              <1> 	; 25/07/2022
  1576 0000773E 41                  <1> 	inc	ecx
  1577 0000773F 83C620              <1> 	add     esi, 32
  1578 00007742 EBE5                <1> 	jmp     short check_root_volume_name
  1579                              <1> 
  1580                              <1> 	; 29/08/2023
  1581                              <1> ;loc_get_volume_name_retn:
  1582                              <1> 	;retn
  1583                              <1>     
  1584                              <1> pass_check_root_volume_name:
  1585 00007744 803D[707F0100]03    <1> 	cmp	byte [DirBuff_FATType], 3
  1586 0000774B 7230                <1> 	jb	short loc_get_volume_name_retn_xor
  1587                              <1> 
  1588 0000774D BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1589 00007752 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1590 00007757 31C0                <1> 	xor	eax, eax
  1591 00007759 8A25[6F7F0100]      <1> 	mov	ah, [DirBuff_DRV]
  1592 0000775F 80EC41              <1> 	sub	ah, 'A' 
  1593 00007762 01C6                <1> 	add	esi, eax
  1594 00007764 A1[767F0100]        <1> 	mov	eax, [DirBuff_Cluster]
  1595 00007769 E8494A0000          <1> 	call	get_next_cluster
  1596 0000776E 7305                <1> 	jnc 	short loc_gfvn_load_FAT32_dir_cluster
  1597                              <1>   	
  1598 00007770 83F801              <1> 	cmp     eax, 1
  1599 00007773 F5                  <1> 	cmc
  1600 00007774 C3                  <1> 	retn
  1601                              <1>   
  1602                              <1> loc_gfvn_load_FAT32_dir_cluster:
  1603 00007775 E8F94B0000          <1> 	call	load_FAT_sub_directory
  1604 0000777A 73A6                <1> 	jnc	short loc_get_volume_name
  1605 0000777C C3                  <1> 	retn
  1606                              <1> 
  1607                              <1> loc_get_volume_name_retn_xor:
  1608 0000777D 31C0                <1> 	xor 	eax, eax
  1609 0000777F C3                  <1> 	retn
  1610                              <1> 
  1611                              <1> get_media_change_status:
  1612                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1613                              <1> 	; 09/09/2009
  1614                              <1> 	; INPUT:
  1615                              <1> 	;     DL = Drive number (physical)
  1616                              <1> 	; OUTPUT: clc & AH = 6 media changed
  1617                              <1> 	;     clc & AH = 0 media not changed         
  1618                              <1> 	;     stc -> Drive not ready or an error 
  1619                              <1>   
  1620 00007780 B416                <1> 	mov	ah, 16h
  1621 00007782 E8F0D7FFFF          <1>   	call	int13h
  1622 00007787 80FC06              <1> 	cmp	ah, 06h
  1623 0000778A 7405                <1> 	je	short loc_gmc_status_retn
  1624 0000778C 08E4                <1> 	or	ah, ah
  1625 0000778E 7401                <1> 	jz	short loc_gmc_status_retn
  1626                              <1> loc_gmc_status_stc_retn:    
  1627 00007790 F9                  <1> 	stc
  1628                              <1> loc_gmc_status_retn:
  1629 00007791 C3                  <1> 	retn
  3239                                  %include 'trdosk3.s' ; 06/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.6) - MAIN PROGRAM : trdosk3.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 30/08/2023  (Previous: 07/08/2022)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 06/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; MAINPROG.ASM (09/11/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; MAINPROG.ASM [ TRDOS KERNEL - COMMAND EXECUTER SECTION - MAIN PROGRAM ]
    14                              <1> ; (c) 2004-2011  Erdogan TAN  [ 17/01/2004 ]  Last Update: 09/11/2011
    15                              <1> ; CMD_INTR.ASM [ TRDOS Command Interpreter Procedure ] Last Update: 09/11/2011
    16                              <1> ; DIR.ASM [ DIRECTORY FUNCTIONS ] Last Update: 09/10/2011
    17                              <1> ; FILE.ASM [ FILE FUNCTIONS ] Last Update: 09/10/2011
    18                              <1> 
    19                              <1> change_current_drive:
    20                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
    21                              <1> 	; 16/10/2016
    22                              <1> 	; 02/02/2016
    23                              <1> 	; 15/01/2016 (TRDOS 386 = TRDOS v2.0)
    24                              <1> 	; 18/08/2011
    25                              <1> 	; 09/09/2009
    26                              <1> 	; INPUT:
    27                              <1> 	;   DL = Logical DOS Drive Number
    28                              <1> 	; OUTPUT:
    29                              <1> 	;  cf=1 -> Not successful
    30                              <1> 	;   EAX = Error code
    31                              <1> 	;  cf=0 ->
    32                              <1> 	;   EAX = 0 (successful)
    33                              <1> 
    34 00007792 31DB                <1> 	xor	ebx, ebx
    35 00007794 88D7                <1> 	mov	bh, dl
    36                              <1> 
    37                              <1> 	;cmp	dl, 1
    38                              <1> 	;jna	short loc_ccdrv_initial_media_change_check
    39                              <1> 	;cmp	bh, [Last_Dos_DiskNo]
    40                              <1> 	;ja	short loc_ccdrv_drive_not_ready_err
    41                              <1> 
    42                              <1> loc_ccdrv_initial_media_change_check:
    43 00007796 BE00010900          <1> 	mov	esi, Logical_DOSDisks
    44 0000779B 01DE                <1> 	add	esi, ebx
    45                              <1> loc_ccdrv_dos_drive_name_check:
    46 0000779D 80FA02              <1> 	cmp	dl, 2
    47 000077A0 720E                <1> 	jb	short loc_ccdrv_dos_drive_name_check_ok
    48                              <1> 
    49 000077A2 8A06                <1> 	mov	al, [esi+LD_Name]
    50 000077A4 2C41                <1> 	sub	al, 'A'
    51 000077A6 38D0                <1> 	cmp	al, dl
    52 000077A8 7406                <1> 	je	short loc_ccdrv_dos_drive_name_check_ok
    53                              <1> 
    54                              <1> loc_ccdrv_drive_not_ready_err:
    55                              <1> 	; 16/10/2016 (15h -> 15)
    56                              <1> 	;mov	eax, 15 ; Drive not ready
    57                              <1> 	; 26/07/2022
    58 000077AA 29C0                <1> 	sub	eax, eax
    59 000077AC B00F                <1> 	mov	al, 15
    60                              <1> loc_change_current_drive_stc_retn:
    61 000077AE F9                  <1> 	stc
    62 000077AF C3                  <1> 	retn  
    63                              <1> 
    64                              <1> loc_ccdrv_dos_drive_name_check_ok:
    65 000077B0 8A667E              <1> 	mov	ah, [esi+LD_MediaChanged]
    66 000077B3 80FC06              <1> 	cmp	ah, 6  ; VOLUME NAME CHECK/MOVE SIGN
    67 000077B6 7455                <1> 	je	short loc_ccdrv_get_FAT_volume_name_0
    68                              <1> 
    69 000077B8 80FA01              <1> 	cmp	dl, 1
    70 000077BB 777D                <1> 	ja	short loc_gmcs_init_drv_hd
    71                              <1> 
    72                              <1> loc_gmcs_init_drv_fd:
    73 000077BD 08E4                <1> 	or	ah, ah 
    74                              <1> 	; AH = 1 is initialization sign (invalid_fd_parameter)
    75 000077BF 7517                <1> 	jnz	short loc_ccdrv_call_fd_init
    76                              <1> 
    77 000077C1 E8BAFFFFFF          <1> 	call	get_media_change_status
    78 000077C6 72E2                <1> 	jc	short loc_ccdrv_drive_not_ready_err
    79                              <1> 
    80 000077C8 20E4                <1> 	and	ah, ah
    81 000077CA 7476                <1> 	jz	short loc_change_current_drv3
    82                              <1> 
    83 000077CC 80F406              <1> 	xor	ah, 6
    84 000077CF 75D9                <1> 	jnz	short loc_ccdrv_drive_not_ready_err
    85                              <1> 
    86                              <1> loc_ccdrv_call_fd_init_check_vol_id:
    87 000077D1 E86D090000          <1> 	call	get_volume_serial_number
    88 000077D6 730D                <1> 	jnc	short loc_ccdrv_check_vol_serial
    89                              <1> 
    90                              <1> loc_ccdrv_call_fd_init:
    91 000077D8 E887FCFFFF          <1> 	call	floppy_drv_init
    92 000077DD 731A                <1> 	jnc	short loc_reset_drv_fd_current_dir
    93                              <1> 
    94                              <1> loc_ccdrv_fdinit_fail_retn:
    95                              <1> 	; 16/10/2016
    96 000077DF B80F000000          <1> 	mov	eax, 15 ; Drive not ready
    97 000077E4 C3                  <1> 	retn
    98                              <1> 
    99                              <1> loc_ccdrv_check_vol_serial:
   100 000077E5 A3[40780100]        <1> 	mov	[Current_VolSerial], eax
   101                              <1> 	;mov	dl, bh
   102 000077EA E875FCFFFF          <1> 	call	floppy_drv_init
   103 000077EF 72EE                <1> 	jc	short loc_ccdrv_fdinit_fail_retn
   104                              <1> 
   105 000077F1 3B05[40780100]      <1> 	cmp	eax, [Current_VolSerial]
   106 000077F7 7445                <1> 	je	short loc_change_current_drv2
   107                              <1> 
   108                              <1> loc_reset_drv_fd_current_dir:
   109 000077F9 31C0                <1> 	xor	eax, eax              
   110 000077FB 88467F              <1>         mov	[esi+LD_CDirLevel], al
   111 000077FE 89F7                <1> 	mov	edi, esi
   112 00007800 81C780000000        <1> 	add	edi, LD_CurrentDirectory
   113 00007806 B920000000          <1> 	mov	ecx, 32
   114 0000780B F3AB                <1> 	rep	stosd   
   115                              <1>  
   116                              <1> loc_ccdrv_get_FAT_volume_name_0:
   117 0000780D 8A4603              <1> 	mov	al, [esi+LD_FATType]
   118 00007810 08C0                <1> 	or	al, al
   119 00007812 742A                <1> 	jz	short loc_change_current_drv2
   120                              <1> 
   121 00007814 56                  <1> 	push	esi 
   122 00007815 3C02                <1> 	cmp	al, 2
   123 00007817 7705                <1> 	ja	short loc_ccdrv_get_FAT32_vol_name
   124                              <1>              
   125                              <1> loc_ccdrv_get_FAT2_16_vol_name:
   126 00007819 83C631              <1> 	add	esi, LD_BPB + VolumeLabel
   127 0000781C EB03                <1> 	jmp	short loc_ccdrv_get_FAT_volume_name_1
   128                              <1> 
   129                              <1> loc_ccdrv_get_FAT32_vol_name:
   130 0000781E 83C64D              <1> 	add	esi, LD_BPB + FAT32_VolLab
   131                              <1> loc_ccdrv_get_FAT_volume_name_1:
   132 00007821 53                  <1> 	push	ebx
   133 00007822 56                  <1> 	push	esi
   134 00007823 E8C7FEFFFF          <1> 	call	get_FAT_volume_name
   135 00007828 5F                  <1> 	pop	edi
   136 00007829 5B                  <1> 	pop	ebx
   137                              <1> 	; BL = 0
   138 0000782A 720B                <1> 	jc	short loc_change_current_drv1
   139 0000782C 20C0                <1> 	and	al, al
   140 0000782E 7407                <1> 	jz	short loc_change_current_drv1
   141                              <1> 
   142                              <1> loc_ccdrv_move_FAT_volume_name:
   143 00007830 B90B000000          <1> 	mov	ecx, 11
   144 00007835 F3A4                <1> 	rep	movsb
   145                              <1> 
   146                              <1> loc_change_current_drv1:
   147 00007837 5E                  <1> 	pop	esi
   148 00007838 EB04                <1> 	jmp	short loc_change_current_drv2
   149                              <1> 
   150                              <1> loc_gmcs_init_drv_hd:
   151 0000783A 08E4                <1> 	or	ah, ah
   152 0000783C 7404                <1> 	jz	short loc_change_current_drv3
   153                              <1> 	; BL = 0, BH = Logical DOS drive number
   154                              <1> loc_change_current_drv2:
   155 0000783E C6467E00            <1> 	mov	byte [esi+LD_MediaChanged], 0
   156                              <1> loc_change_current_drv3:
   157 00007842 883D[4A780100]      <1> 	mov	[Current_Drv], bh
   158                              <1> 
   159                              <1> 	;call	restore_current_directory
   160                              <1> 	;retn
   161                              <1> 
   162                              <1> restore_current_directory:
   163                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
   164                              <1> 	; 11/02/2016
   165                              <1> 	; 15/01/2016 (TRDOS 386 = TRDOS v2.0)
   166                              <1> 	; 25/01/2010
   167                              <1> 	; 12/10/2009
   168                              <1> 	;
   169                              <1> 	; INPUT:
   170                              <1> 	;   ESI = Logical DOS Drive Description Table
   171                              <1> 	;
   172                              <1> 	; OUTPUT:
   173                              <1> 	;   ESI = Logical DOS Drive Description Table
   174                              <1> 	;   EDI = offset Current_Dir_Drv 
   175                              <1> 
   176 00007848 8A4603              <1> 	mov	al, [esi+LD_FATType]
   177 0000784B A2[49780100]        <1> 	mov	[Current_FATType], al
   178                              <1> 
   179 00007850 8A26                <1> 	mov	ah, [esi+LD_Name] 
   180 00007852 8825[4B780100]      <1> 	mov	[Current_Dir_Drv], ah
   181                              <1> 
   182 00007858 20C0                <1> 	and	al, al
   183 0000785A 741D                <1> 	jz	short loc_restore_FS_current_directory
   184                              <1> 
   185                              <1> loc_restore_FAT_current_directory:
   186 0000785C 8A667F              <1> 	mov	ah, [esi+LD_CDirLevel]
   187 0000785F 8825[48780100]      <1> 	mov	[Current_Dir_Level], ah
   188 00007865 08E4                <1> 	or	ah, ah
   189 00007867 7415                <1>         jz	short loc_ccdrv_reset_cdir_FAT_12_16_32_fcluster
   190                              <1> 
   191 00007869 0FB6D4              <1> 	movzx	edx, ah
   192 0000786C C0E204              <1> 	shl	dl, 4 ; * 16
   193 0000786F 01F2                <1>         add	edx, esi
   194 00007871 8B828C000000        <1> 	mov	eax, [edx+LD_CurrentDirectory+12]
   195 00007877 EB29                <1> 	jmp	short loc_ccdrv_reset_cdir_FAT_fcluster
   196                              <1> 
   197                              <1> loc_restore_FS_current_directory:
   198                              <1> 	;call	load_current_FS_directory
   199                              <1> 	;retn
   200                              <1> 	; 26/07/2022
   201 00007879 E92F4B0000          <1> 	jmp	load_current_FS_directory
   202                              <1> 
   203                              <1> loc_ccdrv_reset_cdir_FAT_12_16_32_fcluster:
   204 0000787E 3C03                <1> 	cmp	al, 3
   205 00007880 7205                <1> 	jb	short loc_ccdrv_reset_cdir_FAT_12_16_fcluster
   206                              <1> loc_ccdrv_reset_cdir_FAT32_fcluster:
   207 00007882 8B4632              <1> 	mov	eax, [esi+LD_BPB+FAT32_RootFClust]
   208 00007885 EB02                <1> 	jmp	short loc_ccdrv_check_rootdir_sign
   209                              <1> loc_ccdrv_reset_cdir_FAT_12_16_fcluster:   
   210                              <1> 	;xor	al, al  ; xor eax, eax
   211                              <1> 	; 26/07/2022
   212 00007887 31C0                <1> 	xor	eax, eax
   213                              <1> 	;xor	edx, edx
   214                              <1> loc_ccdrv_check_rootdir_sign:
   215 00007889 80BE8000000000      <1> 	cmp	byte [esi+LD_CurrentDirectory], 0
   216 00007890 7510                <1> 	jne	short loc_ccdrv_reset_cdir_FAT_fcluster
   217                              <1> loc_ccdrv_set_rootdir_FAT_fcluster:
   218 00007892 89868C000000        <1>         mov     [esi+LD_CurrentDirectory+12], eax
   219 00007898 C78680000000524F4F- <1> 	mov	dword [esi+LD_CurrentDirectory], 'ROOT'
   219 000078A1 54                  <1>
   220                              <1> 
   221                              <1> loc_ccdrv_reset_cdir_FAT_fcluster:
   222 000078A2 A3[44780100]        <1> 	mov	[Current_Dir_FCluster], eax
   223                              <1> 
   224 000078A7 BF[A87F0100]        <1> 	mov	edi, PATH_Array
   225 000078AC 89F2                <1> 	mov	edx, esi
   226 000078AE 81C680000000        <1> 	add	esi, LD_CurrentDirectory
   227 000078B4 B920000000          <1> 	mov	ecx, 32
   228 000078B9 F3A5                <1> 	rep	movsd
   229                              <1> 
   230 000078BB E8812B0000          <1> 	call	change_prompt_dir_string
   231                              <1> 	
   232 000078C0 89D6                <1> 	mov	esi, edx
   233                              <1> 	
   234 000078C2 29C0                <1>         sub	eax, eax
   235                              <1>        ;sub	edx, edx
   236 000078C4 BF[4B780100]        <1> 	mov	edi, Current_Dir_Drv
   237                              <1> 
   238 000078C9 A2[92300100]        <1> 	mov	[Restore_CDIR], al ; 0
   239 000078CE C3                  <1> 	retn
   240                              <1> 
   241                              <1> dos_prompt:
   242                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
   243                              <1> 	; 06/05/2016
   244                              <1> 	; 30/01/2016
   245                              <1> 	; 29/01/2016
   246                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
   247                              <1> 	; 15/09/2011
   248                              <1> 	; 13/09/2009
   249                              <1> 	; 2004-2005
   250                              <1> 
   251                              <1> 	; 06/05/2016
   252 000078CF C705[04840100]-     <1> 	mov	dword [mainprog_return_addr], return_from_cmd_interpreter
   252 000078D5 [81790000]          <1>
   253                              <1> 
   254                              <1> loc_TRDOS_prompt:
   255 000078D9 BF[4A790100]        <1> 	mov	edi, TextBuffer
   256 000078DE C6075B              <1> 	mov	byte [edi], "["
   257 000078E1 47                  <1> 	inc	edi
   258 000078E2 BE[ED300100]        <1> 	mov	esi, TRDOSPromptLabel
   259                              <1> get_next_prompt_label_char:
   260 000078E7 803E20              <1> 	cmp	byte [esi], 20h
   261 000078EA 7203                <1> 	jb	short pass_prompt_label
   262 000078EC A4                  <1> 	movsb
   263 000078ED EBF8                <1> 	jmp	short get_next_prompt_label_char
   264                              <1> pass_prompt_label:
   265 000078EF C6075D              <1> 	mov	byte [edi], "]"
   266 000078F2 47                  <1> 	inc	edi
   267 000078F3 C60720              <1> 	mov	byte [edi], 20h
   268 000078F6 47                  <1> 	inc	edi
   269 000078F7 BE[4B780100]        <1> 	mov	esi, Current_Dir_Drv
   270 000078FC 66A5                <1> 	movsw
   271 000078FE A4                  <1> 	movsb 
   272                              <1> loc_prompt_current_directory:
   273 000078FF 803E20              <1> 	cmp	byte [esi], 20h
   274 00007902 7203                <1> 	jb	short pass_prompt_current_directory
   275 00007904 A4                  <1> 	movsb
   276 00007905 EBF8                <1> 	jmp	short loc_prompt_current_directory  
   277                              <1> pass_prompt_current_directory:
   278 00007907 C6073E              <1> 	mov	byte [edi], '>'
   279 0000790A 47                  <1> 	inc	edi
   280 0000790B C60700              <1> 	mov	byte [edi], 0  
   281 0000790E BE[4A790100]        <1> 	mov	esi, TextBuffer
   282 00007913 E842F3FFFF          <1> 	call	print_msg
   283                              <1>         
   284                              <1> 	;sub	bh, bh ; video page = 0
   285                              <1> 	;call	get_cpos ; get cursor position
   286 00007918 668B15[A6770100]    <1> 	mov	dx, [CURSOR_POSN] ; video page 0
   287 0000791F 8815[AA780100]      <1> 	mov	[CursorColumn], dl
   288                              <1> 
   289                              <1> 	; 30/01/2016 (to show cursor on the row, again)
   290                              <1> 	; (Initial color attributes of video page 0 is 0)
   291                              <1> 	; (see: 'StartPMP' in trdos386.s)
   292                              <1> 	; 
   293                              <1> 	;mov	edi, 0B8000h ; start of video page 0
   294                              <1> 	;movzx	ecx, dl ; column	 
   295                              <1> 	;mov	al, 80
   296                              <1> 	;mul	dh
   297                              <1> 	;add	ax, cx
   298                              <1> 	;shl	ax, 1 ; character + attribute
   299                              <1> 	;add	di, ax ; (2*80*row) + (2*column)
   300                              <1> 	;neg	cl
   301                              <1> 	;add	cl, 80
   302                              <1> 	;mov	ax, 700h ;  ah = 7 (color attribute)
   303                              <1> 	;rep	stosw	
   304                              <1> 
   305                              <1> loc_rw_char:
   306 00007925 E8AB000000          <1> 	call	rw_char
   307                              <1> loc_move_command:
   308 0000792A BE[FA780100]        <1> 	mov	esi, CommandBuffer
   309 0000792F 89F7                <1> 	mov	edi, esi
   310 00007931 31C9                <1> 	xor	ecx, ecx
   311                              <1> first_command_char:
   312 00007933 AC                  <1> 	lodsb
   313 00007934 3C20                <1> 	cmp	al, 20h
   314 00007936 770C                <1> 	ja	short pass_space_control
   315 00007938 723F                <1> 	jb	short loc_move_cmd_arguments_ok
   316 0000793A 81FE[49790100]      <1> 	cmp	esi, CommandBuffer + 79
   317 00007940 72F1                <1> 	jb	short first_command_char
   318 00007942 EB35                <1> 	jmp	short loc_move_cmd_arguments_ok
   319                              <1> 
   320                              <1> 	; 26/07/2022
   321                              <1> pass_space_control:
   322 00007944 3C61                <1> 	cmp	al, 61h
   323 00007946 7206                <1> 	jb	short pass_capitalize
   324 00007948 3C7A                <1> 	cmp	al, 7Ah
   325 0000794A 7702                <1> 	ja	short pass_capitalize
   326 0000794C 24DF                <1> 	and	al, 0DFh
   327                              <1> pass_capitalize:
   328 0000794E AA                  <1> 	stosb   
   329 0000794F FEC1                <1> 	inc     cl
   330 00007951 81FE[49790100]      <1> 	cmp     esi, CommandBuffer + 79
   331                              <1> 	;jb	short next_command_char
   332                              <1> 	; 26/07/2022
   333 00007957 7320                <1> 	jnb	short loc_move_cmd_arguments_ok
   334                              <1> 
   335                              <1> next_command_char:
   336 00007959 AC                  <1> 	lodsb
   337 0000795A 3C20                <1> 	cmp	al, 20h
   338 0000795C 77E6                <1> 	ja	short pass_space_control
   339 0000795E 7219                <1> 	jb	short loc_move_cmd_arguments_ok
   340                              <1> 
   341                              <1> loc_1st_cmd_arg: ; 30/01/2016
   342 00007960 AC                  <1> 	lodsb
   343 00007961 3C20                <1> 	cmp	al, 20h
   344 00007963 74FB                <1> 	je	short loc_1st_cmd_arg
   345 00007965 7212                <1> 	jb	short loc_move_cmd_arguments_ok
   346                              <1> 	
   347 00007967 C60700              <1>         mov     byte [edi], 0
   348 0000796A 47                  <1> 	inc	edi
   349                              <1> 
   350                              <1> loc_move_cmd_arguments:
   351 0000796B AA                  <1> 	stosb
   352 0000796C 81FE[49790100]      <1> 	cmp	esi, CommandBuffer + 79
   353 00007972 7305                <1> 	jnb	short loc_move_cmd_arguments_ok
   354 00007974 AC                  <1>         lodsb
   355 00007975 3C20                <1> 	cmp	al, 20h
   356 00007977 73F2                <1> 	jnb	short loc_move_cmd_arguments
   357                              <1> 	; 26/07/2022
   358                              <1> 	;jmp	short loc_move_cmd_arguments_ok
   359                              <1> 
   360                              <1> ; 26/07/2022
   361                              <1> ;pass_space_control:
   362                              <1> ;	cmp	al, 61h
   363                              <1> ;	jb	short pass_capitalize
   364                              <1> ;	cmp	al, 7Ah
   365                              <1> ;	ja	short pass_capitalize
   366                              <1> ;	and	al, 0DFh
   367                              <1> ;pass_capitalize:
   368                              <1> ;	stosb   
   369                              <1> ;	inc     cl
   370                              <1> ;	cmp     esi, CommandBuffer + 79
   371                              <1> ;	jb      short next_command_char 
   372                              <1> 
   373                              <1> loc_move_cmd_arguments_ok:
   374 00007979 C60700              <1>         mov     byte [edi], 0
   375                              <1> 
   376                              <1> call_command_interpreter:
   377 0000797C E8FD070000          <1> 	call    command_interpreter
   378                              <1> 
   379                              <1> return_from_cmd_interpreter:
   380 00007981 B950000000          <1>         mov	ecx, 80
   381                              <1> 	;mov	cx, 80
   382 00007986 BF[FA780100]        <1> 	mov	edi, CommandBuffer
   383 0000798B 30C0                <1> 	xor	al, al
   384 0000798D F3AA                <1> 	rep	stosb
   385                              <1> 	;cmp	byte [Program_Exit], 0
   386                              <1> 	;ja	short loc_terminate_trdos
   387                              <1>         
   388                              <1> 	; 16/01/2016
   389 0000798F 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 3 ; 80*25 color
   390 00007996 7419                <1> 	je	short pass_set_txt_mode
   391                              <1> 
   392 00007998 E867A1FFFF          <1> 	call	set_txt_mode ; set vide mode to 03h
   393                              <1> 	; 07/01/2017
   394 0000799D 30C0                <1> 	xor	al, al
   395                              <1> 
   396                              <1> loc_check_active_page:
   397                              <1> 	;xor	al, al
   398 0000799F 3805[B6770100]      <1> 	cmp	[ACTIVE_PAGE], al ; 0
   399                              <1>         ;je	loc_TRDOS_prompt
   400                              <1> 	; 26/07/2022
   401 000079A5 7405                <1> 	je	short loc_prompt_again
   402                              <1> 
   403                              <1> 	; AL = 0 = video page 0
   404 000079A7 E880A5FFFF          <1> 	call	set_active_page
   405                              <1> loc_prompt_again: ; 26/07/2022		
   406 000079AC E928FFFFFF          <1>         jmp     loc_TRDOS_prompt ; infinitive loop
   407                              <1> 
   408                              <1> pass_set_txt_mode: 
   409 000079B1 BE[1B3B0100]        <1> 	mov	esi, nextline
   410 000079B6 E89FF2FFFF          <1> 	call	print_msg
   411 000079BB EBE2                <1> 	jmp     short loc_check_active_page
   412                              <1> 
   413                              <1> ;rw_char:
   414                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
   415                              <1> loc_arrow:    
   416 000079BD 80FC4B              <1> 	cmp	ah, 4Bh
   417 000079C0 7426                <1> 	je	short loc_back
   418 000079C2 80FC53              <1> 	cmp	ah, 53h
   419 000079C5 7421                <1> 	je      short loc_back
   420 000079C7 80FC4D              <1> 	cmp	ah, 4Dh
   421 000079CA 7509                <1> 	jne	short readnextchar
   422 000079CC 80FA4F              <1> 	cmp	dl, 79
   423 000079CF 7304                <1> 	jnb	short readnextchar
   424 000079D1 FEC2                <1> 	inc	dl
   425 000079D3 EB1D                <1> 	jmp	short set_cursor_pos
   426                              <1> 
   427                              <1> rw_char: 
   428                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
   429                              <1> 	; 13/05/2016
   430                              <1> 	; 30/01/2016
   431                              <1> 	; 29/01/2016
   432                              <1> 	; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   433                              <1> 	; 2004-2005
   434                              <1> 	
   435                              <1> 	; DH = cursor row, DL = cursor column
   436                              <1> 	; BH = 0 = video page number (active page)
   437                              <1> 
   438                              <1> 	;xor	bh, bh ; 0 = video page 0
   439                              <1> 
   440                              <1> readnextchar:
   441 000079D5 30E4                <1> 	xor     ah, ah
   442 000079D7 E82C95FFFF          <1> 	call	int16h
   443 000079DC 20C0                <1> 	and	al, al
   444 000079DE 74DD                <1> 	jz	short loc_arrow    
   445 000079E0 3CE0                <1> 	cmp	al, 0E0h          
   446 000079E2 74D9                <1> 	je	short loc_arrow
   447 000079E4 3C08                <1> 	cmp	al, 08h             
   448 000079E6 752A                <1> 	jne	short char_return
   449                              <1> loc_back:
   450 000079E8 3A15[AA780100]      <1> 	cmp	dl, [CursorColumn]
   451 000079EE 76E5                <1> 	jna     short readnextchar
   452                              <1> prev_column:
   453 000079F0 FECA                <1> 	dec	dl
   454                              <1> set_cursor_pos:
   455                              <1> 	;push	dx
   456 000079F2 52                  <1> 	push	edx ; 29/12/2017
   457                              <1> 	;xor	bh, bh ; 0 = video page 0
   458                              <1> 	; DH = Row, DL = Column
   459 000079F3 E8F8A8FFFF          <1> 	call	_set_cpos ; 17/01/2016
   460 000079F8 5A                  <1>         pop	edx ; 29/12/2017
   461                              <1> 	;pop	dx
   462                              <1> 	;movzx	ebx, dl
   463 000079F9 88D3                <1> 	mov	bl, dl
   464 000079FB 2A1D[AA780100]      <1> 	sub	bl, [CursorColumn] 
   465 00007A01 B020                <1> 	mov	al, 20h
   466 00007A03 8883[FA780100]      <1> 	mov	[CommandBuffer+ebx], al
   467                              <1> 	;sub	bh, bh ; video page 0
   468                              <1> 	;mov	cx, 1
   469 00007A09 B307                <1> 	mov	bl, 7 ; color attribute
   470                              <1> 	; bh = 0 ; 26/07/2022
   471 00007A0B E8C7A7FFFF          <1> 	call	_write_c_current ; 17/01/2016
   472                              <1> 	;mov	dx, [CURSOR_POSN]
   473 00007A10 EBC3                <1> 	jmp	short readnextchar
   474                              <1> 
   475                              <1> 	; 26/07/2022
   476                              <1> ;loc_arrow:    
   477                              <1> ;	cmp	ah, 4Bh
   478                              <1> ;	je	short loc_back
   479                              <1> ;	cmp	ah, 53h
   480                              <1> ;	je      short loc_back
   481                              <1> ;	cmp	ah, 4Dh
   482                              <1> ;	jne	short readnextchar
   483                              <1> ;	cmp	dl, 79
   484                              <1> ;	jnb	short readnextchar
   485                              <1> ;	inc	dl
   486                              <1> ;	jmp	short set_cursor_pos
   487                              <1> 
   488                              <1> char_return:
   489 00007A12 0FB6DA              <1> 	movzx	ebx, dl
   490 00007A15 2A1D[AA780100]      <1> 	sub	bl, [CursorColumn] 
   491 00007A1B 3C20                <1> 	cmp	al, 20h
   492 00007A1D 721D                <1> 	jb	short loc_escape
   493 00007A1F 8883[FA780100]      <1> 	mov	[CommandBuffer+ebx], al
   494 00007A25 80FA4F              <1> 	cmp	dl, 79
   495 00007A28 73AB                <1> 	jnb	short readnextchar
   496 00007A2A 66BB0700            <1> 	mov	bx, 7 ; color attribute
   497 00007A2E E825A8FFFF          <1> 	call	_write_tty
   498 00007A33 668B15[A6770100]    <1> 	mov	dx, [CURSOR_POSN] ; video page 0
   499 00007A3A EB99                <1>         jmp	short readnextchar ; 26/07/2022
   500                              <1> 
   501                              <1> loc_escape:
   502 00007A3C 3C1B                <1> 	cmp	al, 1Bh
   503 00007A3E 7414                <1> 	je	short rw_char_retn
   504                              <1> 	;
   505 00007A40 3C0D                <1> 	cmp	al, 0Dh ; CR
   506 00007A42 7591                <1>         jne	short readnextchar ; 26/07/2022
   507                              <1> 
   508                              <1> 	; 13/05/2016
   509 00007A44 66BB0700            <1> 	mov	bx, 7 ; attribute/color (bl)
   510                              <1> 		      ; video page 0 (bh=0)	
   511 00007A48 E80BA8FFFF          <1> 	call	_write_tty
   512                              <1> 	;mov	bx, 7  ; attribute/color
   513                              <1> 		      ; video page 0 (bh=0)
   514 00007A4D B00A                <1> 	mov	al, 0Ah ; LF
   515 00007A4F E804A8FFFF          <1> 	call	_write_tty
   516                              <1> rw_char_retn:
   517 00007A54 C3                  <1> 	retn
   518                              <1> 
   519                              <1> show_date:
   520                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
   521                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   522                              <1>         ; 2004-2005
   523                              <1> 
   524                              <1> 	;mov	ah, 04h
   525                              <1> 	;call	int1Ah
   526 00007A55 E811E8FFFF          <1> 	call	RTC_40	; GET RTC DATE
   527                              <1> 
   528 00007A5A 88D0                <1> 	mov	al, dl
   529 00007A5C E89A94FFFF          <1>   	call	bcd_to_ascii
   530 00007A61 66A3[D9310100]      <1> 	mov	[Day], ax
   531                              <1> 
   532 00007A67 88F0                <1> 	mov	al, dh
   533 00007A69 E88D94FFFF          <1>   	call	bcd_to_ascii
   534 00007A6E 66A3[DC310100]      <1> 	mov	[Month], ax
   535                              <1> 
   536 00007A74 88E8                <1> 	mov	al, ch
   537 00007A76 E88094FFFF          <1>   	call	bcd_to_ascii
   538 00007A7B 66A3[DF310100]      <1> 	mov	[Century], ax
   539                              <1> 
   540 00007A81 88C8                <1> 	mov	al, cl
   541 00007A83 E87394FFFF          <1>   	call	bcd_to_ascii
   542 00007A88 66A3[E1310100]      <1> 	mov	[Year], ax
   543                              <1> 
   544 00007A8E BE[C9310100]        <1> 	mov	esi, Msg_Show_Date
   545                              <1> 	;call	print_msg
   546                              <1> 	;retn
   547                              <1> 	; 26/07/2022
   548 00007A93 E9C2F1FFFF          <1> 	jmp	print_msg
   549                              <1> 
   550                              <1> set_date:
   551                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
   552                              <1> 	; 13/05/2016
   553                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   554                              <1>         ; 2004-2005
   555                              <1> 
   556 00007A98 BE[AD310100]        <1> 	mov	esi, Msg_Enter_Date
   557 00007A9D E8B8F1FFFF          <1> 	call	print_msg
   558                              <1> 
   559                              <1> loc_enter_day_1:
   560 00007AA2 30E4                <1> 	xor     ah, ah
   561 00007AA4 E85F94FFFF          <1> 	call	int16h
   562                              <1> 	; AL = ASCII Code of the Character
   563 00007AA9 3C0D                <1> 	cmp	al, 13
   564                              <1> 	;je	loc_set_date_retn
   565                              <1> 	; 26/07/2022
   566 00007AAB 7404                <1> 	je	short set_date_0
   567 00007AAD 3C1B                <1> 	cmp	al, 27
   568                              <1> 	;je	loc_set_date_retn
   569                              <1> 	; 26/07/2022
   570 00007AAF 7511                <1> 	jne	short set_date_1
   571                              <1> 
   572                              <1> set_date_0:
   573                              <1> ;loc_set_date_retn:
   574 00007AB1 BE[1B3B0100]        <1> 	mov	esi, nextline
   575                              <1> 	;call	print_msg
   576                              <1> 	;retn
   577                              <1> 	; 26/07/2022
   578 00007AB6 E99FF1FFFF          <1> 	jmp	print_msg
   579                              <1> 
   580                              <1> 	; 26/07/2022
   581                              <1> loc_set_date_stc_0:
   582                              <1> 	;xor	bh, bh ; video page 0
   583 00007ABB E882A8FFFF          <1> 	call	beeper ; BEEP !
   584 00007AC0 EBE0                <1> 	jmp	short loc_enter_day_1
   585                              <1> 
   586                              <1> 	; 26/07/2022
   587                              <1> set_date_1:
   588 00007AC2 A2[D9310100]        <1> 	mov	[Day], al
   589 00007AC7 3C30                <1> 	cmp	al, '0'
   590 00007AC9 72F0                <1> 	jb	short loc_set_date_stc_0
   591 00007ACB 3C33                <1> 	cmp	al, '3'
   592 00007ACD 77EC                <1> 	ja	short loc_set_date_stc_0
   593                              <1> 	; 13/05/2016
   594                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   595                              <1> 		      ; video page 0 (bh)	
   596 00007ACF B307                <1> 	mov	bl, 7
   597 00007AD1 E882A7FFFF          <1> 	call	_write_tty
   598                              <1> loc_enter_day_2:
   599 00007AD6 30E4                <1> 	xor     ah, ah
   600 00007AD8 E82B94FFFF          <1> 	call	int16h
   601                              <1> 	; AL = ASCII Code of the Character
   602 00007ADD 3C1B                <1> 	cmp	al, 27
   603                              <1>         ;je	loc_set_date_retn
   604                              <1> 	; 26/07/2022
   605 00007ADF 74D0                <1> 	je	short set_date_0
   606 00007AE1 A2[DA310100]        <1> 	mov	[Day+1], al
   607 00007AE6 3C30                <1> 	cmp	al, '0'
   608 00007AE8 7211                <1>         jb      short loc_set_date_stc_1
   609 00007AEA 3C39                <1> 	cmp	al, '9'
   610 00007AEC 770D                <1>         ja      short loc_set_date_stc_1
   611 00007AEE 803D[D9310100]33    <1> 	cmp	byte [Day], '3'
   612 00007AF5 7219                <1> 	jb	short pass_set_day_31
   613 00007AF7 3C31                <1> 	cmp	al, '1'
   614                              <1>         ;ja	loc_set_date_stc_1
   615                              <1> 	; 26/07/2022
   616 00007AF9 7615                <1> 	jna	short pass_set_day_31
   617                              <1> 
   618                              <1> 	; 26/07/2022
   619                              <1> loc_set_date_stc_1:
   620 00007AFB E8E4010000          <1> 	call	check_for_backspace
   621 00007B00 7407                <1> 	je	short loc_set_date_bs_1
   622                              <1> 	;xor	bh, bh ; video page 0
   623 00007B02 E83BA8FFFF          <1> 	call	beeper ; BEEP !
   624 00007B07 EBCD                <1> 	jmp	short loc_enter_day_2
   625                              <1> loc_set_date_bs_1:
   626 00007B09 E8C4010000          <1> 	call	write_backspace
   627 00007B0E EB92                <1> 	jmp     short loc_enter_day_1
   628                              <1> 
   629                              <1> pass_set_day_31:
   630                              <1> 	; 13/05/2016
   631                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   632                              <1> 		      ; video page 0 (bh)	
   633 00007B10 B307                <1> 	mov	bl, 7
   634 00007B12 E841A7FFFF          <1> 	call	_write_tty
   635                              <1> loc_enter_separator_1:
   636 00007B17 28E4                <1> 	sub     ah, ah ; 0
   637 00007B19 E8EA93FFFF          <1> 	call	int16h
   638                              <1> 	; AL = ASCII Code of the Character
   639 00007B1E 3C1B                <1> 	cmp	al, 27
   640                              <1>         ;je	loc_set_date_retn
   641                              <1> 	; 26/07/2022
   642 00007B20 748F                <1> 	je	short set_date_0
   643 00007B22 3C2D                <1> 	cmp	al, '-'
   644 00007B24 7443                <1> 	je	short pass_set_date_separator_1
   645 00007B26 3C2F                <1> 	cmp	al, '/'
   646                              <1> 	;jne	loc_set_date_stc_2
   647                              <1> 	; 26/07/2022
   648 00007B28 743F                <1> 	je	short pass_set_date_separator_1
   649                              <1> 
   650                              <1> 	; 26/07/2022
   651                              <1> loc_set_date_stc_2:
   652 00007B2A E8B5010000          <1> 	call	check_for_backspace
   653 00007B2F 7407                <1> 	je	short loc_set_date_bs_2
   654                              <1> 	;xor	bh, bh ; video page 0
   655 00007B31 E80CA8FFFF          <1> 	call	beeper ; BEEP !
   656 00007B36 EBDF                <1> 	jmp	short loc_enter_separator_1
   657                              <1> loc_set_date_bs_2:
   658 00007B38 E895010000          <1> 	call	write_backspace
   659 00007B3D EB97                <1> 	jmp	short loc_enter_day_2
   660                              <1> 
   661                              <1> 	; 26/07/2022
   662                              <1> loc_set_date_stc_3:
   663 00007B3F E8A0010000          <1> 	call	check_for_backspace
   664 00007B44 7407                <1> 	je	short loc_set_date_bs_3
   665                              <1> 	;xor	bh, bh ; video page 0
   666 00007B46 E8F7A7FFFF          <1> 	call	beeper ; BEEP !
   667 00007B4B EB23                <1> 	jmp	short loc_enter_month_1
   668                              <1> loc_set_date_bs_3:
   669 00007B4D E880010000          <1> 	call	write_backspace
   670 00007B52 EBC3                <1> 	jmp	short loc_enter_separator_1
   671                              <1> 
   672                              <1> 	; 26/07/2022
   673                              <1> loc_set_date_stc_4:
   674 00007B54 E88B010000          <1> 	call	check_for_backspace
   675 00007B59 7407                <1> 	je	short loc_set_date_bs_4
   676                              <1> 	;xor	bh, bh ; video page 0
   677 00007B5B E8E2A7FFFF          <1> 	call	beeper ; BEEP !
   678 00007B60 EB2D                <1> 	jmp	short loc_enter_month_2
   679                              <1> loc_set_date_bs_4:
   680 00007B62 E86B010000          <1> 	call	write_backspace
   681 00007B67 EB07                <1> 	jmp	short loc_enter_month_1
   682                              <1> 	
   683                              <1> pass_set_date_separator_1:
   684                              <1> 	; 13/05/2016
   685                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   686                              <1> 		      ; video page 0 (bh)
   687 00007B69 B307                <1> 	mov	bl, 7	
   688 00007B6B E8E8A6FFFF          <1> 	call	_write_tty
   689                              <1> loc_enter_month_1:
   690 00007B70 30E4                <1> 	xor     ah, ah ; 0
   691 00007B72 E89193FFFF          <1> 	call	int16h
   692                              <1> 	; AL = ASCII Code of the Character
   693 00007B77 3C1B                <1> 	cmp	al, 27
   694                              <1>         ;je	loc_set_date_retn
   695                              <1> 	; 26/07/2022
   696                              <1> 	;je	short loc_set_date_ok
   697                              <1> 	; 07/08/2022
   698 00007B79 741F                <1> 	je	short jmp_loc_set_date_ok
   699 00007B7B A2[DC310100]        <1> 	mov	[Month], al
   700 00007B80 3C30                <1> 	cmp	al, '0'
   701 00007B82 72BB                <1>         jb      short loc_set_date_stc_3
   702 00007B84 3C31                <1> 	cmp	al, '1'
   703 00007B86 77B7                <1>         ja	short loc_set_date_stc_3
   704                              <1> 	; 13/05/2016
   705                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   706                              <1> 		      ; video page 0 (bh)	
   707 00007B88 B307                <1> 	mov	bl, 7
   708 00007B8A E8C9A6FFFF          <1> 	call	_write_tty
   709                              <1> loc_enter_month_2:
   710 00007B8F 30E4                <1> 	xor     ah, ah
   711 00007B91 E87293FFFF          <1> 	call	int16h
   712                              <1> 	; AL = ASCII Code of the Character
   713 00007B96 3C1B                <1> 	cmp	al, 27
   714                              <1>         ;;je	loc_set_date_retn
   715                              <1> 	; 26/07/2022
   716                              <1> 	;je	short loc_set_date_ok
   717                              <1> 	; 07/08/2022
   718 00007B98 7505                <1> 	jne	short loc_enter_month_3
   719                              <1> jmp_loc_set_date_ok:	
   720 00007B9A E996000000          <1> 	jmp	loc_set_date_ok 
   721                              <1> loc_enter_month_3:
   722 00007B9F A2[DD310100]        <1> 	mov	[Month+1], al
   723 00007BA4 3C30                <1> 	cmp	al, '0'
   724 00007BA6 72AC                <1>         jb	short loc_set_date_stc_4
   725 00007BA8 3C39                <1> 	cmp	al, '9'
   726 00007BAA 77A8                <1>         ja	short loc_set_date_stc_4
   727 00007BAC 803D[DC310100]31    <1> 	cmp	byte [Month], '1'
   728 00007BB3 7204                <1> 	jb	short pass_set_month_12
   729 00007BB5 3C32                <1> 	cmp	al, '2'
   730 00007BB7 779B                <1>         ja	short loc_set_date_stc_4
   731                              <1> pass_set_month_12:
   732                              <1> 	; 13/05/2016
   733                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   734                              <1> 		      ; video page 0 (bh)
   735 00007BB9 B307                <1> 	mov	bl, 7	
   736 00007BBB E898A6FFFF          <1> 	call	_write_tty
   737                              <1> loc_enter_separator_2:
   738 00007BC0 28E4                <1> 	sub     ah, ah
   739 00007BC2 E84193FFFF          <1> 	call	int16h
   740                              <1> 	; AL = ASCII Code of the Character
   741 00007BC7 3C1B                <1> 	cmp	al, 27
   742                              <1>         ;je	loc_set_date_retn
   743                              <1> 	; 26/07/2022
   744 00007BC9 746A                <1> 	je	short loc_set_date_ok
   745 00007BCB 3C2D                <1> 	cmp	al, '-'
   746 00007BCD 7404                <1> 	je	short pass_set_date_separator_2
   747 00007BCF 3C2F                <1> 	cmp	al, '/'
   748 00007BD1 756C                <1>         jne	short loc_set_date_stc_5
   749                              <1> pass_set_date_separator_2:
   750                              <1> 	; 13/05/2016
   751                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   752                              <1> 		      ; video page 0 (bh)	
   753 00007BD3 B307                <1> 	mov	bl, 7
   754 00007BD5 E87EA6FFFF          <1> 	call	_write_tty
   755                              <1> loc_enter_year_1:
   756 00007BDA 30E4                <1> 	xor    ah, ah
   757 00007BDC E82793FFFF          <1> 	call	int16h
   758                              <1> 	; AL = ASCII Code of the Character
   759 00007BE1 3C1B                <1> 	cmp	al, 27
   760                              <1>         ;je	loc_set_date_retn
   761                              <1> 	; 26/07/2022
   762 00007BE3 7450                <1> 	je	short loc_set_date_ok
   763 00007BE5 A2[E1310100]        <1> 	mov	[Year], al
   764 00007BEA 3C30                <1> 	cmp	al, '0'
   765 00007BEC 726C                <1>         jb	short loc_set_date_stc_6
   766 00007BEE 3C39                <1> 	cmp	al, '9'
   767 00007BF0 7768                <1>         ja	short loc_set_date_stc_6
   768                              <1> 	; 13/05/2016
   769                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   770                              <1> 		      ; video page 0 (bh)
   771 00007BF2 B307                <1> 	mov	bl, 7	
   772 00007BF4 E85FA6FFFF          <1> 	call	_write_tty
   773                              <1> loc_enter_year_2:
   774 00007BF9 30E4                <1> 	xor	ah, ah
   775 00007BFB E80893FFFF          <1> 	call	int16h
   776                              <1> 	; AL = ASCII Code of the Character
   777 00007C00 3C1B                <1> 	cmp	al, 27
   778                              <1> 	;je	short loc_set_date_retn
   779                              <1> 	; 26/07/2022
   780 00007C02 7431                <1> 	je	short loc_set_date_ok
   781 00007C04 A2[E2310100]        <1> 	mov	byte [Year+1], al
   782 00007C09 3C30                <1> 	cmp	al, '0'
   783 00007C0B 7268                <1>         jb 	short loc_set_date_stc_7
   784 00007C0D 3C39                <1> 	cmp	al, '9'
   785 00007C0F 7764                <1>         ja	short loc_set_date_stc_7
   786                              <1> 	; 13/05/2016
   787                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   788                              <1> 		      ; video page 0 (bh)
   789 00007C11 B307                <1> 	mov	bl, 7	
   790 00007C13 E840A6FFFF          <1> 	call	_write_tty
   791                              <1> loc_set_date_get_lchar_again:
   792 00007C18 28E4                <1> 	sub	ah, ah ; 0
   793 00007C1A E8E992FFFF          <1> 	call	int16h
   794                              <1> 	; AL = ASCII Code of the Character
   795 00007C1F 3C0D                <1> 	cmp	al, 13 ; ENTER key
   796 00007C21 746D                <1> 	je	short loc_set_date_progress
   797 00007C23 3C1B                <1> 	cmp	al, 27 ; ESC key
   798                              <1> 	;je	short loc_set_date_retn
   799                              <1> 	; 26/07/2022
   800 00007C25 740E                <1> 	je	short loc_set_date_ok
   801                              <1> 	;
   802 00007C27 E8B8000000          <1> 	call	check_for_backspace
   803 00007C2C 75EA                <1> 	jne	short loc_set_date_get_lchar_again
   804                              <1> 
   805                              <1> loc_set_date_bs_8:
   806 00007C2E E89F000000          <1> 	call	write_backspace
   807 00007C33 EBC4                <1> 	jmp	short loc_enter_year_2
   808                              <1> 
   809                              <1> loc_set_date_ok:
   810                              <1> ;loc_set_date_retn:
   811 00007C35 BE[1B3B0100]        <1> 	mov	esi, nextline
   812                              <1> 	;call	print_msg
   813                              <1> 	;retn
   814                              <1> 	; 26/07/2022
   815 00007C3A E91BF0FFFF          <1> 	jmp	print_msg
   816                              <1> 
   817                              <1> 	; 26/07/2022
   818                              <1> ;loc_set_date_stc_0:
   819                              <1> ;	;xor	bh, bh ; video page 0
   820                              <1> ;	call	beeper ; BEEP !
   821                              <1> ;	jmp	loc_enter_day_1
   822                              <1> ;loc_set_date_stc_1:
   823                              <1> ;	call	check_for_backspace
   824                              <1> ;	je	short loc_set_date_bs_1
   825                              <1> ;	;xor	bh, bh ; video page 0
   826                              <1> ;	call	beeper ; BEEP !
   827                              <1> ;	jmp	loc_enter_day_2
   828                              <1> ;loc_set_date_bs_1:
   829                              <1> ;	call	write_backspace
   830                              <1> ;	jmp     loc_enter_day_1
   831                              <1> ;loc_set_date_stc_2:
   832                              <1> ;	call	check_for_backspace
   833                              <1> ;	je	short loc_set_date_bs_2
   834                              <1> ;	;xor	bh, bh ; video page 0
   835                              <1> ;	call	beeper ; BEEP !
   836                              <1> ;	jmp	loc_enter_separator_1
   837                              <1> ;loc_set_date_bs_2:
   838                              <1> ;	call	write_backspace
   839                              <1> ;	jmp	loc_enter_day_2
   840                              <1> ;loc_set_date_stc_3:
   841                              <1> ;	call	check_for_backspace
   842                              <1> ;	je	short loc_set_date_bs_3
   843                              <1> ;	;xor	bh, bh ; video page 0
   844                              <1> ;	call	beeper ; BEEP !
   845                              <1> ;	jmp	loc_enter_month_1
   846                              <1> ;loc_set_date_bs_3:
   847                              <1> ;	call	write_backspace
   848                              <1> ;	jmp	loc_enter_separator_1
   849                              <1> ;loc_set_date_stc_4:
   850                              <1> ;	call	check_for_backspace
   851                              <1> ;	je	short loc_set_date_bs_4
   852                              <1> ;	;xor	bh, bh ; video page 0
   853                              <1> ;	call	beeper ; BEEP !
   854                              <1> ;	jmp	loc_enter_month_2
   855                              <1> ;loc_set_date_bs_4:
   856                              <1> ;	call	write_backspace
   857                              <1> ;	jmp	loc_enter_month_1
   858                              <1> 
   859                              <1> 	; 26/07/2022
   860                              <1> loc_set_date_stc_5:
   861 00007C3F E8A0000000          <1> 	call	check_for_backspace
   862 00007C44 740A                <1> 	je	short loc_set_date_bs_5
   863                              <1> 	;xor	bh, bh ; video page 0
   864 00007C46 E8F7A6FFFF          <1> 	call	beeper ; BEEP !
   865 00007C4B E970FFFFFF          <1> 	jmp	loc_enter_separator_2
   866                              <1> loc_set_date_bs_5:
   867 00007C50 E87D000000          <1> 	call	write_backspace
   868 00007C55 E935FFFFFF          <1> 	jmp	loc_enter_month_2
   869                              <1> loc_set_date_stc_6:
   870 00007C5A E885000000          <1> 	call	check_for_backspace
   871 00007C5F 740A                <1>         je      short loc_set_date_bs_6
   872                              <1> 	;xor	bh, bh ; video page 0
   873 00007C61 E8DCA6FFFF          <1> 	call	beeper ; BEEP !
   874 00007C66 E96FFFFFFF          <1> 	jmp	loc_enter_year_1
   875                              <1> loc_set_date_bs_6:
   876 00007C6B E862000000          <1> 	call	write_backspace
   877 00007C70 E94BFFFFFF          <1> 	jmp	loc_enter_separator_2
   878                              <1> loc_set_date_stc_7:
   879 00007C75 E86A000000          <1> 	call	check_for_backspace
   880 00007C7A 740A                <1> 	je	short loc_set_date_bs_7
   881                              <1> 	;xor	bh, bh ; video page 0
   882 00007C7C E8C1A6FFFF          <1> 	call	beeper ; BEEP !
   883 00007C81 E973FFFFFF          <1> 	jmp	loc_enter_year_2
   884                              <1> loc_set_date_bs_7:
   885 00007C86 E847000000          <1> 	call	write_backspace
   886 00007C8B E94AFFFFFF          <1> 	jmp	loc_enter_year_1
   887                              <1> 
   888                              <1> loc_set_date_progress:
   889                              <1> 	; Get Current Date
   890                              <1> 	;mov	ah, 04h
   891                              <1> 	;call	int1Ah
   892 00007C90 E8D6E5FFFF          <1> 	call	RTC_40	; GET RTC DATE
   893                              <1> 	; CH = century (in BCD)
   894                              <1> 
   895 00007C95 66A1[E1310100]      <1> 	mov	ax, [Year]
   896 00007C9B 662D3030            <1> 	sub	ax, '00'
   897 00007C9F C0E004              <1> 	shl	al, 4 ; * 16
   898 00007CA2 88C1                <1> 	mov	cl, al
   899 00007CA4 00E1                <1> 	add	cl, ah
   900 00007CA6 66A1[DC310100]      <1> 	mov	ax, [Month]
   901 00007CAC 662D3030            <1> 	sub	ax, '00'
   902 00007CB0 C0E004              <1> 	shl	al, 4 ; * 16
   903 00007CB3 88C6                <1> 	mov	dh, al
   904 00007CB5 00E6                <1> 	add	dh, ah
   905 00007CB7 66A1[D9310100]      <1> 	mov	ax, [Day]
   906 00007CBD 662D3030            <1> 	sub	ax, '00'
   907 00007CC1 C0E004              <1> 	shl	al, 4 ; * 16
   908 00007CC4 88C2                <1> 	mov	dl, al
   909 00007CC6 00E2                <1> 	add	dl, ah
   910                              <1> 
   911                              <1> 	;mov	ah, 05h
   912                              <1> 	;call	int1Ah
   913 00007CC8 E8C4E5FFFF          <1> 	call	RTC_50	; SET RTC DATE
   914                              <1> 
   915                              <1> ;loc_set_date_retn:
   916                              <1> ;	mov	esi, nextline
   917                              <1> ;	;call	print_msg
   918                              <1> ;	;retn
   919                              <1> ;	; 26/07/2022
   920                              <1> ;	jmp	print_msg
   921                              <1> 
   922                              <1> 	; 26/07/2022
   923 00007CCD E963FFFFFF          <1> 	jmp	loc_set_date_ok 
   924                              <1> 
   925                              <1> write_backspace:
   926                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   927 00007CD2 B008                <1> 	mov	al, 08h ; BACKSPACE
   928                              <1> 	; 13/05/2016
   929 00007CD4 66BB0700            <1> 	mov	bx, 7 ; bl = attribute/color
   930                              <1> 		      ; bh = video page = 0	
   931 00007CD8 E87BA5FFFF          <1> 	call	_write_tty
   932 00007CDD B020                <1> 	mov	al, 20h ; BLANK/SPACE char 
   933                              <1> 	;mov	bx, 7 ; attribute/color
   934                              <1> 	;call	_write_c_current
   935                              <1> 	;retn
   936 00007CDF E9F3A4FFFF          <1> 	jmp	_write_c_current
   937                              <1> 
   938                              <1> check_for_backspace:
   939                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   940 00007CE4 663D080E            <1> 	cmp	ax, 0E08h
   941 00007CE8 7410                <1> 	je	short cfbs_retn
   942 00007CEA 663DE04B            <1> 	cmp	ax, 4BE0h
   943 00007CEE 740A                <1> 	je	short cfbs_retn
   944 00007CF0 663D004B            <1> 	cmp	ax, 4B00h
   945 00007CF4 7404                <1> 	je	short cfbs_retn
   946 00007CF6 663DE053            <1> 	cmp	ax, 53E0h
   947                              <1> cfbs_retn:
   948 00007CFA C3                  <1> 	retn
   949                              <1> 
   950                              <1> show_time:
   951                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
   952                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   953                              <1>         ; 2004-2005
   954                              <1> 
   955                              <1> 	;mov	ah, 02h
   956                              <1> 	;call	int1Ah
   957 00007CFB E800E5FFFF          <1> 	call	RTC_20	; GET RTC TIME
   958                              <1> 	
   959 00007D00 88E8                <1> 	mov	al, ch
   960 00007D02 E8F491FFFF          <1> 	call	bcd_to_ascii
   961 00007D07 66A3[07320100]      <1> 	mov	[Hour], ax
   962                              <1> 
   963 00007D0D 88C8                <1> 	mov	al, cl
   964 00007D0F E8E791FFFF          <1> 	call	bcd_to_ascii
   965 00007D14 66A3[0A320100]      <1> 	mov	[Minute], ax
   966                              <1> 
   967 00007D1A 88F0                <1> 	mov	al, dh
   968 00007D1C E8DA91FFFF          <1> 	call	bcd_to_ascii
   969 00007D21 66A3[0D320100]      <1> 	mov	[Second], ax
   970                              <1> 
   971 00007D27 BE[F7310100]        <1> 	mov	esi, Msg_Show_Time
   972                              <1> 	;call	print_msg
   973                              <1> 	;retn
   974                              <1> 	; 26/07/2022
   975 00007D2C E929EFFFFF          <1> 	jmp	print_msg
   976                              <1> 
   977                              <1> set_time:
   978                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
   979                              <1> 	; 13/05/2016
   980                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   981                              <1>         ; 2004-2005
   982                              <1> 
   983 00007D31 BE[E6310100]        <1> 	mov 	esi, Msg_Enter_Time
   984 00007D36 E81FEFFFFF          <1> 	call	print_msg
   985                              <1> 
   986                              <1> loc_enter_hour_1:
   987 00007D3B 30E4                <1> 	xor     ah, ah
   988 00007D3D E8C691FFFF          <1> 	call	int16h
   989                              <1> 	; AL = ASCII Code of the Character
   990 00007D42 3C0D                <1> 	cmp	al, 13 ; ENTER key
   991 00007D44 742D                <1>         je	short loc_set_time_retn
   992 00007D46 3C1B                <1> 	cmp	al, 27 ; ESC key
   993 00007D48 7429                <1>         je	short loc_set_time_retn
   994                              <1> set_time_0:
   995 00007D4A A2[07320100]        <1> 	mov	[Hour], al
   996 00007D4F 3C30                <1> 	cmp	al, '0'
   997 00007D51 7204                <1>         jb	short loc_set_time_stc_0
   998 00007D53 3C32                <1> 	cmp	al, '2'
   999                              <1>  	;ja	loc_set_time_stc_0
  1000                              <1> 	; 26/07/2022
  1001 00007D55 7626                <1> 	jna	short set_time_1
  1002                              <1> 
  1003                              <1> 	; 26/07/2022
  1004                              <1> loc_set_time_stc_0:
  1005                              <1> 	;xor	bh, bh ; video page 0
  1006 00007D57 E8E6A5FFFF          <1> 	call	beeper ; BEEP !
  1007 00007D5C EBDD                <1> 	jmp	short loc_enter_hour_1
  1008                              <1> 
  1009                              <1> loc_set_time_stc_1:
  1010 00007D5E E881FFFFFF          <1> 	call	check_for_backspace
  1011 00007D63 7407                <1> 	je	short loc_set_time_bs_1
  1012                              <1> 	;xor	bh, bh ; video page 0
  1013 00007D65 E8D8A5FFFF          <1> 	call	beeper ; BEEP !
  1014 00007D6A EB18                <1> 	jmp	short loc_enter_hour_2
  1015                              <1> loc_set_time_bs_1:
  1016 00007D6C E861FFFFFF          <1> 	call	write_backspace
  1017 00007D71 EBC8                <1> 	jmp	short loc_enter_hour_1
  1018                              <1> 
  1019                              <1> 	; 26/07/2022
  1020                              <1> loc_set_time_retn:
  1021 00007D73 BE[1B3B0100]        <1> 	mov 	esi, nextline
  1022                              <1> 	;call	print_msg
  1023                              <1> 	;retn
  1024 00007D78 E9DDEEFFFF          <1> 	jmp	print_msg
  1025                              <1> 
  1026                              <1> set_time_1:
  1027                              <1> 	; 13/05/2016
  1028                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  1029                              <1> 		      ; video page 0 (bh)
  1030 00007D7D B307                <1> 	mov	bl, 7	
  1031 00007D7F E8D4A4FFFF          <1> 	call	_write_tty
  1032                              <1> loc_enter_hour_2:
  1033 00007D84 30E4                <1> 	xor     ah, ah
  1034 00007D86 E87D91FFFF          <1> 	call	int16h
  1035                              <1> 	; AL = ASCII Code of the Character
  1036 00007D8B 3C1B                <1> 	cmp	al, 27
  1037 00007D8D 74E4                <1> 	je	short loc_set_time_retn
  1038 00007D8F A2[08320100]        <1> 	mov	[Hour+1], al
  1039 00007D94 3C30                <1> 	cmp	al, '0'
  1040 00007D96 72C6                <1> 	jb	short loc_set_time_stc_1
  1041 00007D98 3C39                <1> 	cmp	al, '9'
  1042 00007D9A 77C2                <1> 	ja	short loc_set_time_stc_1
  1043 00007D9C 803D[07320100]32    <1>         cmp     byte [Hour], '2'
  1044 00007DA3 7204                <1> 	jb	short pass_set_time_24
  1045 00007DA5 3C34                <1> 	cmp	al, '4'
  1046 00007DA7 77B5                <1> 	ja	short loc_set_time_stc_1
  1047                              <1> pass_set_time_24:
  1048                              <1> 	; 13/05/2016
  1049                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  1050                              <1> 		      ; video page 0 (bh)
  1051 00007DA9 B307                <1> 	mov	bl, 7	
  1052 00007DAB E8A8A4FFFF          <1> 	call	_write_tty
  1053                              <1> loc_enter_time_separator_1:
  1054 00007DB0 28E4                <1> 	sub    ah, ah ; 0
  1055 00007DB2 E85191FFFF          <1> 	call	int16h
  1056                              <1> 	; AL = ASCII Code of the Character
  1057 00007DB7 3C1B                <1> 	cmp	al, 27
  1058 00007DB9 74B8                <1> 	je	short loc_set_time_retn
  1059 00007DBB 3C3A                <1> 	cmp	al, ':'
  1060                              <1> 	;jne	loc_set_time_stc_2
  1061                              <1> 	; 26/07/2022
  1062 00007DBD 7415                <1> 	je	short set_time_2
  1063                              <1> 	
  1064                              <1> 	; 26/07/2022
  1065                              <1> loc_set_time_stc_2:
  1066 00007DBF E820FFFFFF          <1> 	call	check_for_backspace
  1067 00007DC4 7407                <1> 	je	short loc_set_time_bs_2
  1068                              <1> 	;xor	bh, bh ; video page 0
  1069 00007DC6 E877A5FFFF          <1> 	call	beeper ; BEEP !
  1070 00007DCB EBE3                <1> 	jmp	short loc_enter_time_separator_1
  1071                              <1> loc_set_time_bs_2:
  1072 00007DCD E800FFFFFF          <1> 	call	write_backspace
  1073 00007DD2 EBB0                <1> 	jmp	short loc_enter_hour_2
  1074                              <1> 
  1075                              <1> set_time_2:
  1076                              <1> 	; 13/05/2016
  1077                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  1078                              <1> 		      ; video page 0 (bh)
  1079 00007DD4 B307                <1> 	mov	bl, 7	
  1080 00007DD6 E87DA4FFFF          <1> 	call	_write_tty
  1081                              <1> loc_enter_minute_1:
  1082 00007DDB 30E4                <1> 	xor     ah, ah
  1083 00007DDD E82691FFFF          <1> 	call	int16h
  1084                              <1> 	; AL = ASCII Code of the Character
  1085 00007DE2 3C1B                <1> 	cmp	al, 27
  1086 00007DE4 748D                <1> 	je	short loc_set_time_retn
  1087 00007DE6 A2[0A320100]        <1> 	mov	[Minute], al
  1088 00007DEB 3C30                <1> 	cmp	al, '0'
  1089 00007DED 7204                <1> 	jb	short loc_set_time_stc_3
  1090 00007DEF 3C35                <1> 	cmp	al, '5'
  1091                              <1> 	;ja	loc_set_time_stc_3
  1092                              <1> 	; 26/07/2022
  1093 00007DF1 7615                <1> 	jna	short set_time_3
  1094                              <1> 
  1095                              <1> 	; 26/07/2022
  1096                              <1> loc_set_time_stc_3:
  1097 00007DF3 E8ECFEFFFF          <1> 	call	check_for_backspace
  1098 00007DF8 7407                <1> 	je	short loc_set_time_bs_3
  1099                              <1> 	;xor	bh, bh ; video page 0
  1100 00007DFA E843A5FFFF          <1> 	call	beeper ; BEEP !6
  1101 00007DFF EBDA                <1> 	jmp	short loc_enter_minute_1
  1102                              <1> loc_set_time_bs_3:
  1103 00007E01 E8CCFEFFFF          <1> 	call	write_backspace
  1104 00007E06 EBA8                <1> 	jmp	short loc_enter_time_separator_1
  1105                              <1> 
  1106                              <1> set_time_3:
  1107                              <1> 	; 13/05/2016
  1108                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  1109                              <1> 		      ; video page 0 (bh)
  1110 00007E08 B307                <1> 	mov	bl, 7	
  1111 00007E0A E849A4FFFF          <1> 	call	_write_tty
  1112                              <1> loc_enter_minute_2:
  1113 00007E0F 30E4                <1> 	xor     ah, ah
  1114 00007E11 E8F290FFFF          <1> 	call	int16h
  1115                              <1> 	; AL = ASCII Code of the Character
  1116 00007E16 3C1B                <1> 	cmp	al, 27
  1117                              <1> 	;je	short loc_set_time_retn
  1118                              <1> 	; 07/08/2022
  1119 00007E18 7505                <1> 	jne	short loc_enter_minute_3
  1120 00007E1A E954FFFFFF          <1> 	jmp	loc_set_time_retn
  1121                              <1> loc_enter_minute_3:	
  1122 00007E1F A2[0B320100]        <1> 	mov	[Minute+1], al
  1123 00007E24 3C30                <1> 	cmp	al, '0'
  1124 00007E26 7204                <1> 	jb	short loc_set_time_stc_4
  1125 00007E28 3C39                <1> 	cmp	al, '9'
  1126                              <1> 	;ja	loc_set_time_stc_4
  1127                              <1> 	; 26/07/2022
  1128 00007E2A 7615                <1> 	jna	short set_time_4
  1129                              <1> 
  1130                              <1> 	; 26/07/2022
  1131                              <1> loc_set_time_stc_4:
  1132 00007E2C E8B3FEFFFF          <1> 	call	check_for_backspace
  1133 00007E31 7407                <1> 	je	short loc_set_time_bs_4
  1134                              <1> 	;xor	bh, bh ; video page 0
  1135 00007E33 E80AA5FFFF          <1> 	call	beeper ; BEEP !
  1136 00007E38 EBD5                <1> 	jmp	short loc_enter_minute_2
  1137                              <1> loc_set_time_bs_4:
  1138 00007E3A E893FEFFFF          <1> 	call	write_backspace
  1139 00007E3F EB9A                <1> 	jmp	short loc_enter_minute_1
  1140                              <1> 
  1141                              <1> set_time_4:
  1142                              <1> 	; 13/05/2016
  1143                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  1144                              <1> 		      ; video page 0 (bh)
  1145 00007E41 B307                <1> 	mov	bl, 7	
  1146 00007E43 E810A4FFFF          <1> 	call	_write_tty
  1147                              <1> loc_enter_time_separator_2:
  1148 00007E48 66C705[0D320100]30- <1> 	mov	word [Second], 3030h
  1148 00007E50 30                  <1>
  1149 00007E51 28E4                <1> 	sub     ah, ah
  1150 00007E53 E8B090FFFF          <1> 	call	int16h
  1151                              <1> 	; AL = ASCII Code of the Character
  1152 00007E58 3C0D                <1> 	cmp	al, 13
  1153                              <1>         ;je	short loc_set_time_progress
  1154                              <1> 	; 07/08/2022
  1155 00007E5A 7505                <1> 	jne	short loc_enter_time_separator_3
  1156                              <1> jmp_loc_set_time_progress:
  1157 00007E5C E9D4000000          <1> 	jmp	loc_set_time_progress
  1158                              <1> loc_enter_time_separator_3:
  1159 00007E61 3C1B                <1> 	cmp	al, 27
  1160                              <1> 	;;je	loc_set_time_retn
  1161                              <1> 	; 26/07/2022
  1162                              <1> 	;je	short loc_set_time_ok
  1163                              <1> 	; 07/08/2022
  1164 00007E63 7505                <1> 	jne	short loc_enter_time_separator_4
  1165 00007E65 E982000000          <1> 	jmp	loc_set_time_ok
  1166                              <1> loc_enter_time_separator_4:
  1167 00007E6A 3C3A                <1> 	cmp	al, ':'
  1168 00007E6C 7563                <1>         jne	short loc_set_time_stc_5
  1169                              <1> 
  1170                              <1> 	; 13/05/2016
  1171                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  1172                              <1> 		      ; video page 0 (bh)
  1173 00007E6E B307                <1> 	mov	bl, 7	
  1174 00007E70 E8E3A3FFFF          <1> 	call	_write_tty
  1175                              <1> loc_enter_second_1:
  1176 00007E75 30E4                <1> 	xor     ah, ah
  1177 00007E77 E88C90FFFF          <1> 	call	int16h
  1178                              <1> 	; AL = ASCII Code of the Character
  1179 00007E7C 3C0D                <1> 	cmp	al, 13
  1180                              <1> 	;je	short loc_set_time_progress
  1181                              <1> 	; 07/08/2022
  1182 00007E7E 74DC                <1> 	je	short jmp_loc_set_time_progress
  1183 00007E80 3C1B                <1> 	cmp	al, 27
  1184                              <1> 	;;je	loc_set_time_retn
  1185                              <1> 	; 26/07/2022
  1186                              <1> 	;je	short loc_set_time_ok
  1187                              <1> 	; 07/08/2022
  1188 00007E82 7502                <1> 	jne	short loc_enter_second_2
  1189 00007E84 EB66                <1> 	jmp	loc_set_time_ok
  1190                              <1> loc_enter_second_2:
  1191 00007E86 A2[0D320100]        <1> 	mov	[Second], al
  1192 00007E8B 3C30                <1> 	cmp	al, '0'
  1193 00007E8D 7267                <1> 	jb	short loc_set_time_stc_6
  1194 00007E8F 3C35                <1> 	cmp	al, '5'
  1195 00007E91 7763                <1> 	ja	short loc_set_time_stc_6
  1196                              <1> 	; 13/05/2016
  1197                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  1198                              <1> 		      ; video page 0 (bh)
  1199 00007E93 B307                <1> 	mov	bl, 7	
  1200 00007E95 E8BEA3FFFF          <1> 	call	_write_tty
  1201                              <1> loc_enter_second_3:
  1202 00007E9A 30E4                <1> 	xor     ah, ah
  1203 00007E9C E86790FFFF          <1> 	call	int16h
  1204                              <1> 	; AL = ASCII Code of the Character
  1205 00007EA1 3C1B                <1> 	cmp	al, 27
  1206                              <1> 	;je	short loc_set_time_retn
  1207                              <1> 	; 26/07/2022
  1208 00007EA3 7447                <1> 	je	short loc_set_time_ok
  1209 00007EA5 3C30                <1> 	cmp	al, '0'
  1210 00007EA7 7271                <1>         jb	short loc_set_time_stc_7
  1211 00007EA9 3C39                <1> 	cmp	al, '9'
  1212 00007EAB 776D                <1>         ja	short loc_set_time_stc_7
  1213                              <1> 	; 13/05/2016
  1214                              <1> 	;mov	bx, 7 ; attribute/color (bl)
  1215                              <1> 		      ; video page 0 (bh)
  1216 00007EAD B307                <1> 	mov	bl, 7	
  1217 00007EAF E8A4A3FFFF          <1> 	call	_write_tty
  1218                              <1> loc_set_time_get_lchar_again:
  1219 00007EB4 28E4                <1> 	sub	ah, ah ; 0
  1220 00007EB6 E84D90FFFF          <1> 	call	int16h
  1221                              <1> 	; AL = ASCII Code of the Character
  1222 00007EBB 3C0D                <1> 	cmp	al, 13
  1223 00007EBD 7476                <1> 	je	short loc_set_time_progress
  1224 00007EBF 3C1B                <1> 	cmp	al, 27
  1225                              <1> 	;je	short loc_set_time_retn
  1226                              <1> 	; 07/08/2022
  1227 00007EC1 7429                <1> 	je	short loc_set_time_ok
  1228                              <1> 	;
  1229 00007EC3 E81CFEFFFF          <1> 	call	check_for_backspace
  1230 00007EC8 75EA                <1> 	jne	short loc_set_time_get_lchar_again
  1231                              <1> 
  1232                              <1> loc_set_time_bs_8:
  1233 00007ECA E803FEFFFF          <1> 	call	write_backspace
  1234 00007ECF EBC9                <1> 	jmp	short loc_enter_second_3
  1235                              <1> 
  1236                              <1> ;	; 26/07/2022
  1237                              <1> ;loc_set_time_retn:
  1238                              <1> ;	mov 	esi, nextline
  1239                              <1> ;	;call	print_msg
  1240                              <1> ;	;retn
  1241                              <1> ;	jmp	print_msg
  1242                              <1> 
  1243                              <1> 	; 26/07/2022
  1244                              <1> ;loc_set_time_stc_0:
  1245                              <1> ;	;xor	bh, bh ; video page 0
  1246                              <1> ;	call	beeper ; BEEP !
  1247                              <1> ;	jmp	loc_enter_hour_1
  1248                              <1> ;loc_set_time_stc_1:
  1249                              <1> ;	call	check_for_backspace
  1250                              <1> ;	je	short loc_set_time_bs_1
  1251                              <1> ;	;xor	bh, bh ; video page 0
  1252                              <1> ;	call	beeper ; BEEP !
  1253                              <1> ;	jmp	loc_enter_hour_2
  1254                              <1> ;loc_set_time_bs_1:
  1255                              <1> ;	call	write_backspace
  1256                              <1> ;	jmp	loc_enter_hour_1
  1257                              <1> ;loc_set_time_stc_2:
  1258                              <1> ;	call	check_for_backspace
  1259                              <1> ;	je	short loc_set_time_bs_2
  1260                              <1> ;	;xor	bh, bh ; video page 0
  1261                              <1> ;	call	beeper ; BEEP !
  1262                              <1> ;	jmp	loc_enter_time_separator_1
  1263                              <1> ;loc_set_time_bs_2:
  1264                              <1> ;	call	write_backspace
  1265                              <1> ;	jmp	loc_enter_hour_2
  1266                              <1> ;loc_set_time_stc_3:
  1267                              <1> ;	call	check_for_backspace
  1268                              <1> ;	je	short loc_set_time_bs_3
  1269                              <1> ;	;xor	bh, bh ; video page 0
  1270                              <1> ;	call	beeper ; BEEP !6
  1271                              <1> ;	jmp	loc_enter_minute_1
  1272                              <1> ;loc_set_time_bs_3:
  1273                              <1> ;	call	write_backspace
  1274                              <1> ;	jmp	loc_enter_time_separator_1
  1275                              <1> ;loc_set_time_stc_4:
  1276                              <1> ;	call	check_for_backspace
  1277                              <1> ;	je	short loc_set_time_bs_4
  1278                              <1> ;	;xor	bh, bh ; video page 0
  1279                              <1> ;	call	beeper ; BEEP !
  1280                              <1> ;	jmp	loc_enter_minute_2
  1281                              <1> ;loc_set_time_bs_4:
  1282                              <1> ;	call	write_backspace
  1283                              <1> ;	jmp	loc_enter_minute_1
  1284                              <1> 
  1285                              <1> 	; 26/07/2022
  1286                              <1> loc_set_time_stc_5:
  1287 00007ED1 E80EFEFFFF          <1> 	call	check_for_backspace
  1288 00007ED6 740A                <1> 	je	short loc_set_time_bs_5
  1289                              <1> 	;xor	bh, bh ; video page 0
  1290 00007ED8 E865A4FFFF          <1> 	call	beeper ; BEEP !
  1291 00007EDD E966FFFFFF          <1> 	jmp	loc_enter_time_separator_2
  1292                              <1> loc_set_time_bs_5:
  1293 00007EE2 E8EBFDFFFF          <1> 	call	write_backspace
  1294 00007EE7 E923FFFFFF          <1> 	jmp	loc_enter_minute_2
  1295                              <1> 
  1296                              <1> 	; 26/07/2022
  1297                              <1> loc_set_time_ok:
  1298 00007EEC BE[1B3B0100]        <1> 	mov 	esi, nextline
  1299                              <1> 	;call	print_msg
  1300                              <1> 	;retn
  1301 00007EF1 E964EDFFFF          <1> 	jmp	print_msg
  1302                              <1> 
  1303                              <1> 	; 07/08/2022
  1304                              <1> loc_set_time_stc_6:
  1305 00007EF6 E8E9FDFFFF          <1> 	call	check_for_backspace
  1306 00007EFB 7413                <1> 	je	short loc_set_time_bs_6
  1307                              <1> 	;xor	bh, bh ; video page 0
  1308 00007EFD E840A4FFFF          <1> 	call	beeper ; BEEP !
  1309 00007F02 66C705[0D320100]30- <1> 	mov	word [Second], 3030h
  1309 00007F0A 30                  <1>
  1310 00007F0B E965FFFFFF          <1> 	jmp	loc_enter_second_1
  1311                              <1> loc_set_time_bs_6:
  1312 00007F10 E8BDFDFFFF          <1> 	call	write_backspace
  1313 00007F15 E92EFFFFFF          <1> 	jmp	loc_enter_time_separator_2
  1314                              <1> loc_set_time_stc_7:
  1315 00007F1A E8C5FDFFFF          <1> 	call	check_for_backspace
  1316 00007F1F 740A                <1> 	je	short loc_set_time_bs_7
  1317                              <1> 	;xor	bh, bh ; video page 0
  1318 00007F21 E81CA4FFFF          <1> 	call	beeper ; BEEP !
  1319 00007F26 E96FFFFFFF          <1> 	jmp	loc_enter_second_3
  1320                              <1> loc_set_time_bs_7:
  1321 00007F2B E8A2FDFFFF          <1> 	call	write_backspace
  1322 00007F30 E940FFFFFF          <1> 	jmp	loc_enter_second_1
  1323                              <1> 
  1324                              <1> loc_set_time_progress:
  1325                              <1> 	; Get Current Time
  1326                              <1> 	;mov 	ah, 02h
  1327                              <1> 	;call	int1Ah
  1328 00007F35 E8C6E2FFFF          <1> 	call	RTC_20	; GET RTC TIME
  1329                              <1> 	;DL = Daylight Savings Enable option (0-1)	
  1330                              <1> 
  1331 00007F3A 66A1[07320100]      <1> 	mov	ax, [Hour]
  1332 00007F40 662D3030            <1> 	sub	ax, '00'
  1333 00007F44 C0E004              <1> 	shl	al, 4 ; * 16
  1334 00007F47 88C5                <1> 	mov	ch, al
  1335 00007F49 00E5                <1> 	add	ch, ah
  1336 00007F4B 66A1[0A320100]      <1> 	mov	ax, [Minute]
  1337 00007F51 662D3030            <1> 	sub	ax, '00'
  1338 00007F55 C0E004              <1> 	shl	al, 4 ; * 16
  1339 00007F58 88C1                <1> 	mov	cl, al
  1340 00007F5A 00E1                <1> 	add	cl, ah
  1341 00007F5C 66A1[0D320100]      <1> 	mov	ax, [Second]
  1342 00007F62 662D3030            <1> 	sub	ax, '00'
  1343 00007F66 C0E004              <1> 	shl	al, 4 ; * 16
  1344 00007F69 88C6                <1> 	mov	dh, al
  1345 00007F6B 00E6                <1> 	add	dh, ah
  1346                              <1> 	
  1347                              <1> 	;mov	ah, 03h
  1348                              <1> 	;call	int1Ah
  1349 00007F6D E8BCE2FFFF          <1> 	call	RTC_30	; SET RTC TIME
  1350                              <1> 
  1351                              <1> 	; 26/07/2022
  1352 00007F72 E975FFFFFF          <1> 	jmp	loc_set_time_ok
  1353                              <1> 
  1354                              <1> print_volume_info:
  1355                              <1> 	; 01/03/2016
  1356                              <1> 	; 08/02/2016
  1357                              <1> 	; 06/02/2016
  1358                              <1> 	; 04/02/2016
  1359                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
  1360                              <1> 	; 25/10/2009
  1361                              <1> 	;
  1362                              <1> 	; "Volume Serial No: "
  1363                              <1>  	;
  1364                              <1> 	; INPUT  : AL = DOS Drive Number
  1365                              <1> 	; OUTPUT : AH = FS Type
  1366                              <1> 	;          AL = DOS Drive Name
  1367                              <1> 	; CF = 0 -> OK
  1368                              <1> 	; CF = 1 -> Drive not ready 
  1369                              <1> 
  1370 00007F77 88C4                <1> 	mov	ah, al
  1371 00007F79 28C0                <1> 	sub	al, al
  1372 00007F7B 0FB7F0              <1> 	movzx	esi, ax	
  1373 00007F7E 81C600010900        <1> 	add	esi, Logical_DOSDisks
  1374 00007F84 8A06                <1> 	mov	al, [esi]
  1375 00007F86 3C41                <1> 	cmp	al, 'A'  
  1376 00007F88 7304                <1> 	jnb	short loc_pvi_set_vol_name
  1377 00007F8A 8A6604              <1> 	mov	ah, [esi+LD_FSType]
  1378 00007F8D C3                  <1> 	retn
  1379                              <1> 
  1380                              <1> loc_pvi_set_vol_name:
  1381 00007F8E A2[41320100]        <1> 	mov	[Vol_Drv_Name], al
  1382 00007F93 56                  <1> 	push	esi
  1383 00007F94 E858010000          <1> 	call	move_volume_name_and_serial_no ;;;
  1384 00007F99 7302                <1> 	jnc	short loc_pvi_mvn_ok
  1385 00007F9B 5E                  <1> 	pop	esi
  1386 00007F9C C3                  <1> 	retn
  1387                              <1> 
  1388                              <1> loc_pvi_mvn_ok:
  1389 00007F9D 8B3424              <1> 	mov	esi, [esp]
  1390 00007FA0 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  1391 00007FA4 7509                <1> 	jne	short loc_pvi_fat_vol_size
  1392 00007FA6 8B4670              <1> 	mov	eax, [esi+LD_FS_VolumeSize]
  1393 00007FA9 0FB75E11            <1> 	movzx	ebx, word [esi+LD_FS_BytesPerSec]
  1394 00007FAD EB07                <1> 	jmp	short loc_vol_size_mul32
  1395                              <1> loc_pvi_fat_vol_size:
  1396 00007FAF 8B4670              <1> 	mov	eax, [esi+LD_TotalSectors]
  1397 00007FB2 0FB75E11            <1> 	movzx	ebx, word [esi+LD_BPB+BPB_BytsPerSec]
  1398                              <1> loc_vol_size_mul32:
  1399 00007FB6 F7E3                <1> 	mul	ebx
  1400 00007FB8 09D2                <1> 	or	edx, edx
  1401 00007FBA 7507                <1> 	jnz	short loc_vol_size_in_kbytes
  1402                              <1> loc_vol_size_in_bytes:
  1403 00007FBC B9[1F320100]        <1> 	mov	ecx, VolSize_Bytes
  1404 00007FC1 EB0D                <1> 	jmp	short loc_write_vol_size_str
  1405                              <1> loc_vol_size_in_kbytes:
  1406 00007FC3 66BB0004            <1> 	mov	bx, 1024
  1407 00007FC7 F7F3                <1> 	div	ebx
  1408 00007FC9 B9[12320100]        <1> 	mov 	ecx, VolSize_KiloBytes
  1409 00007FCE 31D2                <1> 	xor	edx, edx ; 0
  1410                              <1> loc_write_vol_size_str:
  1411 00007FD0 890D[807F0100]      <1> 	mov	[VolSize_Unit1], ecx
  1412                              <1> 	; 
  1413 00007FD6 BF[967F0100]        <1> 	mov	edi, Vol_Tot_Sec_Str_End
  1414                              <1>         ;mov	byte [edi], 0
  1415 00007FDB B90A000000          <1> 	mov	ecx, 10
  1416                              <1> loc_write_vol_size_chr:
  1417 00007FE0 F7F1                <1> 	div	ecx
  1418 00007FE2 80C230              <1> 	add	dl, '0'
  1419 00007FE5 4F                  <1> 	dec	edi	
  1420 00007FE6 8817                <1> 	mov	[edi], dl
  1421 00007FE8 85C0                <1> 	test	eax, eax
  1422 00007FEA 7404                <1> 	jz	short loc_write_vol_size_str_ok
  1423 00007FEC 28D2                <1> 	sub	dl, dl ; 0
  1424 00007FEE EBF0                <1> 	jmp	short loc_write_vol_size_chr
  1425                              <1> 
  1426                              <1> loc_write_vol_size_str_ok:
  1427 00007FF0 893D[887F0100]      <1> 	mov	[Vol_Tot_Sec_Str_Start], edi
  1428                              <1> 	;
  1429 00007FF6 BF[2A320100]        <1> 	mov	edi, Vol_FS_Name
  1430 00007FFB 8A4E03              <1> 	mov	cl, [esi+LD_FATType]
  1431 00007FFE 20C9                <1> 	and	cl, cl ; 0 ?
  1432 00008000 7515                <1> 	jnz	short loc_write_vol_FAT_str_1
  1433 00008002 66C7075452          <1> 	mov	word [edi], 'TR'
  1434 00008007 C7470420465331      <1> 	mov	dword [edi+4], ' FS1'
  1435                              <1> 	;movzx	ebx, word [esi+LD_FS_BytesPerSec]
  1436 0000800E 668B5E11            <1> 	mov	bx, [esi+LD_FS_BytesPerSec]
  1437 00008012 8B4674              <1> 	mov	eax, [esi+LD_FS_FreeSectors]
  1438 00008015 EB36                <1> 	jmp	short loc_vol_freespace_mul32
  1439                              <1> 
  1440                              <1> loc_write_vol_FAT_str_1:
  1441 00008017 66B83332            <1> 	mov	ax, '32' ; FAT32
  1442 0000801B 80F902              <1> 	cmp	cl, 2 ; [esi+LD_FATType]
  1443 0000801E 7708                <1> 	ja	short loc_write_vol_FAT_str_2
  1444 00008020 66B83132            <1> 	mov	ax, '12' ; FAT12
  1445 00008024 7202                <1> 	jb	short loc_write_vol_FAT_str_2
  1446 00008026 B436                <1> 	mov	ah, '6'  ; FAT16
  1447                              <1> loc_write_vol_FAT_str_2:
  1448 00008028 C70746415420        <1> 	mov	dword [edi], 'FAT '
  1449 0000802E 66894704            <1> 	mov	word [edi+4], ax
  1450                              <1> 	;
  1451                              <1> 	;movzx	ebx, word [esi+LD_BPB+BPB_BytsPerSec]
  1452 00008032 668B5E11            <1> 	mov	bx, [esi+LD_BPB+BPB_BytsPerSec]
  1453 00008036 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors]
  1454                              <1> 
  1455                              <1> loc_vol_freespace_recalc0:
  1456                              <1> 	; 01/03/2016
  1457 00008039 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh
  1458 0000803C 720F                <1> 	jb	short loc_vol_freespace_mul32
  1459                              <1> 	;inc	eax ; 0
  1460 0000803E 20C9                <1> 	and	cl, cl ; byte [esi+LD_FATType]
  1461 00008040 740B                <1> 	jz	short loc_vol_freespace_mul32 	
  1462 00008042 53                  <1> 	push	ebx
  1463 00008043 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free sectors
  1464 00008047 E86E470000          <1> 	call	calculate_fat_freespace
  1465 0000804C 5B                  <1> 	pop	ebx
  1466                              <1> 
  1467                              <1> loc_vol_freespace_mul32:
  1468 0000804D F7E3                <1> 	mul	ebx
  1469 0000804F 09D2                <1> 	or	edx, edx
  1470 00008051 7507                <1> 	jnz	short loc_vol_fspace_in_kbytes
  1471                              <1> loc_vol_fspace_in_bytes:
  1472 00008053 B9[1F320100]        <1> 	mov	ecx, VolSize_Bytes
  1473 00008058 EB0D                <1> 	jmp	short loc_write_vol_fspace_str
  1474                              <1> loc_vol_fspace_in_kbytes:
  1475 0000805A 66BB0004            <1> 	mov	bx, 1024
  1476 0000805E F7F3                <1> 	div	ebx
  1477 00008060 B9[12320100]        <1> 	mov 	ecx, VolSize_KiloBytes
  1478 00008065 31D2                <1> 	xor	edx, edx ; 0
  1479                              <1> loc_write_vol_fspace_str:
  1480 00008067 890D[847F0100]      <1> 	mov	[VolSize_Unit2], ecx
  1481                              <1> 	;	
  1482 0000806D BF[A67F0100]        <1> 	mov	edi, Vol_Free_Sectors_Str_End
  1483                              <1>         ;mov	byte [edi], 0
  1484 00008072 B90A000000          <1> 	mov	ecx, 10
  1485                              <1> loc_write_vol_fspace_chr:
  1486 00008077 F7F1                <1> 	div	ecx
  1487 00008079 80C230              <1> 	add	dl, '0'
  1488 0000807C 4F                  <1> 	dec	edi	
  1489 0000807D 8817                <1> 	mov	[edi], dl
  1490 0000807F 85C0                <1> 	test	eax, eax
  1491 00008081 7404                <1> 	jz	short loc_write_vol_fspace_str_ok
  1492 00008083 28D2                <1> 	sub	dl, dl ; 0
  1493 00008085 EBF0                <1> 	jmp	short loc_write_vol_fspace_chr
  1494                              <1> 
  1495                              <1> loc_write_vol_fspace_str_ok:
  1496 00008087 893D[987F0100]      <1> 	mov	[Vol_Free_Sectors_Str_Start], edi
  1497                              <1> 	;
  1498 0000808D BE[28320100]        <1> 	mov	esi, Volume_in_drive
  1499 00008092 E8C3EBFFFF          <1> 	call	print_msg
  1500 00008097 BE[68320100]        <1> 	mov	esi, Vol_Name
  1501 0000809C E8B9EBFFFF          <1> 	call	print_msg
  1502 000080A1 BE[1B3B0100]        <1> 	mov	esi, nextline
  1503 000080A6 E8AFEBFFFF          <1> 	call	print_msg
  1504                              <1> 	;
  1505 000080AB BE[C9320100]        <1> 	mov	esi, Vol_Total_Sector_Header
  1506 000080B0 E8A5EBFFFF          <1> 	call	print_msg
  1507 000080B5 8B35[887F0100]      <1> 	mov	esi, [Vol_Tot_Sec_Str_Start]
  1508 000080BB E89AEBFFFF          <1> 	call	print_msg
  1509 000080C0 8B35[807F0100]      <1> 	mov	esi, [VolSize_Unit1]
  1510 000080C6 E88FEBFFFF          <1> 	call	print_msg
  1511                              <1> 	;
  1512 000080CB BE[DA320100]        <1> 	mov	esi, Vol_Free_Sectors_Header
  1513 000080D0 E885EBFFFF          <1> 	call	print_msg
  1514 000080D5 8B35[987F0100]      <1> 	mov	esi, [Vol_Free_Sectors_Str_Start]
  1515 000080DB E87AEBFFFF          <1> 	call	print_msg
  1516 000080E0 8B35[847F0100]      <1> 	mov	esi, [VolSize_Unit2]
  1517 000080E6 E86FEBFFFF          <1> 	call	print_msg
  1518                              <1> 	;
  1519 000080EB 5E                  <1> 	pop	esi
  1520                              <1> 	
  1521                              <1> 	;mov	ah, [esi+LD_FSType]
  1522                              <1> 	;mov	al, [esi+LD_FATType]
  1523 000080EC 668B4603            <1> 	mov	ax, [esi+LD_FATType]
  1524                              <1> 
  1525 000080F0 C3                  <1> 	retn
  1526                              <1> 
  1527                              <1> move_volume_name_and_serial_no:
  1528                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
  1529                              <1> 	; 08/02/2016  (TRDOS 386 = TRDOS v2.0)
  1530                              <1> 	; this routine will be called by
  1531                              <1> 	; "print_volume_info" and "print_directory"
  1532                              <1> 	; INPUT ->
  1533                              <1> 	;	ESI = Logical DOS drv descripton table address
  1534                              <1> 	; OUTPUT ->
  1535                              <1> 	;	*Volume name will be moved to text area
  1536                              <1> 	;	*Volume serial number will be converted to
  1537                              <1> 	;	 text and will be moved to text area
  1538                              <1> 	;   cf = 1 -> invalid/unknown dos drive
  1539                              <1> 	;   cf = 0 -> ecx = 0
  1540                              <1> 	;
  1541                              <1> 	; (eax, edx, ecx, esi, edi will be changed)
  1542                              <1> 
  1543                              <1> 	; 26/07/2022
  1544 000080F1 31C9                <1> 	xor	ecx, ecx
  1545                              <1> 
  1546 000080F3 BF[68320100]        <1> 	mov 	edi, Vol_Name
  1547                              <1> 
  1548                              <1> 	;mov	ah, [esi+LD_FSType]
  1549                              <1> 	;mov	al, [esi+LD_FATType]
  1550 000080F8 668B4603            <1> 	mov	ax, [esi+LD_FATType]
  1551 000080FC 80FCA1              <1> 	cmp	ah, 0A1h
  1552 000080FF 7418                <1> 	je	short mvn_2
  1553 00008101 08E4                <1> 	or	ah, ah
  1554 00008103 7404                <1> 	jz	short mvn_0
  1555 00008105 08C0                <1> 	or	al, al
  1556 00008107 7504                <1> 	jnz	short mvn_1
  1557                              <1> mvn_0:
  1558 00008109 8A06                <1> 	mov	al, [esi]
  1559 0000810B F9                  <1> 	stc
  1560 0000810C C3                  <1> 	retn
  1561                              <1> mvn_1:
  1562 0000810D 3C02                <1> 	cmp	al, 2
  1563 0000810F 7714                <1> 	ja	short mvn_3 
  1564                              <1> 	;or	al, al
  1565                              <1> 	;jz	short mvn_2
  1566 00008111 8B462D              <1> 	mov	eax, [esi+LD_BPB+VolumeID]
  1567 00008114 83C631              <1> 	add	esi, LD_BPB+VolumeLabel
  1568 00008117 EB12                <1> 	jmp	short mvn_4
  1569                              <1> mvn_2:
  1570 00008119 8B4628              <1> 	mov	eax, [esi+LD_FS_VolumeSerial]
  1571 0000811C 83C62C              <1> 	add	esi, LD_FS_VolumeName
  1572                              <1> 	;mov	ecx, 16
  1573                              <1> 	; 26/07/2022
  1574 0000811F B110                <1> 	mov	cl, 16
  1575 00008121 F3A5                <1> 	rep	movsd
  1576 00008123 EB0D                <1> 	jmp	short mvn_5
  1577                              <1> mvn_3:
  1578 00008125 8B4649              <1> 	mov	eax, [esi+LD_BPB+FAT32_VolID]
  1579 00008128 83C64D              <1> 	add	esi, LD_BPB+FAT32_VolLab
  1580                              <1> mvn_4:
  1581                              <1> 	;mov	ecx, 11
  1582                              <1> 	; 26/07/2022
  1583 0000812B B10B                <1> 	mov	cl, 11
  1584 0000812D F3A4                <1> 	rep	movsb
  1585 0000812F C60700              <1> 	mov	byte [edi], 0
  1586                              <1> mvn_5:
  1587                              <1> 	;mov	[Current_VolSerial], eax  
  1588 00008132 E83CC0FFFF          <1> 	call	dwordtohex
  1589 00008137 8915[BD320100]      <1> 	mov	[Vol_Serial1], edx
  1590 0000813D A3[C2320100]        <1> 	mov	[Vol_Serial2], eax
  1591                              <1> 	; ecx = 0
  1592 00008142 C3                  <1> 	retn
  1593                              <1> 
  1594                              <1> get_volume_serial_number:
  1595                              <1> 	; 19/01/2016 (TRDOS 386 = TRDOS v2.0)
  1596                              <1> 	; 08/08/2010
  1597                              <1> 	;
  1598                              <1> 	; INPUT -> DL = Logical DOS Drive number
  1599                              <1> 	; OUTPUT -> EAX = Volume serial number
  1600                              <1> 	;          BL= FAT Type	    
  1601                              <1> 	;          BH = Logical DOS drv Number (DL input)
  1602                              <1> 	; cf = 1 -> Drive not ready
  1603                              <1> 
  1604 00008143 31DB                <1> 	xor	ebx, ebx
  1605 00008145 88D7                <1> 	mov	bh, dl
  1606 00008147 3815[91300100]      <1> 	cmp	[Last_DOS_DiskNo], dl
  1607 0000814D 7304                <1> 	jnb	short loc_gvsn_start
  1608                              <1> loc_gvsn_stc_retn:
  1609 0000814F 31C0                <1> 	xor	eax, eax
  1610 00008151 F9                  <1> 	stc 
  1611 00008152 C3                  <1>         retn 
  1612                              <1> loc_gvsn_start:
  1613 00008153 56                  <1> 	push	esi
  1614 00008154 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1615 00008159 01DE                <1> 	add	esi, ebx
  1616 0000815B 8A5E03              <1> 	mov	bl, [esi+LD_FATType]
  1617 0000815E 20DB                <1> 	and	bl, bl
  1618 00008160 740F                <1> 	jz	short loc_gvsn_fs
  1619 00008162 80FB02              <1> 	cmp	bl, 2
  1620 00008165 7705                <1> 	ja	short loc_gvsn_fat32
  1621                              <1> loc_gvsn_fat:
  1622 00008167 83C62D              <1> 	add	esi, LD_BPB + VolumeID
  1623 0000816A EB0E                <1> 	jmp	short loc_gvsn_return
  1624                              <1> loc_gvsn_fat32: 
  1625 0000816C 83C649              <1> 	add	esi, LD_BPB + FAT32_VolID
  1626 0000816F EB09                <1> 	jmp	short loc_gvsn_return 
  1627                              <1> loc_gvsn_fs:
  1628 00008171 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  1629 00008175 75D8                <1> 	jne	short loc_gvsn_stc_retn 
  1630 00008177 83C628              <1> 	add	esi, LD_FS_VolumeSerial
  1631                              <1> loc_gvsn_return:
  1632 0000817A 8B06                <1> 	mov	eax, [esi]
  1633 0000817C 5E                  <1> 	pop	esi
  1634 0000817D C3                  <1> 	retn
  1635                              <1> 
  1636                              <1> ; CMD_INTR.ASM [ TRDOS Command Interpreter Procedure ]
  1637                              <1> ; 09/11/2011
  1638                              <1> ; 29/01/2005
  1639                              <1> 
  1640                              <1> command_interpreter:
  1641                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
  1642                              <1> 	; 16/10/2016
  1643                              <1> 	; 12/10/2016
  1644                              <1> 	; 13/05/2016
  1645                              <1> 	; 07/05/2016
  1646                              <1> 	; 04/03/2016
  1647                              <1> 	; 04/02/2016
  1648                              <1> 	; 03/02/2016
  1649                              <1> 	; 30/01/2016
  1650                              <1> 	; 29/01/2016 (TRDOS 386 = TRDOS 2.0)
  1651                              <1> 	; 15/09/2011         
  1652                              <1> 	; 29/01/2005
  1653                              <1>         
  1654                              <1> 	; Input: ecx = command word length (CL)
  1655                              <1> 	;	 CommandBuffer = Command string offset
  1656                              <1>  
  1657 0000817E C605[38800100]00    <1> 	mov	byte [Program_Exit], 0
  1658                              <1> 
  1659                              <1> 	;cmp	cl, 4
  1660                              <1> 	;ja	c_6
  1661                              <1> 	;jb	c_2
  1662                              <1> 
  1663                              <1> 	; 26/07/2022
  1664 00008185 80F903              <1> 	cmp	cl, 3
  1665 00008188 777C                <1> 	ja	short c_4
  1666 0000818A 7405                <1> 	je	short c_3
  1667 0000818C E9D2010000          <1> 	jmp	c_2
  1668                              <1> c_3:
  1669                              <1> cmp_cmd_dir:
  1670 00008191 BF[F9300100]        <1> 	mov	edi, Cmd_Dir
  1671 00008196 E8D1030000          <1> 	call	cmp_cmd	
  1672                              <1> 	;jnc	print_directory_list
  1673                              <1> 	; 26/07/2022
  1674 0000819B 7205                <1> 	jc	short cmp_cmd_cls
  1675 0000819D E97D040000          <1> 	jmp	print_directory_list
  1676                              <1> 
  1677                              <1> cmp_cmd_cls:
  1678 000081A2 B103                <1> 	mov	cl, 3
  1679 000081A4 BF[35310100]        <1> 	mov	edi, Cmd_Cls
  1680 000081A9 E8BE030000          <1> 	call	cmp_cmd	
  1681                              <1>         ;jnc	clear_screen
  1682                              <1> 	; 26/07/2022
  1683 000081AE 7205                <1> 	jc	short cmp_cmd_ver
  1684 000081B0 E9BBEAFFFF          <1> 	jmp	clear_screen
  1685                              <1> 
  1686                              <1> cmp_cmd_ver:
  1687 000081B5 B103                <1> 	mov	cl, 3
  1688 000081B7 BF[03310100]        <1> 	mov	edi, Cmd_Ver
  1689 000081BC E8AB030000          <1> 	call	cmp_cmd	
  1690 000081C1 720A                <1> 	jc	short cmp_cmd_mem
  1691                              <1> 
  1692 000081C3 BE[99300100]        <1> 	mov	esi, mainprog_Version
  1693                              <1> 	;call	print_msg
  1694 000081C8 E98DEAFFFF          <1> 	jmp	print_msg
  1695                              <1> 	;retn
  1696                              <1> 
  1697                              <1> cmp_cmd_mem:
  1698 000081CD B103                <1> 	mov	cl, 3
  1699 000081CF BF[6B310100]        <1> 	mov	edi, Cmd_Mem
  1700 000081D4 E893030000          <1> 	call	cmp_cmd	
  1701                              <1> 	;jnc	memory_info
  1702                              <1> 	; 26/07/2022
  1703 000081D9 7205                <1> 	jc	short cmp_cmd_del
  1704 000081DB E9C5BEFFFF          <1> 	jmp	memory_info
  1705                              <1> 
  1706                              <1> cmp_cmd_del:
  1707 000081E0 B103                <1> 	mov	cl, 3
  1708 000081E2 BF[3E310100]        <1> 	mov	edi, Cmd_Del
  1709 000081E7 E880030000          <1> 	call	cmp_cmd	
  1710                              <1>         ;jnc	delete_file
  1711                              <1> 	; 26/07/2022
  1712 000081EC 7205                <1> 	jc	short cmp_cmd_set
  1713 000081EE E9C2100000          <1> 	jmp	delete_file
  1714                              <1> 
  1715                              <1> cmp_cmd_set:
  1716 000081F3 B103                <1> 	mov	cl, 3
  1717 000081F5 BF[31310100]        <1> 	mov	edi, Cmd_Set
  1718 000081FA E86D030000          <1> 	call	cmp_cmd	
  1719                              <1> 	;jnc	set_get_env
  1720                              <1> 	; 26/07/2022
  1721 000081FF 720F                <1> 	jc	short cmp_cmd_run
  1722 00008201 E91D190000          <1> 	jmp	set_get_env
  1723                              <1> 
  1724                              <1> 	; 07/08/2022
  1725                              <1> c_4:
  1726                              <1> 	; 26/07/2022
  1727 00008206 80F904              <1> 	cmp	cl, 4
  1728 00008209 741D                <1> 	je	short cmp_cmd_4
  1729 0000820B E937020000          <1> 	jmp	c_6
  1730                              <1> 
  1731                              <1> cmp_cmd_run:
  1732 00008210 B103                <1> 	mov	cl, 3
  1733 00008212 BF[2D310100]        <1> 	mov	edi, Cmd_Run
  1734 00008217 E850030000          <1> 	call	cmp_cmd	
  1735                              <1> 	; 07/05/2016
  1736                              <1>         ;jc	cmp_cmd_external
  1737                              <1> 	; 26/07/2022
  1738 0000821C 7305                <1> 	jnc	short c3_run
  1739 0000821E E92C030000          <1> 	jmp	cmp_cmd_external
  1740                              <1> c3_run:
  1741 00008223 E91C1F0000          <1> 	jmp	load_and_execute_file
  1742                              <1> 
  1743                              <1> cmp_cmd_4:
  1744                              <1> 	; 26/07/2022
  1745                              <1> cmp_cmd_exit:
  1746 00008228 BF[07310100]        <1> 	mov	edi, Cmd_Exit
  1747 0000822D E83A030000          <1> 	call	cmp_cmd	
  1748 00008232 7208                <1> 	jc	short cmp_cmd_date
  1749                              <1> 
  1750 00008234 C605[38800100]01    <1>         mov     byte [Program_Exit], 1
  1751 0000823B C3                  <1>         retn
  1752                              <1> 
  1753                              <1> cmp_cmd_date:
  1754 0000823C B104                <1> 	mov	cl, 4
  1755 0000823E BF[23310100]        <1> 	mov	edi, Cmd_Date
  1756 00008243 E824030000          <1> 	call	cmp_cmd	
  1757 00008248 720A                <1>         jc	short cmp_cmd_time
  1758                              <1> 	
  1759 0000824A E806F8FFFF          <1> 	call	show_date
  1760                              <1> 	;call	set_date
  1761                              <1> 	;retn
  1762                              <1> 	; 26/07/2022
  1763 0000824F E944F8FFFF          <1> 	jmp	set_date
  1764                              <1> 
  1765                              <1> cmp_cmd_time:
  1766 00008254 B104                <1> 	mov	cl, 4
  1767 00008256 BF[28310100]        <1> 	mov	edi, Cmd_Time
  1768 0000825B E80C030000          <1>    	call	cmp_cmd	
  1769 00008260 720A                <1> 	jc	short cmp_cmd_show
  1770                              <1> 
  1771 00008262 E894FAFFFF          <1> 	call	show_time
  1772                              <1> 	;call	set_time
  1773                              <1> 	;retn
  1774                              <1> 	; 26/07/2022
  1775 00008267 E9C5FAFFFF          <1> 	jmp	set_time
  1776                              <1> 
  1777                              <1> cmp_cmd_show:
  1778 0000826C B104                <1> 	mov	cl, 4
  1779 0000826E BF[39310100]        <1> 	mov	edi, Cmd_Show
  1780 00008273 E8F4020000          <1>    	call	cmp_cmd	
  1781                              <1>         ;jnc	show_file
  1782                              <1> 	; 26/07/2022
  1783 00008278 7205                <1> 	jc	short cmp_cmd_echo
  1784 0000827A E946090000          <1> 	jmp	show_file
  1785                              <1> 
  1786                              <1> cmp_cmd_echo:
  1787 0000827F B104                <1> 	mov	cl, 4
  1788 00008281 BF[75310100]        <1> 	mov	edi, Cmd_Echo
  1789 00008286 E8E1020000          <1>    	call	cmp_cmd	
  1790 0000828B 7224                <1> 	jc	short cmp_cmd_copy
  1791                              <1> 	
  1792                              <1> 	; 22/11/2017
  1793                              <1> 	; AL = 0
  1794 0000828D 803E20              <1> 	cmp	byte [esi], 20h
  1795 00008290 7215                <1> 	jb	short cmd_echo_nextline
  1796                              <1> 	; 14/04/2016
  1797 00008292 56                  <1> 	push	esi
  1798                              <1> cmd_echo_asciiz:
  1799                              <1> 	;inc	esi
  1800                              <1> 	;mov	al, [esi]
  1801                              <1> 	; 22/11/2017
  1802 00008293 AC                  <1> 	lodsb
  1803 00008294 3C20                <1> 	cmp	al, 20h
  1804 00008296 73FB                <1> 	jnb	short cmd_echo_asciiz
  1805 00008298 4E                  <1> 	dec	esi
  1806 00008299 C60600              <1> 	mov	byte [esi], 0
  1807 0000829C 5E                  <1> 	pop	esi
  1808 0000829D 89F7                <1> 	mov	edi, esi
  1809 0000829F E8B6E9FFFF          <1> 	call	print_msg
  1810 000082A4 C60700              <1> 	mov	byte [edi], 0	
  1811                              <1> cmd_echo_nextline:
  1812 000082A7 BE[893B0100]        <1> 	mov	esi, NextLine
  1813                              <1> 	;call	print_msg   
  1814                              <1> 	;retn
  1815 000082AC E9A9E9FFFF          <1> 	jmp	print_msg
  1816                              <1> 
  1817                              <1> cmp_cmd_copy:
  1818 000082B1 B104                <1> 	mov	cl, 4
  1819 000082B3 BF[5C310100]        <1> 	mov	edi, Cmd_Copy
  1820 000082B8 E8AF020000          <1>    	call	cmp_cmd	
  1821                              <1> 	;jnc	copy_file
  1822                              <1> 	; 26/07/2022
  1823 000082BD 7205                <1> 	jc	short cmp_cmd_move
  1824 000082BF E9AA160000          <1> 	jmp	copy_file
  1825                              <1> 
  1826                              <1> cmp_cmd_move:
  1827 000082C4 B104                <1> 	mov	cl, 4
  1828 000082C6 BF[61310100]        <1> 	mov	edi, Cmd_Move
  1829 000082CB E89C020000          <1>    	call	cmp_cmd	
  1830                              <1> 	;jnc	move_file
  1831                              <1> 	; 26/07/2022
  1832 000082D0 7205                <1> 	jc	short cmp_cmd_path
  1833 000082D2 E955150000          <1> 	jmp	move_file
  1834                              <1> 
  1835                              <1> cmp_cmd_path:
  1836 000082D7 B104                <1> 	mov	cl, 4
  1837 000082D9 BF[66310100]        <1> 	mov	edi, Cmd_Path
  1838 000082DE E889020000          <1>    	call	cmp_cmd	
  1839                              <1> 	;jnc	set_get_path
  1840                              <1> 	; 26/07/2022
  1841 000082E3 7205                <1> 	jc	short cmp_cmd_beep
  1842 000082E5 E9C1180000          <1> 	jmp	set_get_path
  1843                              <1> 
  1844                              <1> cmp_cmd_beep:
  1845 000082EA B104                <1> 	mov	cl, 4
  1846 000082EC BF[93310100]        <1> 	mov	edi, Cmd_Beep
  1847 000082F1 E876020000          <1>    	call	cmp_cmd	
  1848 000082F6 720B                <1> 	jc	short cmp_cmd_find
  1849                              <1> 	; 13/05/2016
  1850 000082F8 8A3D[B6770100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
  1851 000082FE E93FA0FFFF          <1> 	jmp	beeper
  1852                              <1> 
  1853                              <1> cmp_cmd_find:
  1854 00008303 B104                <1> 	mov	cl, 4
  1855 00008305 BF[70310100]        <1> 	mov	edi, Cmd_Find
  1856 0000830A E85D020000          <1>    	call	cmp_cmd	
  1857                              <1>         ;jc	cmp_cmd_external
  1858                              <1> 	; 26/07/2022
  1859 0000830F 7305                <1> 	jnc	short c4_find
  1860 00008311 E939020000          <1> 	jmp	cmp_cmd_external
  1861                              <1> c4_find:
  1862                              <1> 	;call	find_and_list_files
  1863 00008316 E922210000          <1> 	jmp	find_and_list_files
  1864                              <1> 	;retn
  1865                              <1> 
  1866                              <1> c_1:
  1867 0000831B AD                  <1> 	lodsd
  1868                              <1> cmp_cmd_help:
  1869 0000831C 3C3F                <1> 	cmp	al, '?'
  1870 0000831E 751D                <1>         jne     short cmp_cmd_remark
  1871                              <1> 
  1872 00008320 BE[F9300100]        <1> 	mov	esi, Command_List
  1873                              <1> cmd_help_next_w:
  1874 00008325 E830E9FFFF          <1> 	call	print_msg
  1875                              <1> 
  1876 0000832A 803E20              <1> 	cmp	byte [esi], 20h ; 0
  1877 0000832D 7233                <1> 	jb	short cmd_help_retn
  1878                              <1> 	
  1879 0000832F 56                  <1> 	push	esi
  1880 00008330 BE[1B3B0100]        <1> 	mov	esi, nextline
  1881 00008335 E820E9FFFF          <1> 	call	print_msg
  1882 0000833A 5E                  <1> 	pop	esi
  1883 0000833B EBE8                <1> 	jmp	short cmd_help_next_w	
  1884                              <1> 
  1885                              <1> cmp_cmd_remark:
  1886 0000833D 3C2A                <1> 	cmp	al, '*'
  1887                              <1> 	;jne	cmp_cmd_external
  1888                              <1> 	; 26/07/2022
  1889 0000833F 7405                <1> 	je	short cmp_cmd_rem
  1890 00008341 E909020000          <1> 	jmp	cmp_cmd_external
  1891                              <1> cmp_cmd_rem:
  1892 00008346 46                  <1> 	inc	esi
  1893 00008347 BF[AC780100]        <1> 	mov	edi, Remark
  1894 0000834C 8A06                <1> 	mov	al, [esi]
  1895 0000834E 3C20                <1> 	cmp	al, 20h
  1896 00008350 7707                <1> 	ja	short cmd_remark_write
  1897 00008352 89FE                <1> 	mov	esi, edi ; Remark
  1898 00008354 E901E9FFFF          <1> 	jmp	print_msg
  1899                              <1> 
  1900                              <1> cmd_remark_write:
  1901 00008359 AA                  <1> 	stosb
  1902 0000835A AC                  <1> 	lodsb
  1903 0000835B 3C20                <1> 	cmp	al, 20h
  1904 0000835D 73FA                <1> 	jnb	short cmd_remark_write
  1905 0000835F C60700              <1> 	mov	byte [edi], 0
  1906                              <1> 
  1907                              <1> cmd_help_retn:
  1908                              <1> cmd_remark_retn:
  1909                              <1> cd_retn:
  1910 00008362 C3                  <1> 	retn
  1911                              <1> c_2:
  1912                              <1> 	; 26/07/2022
  1913 00008363 BE[FA780100]        <1> 	mov	esi, CommandBuffer
  1914 00008368 80F902              <1> 	cmp	cl, 2
  1915                              <1> 	;ja	c_3
  1916                              <1> 	;mov	esi, CommandBuffer
  1917 0000836B 72AE                <1> 	jb	short c_1
  1918                              <1> 	; 26/07/2022
  1919                              <1> 	;jne	short c_1
  1920                              <1> 
  1921                              <1> cmp_cmd_cd:
  1922 0000836D 66AD                <1> 	lodsw
  1923 0000836F 663D4344            <1> 	cmp	ax, 'CD'
  1924 00008373 754E                <1> 	jne	short cmp_cmd_drive
  1925 00008375 46                  <1>         inc	esi
  1926                              <1> cd_0:
  1927 00008376 668B06              <1> 	mov	ax, [esi]	
  1928 00008379 3C20                <1> 	cmp	al, 20h
  1929 0000837B 76E5                <1> 	jna	short cd_retn
  1930                              <1> 	; 10/02/2016
  1931 0000837D 80FC3A              <1> 	cmp	ah, ':'
  1932 00008380 7504                <1> 	jne	short cd_1
  1933 00008382 46                  <1> 	inc	esi
  1934 00008383 46                  <1> 	inc	esi
  1935 00008384 EB47                <1> 	jmp	short cd_2
  1936                              <1> 
  1937                              <1> cd_1:	; change current directory
  1938                              <1> 	; 29/11/2009
  1939                              <1> 	; AH = CDh	; to separate 'CD' command from others
  1940                              <1> 			; for restoring current directory
  1941                              <1> 			; 0CDh sign is for saving cdir into 
  1942                              <1> 			; DOS drv description table cdir area
  1943                              <1> 	
  1944 00008386 B4CD                <1> 	mov	ah, 0CDh ; mov byte [CD_COMMAND], 0CDh 
  1945                              <1> 
  1946 00008388 E88B210000          <1> 	call	change_current_directory
  1947                              <1> 	;jnc	change_prompt_dir_string
  1948                              <1> 	; 26/07/2022
  1949 0000838D 7205                <1> 	jc	short cd_error_messages
  1950 0000838F E9AD200000          <1> 	jmp	change_prompt_dir_string
  1951                              <1> 
  1952                              <1> cd_error_messages:
  1953 00008394 3C03                <1> 	cmp	al, 3
  1954 00008396 740C                <1> 	je	short cd_path_not_found
  1955                              <1> 	; 16/10/2016 (15h -> 15)
  1956 00008398 3C0F                <1> 	cmp	al, 15 ; drive not ready error 
  1957 0000839A 7453                <1> 	je	short cd_drive_not_ready
  1958 0000839C 3C11                <1> 	cmp	al, 17 ; read error
  1959 0000839E 744F                <1> 	je	short cd_drive_not_ready	
  1960 000083A0 3C13                <1> 	cmp	al, 19 ; ; Bad directory/path name 
  1961 000083A2 7460                <1> 	je	short cd_command_failed
  1962                              <1> 
  1963                              <1> cd_path_not_found:
  1964 000083A4 50                  <1> 	push	eax ; 29/12/2017
  1965                              <1> 	;push	ax	
  1966 000083A5 BE[9C330100]        <1> 	mov	esi, Msg_Dir_Not_Found
  1967 000083AA E8ABE8FFFF          <1> 	call	print_msg
  1968                              <1> 	;pop	ax
  1969 000083AF 58                  <1> 	pop	eax ; 29/12/2017
  1970 000083B0 3A25[48780100]      <1> 	cmp	ah, [Current_Dir_Level]
  1971                              <1>         ;jnb	change_prompt_dir_string
  1972                              <1> 	; 26/07/2022
  1973 000083B6 7306                <1> 	jnb	short cd_cpds
  1974 000083B8 8825[48780100]      <1> 	mov	[Current_Dir_Level], ah
  1975                              <1> cd_cpds:
  1976 000083BE E97E200000          <1>         jmp     change_prompt_dir_string
  1977                              <1> 
  1978                              <1> cmp_cmd_drive: ; change current drive
  1979                              <1> 	; C:, D:, E: etc.
  1980 000083C3 80FC3A              <1> 	cmp	ah, ':'
  1981                              <1> 	;jne	cmp_cmd_external
  1982                              <1> 	; 26/07/2022
  1983 000083C6 7405                <1> 	je	short cd_2
  1984                              <1> cmd_ext:
  1985 000083C8 E982010000          <1> 	jmp	cmp_cmd_external
  1986                              <1> 
  1987                              <1> cd_2:	; 'CD C:', 'CD D:' ...
  1988 000083CD 803E20              <1> 	cmp	byte [esi], 20h
  1989                              <1> 	;ja	loc_cmd_failed
  1990                              <1> 	; 26/07/2022
  1991 000083D0 7706                <1> 	ja	short cd_failed
  1992 000083D2 24DF                <1> 	and	al, 0DFh
  1993 000083D4 2C41                <1> 	sub	al, 'A'
  1994                              <1> 	;jc	loc_cmd_failed
  1995                              <1> 	; 26/07/2022
  1996 000083D6 7305                <1> 	jnc	short cd_3
  1997                              <1> cd_failed:
  1998 000083D8 E97C010000          <1> 	jmp	loc_cmd_failed
  1999                              <1> cd_3:
  2000 000083DD 3A05[91300100]      <1>         cmp     al, [Last_DOS_DiskNo]
  2001 000083E3 770A                <1>         ja	short cd_drive_not_ready
  2002                              <1> 	
  2003 000083E5 88C2                <1> 	mov	dl, al
  2004 000083E7 E8A6F3FFFF          <1> 	call 	change_current_drive
  2005 000083EC 7201                <1> 	jc	short cd_drive_not_ready	
  2006 000083EE C3                  <1> 	retn
  2007                              <1> 
  2008                              <1> cd_drive_not_ready:
  2009 000083EF BE[59330100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  2010 000083F4 E861E8FFFF          <1> 	call	print_msg
  2011                              <1> 
  2012                              <1> cd_fail_drive_restart:
  2013 000083F9 8A15[4A780100]      <1> 	mov	dl, [Current_Drv]
  2014                              <1> 	;call 	change_current_drive
  2015 000083FF E98EF3FFFF          <1>         jmp     change_current_drive
  2016                              <1> 	;retn
  2017                              <1> 
  2018                              <1> cd_command_failed:
  2019 00008404 BE[3A330100]        <1> 	mov	esi, Msg_Bad_Command
  2020 00008409 E84CE8FFFF          <1> 	call	print_msg
  2021 0000840E EBE9                <1> 	jmp	short cd_fail_drive_restart
  2022                              <1> 
  2023                              <1> c_5:
  2024                              <1> cmp_cmd_mkdir:
  2025 00008410 BF[56310100]        <1> 	mov	edi, Cmd_Mkdir
  2026 00008415 E852010000          <1> 	call	cmp_cmd	
  2027                              <1> 	;jnc	make_directory
  2028                              <1> 	; 26/07/2022
  2029 0000841A 7205                <1> 	jc	short cmp_cmd_rmdir
  2030 0000841C E95C0A0000          <1> 	jmp	make_directory
  2031                              <1> 
  2032                              <1> cmp_cmd_rmdir:
  2033 00008421 B105                <1> 	mov	cl, 5
  2034 00008423 BF[50310100]        <1> 	mov	edi, Cmd_Rmdir
  2035 00008428 E83F010000          <1> 	call	cmp_cmd	
  2036                              <1> 	;jnc	delete_directory
  2037                              <1> 	; 26/07/2022
  2038 0000842D 7205                <1> 	jc	short cmp_cmd_chdir
  2039 0000842F E9650B0000          <1> 	jmp	delete_directory
  2040                              <1> 
  2041                              <1> cmp_cmd_chdir:
  2042 00008434 B105                <1> 	mov	cl, 5
  2043 00008436 BF[8D310100]        <1> 	mov	edi, Cmd_Chdir
  2044 0000843B E82C010000          <1> 	call	cmp_cmd	
  2045                              <1> 	;jc	cmp_cmd_external
  2046                              <1> 	; 26/07/2022
  2047 00008440 7286                <1> 	jc	short cmd_ext
  2048                              <1> 
  2049 00008442 E92FFFFFFF          <1> 	jmp	cd_0
  2050                              <1> 
  2051                              <1> c_6:
  2052 00008447 80F906              <1> 	cmp	cl, 6
  2053                              <1> 	;ja	c_8
  2054                              <1> 	; 26/07/2022
  2055 0000844A 72C4                <1> 	jb	short c_5
  2056 0000844C 7405                <1> 	je	short cmd_6
  2057 0000844E E9E4000000          <1> 	jmp	c_8
  2058                              <1> 
  2059                              <1> cmd_6:
  2060                              <1> cmp_cmd_prompt:
  2061 00008453 BF[0C310100]        <1> 	mov	edi, Cmd_Prompt
  2062 00008458 E80F010000          <1> 	call	cmp_cmd	
  2063 0000845D 722F                <1>         jc	short cmp_cmd_volume
  2064                              <1> get_prompt_name_fchar:
  2065 0000845F AC                  <1> 	lodsb
  2066 00008460 3C20                <1> 	cmp	al, 20h
  2067 00008462 74FB                <1> 	je	short get_prompt_name_fchar
  2068 00008464 7713                <1> 	ja	short loc_change_prompt_label
  2069                              <1> default_command_prompt: ; 31/12/2017 ('sysprompt')
  2070 00008466 BE[ED300100]        <1> 	mov	esi, TRDOSPromptLabel
  2071 0000846B C7065452444F        <1> 	mov	dword [esi], "TRDO"
  2072 00008471 66C746045300        <1>        	mov	word [esi+4], "S" 
  2073                              <1> loc_cmd_prompt_return:
  2074 00008477 C3                  <1> 	retn
  2075                              <1> 
  2076                              <1> set_command_prompt: ; 31/12/2017 ('sysprompt')
  2077 00008478 AC                  <1> 	lodsb
  2078                              <1> loc_change_prompt_label:
  2079                              <1> 	;mov	cx, 11
  2080                              <1> 	; 26/07/2022
  2081 00008479 29C9                <1> 	sub	ecx, ecx
  2082 0000847B B10B                <1> 	mov	cl, 11
  2083 0000847D BF[ED300100]        <1> 	mov	edi, TRDOSPromptLabel
  2084                              <1> put_char_new_prompt_label:
  2085 00008482 AA                  <1> 	stosb
  2086 00008483 AC                  <1> 	lodsb
  2087 00008484 3C20                <1> 	cmp	al, 20h
  2088 00008486 7202                <1> 	jb	short pass_put_new_prompt_label
  2089 00008488 E2F8                <1> 	loop	put_char_new_prompt_label
  2090                              <1> pass_put_new_prompt_label:
  2091 0000848A C60700              <1> 	mov	byte [edi], 0
  2092 0000848D C3                  <1> 	retn
  2093                              <1> 
  2094                              <1> cmp_cmd_volume:
  2095 0000848E B106                <1> 	mov	cl, 6
  2096 00008490 BF[13310100]        <1> 	mov	edi, Cmd_Volume
  2097 00008495 E8D2000000          <1> 	call	cmp_cmd	
  2098 0000849A 7259                <1>         jc	short cmp_cmd_attrib
  2099                              <1> 
  2100                              <1> cmd_vol1:
  2101 0000849C AC                  <1> 	lodsb
  2102 0000849D 3C20                <1> 	cmp	al, 20h
  2103 0000849F 7707                <1> 	ja	short cmd_vol2
  2104 000084A1 A0[4A780100]        <1> 	mov	al, [Current_Drv]
  2105 000084A6 EB41                <1> 	jmp	short cmd_vol4
  2106                              <1> cmd_vol2:
  2107 000084A8 3C41                <1> 	cmp	al, 'A'
  2108                              <1> 	;jb	loc_cmd_failed
  2109                              <1> 	; 26/07/2022
  2110 000084AA 722D                <1> 	jb	short cmd_vol_failed_1
  2111 000084AC 3C7A                <1> 	cmp	al, 'z'
  2112                              <1> 	;ja	loc_cmd_failed
  2113                              <1> 	; 26/07/2022
  2114 000084AE 7731                <1> 	ja	short cmd_vol_failed_2
  2115 000084B0 3C5A                <1> 	cmp	al, 'Z'
  2116 000084B2 7606                <1> 	jna	short cmd_vol3
  2117 000084B4 3C61                <1> 	cmp	al, 'a'
  2118                              <1>         ;jb	loc_cmd_failed
  2119                              <1> 	; 26/07/2022
  2120 000084B6 722B                <1> 	jb	short cmd_vol_failed_3
  2121 000084B8 24DF                <1> 	and	al, 0DFh
  2122                              <1> cmd_vol3:
  2123 000084BA 8A26                <1> 	mov	ah, [esi]
  2124 000084BC 80FC3A              <1> 	cmp	ah, ':'
  2125 000084BF 0F8594000000        <1>         jne     loc_cmd_failed
  2126 000084C5 2C41                <1> 	sub	al, 'A'
  2127 000084C7 3A05[91300100]      <1>         cmp     al, [Last_DOS_DiskNo]
  2128 000084CD 761A                <1> 	jna	short cmd_vol4
  2129                              <1> 
  2130 000084CF BE[59330100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  2131 000084D4 E981E7FFFF          <1> 	jmp	print_msg
  2132                              <1> 
  2133                              <1> 	; 26/07/2022
  2134                              <1> 	; (numeric characters and underscore are allowed)
  2135                              <1> cmd_vol_failed_1:
  2136                              <1> 	; check for numeric characters
  2137 000084D9 3C30                <1> 	cmp	al, '0'
  2138 000084DB 7204                <1> 	jb	short cmd_vol_failed_2
  2139 000084DD 3C39                <1> 	cmp	al, '9'
  2140 000084DF 76D9                <1> 	jna	short cmd_vol3
  2141                              <1> cmd_vol_failed_2:		
  2142 000084E1 EB76                <1> 	jmp	loc_cmd_failed
  2143                              <1> cmd_vol_failed_3:
  2144 000084E3 3C5F                <1> 	cmp	al, '_' ; underline ?
  2145 000084E5 74D3                <1> 	je	short cmd_vol3 ; is ok..
  2146 000084E7 EBF8                <1> 	jmp	short cmd_vol_failed_2
  2147                              <1> 
  2148                              <1> cmd_vol4:
  2149 000084E9 E889FAFFFF          <1> 	call	print_volume_info
  2150                              <1> 	;jc	cd_drive_not_ready
  2151                              <1> 	; 26/07/2022
  2152 000084EE 7339                <1> 	jnc	short cmd_vol5
  2153 000084F0 E9FAFEFFFF          <1> 	jmp	cd_drive_not_ready	
  2154                              <1> ;cmd_vol5:
  2155                              <1> ;	retn
  2156                              <1> 
  2157                              <1> cmp_cmd_attrib:
  2158 000084F5 B106                <1> 	mov	cl, 6
  2159 000084F7 BF[42310100]        <1> 	mov	edi, Cmd_Attrib
  2160 000084FC E86B000000          <1> 	call	cmp_cmd	
  2161                              <1> 	;jnc	set_file_attributes
  2162                              <1> 	; 26/07/2022
  2163 00008501 7205                <1> 	jc	short cmp_cmd_rename
  2164 00008503 E9B80E0000          <1> 	jmp	set_file_attributes
  2165                              <1> 
  2166                              <1> cmp_cmd_rename:
  2167 00008508 B106                <1> 	mov	cl, 6
  2168 0000850A BF[49310100]        <1> 	mov	edi, Cmd_Rename
  2169 0000850F E858000000          <1> 	call	cmp_cmd	
  2170                              <1> 	;jnc	rename_file
  2171                              <1> 	; 26/07/2022
  2172 00008514 7205                <1> 	jc	short cmp_cmd_device
  2173 00008516 E9D6100000          <1> 	jmp	rename_file
  2174                              <1> 
  2175                              <1> cmp_cmd_device:
  2176 0000851B B106                <1> 	mov	cl, 6
  2177 0000851D BF[7E310100]        <1> 	mov	edi, Cmd_Device
  2178 00008522 E845000000          <1> 	call	cmp_cmd	
  2179 00008527 7226                <1> 	jc	short cmp_cmd_external
  2180                              <1> 	; 26/07/2022
  2181                              <1> cmd_vol5:
  2182                              <1> cmd_dev:
  2183 00008529 C3                  <1> 	retn
  2184                              <1> 
  2185                              <1> c_7:
  2186                              <1> cmp_cmd_devlist:
  2187 0000852A BF[85310100]        <1> 	mov	edi, Cmd_DevList
  2188 0000852F E838000000          <1> 	call	cmp_cmd	
  2189 00008534 7219                <1>         jc	short cmp_cmd_external
  2190                              <1> 
  2191                              <1> loc_cmd_return:
  2192 00008536 C3                  <1> 	retn
  2193                              <1> 
  2194                              <1> c_8:
  2195 00008537 80F908              <1>         cmp	cl, 8
  2196 0000853A 7713                <1> 	ja	short cmp_cmd_external
  2197 0000853C 72EC                <1> 	jb	short c_7
  2198                              <1> 
  2199                              <1> cmp_cmd_longname:
  2200 0000853E BF[1A310100]        <1> 	mov	edi, Cmd_LongName
  2201 00008543 E824000000          <1> 	call	cmp_cmd	
  2202                              <1> 	;jnc	get_and_print_longname
  2203                              <1> 	; 26/07/2022
  2204 00008548 7205                <1> 	jc	short cmp_cmd_external
  2205 0000854A E923060000          <1> 	jmp	get_and_print_longname
  2206                              <1> 
  2207                              <1> cmp_cmd_external:
  2208                              <1> 	; 07/05/2016
  2209                              <1> 	; 22/04/2016
  2210 0000854F BE[FA780100]        <1> 	mov	esi, CommandBuffer
  2211 00008554 E9EB1B0000          <1> 	jmp	loc_run_check_filename 
  2212                              <1> 
  2213                              <1> loc_cmd_failed:
  2214 00008559 803D[FA780100]20    <1> 	cmp	byte [CommandBuffer], 20h
  2215 00008560 76D4                <1> 	jna	short loc_cmd_return
  2216 00008562 BE[3A330100]        <1> 	mov	esi, Msg_Bad_Command
  2217                              <1> ;	call	print_msg
  2218                              <1> ;loc_cmd_return:
  2219                              <1> ;	retn
  2220 00008567 E9EEE6FFFF          <1> 	jmp	print_msg
  2221                              <1> 
  2222                              <1> cmp_cmd:
  2223                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
  2224                              <1> 	; 29/01/2016 (TRDOS 386 = TRDOS v2.0)
  2225 0000856C BE[FA780100]        <1>         mov	esi, CommandBuffer
  2226                              <1>         ; edi = internal command word (ASCIIZ)
  2227                              <1> 	; ecx = command length (<=8)
  2228                              <1> cmp_cmd_1:
  2229 00008571 AC                  <1> 	lodsb
  2230 00008572 AE                  <1> 	scasb
  2231 00008573 750D                <1> 	jne	short cmp_cmd_3
  2232 00008575 E2FA                <1> 	loop	cmp_cmd_1
  2233 00008577 AC                  <1>  	lodsb
  2234 00008578 3C20                <1> 	cmp	al, 20h
  2235 0000857A 7703                <1> 	ja	short cmp_cmd_2
  2236 0000857C 30C0                <1> 	xor	al, al
  2237                              <1> 	; ZF = 1 -> internal command word matches
  2238 0000857E C3                  <1> 	retn
  2239                              <1> cmp_cmd_2:
  2240                              <1> 	; ZF = 0 (CF = 0) -> external command word 	
  2241 0000857F 58                  <1> 	pop	eax ; no return to the caller from here 
  2242 00008580 EBCD                <1> 	jmp	short cmp_cmd_external  ; 26/07/2022	
  2243                              <1> cmp_cmd_3:
  2244 00008582 F9                  <1> 	stc
  2245                              <1> 	; CF = 1 -> internal command word does not match
  2246 00008583 C3                  <1> 	retn
  2247                              <1> 
  2248                              <1> loc_run_cmd_failed:
  2249                              <1> 	; 26/07/2022 (TRDOS 386 Kernel v2.0.5)
  2250                              <1> 	; 15/03/2016
  2251                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  2252                              <1> 	; 07/12/2009 (CMD_INTR.ASM)	
  2253                              <1> 	; 29/11/2009
  2254                              <1> 
  2255 00008584 E863000000          <1> 	call	restore_cdir_after_cmd_fail
  2256                              <1> 
  2257                              <1> loc_run_cmd_failed_cmp_al:
  2258                              <1> 	; End of Restore_CDIR code (29/11/2009)
  2259                              <1> 
  2260 00008589 3C01                <1> 	cmp	al, 1 ; Bad command or file name
  2261 0000858B 74CC                <1> 	je	short loc_cmd_failed ; 26/07/2022
  2262                              <1> loc_run_dir_not_found:
  2263 0000858D 3C03                <1> 	cmp	al, 3
  2264 0000858F 750A                <1> 	jne	short loc_run_file_notfound_msg
  2265                              <1> 	; Path not found (MS-DOS Error Code = 3)
  2266 00008591 BE[9C330100]        <1> 	mov	esi, Msg_Dir_Not_Found
  2267 00008596 E9BFE6FFFF          <1> 	jmp	print_msg
  2268                              <1> 
  2269                              <1> loc_run_file_notfound_msg:
  2270 0000859B 3C02                <1> 	cmp	al, 2 ; File not found
  2271 0000859D 750A                <1> 	jne	short loc_run_file_drv_read_err
  2272                              <1> 
  2273                              <1> loc_print_file_notfound_msg: 
  2274 0000859F BE[B3330100]        <1>         mov     esi, Msg_File_Not_Found
  2275                              <1> 	;call	proc_printmsg
  2276                              <1> 	;retn
  2277 000085A4 E9B1E6FFFF          <1> 	jmp	print_msg
  2278                              <1> 
  2279                              <1> loc_run_file_drv_read_err:
  2280                              <1> 	; Err: 17 (Read fault)
  2281 000085A9 3C11                <1> 	cmp	al, 17 ; Drive not ready or read error
  2282 000085AB 7404                <1> 	je	short loc_run_file_print_drv_read_err
  2283                              <1> 	;
  2284 000085AD 3C0F                <1> 	cmp	al, 15 ; Drive not ready (or read error)
  2285 000085AF 750A                <1> 	jne	short loc_run_file_toobig
  2286                              <1> 
  2287                              <1> loc_run_file_print_drv_read_err:
  2288 000085B1 BE[59330100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  2289 000085B6 E99FE6FFFF          <1> 	jmp	print_msg
  2290                              <1> 
  2291                              <1> loc_run_file_toobig:
  2292 000085BB 3C08                <1> 	cmp	al, 8 ; Not enough free memory to load&run file
  2293 000085BD 750A                <1> 	jne	short loc_run_file_perm_denied
  2294 000085BF BE[FE330100]        <1> 	mov	esi, Msg_Insufficient_Memory
  2295 000085C4 E991E6FFFF          <1> 	jmp	print_msg
  2296                              <1> 
  2297                              <1> loc_run_file_perm_denied:
  2298                              <1> 	; 29/12/2017
  2299 000085C9 3C0B                <1> 	cmp	al, ERR_PERM_DENIED ; 11 ; Permission denied
  2300 000085CB 750A                <1> 	jne	short loc_run_misc_error
  2301 000085CD BE[92350100]        <1> 	mov	esi, Msg_Permission_Denied
  2302 000085D2 E983E6FFFF          <1> 	jmp	print_msg	
  2303                              <1> 
  2304                              <1> 	; 15/03/2016
  2305                              <1> print_misc_error_msg:
  2306                              <1> loc_run_misc_error:
  2307                              <1> 	; AL = Error code
  2308 000085D7 E857BBFFFF          <1> 	call	bytetohex
  2309 000085DC 66A3[32340100]      <1>         mov     [error_code_hex], ax
  2310                              <1> 	
  2311 000085E2 BE[15340100]        <1> 	mov	esi, Msg_Error_Code 
  2312                              <1> 	;call	print_msg 
  2313                              <1> 	;retn
  2314 000085E7 E96EE6FFFF          <1> 	jmp	print_msg
  2315                              <1> 
  2316                              <1> restore_cdir_after_cmd_fail:
  2317                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  2318 000085EC 50                  <1> 	push	eax
  2319 000085ED 8A3D[A77F0100]      <1> 	mov	bh, [RUN_CDRV] ; it is set at the beginning
  2320                              <1> 				; of the 'run' command.
  2321 000085F3 3A3D[4A780100]      <1> 	cmp	bh, [Current_Drv]
  2322 000085F9 7409                <1> 	je	short loc_run_restore_cdir
  2323 000085FB 88FA                <1> 	mov	dl, bh
  2324 000085FD E890F1FFFF          <1> 	call	change_current_drive 
  2325 00008602 EB19                <1> 	jmp	short loc_run_err_pass_restore_cdir
  2326                              <1> 
  2327                              <1> loc_run_restore_cdir:
  2328 00008604 803D[92300100]00    <1> 	cmp	byte [Restore_CDIR], 0
  2329 0000860B 7610                <1> 	jna	short loc_run_err_pass_restore_cdir
  2330 0000860D 30DB                <1> 	xor	bl, bl
  2331 0000860F 0FB7F3              <1> 	movzx	esi, bx
  2332 00008612 81C600010900        <1> 	add	esi, Logical_DOSDisks
  2333 00008618 E82BF2FFFF          <1> 	call	restore_current_directory
  2334                              <1> 
  2335                              <1> loc_run_err_pass_restore_cdir:
  2336 0000861D 58                  <1> 	pop	eax
  2337 0000861E C3                  <1> 	retn
  2338                              <1> 
  2339                              <1> print_directory_list:
  2340                              <1> 	; 07/08/2022
  2341                              <1> 	; 27/07/2022 (TRDOS 386 Kernel v2.0.5)
  2342                              <1> 	; 10/02/2016
  2343                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  2344                              <1> 	; 06/12/2009 ('cmp_cmd_dir')	
  2345                              <1> 	;
  2346 0000861F 66C705[E8800100]00- <1> 	mov	word [AttributesMask], 0800h ; ..except volume names..
  2346 00008627 08                  <1>
  2347 00008628 A0[4A780100]        <1> 	mov	al, [Current_Drv]
  2348 0000862D A2[A77F0100]        <1> 	mov	[RUN_CDRV], al
  2349                              <1> get_dfname_fchar:
  2350 00008632 AC                  <1> 	lodsb
  2351 00008633 3C20                <1> 	cmp	al, 20h
  2352 00008635 74FB                <1> 	je	short get_dfname_fchar
  2353 00008637 0F82E0000000        <1>         jb      loc_print_dir_call_all
  2354 0000863D 3C2D                <1> 	cmp	al, '-'
  2355 0000863F 753C                <1> 	jne	short loc_print_dir_call_flt
  2356                              <1> get_next_attr_char:
  2357 00008641 AC                  <1> 	lodsb
  2358 00008642 3C20                <1> 	cmp	al, 20h
  2359 00008644 74FB                <1> 	je	short get_next_attr_char
  2360                              <1> 	;jb	loc_cmd_failed
  2361                              <1> 	; 27/07/2022
  2362 00008646 7305                <1> 	jnb	short pdl_1
  2363                              <1> pdl_0:
  2364 00008648 E90CFFFFFF          <1> 	jmp	loc_cmd_failed
  2365                              <1> pdl_1:
  2366 0000864D 24DF                <1> 	and	al, 0DFh
  2367 0000864F 3C44                <1> 	cmp	al, 'D' ; directories only ?
  2368 00008651 750E                <1> 	jne	short pass_only_directories
  2369 00008653 AC                  <1> 	lodsb
  2370 00008654 3C20                <1> 	cmp	al, 20h
  2371                              <1> 	;ja	loc_cmd_failed
  2372                              <1> 	; 27/07/2022
  2373 00008656 77F0                <1> 	ja	short pdl_0
  2374 00008658 800D[E8800100]10    <1> 	or	byte [AttributesMask], 10h ; ..directory..
  2375 0000865F EB10                <1> 	jmp	short get_dfname_fchar_attr
  2376                              <1> pass_only_directories:
  2377 00008661 3C46                <1> 	cmp	al, 'F'	; files only ?
  2378 00008663 7530                <1> 	jne	short check_attr_s ; 27/07/2022
  2379 00008665 AC                  <1> 	lodsb
  2380 00008666 3C20                <1> 	cmp	al, 20h
  2381                              <1> 	;ja	loc_cmd_failed
  2382                              <1> 	; 27/07/2022
  2383 00008668 77DE                <1> 	ja	short pdl_0
  2384 0000866A 800D[E9800100]10    <1> 	or	byte [AttributesMask+1], 10h ; ..except directories..
  2385                              <1> get_dfname_fchar_attr:
  2386 00008671 AC                  <1> 	lodsb
  2387 00008672 3C20                <1> 	cmp	al, 20h
  2388 00008674 74FB                <1> 	je	short get_dfname_fchar_attr
  2389                              <1> 	;jb	short loc_print_dir_call_all
  2390                              <1> 	; 07/08/2022
  2391 00008676 7305                <1> 	jnb	short loc_print_dir_call_flt
  2392 00008678 E9A0000000          <1> 	jmp	loc_print_dir_call_all
  2393                              <1> loc_print_dir_call_flt:
  2394 0000867D 4E                  <1> 	dec	esi
  2395 0000867E BF[EA800100]        <1> 	mov	edi, FindFile_Drv
  2396 00008683 E87C240000          <1> 	call	parse_path_name
  2397 00008688 7352                <1>  	jnc	short loc_print_dir_change_drv_1
  2398 0000868A 3C01                <1> 	cmp	al, 1
  2399                              <1> 	;ja	loc_run_cmd_failed
  2400                              <1> 	; 27/07/2022
  2401 0000868C 764E                <1> 	jna	short loc_print_dir_change_drv_1
  2402                              <1> pdl_2:
  2403 0000868E E9F1FEFFFF          <1> 	jmp	loc_run_cmd_failed
  2404                              <1> 
  2405                              <1> 	; 27/07/2022
  2406                              <1> check_attr_s_cap:
  2407 00008693 24DF                <1> 	and	al, 0DFh
  2408                              <1> check_attr_s:
  2409 00008695 3C53                <1> 	cmp	al, 'S'
  2410 00008697 7510                <1> 	jne	short pass_attr_s
  2411 00008699 800D[E8800100]04    <1> 	or	byte [AttributesMask], 4 ; system
  2412 000086A0 AC                  <1> 	lodsb
  2413 000086A1 3C20                <1> 	cmp	al, 20h
  2414 000086A3 74CC                <1> 	je	short get_dfname_fchar_attr
  2415 000086A5 7276                <1> 	jb	short loc_print_dir_call_all
  2416 000086A7 24DF                <1> 	and	al, 0DFh
  2417                              <1> pass_attr_s:
  2418 000086A9 3C48                <1> 	cmp	al, 'H'
  2419 000086AB 7510                <1> 	jne	short pass_attr_h
  2420 000086AD 800D[E8800100]02    <1> 	or	byte [AttributesMask], 2 ; hidden
  2421                              <1> pass_attr_shr:
  2422 000086B4 AC                  <1> 	lodsb
  2423 000086B5 3C20                <1> 	cmp	al, 20h
  2424 000086B7 74B8                <1> 	je	short get_dfname_fchar_attr
  2425 000086B9 7262                <1> 	jb	short loc_print_dir_call_all
  2426 000086BB EBD6                <1> 	jmp	short check_attr_s_cap
  2427                              <1> pass_attr_h:
  2428 000086BD 3C52                <1> 	cmp	al, 'R'
  2429 000086BF 7509                <1> 	jne	short pass_attr_r
  2430 000086C1 800D[E8800100]01    <1> 	or	byte [AttributesMask], 1 ; read only
  2431 000086C8 EBEA                <1> 	jmp	short pass_attr_shr
  2432                              <1> pass_attr_r:
  2433 000086CA 3C41                <1> 	cmp	al, 'A'
  2434                              <1> 	;jne	loc_cmd_failed
  2435                              <1> 	; 27/07/2022
  2436 000086CC 7405                <1> 	je	short pass_attr_a
  2437 000086CE E986FEFFFF          <1> 	jmp	loc_cmd_failed
  2438                              <1> pass_attr_a:
  2439 000086D3 800D[E8800100]20    <1> 	or	byte [AttributesMask], 20h ; archive
  2440 000086DA EBD8                <1> 	jmp	short pass_attr_shr
  2441                              <1> 
  2442                              <1> 	; 07/08/2022
  2443                              <1> loc_print_dir_change_drv_1:
  2444 000086DC 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
  2445                              <1> loc_print_dir_change_drv_2:
  2446 000086E2 3A15[A77F0100]      <1> 	cmp	dl, [RUN_CDRV]
  2447 000086E8 7407                <1> 	je	short loc_print_dir_change_directory 
  2448 000086EA E8A3F0FFFF          <1> 	call	change_current_drive
  2449                              <1>         ;jc	loc_run_cmd_failed
  2450                              <1> 	; 27/07/2022
  2451 000086EF 729D                <1> 	jc	short pdl_2
  2452                              <1> loc_print_dir_change_directory:
  2453 000086F1 803D[EB800100]20    <1> 	cmp	byte [FindFile_Directory], 20h ; 0 or 20h ?
  2454 000086F8 7619                <1> 	jna	short pass_print_dir_change_directory
  2455                              <1> 
  2456 000086FA FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  2457 00008700 BE[EB800100]        <1> 	mov	esi, FindFile_Directory
  2458 00008705 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  2459 00008707 E80C1E0000          <1> 	call	change_current_directory
  2460                              <1>         ;jc	loc_run_cmd_failed
  2461                              <1> 	; 27/07/2022
  2462 0000870C 7280                <1> 	jc	short pdl_2
  2463                              <1> 
  2464                              <1> loc_print_dir_change_prompt_dir_string:
  2465 0000870E E82E1D0000          <1> 	call	change_prompt_dir_string
  2466                              <1> 
  2467                              <1> pass_print_dir_change_directory:
  2468 00008713 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  2469 00008718 803E20              <1> 	cmp	byte [esi], 20h ; ; 0 or 20h ?
  2470 0000871B 7706                <1> 	ja	short loc_print_dir_call
  2471                              <1> 
  2472                              <1> loc_print_dir_call_all:
  2473 0000871D C7062A2E2A00        <1> 	mov	dword [esi], '*.*'
  2474                              <1> loc_print_dir_call:
  2475 00008723 E82D000000          <1> 	call	print_directory
  2476                              <1> 
  2477 00008728 8A15[A77F0100]      <1> 	mov	dl, [RUN_CDRV]  ; it is set at the beginning
  2478 0000872E 3A15[4A780100]      <1> 	cmp	dl, [Current_Drv]
  2479 00008734 7405                <1> 	je	short loc_print_dir_call_restore_cdir_retn
  2480                              <1> 	;call	change_current_drive
  2481                              <1> 	;retn
  2482                              <1> 	; 27/07/2022
  2483 00008736 E957F0FFFF          <1> 	jmp	change_current_drive	
  2484                              <1> 
  2485                              <1> loc_print_dir_call_restore_cdir_retn:
  2486 0000873B 803D[92300100]00    <1> 	cmp	byte [Restore_CDIR], 0
  2487 00008742 7610                <1> 	jna	short pass_print_dir_call_restore_cdir_retn
  2488                              <1> 
  2489 00008744 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2490 00008749 31C0                <1> 	xor	eax, eax
  2491 0000874B 88D4                <1> 	mov	ah, dl
  2492 0000874D 01C6                <1> 	add	esi, eax
  2493                              <1> 
  2494                              <1> 	;call	restore_current_directory
  2495                              <1> 	; 27/07/2022
  2496 0000874F E9F4F0FFFF          <1> 	jmp	restore_current_directory
  2497                              <1> 
  2498                              <1> pass_print_dir_call_restore_cdir_retn:
  2499 00008754 C3                  <1> 	retn
  2500                              <1> 
  2501                              <1> print_directory:
  2502                              <1> 	; 27/07/2022 (TRDOS 386 Kernel v2.0.5)
  2503                              <1> 	; 13/05/2016
  2504                              <1> 	; 11/02/2016
  2505                              <1> 	; 10/02/2016
  2506                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  2507                              <1> 	; 30/10/2010 ('proc_print_directory')	
  2508                              <1> 	; 19/09/2009
  2509                              <1> 	; 2005 
  2510                              <1> 	; INPUT ->
  2511                              <1> 	;	ESI = Asciiz File/Dir Name Address
  2512                              <1> 
  2513 00008755 56                  <1> 	push	esi
  2514                              <1> 
  2515 00008756 29C0                <1> 	sub	eax, eax
  2516                              <1> 
  2517 00008758 66A3[74810100]      <1> 	mov	[Dir_Count], ax ; 0
  2518 0000875E 66A3[72810100]      <1> 	mov 	[File_Count], ax ; 0
  2519 00008764 A3[76810100]        <1> 	mov 	[Total_FSize], eax ; 0
  2520                              <1> 
  2521 00008769 E802E5FFFF          <1> 	call    clear_screen
  2522                              <1> 	
  2523 0000876E 31C9                <1> 	xor	ecx, ecx	
  2524 00008770 8A2D[4A780100]      <1> 	mov     ch, [Current_Drv] ; DirBuff_Drv - 'A'
  2525 00008776 A0[4B780100]        <1> 	mov     al, [Current_Dir_Drv] 
  2526 0000877B A2[57320100]        <1> 	mov     [Dir_Drive_Name], al
  2527 00008780 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2528 00008785 01CE                <1> 	add	esi, ecx
  2529                              <1> 
  2530 00008787 E865F9FFFF          <1> 	call	move_volume_name_and_serial_no
  2531 0000878C 730C                <1> 	jnc	short print_dir_strlen_check
  2532                              <1> 
  2533 0000878E 5E                  <1> 	pop	esi
  2534 0000878F 8A3D[B6770100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
  2535                              <1> 	;call	beeper
  2536                              <1> 	;retn
  2537 00008795 E9A89BFFFF          <1> 	jmp	beeper  ; beep ! and return
  2538                              <1> 
  2539                              <1> print_dir_strlen_check:
  2540 0000879A BE[4D780100]        <1> 	mov	esi, Current_Dir_Root
  2541 0000879F BF[F4320100]        <1> 	mov	edi, Dir_Str_Root
  2542                              <1> 	
  2543                              <1> 	;xor	ecx, ecx
  2544 000087A4 8A0D[A9780100]      <1>         mov     cl, [Current_Dir_StrLen]
  2545 000087AA FEC1                <1> 	inc	cl
  2546 000087AC 80F940              <1> 	cmp	cl, 64
  2547 000087AF 760D                <1> 	jna	short pass_print_dir_strlen_shorting
  2548 000087B1 46                  <1> 	inc	esi
  2549 000087B2 01CE                <1> 	add	esi, ecx
  2550 000087B4 83EE40              <1> 	sub	esi, 64 
  2551 000087B7 47                  <1> 	inc	edi
  2552 000087B8 B82E2E2E20          <1> 	mov	eax, '... ' 
  2553 000087BD AB                  <1> 	stosd
  2554                              <1>  
  2555                              <1> pass_print_dir_strlen_shorting:
  2556 000087BE F3A4                <1> 	rep	movsb
  2557                              <1> 
  2558 000087C0 BE[4A320100]        <1> 	mov	esi, Dir_Drive_Str
  2559 000087C5 E890E4FFFF          <1> 	call	print_msg
  2560                              <1> 
  2561 000087CA BE[A9320100]        <1> 	mov	esi, Vol_Serial_Header
  2562 000087CF E886E4FFFF          <1> 	call	print_msg
  2563                              <1> 
  2564 000087D4 BE[E9320100]        <1> 	mov	esi, Dir_Str_Header
  2565 000087D9 E87CE4FFFF          <1> 	call	print_msg
  2566                              <1> 	
  2567 000087DE BE[193B0100]        <1> 	mov	esi, next2line
  2568 000087E3 E872E4FFFF          <1> 	call	print_msg
  2569                              <1> 
  2570                              <1> loc_print_dir_first_file:
  2571 000087E8 C605[89810100]10    <1> 	mov	byte [PrintDir_RowCounter], 16
  2572 000087EF 66A1[E8800100]      <1> 	mov	ax, [AttributesMask]
  2573 000087F5 5E                  <1> 	pop	esi
  2574                              <1> 
  2575 000087F6 E845020000          <1> 	call	find_first_file
  2576                              <1> 	;jc	loc_dir_ok
  2577                              <1> 	; 27/07/2022
  2578 000087FB 7305                <1> 	jnc	short loc_dfname_use_this
  2579 000087FD E97B010000          <1> 	jmp	loc_dir_ok
  2580                              <1> 	 
  2581                              <1> loc_dfname_use_this:
  2582                              <1> 	; bl =	File Attributes (bh = Long Name Entry Length)
  2583 00008802 F6C310              <1> 	test	bl, 10h  ; Is it a directory?
  2584 00008805 741B                <1> 	jz	short loc_not_dir
  2585                              <1> 
  2586 00008807 66FF05[74810100]    <1> 	inc	word [Dir_Count]
  2587 0000880E 89F2                <1> 	mov	edx, esi 	; FindFile_DirEntry address
  2588 00008810 BE[38340100]        <1>  	mov	esi, Type_Dir	; '<DIR>     '
  2589 00008815 BF[4F340100]        <1> 	mov	edi, Dir_Or_FileSize
  2590                              <1> 	; move 10 bytes
  2591 0000881A A5                  <1> 	movsd
  2592 0000881B A5                  <1> 	movsd
  2593 0000881C 66A5                <1> 	movsw	    	
  2594 0000881E 89D6                <1> 	mov	esi, edx
  2595 00008820 EB36                <1> 	jmp     short loc_dir_attribute
  2596                              <1> 
  2597                              <1> loc_not_dir:
  2598 00008822 66FF05[72810100]    <1> 	inc	word [File_Count]
  2599 00008829 0105[76810100]      <1> 	add	[Total_FSize], eax
  2600                              <1> 
  2601 0000882F B90A000000          <1> 	mov	ecx, 10  ; 32 bit divisor
  2602 00008834 89CF                <1> 	mov	edi, ecx
  2603 00008836 81C7[4F340100]      <1> 	add	edi, Dir_Or_FileSize
  2604                              <1> loc_dir_rdivide:
  2605 0000883C 29D2                <1> 	sub	edx, edx
  2606 0000883E F7F1                <1> 	div	ecx 	 ; remainder in dl (< 10)
  2607 00008840 80C230              <1> 	add     dl, '0'	 ; to make visible (ascii)
  2608 00008843 4F                  <1> 	dec	edi
  2609 00008844 8817                <1> 	mov     [edi], dl
  2610 00008846 21C0                <1> 	and	eax, eax
  2611 00008848 75F2                <1> 	jnz	short loc_dir_rdivide
  2612                              <1> 
  2613                              <1> loc_dir_fill_space:
  2614 0000884A 81FF[4F340100]      <1> 	cmp     edi, Dir_Or_FileSize
  2615 00008850 7606                <1> 	jna     short loc_dir_attribute
  2616 00008852 4F                  <1> 	dec     edi
  2617 00008853 C60720              <1> 	mov     byte [edi], 20h
  2618 00008856 EBF2                <1> 	jmp     short loc_dir_fill_space
  2619                              <1> 
  2620                              <1> loc_dir_attribute:
  2621 00008858 C705[5A340100]2020- <1> 	mov	dword [File_Attribute], 20202020h
  2621 00008860 2020                <1>
  2622                              <1> 
  2623 00008862 80FB20              <1> 	cmp	bl, 20h  ; Is it an archive file?
  2624 00008865 7207                <1> 	jb	short loc_dir_pass_arch
  2625 00008867 C605[5D340100]41    <1> 	mov	byte [File_Attribute+3], 'A'
  2626                              <1> 
  2627                              <1> loc_dir_pass_arch:
  2628 0000886E 80E307              <1> 	and	bl, 7
  2629 00008871 7428                <1> 	jz	short loc_dir_file_name
  2630 00008873 88DF                <1> 	mov	bh, bl
  2631 00008875 80E303              <1> 	and	bl, 3
  2632 00008878 38DF                <1> 	cmp	bh, bl
  2633 0000887A 7607                <1> 	jna	short loc_dir_pass_s
  2634 0000887C C605[5A340100]53    <1> 	mov	byte [File_Attribute], 'S'
  2635                              <1> 
  2636                              <1> loc_dir_pass_s:
  2637 00008883 80E302              <1> 	and     bl,2
  2638 00008886 7407                <1> 	jz      short loc_dir_pass_h
  2639 00008888 C605[5B340100]48    <1> 	mov     byte [File_Attribute+1], 'H'
  2640                              <1> loc_dir_pass_h:
  2641 0000888F 80E701              <1> 	and     bh,1
  2642 00008892 7407                <1> 	jz      short loc_dir_file_name
  2643 00008894 C605[5C340100]52    <1> 	mov     byte [File_Attribute+2], 'R'
  2644                              <1> loc_dir_file_name:
  2645                              <1> 	;mov	bx, [esi+18h] ; Date
  2646                              <1> 	;mov	dx, [esi+16h] ; Time
  2647 0000889B 8B5E16              <1> 	mov	ebx, [esi+16h]
  2648 0000889E 89F1                <1> 	mov	ecx, esi ; FindFile_DirEntry address
  2649 000088A0 BF[42340100]        <1> 	mov     edi, File_Name
  2650                              <1> 	; move 8 bytes
  2651 000088A5 A5                  <1> 	movsd
  2652 000088A6 A5                  <1> 	movsd
  2653 000088A7 C60720              <1> 	mov	byte [edi], 20h
  2654 000088AA 47                  <1> 	inc	edi
  2655                              <1> 	; move 3 bytes
  2656 000088AB 66A5                <1> 	movsw
  2657 000088AD A4                  <1> 	movsb
  2658 000088AE 89CE                <1> 	mov	esi, ecx
  2659                              <1> 
  2660                              <1> Dir_Time_start:
  2661                              <1> 	;mov	ax, dx		; Time
  2662 000088B0 6689D8              <1> 	mov	ax, bx
  2663 000088B3 66C1E805            <1> 	shr	ax, 5		; shift right 5 times
  2664 000088B7 6683E03F            <1> 	and	ax, 0000111111b	; Minute Mask
  2665 000088BB D40A                <1> 	aam			; Q([AL]/10)->AH
  2666                              <1> 				; R([AL]/10)->AL
  2667                              <1> 				; [AL]+[AH]= Minute as BCD
  2668 000088BD 660D3030            <1> 	or	ax, '00'	; Convert to ASCII
  2669 000088C1 86E0                <1> 	xchg	ah, al
  2670 000088C3 66A3[6D340100]      <1> 	mov	[File_Minute], ax
  2671                              <1> 
  2672                              <1> 	;mov	al, dh
  2673 000088C9 88F8                <1> 	mov	al, bh
  2674 000088CB C0E803              <1> 	shr	al, 3		; shift right 3 times
  2675 000088CE D40A                <1> 	aam			; [AL]+[AH]= Hours as BCD
  2676 000088D0 660D3030            <1> 	or	ax, '00'
  2677 000088D4 86E0                <1> 	xchg	ah, al
  2678 000088D6 66A3[6A340100]      <1> 	mov     [File_Hour], ax
  2679                              <1> 
  2680 000088DC C1EB10              <1> 	shr	ebx, 16		; BX = Date
  2681                              <1> 	
  2682                              <1> Dir_Date_start:
  2683                              <1> 	;mov	ax, bx		; Date
  2684                              <1> 	; 27/07/2022
  2685 000088DF 89D8                <1> 	mov	eax, ebx
  2686 000088E1 6683E01F            <1> 	and	ax, 00011111b	; Day Mask
  2687 000088E5 D40A                <1> 	aam			; Q([AL]/10)->AH
  2688                              <1> 				; R([AL]/10)->AL
  2689                              <1> 				; [AL]+[AH]= Day as BCD
  2690 000088E7 660D3030            <1> 	or	ax, '00'	; Convert to ASCII
  2691 000088EB 86C4                <1> 	xchg	al, ah
  2692                              <1> 
  2693 000088ED 66A3[5F340100]      <1> 	mov	[File_Day], ax
  2694                              <1> 
  2695                              <1> 	;mov	ax, bx
  2696                              <1> 	; 27/07/2022
  2697 000088F3 89D8                <1> 	mov	eax, ebx
  2698                              <1> 	;shr	ax, 5		; shift right 5 times
  2699 000088F5 C1E805              <1> 	shr	eax, 5
  2700 000088F8 6683E00F            <1> 	and	ax, 00001111b	; Month Mask
  2701 000088FC D40A                <1> 	aam
  2702 000088FE 660D3030            <1> 	or	ax, '00'
  2703 00008902 86E0                <1> 	xchg	ah, al
  2704 00008904 66A3[62340100]      <1> 	mov	[File_Month], ax
  2705                              <1> 
  2706                              <1> 	;mov	ax, bx
  2707                              <1> 	; 27/07/2022
  2708 0000890A 89D8                <1> 	mov	eax, ebx
  2709                              <1> 	;shr	ax, 9
  2710 0000890C C1E809              <1> 	shr	eax, 9
  2711 0000890F 6683E07F            <1> 	and	ax, 01111111b	; Result = Year - 1980
  2712 00008913 6605BC07            <1> 	add	ax, 1980
  2713                              <1> 
  2714 00008917 B10A                <1> 	mov	cl, 10
  2715 00008919 F6F1                <1> 	div	cl		; Q -> AL, R -> AH 
  2716 0000891B 80CC30              <1> 	or	ah, '0'
  2717 0000891E 8825[68340100]      <1> 	mov	[File_Year+3], ah
  2718 00008924 D40A                <1> 	aam
  2719 00008926 86E0                <1> 	xchg	ah, al
  2720 00008928 80CC30              <1> 	or	ah, '0'	  ; Convert to ASCII
  2721 0000892B 8825[67340100]      <1> 	mov	[File_Year+2], ah
  2722 00008931 D40A                <1> 	aam
  2723 00008933 86C4                <1> 	xchg	al, ah
  2724 00008935 660D3030            <1> 	or	ax, '00'
  2725 00008939 66A3[65340100]      <1> 	mov	[File_Year], ax
  2726                              <1> 
  2727                              <1> loc_show_line:
  2728 0000893F 56                  <1> 	push	esi
  2729 00008940 BE[42340100]        <1> 	mov     esi, File_Name
  2730 00008945 E810E3FFFF          <1> 	call	print_msg
  2731 0000894A BE[1B3B0100]        <1> 	mov	esi, nextline
  2732 0000894F E806E3FFFF          <1> 	call	print_msg
  2733 00008954 5E                  <1> 	pop	esi
  2734                              <1> 
  2735 00008955 FE0D[89810100]      <1> 	dec	byte [PrintDir_RowCounter]
  2736 0000895B 740C                <1> 	jz	short pause_dir_scroll ; 27/07/2022
  2737                              <1> 
  2738                              <1> loc_next_entry:
  2739 0000895D E88B010000          <1> 	call	find_next_file
  2740                              <1> 	;jnc	loc_dfname_use_this
  2741                              <1> 	; 27/07/2022
  2742 00008962 7219                <1> 	jc	short loc_dir_ok
  2743 00008964 E999FEFFFF          <1> 	jmp	loc_dfname_use_this
  2744                              <1> 
  2745                              <1> 	; 27/07/2022
  2746                              <1> pause_dir_scroll:
  2747 00008969 28E4                <1> 	sub	ah, ah           
  2748 0000896B E89885FFFF          <1> 	call	int16h
  2749 00008970 3C1B                <1> 	cmp	al, 1Bh
  2750 00008972 7409                <1> 	je	short loc_dir_ok
  2751 00008974 C605[89810100]10    <1> 	mov	byte [PrintDir_RowCounter], 16 ; Reset counter
  2752 0000897B EBE0                <1>         jmp     short loc_next_entry
  2753                              <1> 
  2754                              <1> loc_dir_ok:
  2755 0000897D B90A000000          <1> 	mov     ecx, 10
  2756                              <1> 	;mov	ax, [Dir_Count]
  2757                              <1> 	; 27/07/2022
  2758 00008982 0FB705[74810100]    <1> 	movzx	eax, word [Dir_Count]
  2759 00008989 BF[83340100]        <1> 	mov	edi, Decimal_Dir_Count
  2760                              <1> 	;cmp	ax, cx ; 10
  2761                              <1> 	; 27/07/2022
  2762 0000898E 39C8                <1> 	cmp	eax, ecx
  2763 00008990 7216                <1> 	jb	short pass_ddc
  2764 00008992 47                  <1> 	inc	edi
  2765 00008993 6683F864            <1> 	cmp	ax, 100
  2766 00008997 720F                <1> 	jb	short pass_ddc
  2767 00008999 47                  <1> 	inc	edi
  2768 0000899A 663DE803            <1> 	cmp	ax, 1000
  2769 0000899E 7208                <1> 	jb	short pass_ddc
  2770 000089A0 47                  <1> 	inc	edi
  2771 000089A1 663D1027            <1> 	cmp	ax, 10000
  2772 000089A5 7201                <1> 	jb	short pass_ddc
  2773 000089A7 47                  <1> 	inc	edi
  2774                              <1> pass_ddc:
  2775 000089A8 886F01              <1> 	mov     [edi+1], ch ; 0
  2776                              <1> loc_ddc_rediv:
  2777 000089AB 31D2                <1> 	xor     edx, edx
  2778                              <1> 	;div	cx  ; 10
  2779                              <1> 	; 27/07/2022
  2780 000089AD F7F1                <1> 	div	ecx
  2781 000089AF 80C230              <1> 	add     dl, '0'
  2782 000089B2 8817                <1> 	mov     [edi], dl
  2783 000089B4 4F                  <1> 	dec     edi
  2784                              <1> 	;or	ax, ax
  2785                              <1> 	; 27/07/2022
  2786 000089B5 09C0                <1> 	or	eax, eax
  2787 000089B7 75F2                <1> 	jnz	short loc_ddc_rediv
  2788                              <1> 
  2789 000089B9 66A1[72810100]      <1> 	mov     ax, [File_Count]
  2790 000089BF BF[72340100]        <1> 	mov     edi, Decimal_File_Count
  2791                              <1> 	;cmp	ax, cx ; 10
  2792                              <1> 	; 27/07/2022
  2793 000089C4 39C8                <1> 	cmp	eax, ecx ; 10
  2794 000089C6 7216                <1> 	jb      short pass_dfc
  2795 000089C8 47                  <1> 	inc     edi
  2796 000089C9 6683F864            <1> 	cmp     ax, 100
  2797 000089CD 720F                <1> 	jb      short pass_dfc
  2798 000089CF 47                  <1> 	inc     edi
  2799 000089D0 663DE803            <1> 	cmp     ax, 1000
  2800 000089D4 7208                <1> 	jb      short pass_dfc
  2801 000089D6 47                  <1> 	inc     edi
  2802 000089D7 663D1027            <1> 	cmp     ax, 10000
  2803 000089DB 7201                <1> 	jb      short pass_dfc
  2804 000089DD 47                  <1> 	inc     edi
  2805                              <1> pass_dfc:
  2806                              <1> 	;mov    cx, 10
  2807 000089DE 886F01              <1> 	mov     [edi+1], ch ; 00
  2808                              <1> loc_dfc_rediv:
  2809                              <1> 	;;xor	dx, dx
  2810                              <1> 	;xor	dl, dl
  2811                              <1> 	;div	cx
  2812                              <1> 	; 27/07/022
  2813 000089E1 31D2                <1> 	xor	edx, edx
  2814 000089E3 F7F1                <1> 	div	ecx
  2815 000089E5 80C230              <1> 	add	dl, '0'
  2816 000089E8 8817                <1> 	mov	[edi], dl
  2817 000089EA 4F                  <1> 	dec	edi
  2818                              <1> 	;or	ax, ax
  2819                              <1> 	; 27/07/2022
  2820 000089EB 09C0                <1> 	or	eax, eax
  2821 000089ED 75F2                <1> 	jnz	short loc_dfc_rediv
  2822                              <1> 
  2823 000089EF BF[88810100]        <1> 	mov     edi, TFS_Dec_End
  2824                              <1>         ;mov    byte [edi], 0
  2825 000089F4 A1[76810100]        <1> 	mov     eax, [Total_FSize]
  2826                              <1> 	;mov    ecx, 10
  2827                              <1> rediv_tfs_hex:
  2828 000089F9 29D2                <1> 	sub	edx, edx ; 27/07/2022
  2829                              <1> 	;sub	dl, dl
  2830 000089FB F7F1                <1> 	div	ecx
  2831 000089FD 80C230              <1> 	add	dl, '0'
  2832 00008A00 4F                  <1> 	dec     edi
  2833 00008A01 8817                <1> 	mov     [edi], dl
  2834 00008A03 21C0                <1> 	and	eax, eax
  2835 00008A05 75F2                <1> 	jnz	short rediv_tfs_hex
  2836                              <1> 	
  2837 00008A07 893D[7A810100]      <1> 	mov	[TFS_Dec_Begin], edi
  2838 00008A0D BE[70340100]        <1> 	mov	esi, Decimal_File_Count_Header
  2839 00008A12 E843E2FFFF          <1> 	call	print_msg
  2840 00008A17 BE[78340100]        <1> 	mov	esi, str_files
  2841 00008A1C E839E2FFFF          <1> 	call	print_msg
  2842 00008A21 BE[89340100]        <1> 	mov	esi, str_dirs
  2843 00008A26 E82FE2FFFF          <1> 	call	print_msg
  2844 00008A2B 8B35[7A810100]      <1> 	mov	esi, [TFS_Dec_Begin]
  2845 00008A31 E824E2FFFF          <1> 	call	print_msg
  2846 00008A36 BE[9A340100]        <1> 	mov	esi, str_bytes
  2847                              <1> 	;call	print_msg
  2848                              <1> 	;retn
  2849                              <1> 	; 27/07/2022
  2850 00008A3B E91AE2FFFF          <1> 	jmp	print_msg
  2851                              <1> 
  2852                              <1> find_first_file:
  2853                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  2854                              <1> 	; 11/02/2016
  2855                              <1> 	; 10/02/2016
  2856                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  2857                              <1> 	; 09/10/2011
  2858                              <1> 	; 17/09/2009
  2859                              <1> 	; 2005
  2860                              <1> 	; INPUT ->
  2861                              <1> 	;	ESI = ASCIIZ File/Dir Name Address (in Current Directory)
  2862                              <1> 	;	AL = Attributes AND mask (The AND result must be equal to AL)
  2863                              <1> 	;	      bit 0 = Read Only
  2864                              <1> 	;	      bir 1 = Hidden
  2865                              <1> 	;	      bit 2 = System
  2866                              <1> 	;	      bit 3 = Volume Label
  2867                              <1> 	;	      bit 4 = Directory
  2868                              <1> 	;	      bit 5 = Archive
  2869                              <1> 	;	      bit 6 = Reserved, must be 0
  2870                              <1> 	;	      bit 7 = Reserved, must be 0
  2871                              <1> 	;       AH = Attributes Negative AND mask (The AND result must be ZERO)
  2872                              <1> 	;
  2873                              <1> 	; OUTPUT ->
  2874                              <1> 	;	CF = 1 -> Error, Error Code in EAX (AL)
  2875                              <1> 	;	CF = 0 ->
  2876                              <1> 	;	     ESI = Directory Entry (FindFile_DirEntry) Location
  2877                              <1> 	;	     EDI = Directory Buffer Directory Entry Location
  2878                              <1> 	;	     EAX = File Size
  2879                              <1> 	;	      BL = Attributes of The File/Directory
  2880                              <1> 	;	      BH = Long Name Yes/No Status (>0 is YES)
  2881                              <1> 	;             DX > 0 : Ambiguous filename chars are used
  2882                              <1> 	;
  2883                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  2884                              <1> 
  2885 00008A40 66A3[3A810100]      <1> 	mov	[FindFile_AttributesMask], ax
  2886 00008A46 BF[3C810100]        <1> 	mov	edi, FindFile_DirEntry ; TR-DOS Fullfilename formatted buffer
  2887 00008A4B 31C0                <1> 	xor	eax, eax
  2888                              <1> 	;mov	ecx, 11
  2889                              <1> 	; 28/07/2022
  2890 00008A4D 31C9                <1> 	xor	ecx, ecx
  2891 00008A4F B10B                <1> 	mov	cl, 11
  2892 00008A51 F3AB                <1> 	rep	stosd	; 44 bytes
  2893                              <1> 	;stosw		; +2 bytes 
  2894                              <1> 	    
  2895 00008A53 BF[2C810100]        <1> 	mov	edi, FindFile_Name ; FFF structure, offset 66
  2896 00008A58 39FE                <1> 	cmp	esi, edi
  2897 00008A5A 7408                <1> 	je	short loc_fff_mfn_ok
  2898 00008A5C 89FA                <1> 	mov	edx, edi 
  2899                              <1> 	; move 13 bytes
  2900 00008A5E A5                  <1> 	movsd
  2901 00008A5F A5                  <1> 	movsd
  2902 00008A60 A5                  <1> 	movsd
  2903 00008A61 AA                  <1> 	stosb
  2904 00008A62 89D6                <1> 	mov	esi, edx
  2905                              <1> loc_fff_mfn_ok:
  2906 00008A64 BF[DB800100]        <1> 	mov	edi, Dir_Entry_Name ; Dir Entry Format File Name
  2907 00008A69 E8CC1F0000          <1> 	call	convert_file_name
  2908 00008A6E 89FE                <1> 	mov	esi, edi ; offset Dir_Entry_Name
  2909                              <1> 
  2910 00008A70 66A1[3A810100]      <1> 	mov	ax, [FindFile_AttributesMask]
  2911                              <1> 	;xor	ecx, ecx
  2912 00008A76 30C9                <1> 	xor	cl, cl  
  2913 00008A78 E8EE1C0000          <1> 	call	locate_current_dir_file
  2914 00008A7D 726D                <1> 	jc	short loc_fff_retn
  2915                              <1> 	; EDI = Directory Entry
  2916                              <1> 	; EBX = Directory Buffer Entry Index/Number
  2917                              <1> 
  2918                              <1> loc_fff_fnf_ln_check:
  2919 00008A7F 30ED                <1> 	xor	ch, ch 
  2920 00008A81 80F60F              <1> 	xor	dh, 0Fh
  2921 00008A84 7408                <1> 	jz	short loc_fff_longname_yes
  2922 00008A86 882D[39810100]      <1> 	mov	[FindFile_LongNameYes], ch ; 0
  2923 00008A8C EB0C                <1> 	jmp	short loc_fff_longname_no
  2924                              <1> 
  2925                              <1> loc_fff_longname_yes:
  2926                              <1> 	;inc	byte [FindFile_LongNameYes]
  2927 00008A8E 8A0D[46800100]      <1> 	mov	cl, [LFN_EntryLength]  
  2928 00008A94 880D[39810100]      <1> 	mov	[FindFile_LongNameEntryLength], cl ; FindFile_LongNameYes
  2929                              <1> 
  2930                              <1> loc_fff_longname_no:
  2931                              <1> 	;mov	bx, [DirBuff_CurrentEntry]
  2932 00008A9A 66891D[64810100]    <1> 	mov	[FindFile_DirEntryNumber], bx
  2933                              <1> 	;mov	dx, ax ; Ambiguous Filename chars used sign > 0
  2934                              <1> 	; 28/07/2022
  2935 00008AA1 89C2                <1> 	mov	edx, eax
  2936                              <1> 
  2937 00008AA3 A0[4A780100]        <1> 	mov	al, [Current_Drv]
  2938 00008AA8 A2[EA800100]        <1> 	mov	[FindFile_Drv], al 
  2939                              <1> 
  2940 00008AAD A1[44780100]        <1> 	mov	eax, [Current_Dir_FCluster]
  2941 00008AB2 A3[5C810100]        <1> 	mov	[FindFile_DirFirstCluster], eax
  2942                              <1> 
  2943 00008AB7 A1[767F0100]        <1> 	mov	eax, [DirBuff_Cluster]
  2944 00008ABC A3[60810100]        <1> 	mov	[FindFile_DirCluster], eax
  2945                              <1> 
  2946 00008AC1 66FF05[66810100]    <1> 	inc	word [FindFile_MatchCounter]
  2947                              <1> 
  2948 00008AC8 89FB                <1> 	mov	ebx, edi
  2949 00008ACA 89FE                <1> 	mov	esi, edi
  2950 00008ACC BF[3C810100]        <1> 	mov	edi, FindFile_DirEntry
  2951 00008AD1 89F8                <1> 	mov	eax, edi
  2952 00008AD3 B108                <1> 	mov	cl, 8
  2953 00008AD5 F3A5                <1> 	rep	movsd
  2954 00008AD7 89C6                <1> 	mov	esi, eax
  2955 00008AD9 89DF                <1> 	mov	edi, ebx
  2956                              <1> 
  2957 00008ADB A1[58810100]        <1> 	mov	eax, [FindFile_DirEntry+28] ; File Size
  2958                              <1> 
  2959 00008AE0 8A1D[47810100]      <1> 	mov	bl, [FindFile_DirEntry+11] ; File Attributes 
  2960 00008AE6 8A3D[39810100]      <1> 	mov	bh, [FindFile_LongNameYes]
  2961                              <1> 
  2962                              <1> 	;mov	cx, [DirBuff_EntryCounter]
  2963                              <1> 	;mov	[FindFile_DirEntryNumber], cx
  2964                              <1> 	;mov	cx, [FindFile_DirEntryNumber]
  2965                              <1> 	; ecx = 0
  2966                              <1> 
  2967                              <1> loc_fff_retn:
  2968 00008AEC C3                  <1> 	retn
  2969                              <1> 
  2970                              <1> find_next_file:
  2971                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  2972                              <1> 	; 15/10/2016
  2973                              <1> 	; 10/02/2016
  2974                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  2975                              <1> 	; 06/02/2011
  2976                              <1> 	; 17/09/2009
  2977                              <1> 	; 2005
  2978                              <1> 	; INPUT ->
  2979                              <1> 	;	NONE, Find First File Parameters
  2980                              <1> 	; OUTPUT ->
  2981                              <1> 	;	CF = 1 -> Error, Error Code in EAX (AL)
  2982                              <1> 	;	CF = 0 -> 
  2983                              <1> 	;	    ESI = Directory Entry (FindFile_DirEntry) Location
  2984                              <1> 	;	    EDI = Directory Buffer Directory Entry Location
  2985                              <1> 	;	    EAX = File Size
  2986                              <1> 	;	      BL = Attributes of The File/Directory
  2987                              <1> 	;	      BH = Long Name Yes/No Status (>0 is YES)
  2988                              <1> 	;             DX > 0 : Ambiguous filename chars are used 
  2989                              <1> 	;
  2990                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  2991                              <1> 
  2992 00008AED 66833D[66810100]00  <1> 	cmp	word [FindFile_MatchCounter], 0
  2993 00008AF5 7707                <1> 	ja	short loc_start_search_next_file
  2994                              <1> 
  2995                              <1> loc_fnf_stc_retn:
  2996 00008AF7 F9                  <1> 	stc
  2997                              <1> loc_fnf_ax12h_retn:
  2998 00008AF8 B80C000000          <1> 	mov	eax, 12 ; No More files
  2999                              <1> ;loc_fnf_retn:
  3000 00008AFD C3                  <1> 	retn
  3001                              <1> 
  3002                              <1> loc_start_search_next_file:
  3003 00008AFE 668B1D[64810100]    <1> 	mov	bx, [FindFile_DirEntryNumber]
  3004                              <1> 	;inc	bx
  3005                              <1> 	; 28/07/2022
  3006 00008B05 43                  <1> 	inc	ebx
  3007 00008B06 663B1D[747F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  3008 00008B0D 7719                <1> 	ja	short loc_cont_search_next_file
  3009                              <1> 
  3010                              <1> loc_fnf_search:
  3011 00008B0F BE[DB800100]        <1> 	mov	esi, Dir_Entry_Name
  3012 00008B14 66A1[3A810100]      <1> 	mov	ax, [FindFile_AttributesMask]
  3013                              <1> 	;xor	cx, cx
  3014                              <1> 	; 28/07/2022
  3015 00008B1A 31C9                <1> 	xor	ecx, ecx
  3016 00008B1C E8481D0000          <1> 	call	find_directory_entry
  3017                              <1> 	;jnc	loc_fff_fnf_ln_check
  3018                              <1> 	; 28/07/2022
  3019 00008B21 7205                <1> 	jc	short loc_cont_search_next_file
  3020 00008B23 E957FFFFFF          <1> 	jmp	loc_fff_fnf_ln_check
  3021                              <1> 
  3022                              <1> loc_cont_search_next_file:
  3023 00008B28 31DB                <1> 	xor	ebx, ebx
  3024 00008B2A 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv]
  3025 00008B30 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3026 00008B35 01DE                <1> 	add	esi, ebx
  3027                              <1> 
  3028 00008B37 803D[48780100]00    <1> 	cmp	byte [Current_Dir_Level], 0
  3029 00008B3E 7608                <1> 	jna	short loc_fnf_check_FAT_type
  3030 00008B40 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  3031 00008B44 72B2                <1> 	jb	short loc_fnf_ax12h_retn
  3032 00008B46 EB06                <1> 	jmp	short loc_fnf_check_next_cluster
  3033                              <1>  
  3034                              <1> loc_fnf_check_FAT_type:
  3035 00008B48 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3
  3036 00008B4C 72AA                <1> 	jb	short loc_fnf_ax12h_retn
  3037                              <1> 
  3038                              <1> loc_fnf_check_next_cluster:
  3039 00008B4E A1[767F0100]        <1> 	mov	eax, [DirBuff_Cluster]
  3040 00008B53 E85F360000          <1> 	call	get_next_cluster
  3041 00008B58 7306                <1> 	jnc	short loc_fnf_load_next_dir_cluster
  3042 00008B5A 09C0                <1> 	or	eax, eax
  3043 00008B5C 7499                <1> 	jz	short loc_fnf_stc_retn
  3044                              <1> 	;mov	eax, 17 ;Drive not ready or read error
  3045 00008B5E F5                  <1>  	cmc	;stc
  3046                              <1> loc_fnf_retn:
  3047 00008B5F C3                  <1> 	retn
  3048                              <1> 
  3049                              <1> loc_fnf_load_next_dir_cluster:
  3050 00008B60 E80E380000          <1> 	call	load_FAT_sub_directory
  3051 00008B65 72F8                <1> 	jc	short loc_fnf_retn
  3052                              <1> 	;xor	bx, bx
  3053                              <1> 	; 28/07/2022
  3054 00008B67 31DB                <1> 	xor	ebx, ebx
  3055 00008B69 66891D[64810100]    <1> 	mov	[FindFile_DirEntryNumber], bx
  3056 00008B70 EB9D                <1> 	jmp	short loc_fnf_search
  3057                              <1> 
  3058                              <1> get_and_print_longname:
  3059                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  3060                              <1> 	; 16/10/2016
  3061                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
  3062                              <1> 	; 24/01/2010
  3063                              <1> 	; 17/10/2009 (CMD_INTR.ASM, 'cmp_cmd_longname')
  3064                              <1> get_longname_fchar:
  3065 00008B72 803E20              <1> 	cmp	byte [esi], 20h
  3066 00008B75 7701                <1> 	ja	short loc_find_longname
  3067                              <1> 	;jb	short loc_longname_retn
  3068                              <1> 	;inc	esi
  3069                              <1> 	;je	short get_longname_fchar
  3070                              <1> ;loc_longname_retn:
  3071 00008B77 C3                  <1> 	retn
  3072                              <1> loc_find_longname:
  3073 00008B78 E82A200000          <1> 	call	find_longname
  3074 00008B7D 731D                <1> 	jnc	short loc_print_longname
  3075                              <1> 	
  3076 00008B7F 08C0                <1> 	or	al, al
  3077 00008B81 7412                <1> 	jz	short loc_longname_not_found
  3078                              <1> 	  
  3079                              <1> 	; 16/10/2016 (15h -> 15, 17)
  3080 00008B83 3C0F                <1> 	cmp	al, 15
  3081                              <1> 	;je	cd_drive_not_ready ; drive not ready
  3082                              <1> 	; 28/07/2022
  3083 00008B85 7505                <1> 	jne	short loc_fln_err2
  3084                              <1> loc_fln_err1:
  3085 00008B87 E963F8FFFF          <1> 	jmp	cd_drive_not_ready	
  3086                              <1> loc_fln_err2:
  3087                              <1> 				   ; or
  3088 00008B8C 3C11                <1> 	cmp	al, 17		   ; read error	
  3089                              <1> 	;je	cd_drive_not_ready
  3090                              <1> 	; 28/07/2022
  3091                              <1> 	;je	short loc_fln_err1 
  3092                              <1> 
  3093                              <1> loc_ln_file_dir_not_found:
  3094 00008B8E BE[C5330100]        <1> 	mov	esi, Msg_File_Directory_Not_Found
  3095                              <1> 	;;call	print_msg
  3096                              <1>         ;;retn
  3097                              <1> 	;jmp	print_msg
  3098                              <1> 	; 28/07/2022
  3099 00008B93 EB2B                <1> 	jmp	short loc_lfn_err3
  3100                              <1> 
  3101                              <1> loc_longname_not_found:
  3102 00008B95 BE[E4330100]        <1>         mov     esi, Msg_LongName_Not_Found
  3103                              <1> 	;;call	print_msg
  3104                              <1>         ;;retn
  3105                              <1> 	;jmp	print_msg
  3106                              <1> 	; 28/07/2022
  3107 00008B9A EB24                <1> 	jmp	short loc_lfn_err3
  3108                              <1> 
  3109                              <1> loc_print_longname:
  3110                              <1> 	;mov	esi, LongFileName
  3111 00008B9C BF[4A790100]        <1> 	mov	edi, TextBuffer
  3112 00008BA1 57                  <1> 	push	edi 
  3113 00008BA2 3C00                <1> 	cmp	al, 0
  3114 00008BA4 7708                <1> 	ja	short loc_print_longname_1
  3115                              <1> loc_print_FS_longname: ; Singlix FS (64 byte ASCIIZ file name)
  3116 00008BA6 AC                  <1> 	lodsb
  3117 00008BA7 AA                  <1> 	stosb  
  3118 00008BA8 08C0                <1> 	or	al, al
  3119 00008BAA 75FA                <1> 	jnz	short loc_print_FS_longname
  3120 00008BAC EB07                <1> 	jmp	short loc_print_longname_2
  3121                              <1> 	;
  3122                              <1> loc_print_longname_1: ; MS Windows long name (UNICODE chars)
  3123 00008BAE 66AD                <1> 	lodsw
  3124 00008BB0 AA                  <1> 	stosb  
  3125 00008BB1 08C0                <1> 	or	al, al
  3126 00008BB3 75F9                <1> 	jnz	short loc_print_longname_1
  3127                              <1> 	;
  3128                              <1> loc_print_longname_2:	
  3129 00008BB5 5E                  <1> 	pop	esi
  3130 00008BB6 E89FE0FFFF          <1> 	call	print_msg
  3131 00008BBB BE[1B3B0100]        <1>   	mov	esi, nextline
  3132                              <1> loc_lfn_err3:
  3133                              <1> 	;call	print_msg
  3134                              <1> 	;retn
  3135 00008BC0 E995E0FFFF          <1> 	jmp	print_msg	
  3136                              <1> 
  3137                              <1> show_file:
  3138                              <1> 	; 07/08/2022
  3139                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  3140                              <1> 	; 18/02/2016
  3141                              <1> 	; 17/02/2016
  3142                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  3143                              <1> 	; 13/09/2011 (CMD_INTR.ASM, 'cmp_cmd_show')
  3144                              <1> 	; 08/11/2009
  3145                              <1> 
  3146                              <1> loc_show_parse_path_name:
  3147 00008BC5 BF[EA800100]        <1> 	mov	edi, FindFile_Drv
  3148 00008BCA E8351F0000          <1> 	call	parse_path_name
  3149                              <1> 	;jc	loc_cmd_failed
  3150                              <1> 	; 28/07/2022
  3151 00008BCF 7305                <1> 	jnc	short loc_show_check_filename_exists
  3152                              <1> show_file_err1:
  3153 00008BD1 E983F9FFFF          <1> 	jmp	loc_cmd_failed
  3154                              <1> 
  3155                              <1> loc_show_check_filename_exists:
  3156 00008BD6 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  3157 00008BDB 803E20              <1> 	cmp	byte [esi], 20h
  3158                              <1> 	;jna	loc_cmd_failed
  3159                              <1> 	; 28/07/2022
  3160 00008BDE 76F1                <1> 	jna	short show_file_err1
  3161                              <1> 
  3162                              <1> 	; 15/02/2016 (invalid file name check)
  3163 00008BE0 E800020000          <1> 	call	check_filename 	
  3164 00008BE5 730A                <1> 	jnc	short loc_show_change_drv
  3165                              <1> 
  3166 00008BE7 BE[B0340100]        <1> 	mov	esi, Msg_invalid_name_chars
  3167 00008BEC E969E0FFFF          <1> 	jmp	print_msg
  3168                              <1>    
  3169                              <1> loc_show_change_drv:
  3170 00008BF1 8A35[4A780100]      <1> 	mov	dh, [Current_Drv]
  3171 00008BF7 8835[A77F0100]      <1> 	mov	[RUN_CDRV], dh
  3172 00008BFD 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
  3173 00008C03 38F2                <1> 	cmp	dl, dh
  3174 00008C05 740C                <1> 	je	short loc_show_change_directory
  3175 00008C07 E886EBFFFF          <1> 	call	change_current_drive
  3176                              <1> 	;;jc	loc_file_rw_cmd_failed
  3177                              <1> 	;jc	loc_run_cmd_failed
  3178                              <1> 	; 28/07/2022
  3179 00008C0C 7305                <1> 	jnc	short loc_show_change_directory
  3180                              <1> show_file_err2:
  3181 00008C0E E971F9FFFF          <1> 	jmp	loc_run_cmd_failed
  3182                              <1> 
  3183                              <1> loc_show_change_directory:
  3184 00008C13 803D[EB800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  3185 00008C1A 7614                <1> 	jna	short loc_findload_showfile
  3186                              <1> 
  3187 00008C1C FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  3188 00008C22 BE[EB800100]        <1> 	mov	esi, FindFile_Directory
  3189 00008C27 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3190 00008C29 E8EA180000          <1> 	call	change_current_directory
  3191                              <1> 	;;jc	loc_file_rw_cmd_failed
  3192                              <1> 	;jc	loc_run_cmd_failed
  3193                              <1> 	; 28/07/2022
  3194 00008C2E 72DE                <1> 	jc	short show_file_err2
  3195                              <1> 
  3196                              <1> ;loc_show_change_prompt_dir_string:
  3197                              <1> 	;call	change_prompt_dir_string
  3198                              <1> 
  3199                              <1> loc_findload_showfile:
  3200                              <1> 	; 15/02/2016
  3201 00008C30 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  3202 00008C35 BF[DB800100]        <1> 	mov	edi, Dir_Entry_Name ; Dir Entry Format File Name
  3203 00008C3A E8FB1D0000          <1> 	call	convert_file_name
  3204 00008C3F 89FE                <1> 	mov	esi, edi ; offset Dir_Entry_Name
  3205                              <1> 
  3206 00008C41 28C0                <1> 	sub	al, al	; Attrib AND mask = 0
  3207                              <1> 	; Directory attribute : 10h
  3208                              <1> 	; Volume name attribute: 8h
  3209 00008C43 B418                <1> 	mov	ah, 00011000b ; 18h (Attrib NAND, AND --> zero mask)
  3210                              <1> 	;
  3211                              <1> 	;xor	cx, cx  
  3212                              <1> 	; 28/07/2022
  3213 00008C45 31C9                <1> 	xor	ecx, ecx
  3214 00008C47 E81F1B0000          <1> 	call	locate_current_dir_file
  3215                              <1> 	;;jc	loc_file_rw_cmd_failed
  3216                              <1> 	;jc	loc_run_cmd_failed
  3217                              <1> 	; 28/07/2022
  3218 00008C4C 72C0                <1> 	jc	short show_file_err2
  3219                              <1> 
  3220                              <1> loc_show_load_file:
  3221                              <1> 	; EDI = Directory Entry
  3222 00008C4E 668B4714            <1> 	mov	ax, [edi+DirEntry_FstClusHI] ; First Cluster High Word
  3223 00008C52 C1E010              <1> 	shl	eax, 16
  3224 00008C55 668B471A            <1> 	mov	ax, [edi+DirEntry_FstClusLO] ; First Cluster Low Word
  3225 00008C59 A3[94810100]        <1> 	mov	[Show_Cluster], eax
  3226 00008C5E 8B471C              <1> 	mov	eax, [edi+DirEntry_FileSize] ; File Size
  3227 00008C61 21C0                <1> 	and	eax, eax ; Empty file !
  3228                              <1> 	;jz	end_of_show_file
  3229                              <1> 	; 28/07/2022
  3230 00008C63 7505                <1> 	jnz	short loc_show_load_file_set_size
  3231 00008C65 E904010000          <1> 	jmp	end_of_show_file 
  3232                              <1> 
  3233                              <1> loc_show_load_file_set_size: ; 28/07/2022
  3234 00008C6A A3[98810100]        <1> 	mov	[Show_FileSize], eax
  3235 00008C6F 31C0                <1> 	xor	eax, eax
  3236 00008C71 A3[9C810100]        <1> 	mov	[Show_FilePointer], eax ; 0
  3237 00008C76 66A3[A0810100]      <1> 	mov	[Show_ClusterPointer], ax ; 0
  3238 00008C7C 29DB                <1> 	sub	ebx, ebx
  3239 00008C7E 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv]
  3240 00008C84 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3241 00008C89 01DE                <1> 	add	esi, ebx
  3242 00008C8B 8935[90810100]      <1> 	mov	[Show_LDDDT], esi ; Logical DOS Drv Description Table addr
  3243                              <1> 
  3244 00008C91 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0	
  3245 00008C95 7713                <1> 	ja	short loc_show_calculate_cluster_size
  3246                              <1> 	; Singlix FS
  3247                              <1> 	; First Cluster Number is FDT number (in compatibility buffer)
  3248 00008C97 8B15[94810100]      <1> 	mov	edx, [Show_Cluster] ; Compatibility dir. buffer value (FDT)	
  3249 00008C9D 8915[8C810100]      <1> 	mov	[Show_FDT], edx
  3250 00008CA3 31C0                <1> 	xor	eax, eax
  3251 00008CA5 A3[94810100]        <1> 	mov	[Show_Cluster], eax ; Sector index  = 0
  3252                              <1> 				    ; (next time it will be 1)			
  3253                              <1> loc_show_calculate_cluster_size:
  3254 00008CAA 668B5E11            <1> 	mov	bx, [esi+LD_BPB+BPB_BytsPerSec] ; FAT 12-16-32 (512)
  3255                              <1> 	; BX = 512 = [esi+LD_FS_BytesPerSec] ; Singlix FS	
  3256 00008CAE 8A4613              <1> 	mov	al, [esi+LD_BPB+BPB_SecPerClust] ; FAT 12-16-32 (<= 128)
  3257                              <1> 	; AL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
  3258 00008CB1 F7E3                <1> 	mul	ebx	
  3259                              <1> 
  3260                              <1> 	;cmp	eax, 65536 ; non-compatible (very big) cluster size
  3261                              <1> 	;ja	short end_of_show_file	
  3262 00008CB3 66A3[A2810100]      <1> 	mov	[Show_ClusterSize], ax
  3263                              <1> 
  3264                              <1> loc_start_show_file:
  3265 00008CB9 BE[1B3B0100]        <1> 	mov	esi, nextline
  3266 00008CBE E897DFFFFF          <1> 	call	print_msg
  3267                              <1> 
  3268 00008CC3 A1[94810100]        <1> 	mov	eax, [Show_Cluster]
  3269 00008CC8 C605[A4810100]17    <1> 	mov	byte [Show_RowCount], 23
  3270                              <1> 
  3271                              <1> 	; 17/02/2016
  3272 00008CCF 8B35[90810100]      <1> 	mov	esi, [Show_LDDDT]
  3273                              <1> 
  3274                              <1> 	; 07/08/2022
  3275                              <1> loc_show_next_cluster:
  3276                              <1> 	; 15/02/2016
  3277 00008CD5 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; 70000h (for current TRDOS 386 version)
  3278                              <1> 	; ESI = Logical DOS drv description table address
  3279 00008CDA E8CF360000          <1> 	call	read_cluster
  3280                              <1> 	;;jc	loc_file_rw_cmd_failed
  3281                              <1> 	;jc	loc_run_cmd_failed
  3282                              <1> 	; 07/08/2022
  3283 00008CDF 7305                <1> 	jnc	short loc_show_nc_rc_ok
  3284 00008CE1 E99EF8FFFF          <1> 	jmp	loc_run_cmd_failed
  3285                              <1> loc_show_nc_rc_ok:
  3286 00008CE6 31DB                <1> 	xor 	ebx, ebx
  3287                              <1> loc_show_next_byte:
  3288 00008CE8 803D[A4810100]00    <1> 	cmp	byte [Show_RowCount], 0
  3289 00008CEF 7512                <1> 	jne	short pass_show_wait_for_key
  3290 00008CF1 30E4                <1> 	xor	ah, ah
  3291 00008CF3 E81082FFFF          <1> 	call	int16h
  3292 00008CF8 3C1B                <1> 	cmp	al, 1Bh
  3293                              <1> 	;jne	short pass_exit_show
  3294                              <1> 	; 28/07/2022
  3295 00008CFA 7472                <1> 	je	short end_of_show_file
  3296                              <1> 
  3297                              <1> ;end_of_show_file:
  3298                              <1> ;pass_show_file:
  3299                              <1> ;	mov	esi, nextline
  3300                              <1> ;	call	print_msg
  3301                              <1> ;	jmp	loc_file_rw_restore_retn
  3302                              <1> 
  3303                              <1> pass_exit_show:
  3304 00008CFC C605[A4810100]14    <1> 	mov	byte [Show_RowCount], 20
  3305                              <1> pass_show_wait_for_key:
  3306 00008D03 81C300000700        <1> 	add	ebx, Cluster_Buffer
  3307 00008D09 8A03                <1> 	mov	al, [ebx]
  3308 00008D0B 3C0D                <1> 	cmp	al, 0Dh
  3309                              <1>  	;jne	loc_show_check_tab_space
  3310                              <1> 	; 28/07/2022
  3311 00008D0D 740B                <1> 	je	short loc_show_dec_row_count
  3312 00008D0F E991000000          <1> 	jmp	loc_show_check_tab_space
  3313                              <1> 
  3314                              <1> 	; 07/08/2022
  3315                              <1> loc_show_next:
  3316                              <1> 	;and	bx, bx ; 65536 -> 0
  3317                              <1> 	; 28/07/2022
  3318 00008D14 21DB                <1> 	and	ebx, ebx
  3319 00008D16 75D0                <1> 	jnz	short loc_show_next_byte
  3320 00008D18 EBBB                <1> 	jmp     short loc_show_next_cluster
  3321                              <1> 
  3322                              <1> loc_show_dec_row_count:	; 28/07/2022
  3323 00008D1A FE0D[A4810100]      <1> 	dec	byte [Show_RowCount]
  3324                              <1> pass_show_dec_rowcount:
  3325 00008D20 B307                <1> 	mov	bl, 7 ; (light gray character color, black background)
  3326 00008D22 8A3D[B6770100]      <1> 	mov	bh, [ACTIVE_PAGE] ; [ptty]
  3327 00008D28 E82B95FFFF          <1> 	call	_write_tty
  3328                              <1> loc_show_check_eof:
  3329 00008D2D FF05[9C810100]      <1> 	inc	dword [Show_FilePointer]
  3330 00008D33 A1[9C810100]        <1> 	mov	eax, [Show_FilePointer]
  3331 00008D38 3B05[98810100]      <1> 	cmp	eax, [Show_FileSize]
  3332 00008D3E 732E                <1> 	jnb	short end_of_show_file
  3333 00008D40 66FF05[A0810100]    <1> 	inc	word [Show_ClusterPointer]
  3334 00008D47 0FB71D[A0810100]    <1> 	movzx	ebx, word [Show_ClusterPointer]
  3335                              <1> 
  3336                              <1> 	; 17/02/2016
  3337                              <1> 	; (sector boundary -9 bits- check, 512 = 0)
  3338 00008D4E 66F7C3FF01          <1>         test    bx, 1FFh ; 1 to 511
  3339 00008D53 7593                <1> 	jnz	short loc_show_next_byte
  3340                              <1> 
  3341                              <1> 	; 16/02/2016
  3342 00008D55 8B35[90810100]      <1> 	mov	esi, [Show_LDDDT]
  3343                              <1> 	;
  3344 00008D5B 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3345 00008D5F 771C                <1> 	ja	short loc_show_check_fat_cluster_size
  3346                              <1> 
  3347                              <1> 	; Singlix FS
  3348                              <1> 	; 1 sector, more... (cluster size = 1 sector)
  3349 00008D61 A1[94810100]        <1> 	mov	eax, [Show_Cluster]
  3350 00008D66 40                  <1> 	inc	eax
  3351 00008D67 A3[94810100]        <1> 	mov	[Show_Cluster], eax
  3352                              <1> 
  3353                              <1> 	; 07/08/2022
  3354 00008D6C EBA6                <1> 	jmp	short loc_show_next
  3355                              <1> 
  3356                              <1> 	; 28/07/2022
  3357                              <1> end_of_show_file:
  3358                              <1> pass_show_file:
  3359 00008D6E BE[1B3B0100]        <1> 	mov	esi, nextline
  3360 00008D73 E8E2DEFFFF          <1> 	call	print_msg
  3361 00008D78 E9D7000000          <1> 	jmp	loc_file_rw_restore_retn
  3362                              <1> 	 
  3363                              <1> loc_show_check_fat_cluster_size:
  3364                              <1> 	; 17/02/2016
  3365 00008D7D 663B1D[A2810100]    <1> 	cmp	bx, [Show_ClusterSize] ; cluster size in bytes
  3366                              <1>         ;jb	short loc_show_next_byte ; 28/07/2022
  3367                              <1> 	; 07/08/2022
  3368 00008D84 7305                <1> 	jnb	short loc_show_file_cluster_ok
  3369 00008D86 E95DFFFFFF          <1> 	jmp	loc_show_next_byte
  3370                              <1> 
  3371                              <1> loc_show_file_cluster_ok:
  3372 00008D8B 66C705[A0810100]00- <1> 	mov	word [Show_ClusterPointer], 0
  3372 00008D93 00                  <1>
  3373                              <1> 
  3374 00008D94 A1[94810100]        <1> 	mov	eax, [Show_Cluster]
  3375                              <1> 	;mov	esi, [Show_LDDDT]
  3376                              <1> loc_show_get_next_cluster:
  3377 00008D99 E819340000          <1> 	call	get_next_cluster
  3378                              <1> 	;;jc	loc_file_rw_cmd_failed
  3379                              <1> 	;jc	loc_run_cmd_failed
  3380                              <1> 	; 28/07/2022
  3381 00008D9E 733B                <1> 	jnc	short loc_show_update_ccluster
  3382 00008DA0 E9DFF7FFFF          <1> 	jmp	loc_run_cmd_failed
  3383                              <1> 
  3384                              <1> loc_show_check_tab_space:
  3385 00008DA5 3C09                <1> 	cmp	al, 09h
  3386                              <1> 	;jne	short pass_show_dec_rowcount ; 28/07/2022
  3387                              <1> 	; 07/08/2022
  3388 00008DA7 7405                <1> 	je	short loc_show_put_tab_space
  3389 00008DA9 E972FFFFFF          <1> 	jmp	pass_show_dec_rowcount
  3390                              <1> loc_show_put_tab_space:
  3391 00008DAE 8A3D[B6770100]      <1> 	mov	bh, [ACTIVE_PAGE] ; [ptty]
  3392 00008DB4 E83D91FFFF          <1> 	call	get_cpos
  3393                              <1> 	; dl = cursor column
  3394 00008DB9 80E207              <1> 	and	dl, 7 ; 18/02/2016
  3395                              <1> 	;shr	bh, 1 ; [ACTIVE_PAGE]
  3396 00008DBC 8A3D[B6770100]      <1> 	mov	bh, [ACTIVE_PAGE]
  3397 00008DC2 B307                <1> 	mov	bl, 7 ; color attribute
  3398                              <1> loc_show_put_space_chars:
  3399 00008DC4 B020                <1> 	mov	al, 20h ; space
  3400                              <1> 	;mov	bh, [ACTIVE_PAGE] ; [ptty]
  3401                              <1> 	;mov	bl, 7 ; color attribute
  3402                              <1> 	;push	dx
  3403 00008DC6 52                  <1> 	push	edx ; 29/12/2017
  3404 00008DC7 E88C94FFFF          <1> 	call	_write_tty
  3405 00008DCC 5A                  <1> 	pop	edx ; 29/12/2017
  3406                              <1> 	;pop	dx
  3407                              <1> 	; 18/02/2016
  3408 00008DCD 80FA07              <1> 	cmp	dl, 7
  3409                              <1> 	;jnb	short loc_show_check_eof ; 28/07/2022
  3410                              <1> 	; 07/08/2022
  3411 00008DD0 7205                <1> 	jb	short loc_show_next_tab_space
  3412 00008DD2 E956FFFFFF          <1> 	jmp	loc_show_check_eof
  3413                              <1> loc_show_next_tab_space:
  3414 00008DD7 FEC2                <1> 	inc	dl
  3415 00008DD9 EBE9                <1> 	jmp	short loc_show_put_space_chars
  3416                              <1> 
  3417                              <1> loc_show_update_ccluster:
  3418 00008DDB A3[94810100]        <1> 	mov	[Show_Cluster], eax
  3419 00008DE0 E9F0FEFFFF          <1>         jmp     loc_show_next_cluster
  3420                              <1> 
  3421                              <1> check_filename:
  3422                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  3423                              <1> 	; 10/10/2016
  3424                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  3425                              <1> 	; 07/08/2010 (FILE.ASM, 'proc_check_filename')
  3426                              <1> 	; 10/07/2010
  3427                              <1> 	; Derived from 'proc_check_filename'
  3428                              <1> 	; in the old TRDOS.ASM (09/02/2005).
  3429                              <1> 	;
  3430                              <1> 	; INPUT -> 
  3431                              <1> 	;	ESI = Dot File Name Location
  3432                              <1> 	; OUTPUT ->
  3433                              <1> 	;	cf = 1 -> error code in AL
  3434                              <1> 	;	     AL = ERR_INV_FILE_NAME (=26)
  3435                              <1> 	;		  Invalid file name chars   
  3436                              <1> 	;	cf = 0 -> valid file name
  3437                              <1> 	; 
  3438                              <1> 	; (EAX, ECX, EDI will be changed)
  3439                              <1> 
  3440                              <1> check_invalid_filename_chars:
  3441                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  3442                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  3443                              <1> 	; 10/07/2010 (FILE.ASM, 'proc_check_invalid_filename_chars')
  3444                              <1> 	; 10/02/2010
  3445                              <1> 	; Derived from 'proc_check_invalid_filename_chars'
  3446                              <1> 	; in the old TRDOS.ASM (09/02/2005).
  3447                              <1> 	;
  3448                              <1> 	; INPUT -> 
  3449                              <1> 	;	ESI = ASCIIZ FileName
  3450                              <1> 	; OUTPUT ->
  3451                              <1> 	;	cf = 1 -> invalid
  3452                              <1> 	;	cf = 0 -> valid
  3453                              <1> 	; 
  3454                              <1> 	;(EAX, ECX, EDI will be changed)
  3455                              <1>   
  3456 00008DE5 56                  <1> 	push	esi
  3457                              <1> 
  3458 00008DE6 BF[99310100]        <1>         mov     edi, invalid_fname_chars
  3459 00008DEB AC                  <1> 	lodsb
  3460                              <1> check_filename_next_char:
  3461 00008DEC B914000000          <1> 	mov	ecx, sizeInvFnChars
  3462 00008DF1 BF[99310100]        <1> 	mov	edi, invalid_fname_chars
  3463                              <1> loc_scan_invalid_filename_char:
  3464 00008DF6 AE                  <1> 	scasb 
  3465 00008DF7 741E                <1> 	je	short loc_invalid_filename_stc 
  3466 00008DF9 E2FB                <1> 	loop	loc_scan_invalid_filename_char
  3467 00008DFB AC                  <1> 	lodsb
  3468 00008DFC 3C1F                <1> 	cmp	al, 1Fh  ; 20h and above 
  3469 00008DFE 77EC                <1> 	ja	short check_filename_next_char
  3470                              <1> 
  3471                              <1> check_filename_dot:
  3472 00008E00 8B3424              <1> 	mov	esi, [esp]
  3473                              <1> 
  3474 00008E03 B421                <1> 	mov	ah, 21h
  3475                              <1> 	;mov	ecx, 8
  3476                              <1> 	; 28/07/2022
  3477 00008E05 29C9                <1> 	sub	ecx, ecx
  3478 00008E07 B108                <1> 	mov	cl, 8
  3479                              <1> loc_check_filename_next_char:
  3480 00008E09 AC                  <1> 	lodsb
  3481 00008E0A 3C2E                <1> 	cmp	al, 2Eh
  3482 00008E0C 7511                <1> 	jne	short pass_check_fn_dot_check
  3483                              <1> loc_check_filename_ext_0:
  3484 00008E0E AC                  <1> 	lodsb
  3485 00008E0F 38E0                <1> 	cmp	al, ah ; 21h
  3486 00008E11 7205                <1> 	jb	short loc_invalid_filename
  3487 00008E13 3C2E                <1> 	cmp	al, 2Eh
  3488 00008E15 7519                <1> 	jne	short loc_check_filename_ext_1
  3489                              <1> 
  3490                              <1> loc_invalid_filename_stc:
  3491                              <1> loc_check_fn_stc_rtn:
  3492 00008E17 F9                  <1> 	stc
  3493                              <1> loc_invalid_filename:
  3494                              <1> 	; 10/10/2016 (0Bh -> 26)
  3495 00008E18 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; (=26)
  3496                              <1> 	; Invalid file name chars
  3497                              <1> loc_check_fn_rtn:
  3498 00008E1D 5E                  <1> 	pop	esi
  3499 00008E1E C3                  <1> 	retn
  3500                              <1> 
  3501                              <1> pass_check_fn_dot_check:
  3502 00008E1F 38E0                <1> 	cmp	al, ah ; 21h
  3503 00008E21 7224                <1> 	jb	short loc_check_fn_clc_rtn
  3504 00008E23 E2E4                <1> 	loop	loc_check_filename_next_char
  3505 00008E25 AC                  <1> 	lodsb
  3506 00008E26 38E0                <1> 	cmp	al, ah ; 21h
  3507 00008E28 721D                <1> 	jb	short loc_check_fn_clc_rtn
  3508 00008E2A 3C2E                <1> 	cmp	al, 2Eh
  3509 00008E2C 75E9                <1> 	jne	short loc_check_fn_stc_rtn
  3510 00008E2E EBDE                <1> 	jmp	short loc_check_filename_ext_0
  3511                              <1> 
  3512                              <1> loc_check_filename_ext_1:
  3513 00008E30 AC                  <1> 	lodsb
  3514 00008E31 38E0                <1> 	cmp	al, ah ; 21h
  3515 00008E33 7212                <1> 	jb	short loc_check_fn_clc_rtn
  3516 00008E35 3C2E                <1> 	cmp	al, 2Eh
  3517 00008E37 74DE                <1> 	je	short loc_check_fn_stc_rtn
  3518 00008E39 AC                  <1> 	lodsb
  3519 00008E3A 38E0                <1> 	cmp	al, ah ; 21h
  3520 00008E3C 7209                <1> 	jb	short loc_check_fn_clc_rtn
  3521 00008E3E 3C2E                <1> 	cmp	al, 2Eh
  3522 00008E40 74D5                <1> 	je	short loc_check_fn_stc_rtn
  3523 00008E42 AC                  <1> 	lodsb
  3524 00008E43 38E0                <1> 	cmp	al, ah ; 21h
  3525 00008E45 73D0                <1> 	jnb	short loc_check_fn_stc_rtn
  3526                              <1> 
  3527                              <1> loc_check_fn_clc_rtn:
  3528 00008E47 5E                  <1> 	pop	esi
  3529 00008E48 F8                  <1> 	clc
  3530 00008E49 C3                  <1> 	retn
  3531                              <1> 
  3532                              <1> loc_print_deleted_message:
  3533 00008E4A BE[85350100]        <1> 	mov	esi, Msg_Deleted
  3534 00008E4F E806DEFFFF          <1> 	call	print_msg
  3535                              <1> 
  3536                              <1> 	;clc
  3537                              <1> 
  3538                              <1> loc_file_rw_restore_retn:
  3539                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  3540                              <1> 	; 28/02/2010 (CMD_INTR.ASM)
  3541                              <1> loc_file_rw_cmd_failed:
  3542 00008E54 9C                  <1> 	pushf 
  3543 00008E55 E892F7FFFF          <1> 	call	restore_cdir_after_cmd_fail	
  3544 00008E5A 9D                  <1> 	popf
  3545 00008E5B 720D                <1> 	jc	short loc_file_rw_check_write_fault
  3546 00008E5D C3                  <1> 	retn
  3547                              <1> 
  3548                              <1> loc_permission_denied:
  3549                              <1> 	; 27/02/2016
  3550 00008E5E BE[92350100]        <1> 	mov	esi, Msg_Permission_Denied
  3551 00008E63 E8F2DDFFFF          <1> 	call	print_msg
  3552 00008E68 EBEA                <1> 	jmp	short loc_file_rw_restore_retn
  3553                              <1> 
  3554                              <1> loc_file_rw_check_write_fault:
  3555                              <1> 	;cmp	al, 1Dh ; Write Fault
  3556 00008E6A 3C12                <1>         cmp	al, 18 ; 05/11/2016
  3557                              <1> 	;jne	loc_run_cmd_failed_cmp_al
  3558                              <1> 	; 28/07/2022
  3559 00008E6C 7405                <1> 	je	short loc_file_rw_fault
  3560 00008E6E E916F7FFFF          <1> 	jmp	loc_run_cmd_failed_cmp_al
  3561                              <1> 
  3562                              <1> loc_file_rw_fault:
  3563 00008E73 BE[7A330100]        <1> 	mov	esi, Msg_Not_Ready_Write_Err
  3564                              <1> 	;call	print_msg
  3565                              <1> 	;retn
  3566 00008E78 E9DDDDFFFF          <1> 	jmp	print_msg
  3567                              <1> 
  3568                              <1> make_directory:
  3569                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  3570                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  3571                              <1> 	; 12/03/2011 (CMD_INTR.ASM, 'cmp_cmd_mkdir')
  3572                              <1> 	; 14/08/2010
  3573                              <1> 	; 10/07/2010
  3574                              <1> 	; 29/11/2009
  3575                              <1> 	;
  3576                              <1> get_mkdir_fchar:
  3577                              <1> 	; esi = directory name
  3578 00008E7D 803E20              <1> 	cmp	byte [esi], 20h
  3579 00008E80 7701                <1>         ja	short loc_mkdir_parse_path_name
  3580                              <1> 
  3581                              <1> loc_mkdir_nodirname_retn:
  3582 00008E82 C3                  <1> 	retn
  3583                              <1> 
  3584                              <1> loc_mkdir_parse_path_name:
  3585 00008E83 BF[EA800100]        <1> 	mov	edi, FindFile_Drv
  3586 00008E88 E8771C0000          <1>         call    parse_path_name
  3587                              <1> 	;jc	loc_cmd_failed
  3588                              <1> 	; 28/07/2022
  3589 00008E8D 7305                <1> 	jnc	short loc_mkdir_check_dirname_exists
  3590                              <1> loc_mkdir_cmd_failed:
  3591 00008E8F E9C5F6FFFF          <1> 	jmp	loc_cmd_failed
  3592                              <1> 
  3593                              <1> loc_mkdir_check_dirname_exists:
  3594 00008E94 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  3595 00008E99 803E20              <1> 	cmp	byte [esi], 20h
  3596                              <1> 	;jna	loc_cmd_failed
  3597                              <1> 	; 28/07/2022
  3598 00008E9C 76F1                <1> 	jna	short loc_mkdir_cmd_failed
  3599 00008E9E 8935[A8810100]      <1> 	mov	[DelFile_FNPointer], esi
  3600 00008EA4 E83CFFFFFF          <1> 	call	check_filename
  3601 00008EA9 725B                <1> 	jc	short loc_mkdir_invalid_dir_name_chars
  3602                              <1> 
  3603                              <1> loc_mkdir_drv:
  3604 00008EAB 8A35[4A780100]      <1> 	mov	dh, [Current_Drv]
  3605 00008EB1 8835[A77F0100]      <1> 	mov	[RUN_CDRV], dh
  3606                              <1> 	
  3607 00008EB7 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
  3608 00008EBD 38F2                <1> 	cmp	dl, dh
  3609 00008EBF 7409                <1> 	je	short loc_mkdir_change_directory
  3610                              <1> 
  3611 00008EC1 E8CCE8FFFF          <1> 	call	change_current_drive
  3612                              <1> 	;jc	loc_file_rw_cmd_failed
  3613                              <1> 	; 28/07/2022
  3614 00008EC6 7302                <1> 	jnc	short loc_mkdir_change_directory
  3615 00008EC8 EB8A                <1> 	jmp	loc_file_rw_cmd_failed
  3616                              <1> 
  3617                              <1> loc_mkdir_change_directory:
  3618 00008ECA 803D[EB800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  3619 00008ED1 7614                <1> 	jna	short loc_mkdir_find_directory
  3620                              <1> 
  3621 00008ED3 FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  3622 00008ED9 BE[EB800100]        <1> 	mov	esi, FindFile_Directory
  3623 00008EDE 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3624 00008EE0 E833160000          <1> 	call	change_current_directory
  3625 00008EE5 7226                <1> 	jc	short loc_mkdir_check_error_code
  3626                              <1> 
  3627                              <1> ;loc_mkdir_change_prompt_dir_string:
  3628                              <1> 	;call	change_prompt_dir_string
  3629                              <1> 
  3630                              <1> loc_mkdir_find_directory:
  3631                              <1> 	;mov	esi, FindFile_Name
  3632 00008EE7 8B35[A8810100]      <1> 	mov	esi, [DelFile_FNPointer]
  3633                              <1> 	;xor	eax, eax
  3634 00008EED 6631C0              <1> 	xor	ax, ax ; any name (dir, file, volume)
  3635 00008EF0 E84BFBFFFF          <1> 	call	find_first_file
  3636 00008EF5 7216                <1> 	jc	short loc_mkdir_check_error_code
  3637                              <1> 
  3638                              <1> loc_mkdir_directory_found:
  3639 00008EF7 BE[DD340100]        <1> 	mov	esi, Msg_Name_Exists
  3640                              <1> loc_mkdir_inv_dname_chrs_msg:
  3641 00008EFC E859DDFFFF          <1> 	call	print_msg
  3642 00008F01 E94EFFFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3643                              <1> 
  3644                              <1> loc_mkdir_invalid_dir_name_chars:
  3645 00008F06 BE[B0340100]        <1> 	mov	esi, Msg_invalid_name_chars
  3646                              <1> 	;call	print_msg
  3647                              <1>         ;jmp	loc_file_rw_restore_retn
  3648                              <1> 	; 28/07/2022
  3649 00008F0B EBEF                <1> 	jmp	short loc_mkdir_inv_dname_chrs_msg
  3650                              <1> 
  3651                              <1> loc_mkdir_check_error_code:
  3652 00008F0D 3C02                <1> 	cmp	al, 2
  3653                              <1> 	;je	short loc_mkdir_directory_not_found
  3654 00008F0F 7406                <1> 	je	short loc_mkdir_ask_for_yes_no
  3655 00008F11 F9                  <1> 	stc
  3656 00008F12 E93DFFFFFF          <1>         jmp     loc_file_rw_cmd_failed
  3657                              <1> 
  3658                              <1> loc_mkdir_directory_not_found:
  3659                              <1> loc_mkdir_ask_for_yes_no:
  3660 00008F17 BE[FE340100]        <1> 	mov	esi, Msg_DoYouWantMkdir
  3661 00008F1C E839DDFFFF          <1> 	call	print_msg
  3662 00008F21 8B35[A8810100]      <1> 	mov	esi, [DelFile_FNPointer]
  3663 00008F27 E82EDDFFFF          <1> 	call	print_msg
  3664 00008F2C BE[1D350100]        <1> 	mov	esi, Msg_YesNo
  3665 00008F31 E824DDFFFF          <1> 	call	print_msg
  3666                              <1> 
  3667 00008F36 C605[27350100]20    <1> 	mov	byte [Y_N_nextline], 20h
  3668                              <1> 
  3669                              <1> loc_mkdir_ask_again:
  3670 00008F3D 30E4                <1> 	xor	ah, ah
  3671 00008F3F E8C47FFFFF          <1> 	call	int16h
  3672 00008F44 3C1B                <1> 	cmp	al, 1Bh
  3673                              <1> 	;je	short loc_do_not_make_directory
  3674 00008F46 743B                <1> 	je	short loc_mkdir_y_n_escape
  3675 00008F48 24DF                <1> 	and	al, 0DFh ; y -> Y, n -> N
  3676 00008F4A 3C59                <1> 	cmp	al, 'Y' ; 'yes'
  3677 00008F4C 7404                <1> 	je	short loc_mkdir_yes_make_directory
  3678 00008F4E 3C4E                <1> 	cmp	al, 'N' ; 'no'
  3679 00008F50 75EB                <1> 	jne	short loc_mkdir_ask_again
  3680                              <1> 
  3681                              <1> loc_do_not_make_directory:
  3682                              <1> loc_mkdir_yes_make_directory:
  3683 00008F52 E830000000          <1> 	call	y_n_answer ; 29/12/2017
  3684                              <1> 	;cmp	al, 'Y' ; 'yes'
  3685                              <1> 	;cmc
  3686                              <1>         ;jnc	loc_file_rw_restore_retn
  3687 00008F57 3C4E                <1> 	cmp	al, 'N' ; 'no'
  3688                              <1> 	;je	loc_file_rw_restore_retn
  3689                              <1> 	; 28/07/2022
  3690 00008F59 7505                <1> 	jne	short loc_mkdir_call_make_sub_dir
  3691 00008F5B E9F4FEFFFF          <1> 	jmp	loc_file_rw_restore_retn		
  3692                              <1> 
  3693                              <1> loc_mkdir_call_make_sub_dir:
  3694 00008F60 8B35[A8810100]      <1> 	mov	esi, [DelFile_FNPointer]
  3695 00008F66 B110                <1> 	mov	cl, 10h ; Directory attributes 
  3696 00008F68 E88B1C0000          <1> 	call	make_sub_directory
  3697                              <1> loc_rename_file_ok: ; 06/03/2016
  3698                              <1>         ;jc	loc_file_rw_cmd_failed
  3699                              <1> 	; 28/07/2022
  3700 00008F6D 7305                <1> 	jnc	short move_source_file_to_dest_OK
  3701 00008F6F E9E0FEFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3702                              <1> move_source_file_to_dest_OK:
  3703 00008F74 BE[2B350100]        <1> 	mov	esi, Msg_OK
  3704 00008F79 E8DCDCFFFF          <1> 	call	print_msg
  3705 00008F7E E9D1FEFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3706                              <1> 
  3707                              <1> loc_mkdir_y_n_escape:
  3708 00008F83 B04E                <1> 	mov	al, 'N' ; 'no'
  3709 00008F85 EBCB                <1> 	jmp	short loc_do_not_make_directory
  3710                              <1> 
  3711                              <1> y_n_answer:
  3712                              <1> 	; 29/12/2017
  3713 00008F87 A2[27350100]        <1> 	mov	[Y_N_nextline], al
  3714                              <1> 	;push	ax
  3715 00008F8C 50                  <1> 	push	eax
  3716 00008F8D BE[27350100]        <1> 	mov	esi, Y_N_nextline
  3717 00008F92 E8C3DCFFFF          <1> 	call	print_msg
  3718 00008F97 58                  <1> 	pop	eax
  3719                              <1> 	;pop	ax
  3720 00008F98 C3                  <1> 	retn
  3721                              <1> 
  3722                              <1> delete_directory:
  3723                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  3724                              <1> 	; 29/12/2017
  3725                              <1> 	; 15/10/2016
  3726                              <1> 	; 01/03/2016, 06/03/2016
  3727                              <1> 	; 27/02/2016, 28/02/2016, 29/02/2016
  3728                              <1> 	; 26/02/2016 (TRDOS 386 = TRDOS v2.0)
  3729                              <1> 	; 16/10/2010 (CMD_INTR.ASM, 'cmp_cmd_rmdir')
  3730                              <1> 	; 05/06/2010
  3731                              <1> 	;
  3732                              <1> get_fchar:
  3733                              <1> 	; esi = directory name
  3734 00008F99 803E20              <1> 	cmp	byte [esi], 20h
  3735 00008F9C 7701                <1>         ja	short loc_rmdir_parse_path_name
  3736                              <1> 
  3737                              <1> loc_rmdir_nodirname_retn:
  3738 00008F9E C3                  <1> 	retn
  3739                              <1> 
  3740                              <1> loc_rmdir_parse_path_name:
  3741 00008F9F BF[EA800100]        <1> 	mov	edi, FindFile_Drv
  3742 00008FA4 E85B1B0000          <1> 	call	parse_path_name
  3743                              <1> 	;jc	loc_cmd_failed
  3744                              <1> 	; 28/07/2022
  3745 00008FA9 7305                <1> 	jnc	short loc_rmdir_check_dirname_exists
  3746                              <1> lc_del_dir_failed:
  3747 00008FAB E9A9F5FFFF          <1> 	jmp	loc_cmd_failed
  3748                              <1> 
  3749                              <1> loc_rmdir_check_dirname_exists:
  3750 00008FB0 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  3751 00008FB5 803E20              <1> 	cmp	byte [esi], 20h
  3752                              <1> 	;jna	loc_cmd_failed
  3753                              <1> 	; 28/07/2022
  3754 00008FB8 76F1                <1> 	jna	short lc_del_dir_failed 
  3755 00008FBA 8935[A8810100]      <1> 	mov	[DelFile_FNPointer], esi 
  3756                              <1> 
  3757                              <1> loc_rmdir_drv:
  3758 00008FC0 8A35[4A780100]      <1> 	mov	dh, [Current_Drv]
  3759 00008FC6 8835[A77F0100]      <1> 	mov	[RUN_CDRV], dh
  3760                              <1> 
  3761 00008FCC 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
  3762 00008FD2 38F2                <1> 	cmp	dl, dh
  3763 00008FD4 7407                <1> 	je	short loc_rmdir_change_directory
  3764                              <1> 
  3765 00008FD6 E8B7E7FFFF          <1> 	call	change_current_drive
  3766                              <1> 	;jc	loc_file_rw_cmd_failed
  3767                              <1> 	; 28/07/2022
  3768                              <1> 	;jnc	short loc_rmdir_change_directory
  3769                              <1> 	;jmp	loc_file_rw_cmd_failed
  3770 00008FDB 7233                <1> 	jc	short loc_rmdir_chdrv_failed
  3771                              <1> 
  3772                              <1> loc_rmdir_change_directory:
  3773 00008FDD 803D[EB800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  3774 00008FE4 7614                <1> 	jna	short loc_rmdir_find_directory
  3775                              <1> 
  3776 00008FE6 FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  3777 00008FEC BE[EB800100]        <1> 	mov	esi, FindFile_Directory
  3778 00008FF1 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3779 00008FF3 E820150000          <1> 	call	change_current_directory
  3780 00008FF8 7211                <1> 	jc	short loc_rmdir_check_error_code
  3781                              <1> 
  3782                              <1> ;loc_rmdir_change_prompt_dir_string:
  3783                              <1> 	;call	change_prompt_dir_string
  3784                              <1> 
  3785                              <1> loc_rmdir_find_directory:
  3786                              <1> 	;mov	esi, FindFile_Name
  3787 00008FFA 8B35[A8810100]      <1> 	mov	esi, [DelFile_FNPointer]
  3788 00009000 66B81008            <1> 	mov	ax, 0810h ; Only directories
  3789 00009004 E837FAFFFF          <1> 	call	find_first_file
  3790 00009009 730A                <1> 	jnc	short loc_rmdir_ambgfn_check
  3791                              <1> 
  3792                              <1> loc_rmdir_check_error_code:
  3793 0000900B 3C02                <1> 	cmp	al, 2
  3794 0000900D 740B                <1> 	je	short loc_rmdir_directory_not_found
  3795 0000900F F9                  <1> 	stc
  3796                              <1> loc_rmdir_chdrv_failed:
  3797 00009010 E93FFEFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3798                              <1> 
  3799                              <1> loc_rmdir_ambgfn_check:
  3800 00009015 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3801 00009018 740F                <1> 	jz	short loc_rmdir_directory_found
  3802                              <1> 
  3803                              <1> loc_rmdir_directory_not_found:
  3804 0000901A BE[9C330100]        <1> 	mov	esi, Msg_Dir_Not_Found
  3805 0000901F E836DCFFFF          <1> 	call	print_msg
  3806                              <1> 
  3807 00009024 E92BFEFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3808                              <1> 
  3809                              <1> loc_rmdir_directory_found:
  3810 00009029 80E307              <1> 	and	bl, 07h ; Attributes
  3811                              <1> 	;jnz	loc_permission_denied
  3812                              <1> 	; 28/07/2022
  3813 0000902C 7405                <1> 	jz	short loc_rmdir_save_lnel
  3814 0000902E E92BFEFFFF          <1> 	jmp	loc_permission_denied	
  3815                              <1> 
  3816                              <1> loc_rmdir_save_lnel: ; 28/02/2016
  3817                              <1>        ;mov	bh, [LongName_EntryLength]
  3818 00009033 883D[B2810100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
  3819                              <1> 	; edi = Directory Entry Offset (DirBuff)
  3820                              <1> 	; esi = Directory Entry (FFF Structure)
  3821                              <1> 	;mov	[DelFile_DirEntryAddr], edi ; not required
  3822                              <1> 	;mov	ax, [edi+20] ; First Cluster High Word
  3823                              <1>         ;shl	eax, 16
  3824                              <1> 	;mov	ax, [edi+26] ; First Cluster Low Word
  3825                              <1> 	; ROOT Dir First Cluster = 0
  3826                              <1>         ;cmp	eax, 2
  3827                              <1> 	;jb	loc_update_direntry_1
  3828                              <1> 
  3829                              <1> pass_rmdir_fc_check:
  3830 00009039 57                  <1> 	push	edi ; * (29/02/2016)
  3831                              <1> 
  3832 0000903A BE[31350100]        <1> 	mov	esi, Msg_DoYouWantRmDir
  3833 0000903F E816DCFFFF          <1> 	call	print_msg
  3834 00009044 8B35[A8810100]      <1> 	mov	esi, [DelFile_FNPointer]
  3835 0000904A E80BDCFFFF          <1> 	call	print_msg
  3836 0000904F BE[1D350100]        <1> 	mov	esi, Msg_YesNo
  3837 00009054 E801DCFFFF          <1> 	call	print_msg
  3838                              <1> 
  3839                              <1> loc_rmdir_ask_again:
  3840 00009059 30E4                <1> 	xor	ah, ah
  3841 0000905B E8A87EFFFF          <1> 	call	int16h
  3842 00009060 3C1B                <1> 	cmp	al, 1Bh
  3843                              <1> 	;je	short loc_do_not_delete_directory
  3844 00009062 742F                <1>         je	short loc_rmdir_y_n_escape ; 06/03/2016
  3845 00009064 24DF                <1> 	and	al, 0DFh
  3846 00009066 A2[27350100]        <1> 	mov	[Y_N_nextline], al
  3847 0000906B 3C59                <1> 	cmp	al, 'Y'
  3848 0000906D 7404                <1> 	je	short loc_rmdir_yes_delete_directory
  3849 0000906F 3C4E                <1> 	cmp	al, 'N'
  3850 00009071 75E6                <1> 	jne	short loc_rmdir_ask_again
  3851                              <1> 
  3852                              <1> loc_do_not_delete_directory:
  3853                              <1> loc_rmdir_yes_delete_directory:
  3854 00009073 E80FFFFFFF          <1> 	call	y_n_answer ; 29/12/2017
  3855 00009078 5F                  <1> 	pop	edi ; * (29/02/2016)
  3856                              <1> 	;cmp	al, 'Y' ; 'yes'
  3857                              <1> 	;cmc
  3858                              <1>         ;jnc	loc_file_rw_restore_retn
  3859 00009079 3C4E                <1> 	cmp	al, 'N' ; 'no'
  3860                              <1> 	;je	loc_file_rw_restore_retn
  3861                              <1> 	; 28/07/2022
  3862                              <1> 	;jne	short loc_delete_sub_dir
  3863                              <1> 	;jmp	loc_file_rw_restore_retn
  3864 0000907B 7411                <1> 	je	short loc_rmdir_rw_restore_retn
  3865                              <1> 
  3866                              <1> loc_delete_sub_dir:
  3867                              <1> 	; 29/12/2017
  3868 0000907D E85E000000          <1> 	call	delete_sub_directory
  3869 00009082 7213                <1> 	jc	short loc_rmdir_cmd_failed
  3870                              <1> 
  3871                              <1> loc_rmdir_ok:
  3872 00009084 BE[2B350100]        <1> 	mov	esi, Msg_OK
  3873 00009089 E8CCDBFFFF          <1> 	call	print_msg
  3874                              <1> loc_rmdir_rw_restore_retn: ; 28/07/2022
  3875 0000908E E9C1FDFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3876                              <1> 
  3877                              <1> loc_rmdir_y_n_escape:
  3878 00009093 B04E                <1> 	mov	al, 'N' ; 'no'
  3879 00009095 EBDC                <1>         jmp     loc_do_not_delete_directory
  3880                              <1> 
  3881                              <1> loc_rmdir_cmd_failed:
  3882                              <1> 	; 29/12/2017
  3883 00009097 09C0                <1> 	or	eax, eax ; EAX = 0 -> Directory not empty!
  3884 00009099 7423                <1> 	jz	short loc_rmdir_directory_not_empty
  3885                              <1> 
  3886                              <1> 	; EAX > 0 -> Error code in AL (or AX or EAX)
  3887                              <1> 
  3888 0000909B 833D[667F0100]01    <1> 	cmp	dword [FAT_ClusterCounter], 1
  3889                              <1> 	;jb	loc_file_rw_cmd_failed
  3890                              <1> 	; 28/07/2022
  3891 000090A2 7305                <1> 	jnb	short loc_rmdir_failed
  3892 000090A4 E9ABFDFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3893                              <1> 	
  3894                              <1> loc_rmdir_failed:
  3895 000090A9 F9                  <1> 	stc
  3896                              <1> loc_rmdir_cmd_return:
  3897                              <1> 	; 01/03/2016
  3898 000090AA 9C                  <1> 	pushf
  3899                              <1> 	; ESI = Logical DOS Drive Description Table address	
  3900 000090AB 66BB00FF            <1> 	mov	bx, 0FF00h ; BH = FFh -> use ESI for Drive parameters
  3901                              <1> 	           ; BL = 0 -> Recalculate free cluster count
  3902 000090AF 50                  <1> 	push	eax
  3903 000090B0 E805370000          <1> 	call	calculate_fat_freespace	
  3904 000090B5 58                  <1> 	pop	eax
  3905 000090B6 9D                  <1> 	popf
  3906                              <1> 	;jc	loc_file_rw_cmd_failed
  3907                              <1> 	;jmp	loc_file_rw_restore_retn
  3908                              <1> 	; 28/07/2022
  3909 000090B7 73D5                <1> 	jnc	short loc_rmdir_rw_restore_retn
  3910 000090B9 E996FDFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3911                              <1> 
  3912                              <1> loc_rmdir_directory_not_empty:
  3913 000090BE BE[52350100]        <1> 	mov	esi, Msg_Dir_Not_Empty
  3914 000090C3 E892DBFFFF          <1> 	call	print_msg
  3915                              <1> 	; 01/03/2016
  3916 000090C8 A1[667F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
  3917 000090CD 09C0                <1> 	or	eax, eax ; 0 ?
  3918                              <1> 	;jz	loc_file_rw_restore_retn
  3919                              <1> 	; 28/07/2022
  3920 000090CF 74BD                <1> 	jz	short loc_rmdir_rw_restore_retn	
  3921                              <1> 
  3922                              <1> 	; ESI = Logical DOS Drive Description Table address	
  3923 000090D1 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> use ESI for Drive parameters
  3924                              <1> 	           ; BL = 1 -> add free clusters
  3925 000090D5 E8E0360000          <1> 	call	calculate_fat_freespace
  3926 000090DA 09C9                <1> 	or	ecx, ecx
  3927                              <1> 	;jz	loc_file_rw_restore_retn ; ecx = 0 -> OK
  3928                              <1> 	;; ecx > 0 -> Error (Recalculation is needed)
  3929                              <1> 	;jmp	short loc_rmdir_cmd_return
  3930                              <1> 	; 28/07/2022
  3931 000090DC 75CC                <1> 	jnz	short loc_rmdir_cmd_return
  3932 000090DE EBAE                <1> 	jmp	short loc_rmdir_rw_restore_retn
  3933                              <1> 	;jmp	loc_file_rw_restore_retn
  3934                              <1> 
  3935                              <1> 
  3936                              <1> delete_sub_directory:
  3937                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  3938                              <1> 	; 29/12/2017 
  3939                              <1> 	; (moved here from 'delete_directory' for 'sysrmdir' )
  3940                              <1> 
  3941                              <1> 	; EDI = Directory buffer entry offset/address
  3942                              <1> 
  3943                              <1> loc_rmdir_delete_short_name_check_dir_empty:
  3944 000090E0 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  3945 000090E4 C1E010              <1>         shl	eax, 16
  3946 000090E7 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  3947                              <1> 
  3948                              <1> 	;mov 	[DelFile_FCluster], eax
  3949                              <1> 
  3950                              <1> 	;;mov	bx, [DirBuff_EntryCounter]
  3951                              <1> 	;mov	bx, [FindFile_DirEntryNumber] ; 27/02/2016
  3952                              <1> 	;mov	[DelFile_EntryCounter], bx
  3953                              <1> 
  3954 000090EB 29DB                <1>     	sub	ebx, ebx
  3955                              <1> 	; 29/12/2017
  3956 000090ED 891D[667F0100]      <1> 	mov	[FAT_ClusterCounter], ebx ; 0 ; Reset
  3957                              <1> 
  3958 000090F3 8A3D[EA800100]      <1> 	mov	bh, [FindFile_Drv]
  3959 000090F9 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3960 000090FE 01DE                <1> 	add	esi, ebx
  3961                              <1> 
  3962 00009100 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h
  3963 00009106 745A                <1> 	je	short loc_rmdir_check_fs_directory
  3964                              <1> 
  3965                              <1> 	;cmp	byte [esi+LD_FATType], 1
  3966                              <1> 	;jb	short loc_rmdir_get__last_cluster_0
  3967                              <1> 
  3968                              <1> 	; 29/12/2017
  3969 00009108 83F802              <1> 	cmp	eax, 2
  3970 0000910B 7306                <1> 	jnb	short loc_rmdir_get_last_cluster_1
  3971                              <1> 	; eax < 2
  3972                              <1> loc_rmdir_get_last_cluster_0:
  3973                              <1> 	;mov	eax, ERR_INV_FORMAT ; invalid format!
  3974 0000910D B813000000          <1> 	mov	eax, ERR_NOT_DIR ; not a valid directory!
  3975                              <1> 	;stc
  3976 00009112 C3                  <1> 	retn
  3977                              <1> 
  3978                              <1> loc_rmdir_get_last_cluster_1:
  3979 00009113 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3 ; FAT32
  3980 00009117 750C                <1> 	jne	short loc_rmdir_get_last_cluster_2
  3981                              <1> 
  3982                              <1> 	; is it root directory ?
  3983 00009119 3B4632              <1> 	cmp	eax, [esi+LD_BPB+BPB_RootClus]
  3984 0000911C 7507                <1> 	jne	short loc_rmdir_get_last_cluster_2
  3985                              <1> 
  3986                              <1> 	; root directory can not be deleted !!
  3987                              <1> loc_rmdir_permission_denied:
  3988 0000911E B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; permission denied!
  3989 00009123 F9                  <1> 	stc
  3990 00009124 C3                  <1> 	retn		
  3991                              <1> 
  3992                              <1> loc_rmdir_get_last_cluster_2:
  3993                              <1> 	; 29/12/2017
  3994 00009125 A3[AC810100]        <1> 	mov 	[DelFile_FCluster], eax
  3995                              <1> 	
  3996                              <1> 	;mov	dx, [DirBuff_EntryCounter]
  3997 0000912A 668B15[64810100]    <1> 	mov	dx, [FindFile_DirEntryNumber] ; 27/02/2016
  3998 00009131 668915[B0810100]    <1> 	mov	[DelFile_EntryCounter], dx
  3999                              <1> 	
  4000 00009138 8B15[767F0100]      <1> 	mov	edx, [DirBuff_Cluster]
  4001 0000913E 8915[DC810100]      <1> 	mov	[RmDir_ParentDirCluster], edx
  4002                              <1> 
  4003 00009144 893D[D8810100]      <1> 	mov	[RmDir_DirEntryOffset], edi
  4004                              <1> 
  4005                              <1> 	; 01/03/2016
  4006                              <1> 	;mov	dword [FAT_ClusterCounter], 0 ; Reset
  4007                              <1> 
  4008                              <1> loc_rmdir_get_last_cluster_3:
  4009 0000914A E8E9370000          <1> 	call	get_last_cluster
  4010                              <1>         ;jc	loc_rmdir_cmd_failed
  4011 0000914F 721E                <1> 	jc	short loc_delete_sub_dir_retn ; 29/12/2017
  4012                              <1> 	
  4013 00009151 3B05[AC810100]      <1> 	cmp	eax, [DelFile_FCluster]
  4014 00009157 7517                <1> 	jne	short loc_rmdir_multi_dir_clusters
  4015                              <1> 
  4016 00009159 C605[D7810100]00    <1> 	mov	byte [RmDir_MultiClusters], 0
  4017 00009160 EB15                <1> 	jmp	short pass_rmdir_multi_dir_clusters
  4018                              <1> 
  4019                              <1> loc_rmdir_check_fs_directory:
  4020                              <1> 	; 29/12/2017
  4021 00009162 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  4022 00009166 75B6                <1> 	jne	short loc_rmdir_permission_denied
  4023                              <1> 
  4024                              <1> loc_rmdir_delete_fs_directory:
  4025 00009168 E8D1120000          <1> 	call	delete_fs_directory
  4026                              <1> 	;jnc	loc_print_deleted_message
  4027 0000916D 7300                <1> 	jnc	short loc_delete_sub_dir_retn ; 29/12/2017
  4028                              <1> 
  4029                              <1> 	; EAX=0 -> Directory not empty !
  4030                              <1> 	; EAX>0 -> Disk r/w error or another (misc) error
  4031                              <1> 	
  4032                              <1> 	;or	eax, eax
  4033                              <1> 	;jz	loc_rmdir_directory_not_empty_2         
  4034                              <1> 	;;stc
  4035                              <1> 	;;jmp	loc_file_rw_cmd_failed
  4036                              <1> 	
  4037                              <1> loc_delete_sub_dir_retn:
  4038 0000916F C3                  <1> 	retn
  4039                              <1>  
  4040                              <1> loc_rmdir_multi_dir_clusters:
  4041 00009170 C605[D7810100]01    <1> 	mov	byte [RmDir_MultiClusters], 1
  4042                              <1> 
  4043                              <1> pass_rmdir_multi_dir_clusters:
  4044 00009177 A3[E0810100]        <1> 	mov 	[RmDir_DirLastCluster], eax
  4045 0000917C 890D[E4810100]      <1> 	mov	[RmDir_PreviousCluster], ecx
  4046                              <1> 
  4047                              <1> loc_rmdir_load_fat_sub_directory:
  4048 00009182 E8EC310000          <1> 	call	load_FAT_sub_directory
  4049                              <1> 	;jc	loc_rmdir_cmd_failed
  4050 00009187 72E6                <1> 	jc	short loc_delete_sub_dir_retn
  4051                              <1> 
  4052                              <1> loc_rmdir_find_last_dir_entry:
  4053 00009189 56                  <1> 	push	esi
  4054 0000918A BE[CE800100]        <1> 	mov	esi, Dir_File_Name
  4055 0000918F C6062A              <1> 	mov	byte [esi], '*'
  4056 00009192 C646082A            <1> 	mov	byte [esi+8], '*'
  4057 00009196 31DB                <1> 	xor	ebx, ebx ; Entry offset  = 0
  4058                              <1> loc_rmdir_find_last_dir_entry_next:
  4059                              <1> 	;mov	ax, 0800h ; Except volume/long names
  4060                              <1> 	;xor	cx, cx ; 0 = Find a valid file or dir name
  4061                              <1> 	; 28/07/2022
  4062 00009198 31C0                <1> 	xor	eax, eax
  4063 0000919A B408                <1> 	mov	ah, 8
  4064                              <1> 	; eax = 0800h
  4065 0000919C 31C9                <1> 	xor	ecx, ecx ; 0
  4066 0000919E E8C6160000          <1> 	call	find_directory_entry
  4067 000091A3 7225                <1> 	jc	short loc_rmdir_empty_dir_cluster
  4068 000091A5 83FB01              <1> 	cmp	ebx, 1
  4069 000091A8 771B                <1> 	ja	short loc_rmdir_directory_not_empty_1
  4070                              <1> loc_rmdir_dot_entry_check:
  4071 000091AA 80FD2E              <1> 	cmp	ch, '.' ; The first char of the dir entry
  4072 000091AD 7516                <1> 	jne	short loc_rmdir_directory_not_empty_1
  4073 000091AF 08DB                <1> 	or	bl, bl
  4074 000091B1 7506                <1> 	jnz	short loc_rmdir_dotdot_entry_check
  4075 000091B3 807F0120            <1> 	cmp	byte [edi+1], 20h
  4076 000091B7 EB06                <1> 	jmp	short pass_rmdir_dot_entry_check
  4077                              <1> 
  4078                              <1> loc_rmdir_dotdot_entry_check:
  4079 000091B9 66817F012E20        <1> 	cmp	word [edi+1], '. '
  4080                              <1> pass_rmdir_dot_entry_check:	
  4081 000091BF 7504                <1> 	jne	short loc_rmdir_directory_not_empty_1 
  4082 000091C1 FEC3                <1> 	inc	bl
  4083 000091C3 EBD3                <1> 	jmp	short loc_rmdir_find_last_dir_entry_next 
  4084                              <1> 
  4085                              <1> loc_rmdir_directory_not_empty_1:
  4086 000091C5 58                  <1> 	pop	eax ; pushed esi 
  4087 000091C6 31C0                <1> 	xor	eax, eax ; 0
  4088                              <1> loc_rmdir_directory_not_empty_2:
  4089                              <1> loc_delete_sub_dir_stc_retn:
  4090 000091C8 F9                  <1> 	stc
  4091 000091C9 C3                  <1> 	retn
  4092                              <1> 
  4093                              <1> loc_rmdir_empty_dir_cluster:
  4094 000091CA 5E                  <1> 	pop	esi
  4095                              <1> 
  4096                              <1> loc_rmdir_set_prev_cluster_dir_last_cluster:
  4097 000091CB 803D[D7810100]00    <1> 	cmp	byte [RmDir_MultiClusters], 0
  4098 000091D2 7613                <1> 	jna	short loc_rmdir_unlink_dir_last_cluster
  4099                              <1> 
  4100 000091D4 A1[E4810100]        <1> 	mov	eax, [RmDir_PreviousCluster]
  4101                              <1> 	;xor	ecx, ecx
  4102 000091D9 49                  <1> 	dec	ecx ; FFFFFFFFh
  4103 000091DA E8C7320000          <1> 	call	update_cluster
  4104 000091DF 7306                <1> 	jnc	short loc_rmdir_unlink_dir_last_cluster
  4105                              <1> 
  4106                              <1> 	; 01/03/2016
  4107                              <1> 	;cmp	eax, 1  ; eax = 0 -> end of cluster chain
  4108                              <1> 	;cmc 
  4109                              <1> 	;jc	short loc_rmdir_cmd_failed
  4110                              <1> 	;jmp	short loc_rmdir_save_fat_buffer
  4111                              <1> 	; 29/12/2017 
  4112 000091E1 21C0                <1> 	and	eax, eax
  4113 000091E3 75E3                <1> 	jnz	short loc_delete_sub_dir_stc_retn
  4114 000091E5 EB12                <1> 	jmp	short loc_rmdir_save_fat_buffer	
  4115                              <1> 
  4116                              <1> loc_rmdir_unlink_dir_last_cluster:
  4117 000091E7 A1[E0810100]        <1> 	mov	eax, [RmDir_DirLastCluster]
  4118 000091EC 31C9                <1> 	xor	ecx, ecx ; 0
  4119 000091EE E8B3320000          <1> 	call	update_cluster
  4120 000091F3 7327                <1> 	jnc	short loc_rmdir_unlink_stc_retn_0Bh
  4121                              <1> 	; Because of it is the last cluster
  4122                              <1> 	; 'update_cluster' must return with eocc error 
  4123 000091F5 09C0                <1> 	or	eax, eax
  4124                              <1> 	;jz	short loc_rmdir_save_fat_buffer ; eocc	
  4125                              <1> 	;stc
  4126                              <1>         ;jmp	short loc_rmdir_cmd_failed
  4127                              <1> 	; 29/12/2017
  4128 000091F7 75CF                <1> 	jnz	short loc_delete_sub_dir_stc_retn
  4129                              <1> 	
  4130                              <1> loc_rmdir_save_fat_buffer:
  4131 000091F9 803D[5E7F0100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
  4132 00009200 7527                <1> 	jne	short loc_rmdir_calculate_FAT_freespace
  4133 00009202 E822350000          <1> 	call	save_fat_buffer
  4134                              <1> 	;jc	short loc_rmdir_cmd_failed
  4135                              <1> 	; 29/12/2017
  4136 00009207 7219                <1> 	jc	short loc_rmdir_unlink_error_retn
  4137                              <1> 
  4138                              <1> 	; 01/03/2016
  4139 00009209 803D[D7810100]00    <1> 	cmp	byte [RmDir_MultiClusters], 0
  4140 00009210 7617                <1> 	jna	short loc_rmdir_calculate_FAT_freespace
  4141                              <1> 
  4142 00009212 A1[AC810100]        <1> 	mov	eax, [DelFile_FCluster]
  4143 00009217 E92EFFFFFF          <1>         jmp     loc_rmdir_get_last_cluster_3
  4144                              <1> 
  4145                              <1> loc_rmdir_unlink_stc_retn_0Bh:
  4146                              <1> 	; 15/10/2016 (0Bh -> 28)
  4147 0000921C B81C000000          <1> 	mov	eax, ERR_INV_FORMAT ; 28 = Invalid format
  4148                              <1> loc_rmdir_unlink_stc_retn:
  4149 00009221 F9                  <1> 	stc
  4150                              <1> loc_rmdir_unlink_error_retn:
  4151 00009222 C3                  <1> 	retn
  4152                              <1> 
  4153                              <1> loc_rmdir_delete_short_name_invalid_data:
  4154                              <1> 	;mov	eax, 29 ; Invalid data (15/10/2016)
  4155                              <1> 	; 28/07/2022
  4156 00009223 29C0                <1> 	sub	eax, eax
  4157 00009225 B01D                <1> 	mov	al, 29
  4158                              <1> 	;stc
  4159                              <1>         ;jmp	loc_rmdir_cmd_failed
  4160                              <1> 	; 29/12/2017
  4161 00009227 EBF8                <1> 	jmp	short loc_rmdir_unlink_stc_retn
  4162                              <1> 
  4163                              <1> loc_rmdir_calculate_FAT_freespace:
  4164                              <1> 	;mov	eax, [FAT_ClusterCounter]
  4165                              <1> 	; 29/12/2017
  4166 00009229 29C0                <1> 	sub	eax, eax ; 0
  4167 0000922B 8705[667F0100]      <1> 	xchg	eax, [FAT_ClusterCounter]
  4168                              <1> 	;
  4169 00009231 66BB01FF            <1> 	mov	bx, 0FF01h
  4170                              <1> 	; BL = 1 -> Add EAX to free space count
  4171                              <1> 	; BH = FFh ->
  4172                              <1> 	; ESI = Logical DOS Drive Description Table address
  4173 00009235 E880350000          <1> 	call	calculate_fat_freespace
  4174                              <1> 
  4175 0000923A 21C9                <1> 	and	ecx, ecx ; ecx = 0 -> valid free sector count
  4176 0000923C 7409                <1> 	jz 	short loc_rmdir_delete_short_name_continue
  4177                              <1> 
  4178                              <1> loc_rmdir_recalculate_FAT_freespace:
  4179 0000923E 66BB00FF            <1>         mov     bx, 0FF00h ; BL = 0 -> Recalculate free space
  4180 00009242 E873350000          <1> 	call	calculate_fat_freespace
  4181                              <1> 	          
  4182                              <1> loc_rmdir_delete_short_name_continue:
  4183 00009247 A1[DC810100]        <1> 	mov	eax, [RmDir_ParentDirCluster]
  4184 0000924C 83F802              <1> 	cmp	eax, 2
  4185 0000924F 7309                <1> 	jnb	short loc_rmdir_del_short_name_load_sub_dir
  4186 00009251 E89F300000          <1> 	call	load_FAT_root_directory
  4187                              <1> 	;jc	loc_file_rw_cmd_failed
  4188                              <1> 	; 29/12/2017
  4189 00009256 72CA                <1> 	jc	short loc_rmdir_unlink_error_retn
  4190 00009258 EB07                <1> 	jmp	short loc_rmdir_del_short_name_ld_chk_fclust
  4191                              <1> 
  4192                              <1> loc_rmdir_del_short_name_load_sub_dir:	
  4193 0000925A E814310000          <1> 	call	load_FAT_sub_directory
  4194                              <1> 	;jc	loc_file_rw_cmd_failed
  4195                              <1> 	; 29/12/2017
  4196 0000925F 72C1                <1> 	jc	short loc_rmdir_unlink_error_retn
  4197                              <1> 
  4198                              <1> loc_rmdir_del_short_name_ld_chk_fclust:
  4199 00009261 0FB73D[D8810100]    <1> 	movzx	edi, word [RmDir_DirEntryOffset]
  4200 00009268 81C700000800        <1> 	add	edi, Directory_Buffer
  4201                              <1> 
  4202 0000926E 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  4203 00009272 C1E010              <1> 	shl	eax, 16
  4204 00009275 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  4205                              <1>         ; Not necessary... 
  4206 00009279 3B05[AC810100]      <1> 	cmp	eax, [DelFile_FCluster]
  4207 0000927F 75A2                <1> 	jne	short loc_rmdir_delete_short_name_invalid_data
  4208                              <1> 	;
  4209 00009281 C607E5              <1> 	mov	byte [edi], 0E5h ; 'Deleted' sign
  4210                              <1> 	; 27/02/2016
  4211                              <1> 	; TRDOS v1 has a bug here! it does not set
  4212                              <1> 	; 'DirBuff_ValidData' to 2; as result of this bug,
  4213                              <1> 	; 'save_directory_buffer' would not save the change ! 
  4214 00009284 C605[717F0100]02    <1>   	mov	byte [DirBuff_ValidData], 2 ; change sign
  4215                              <1> 	;
  4216 0000928B E8B01C0000          <1> 	call	save_directory_buffer
  4217                              <1> 	;jc	loc_file_rw_cmd_failed
  4218                              <1> 	; 29/12/2017
  4219 00009290 7290                <1> 	jc	short loc_rmdir_unlink_error_retn
  4220                              <1> 
  4221                              <1> loc_rmdir_del_long_name:
  4222 00009292 0FB615[B2810100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  4223 00009299 08D2                <1> 	or	dl, dl
  4224 0000929B 7410                <1> 	jz	short loc_rmdir_update_parent_dir_lmdt
  4225                              <1>              
  4226 0000929D 0FB705[B0810100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
  4227 000092A4 29D0                <1> 	sub	eax, edx
  4228                              <1> 	; 29/12/2017
  4229 000092A6 7205                <1> 	jc	short loc_rmdir_update_parent_dir_lmdt
  4230                              <1>  
  4231                              <1>  	; EAX = Directory Entry Number of the long name last entry
  4232 000092A8 E8EC1D0000          <1> 	call	delete_longname
  4233                              <1> 
  4234                              <1> loc_rmdir_update_parent_dir_lmdt:
  4235 000092AD E8261D0000          <1> 	call	update_parent_dir_lmdt
  4236                              <1> 	;jc	short loc_file_rw_cmd_failed
  4237                              <1> 	; 29/12/2017
  4238                              <1> 	;jc	short loc_rmdir_unlink_error_retn
  4239                              <1> 
  4240                              <1> loc_delete_sub_directory_ok:
  4241                              <1> 	; 29/12/2017
  4242 000092B2 31C0                <1> 	xor	eax, eax ;  0 ;  cf = 0
  4243 000092B4 C3                  <1> 	retn
  4244                              <1> 
  4245                              <1> delete_file:
  4246                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  4247                              <1> 	; 29/02/2016
  4248                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  4249                              <1> 	; 09/08/2010 (CMD_INTR.ASM, 'cmp_cmd_del')
  4250                              <1> 	; 28/02/2010
  4251                              <1> 
  4252                              <1> get_delfile_fchar:
  4253                              <1> 	; esi = file name
  4254 000092B5 803E20              <1> 	cmp	byte [esi], 20h
  4255 000092B8 7701                <1>         ja	short loc_delfile_parse_path_name
  4256                              <1> 
  4257                              <1> loc_delfile_nofilename_retn:
  4258 000092BA C3                  <1> 	retn
  4259                              <1> 
  4260                              <1> loc_delfile_parse_path_name:
  4261 000092BB BF[EA800100]        <1> 	mov	edi, FindFile_Drv
  4262 000092C0 E83F180000          <1> 	call	parse_path_name
  4263                              <1> 	;jc	loc_cmd_failed
  4264                              <1> 	; 28/07/2022
  4265 000092C5 7305                <1> 	jnc	short loc_delfile_check_filename_exists
  4266                              <1> loc_delfile_failed:
  4267 000092C7 E98DF2FFFF          <1> 	jmp	loc_cmd_failed
  4268                              <1> 
  4269                              <1> loc_delfile_check_filename_exists:
  4270 000092CC BE[2C810100]        <1> 	mov	esi, FindFile_Name
  4271 000092D1 803E20              <1> 	cmp	byte [esi], 20h
  4272                              <1> 	;jna	loc_cmd_failed
  4273                              <1> 	; 28/07/2022
  4274 000092D4 76F1                <1> 	jna	short loc_delfile_failed
  4275 000092D6 8935[A8810100]      <1> 	mov	[DelFile_FNPointer], esi 
  4276                              <1> 
  4277                              <1> loc_delfile_drv:
  4278 000092DC 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
  4279 000092E2 8A35[4A780100]      <1> 	mov	dh, [Current_Drv]
  4280 000092E8 8835[A77F0100]      <1> 	mov	[RUN_CDRV], dh
  4281 000092EE 38F2                <1> 	cmp	dl, dh
  4282 000092F0 7407                <1> 	je	short loc_delfile_change_directory
  4283                              <1> 
  4284 000092F2 E89BE4FFFF          <1> 	call	change_current_drive
  4285                              <1> 	;jc	loc_file_rw_cmd_failed
  4286                              <1> 	; 28/07/2022
  4287                              <1> 	;jnc	short loc_delfile_change_directory
  4288                              <1> 	;jmp	loc_file_rw_cmd_failed
  4289 000092F7 721D                <1> 	jc	short loc_delfile_chdrv_failed
  4290                              <1> 
  4291                              <1> loc_delfile_change_directory:
  4292 000092F9 803D[EB800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  4293 00009300 7619                <1> 	jna	short loc_delfile_find
  4294                              <1> 
  4295 00009302 FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  4296 00009308 BE[EB800100]        <1> 	mov	esi, FindFile_Directory
  4297 0000930D 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  4298 0000930F E804120000          <1> 	call	change_current_directory
  4299                              <1> 	;jc	loc_file_rw_cmd_failed
  4300                              <1> 	; 28/07/2022
  4301 00009314 7305                <1> 	jnc	short loc_delfile_chdir_ok
  4302                              <1> loc_delfile_chdrv_failed:
  4303                              <1> loc_delfile_fff_failed:
  4304 00009316 E939FBFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4305                              <1> 
  4306                              <1> loc_delfile_chdir_ok: ; 28/07/2022
  4307                              <1> 
  4308                              <1> ;loc_delfile_change_prompt_dir_string:
  4309                              <1> 	;call	change_prompt_dir_string
  4310                              <1> 
  4311                              <1> loc_delfile_find:
  4312                              <1> 	;mov	esi, FindFile_Name
  4313 0000931B 8B35[A8810100]      <1> 	mov	esi, [DelFile_FNPointer]
  4314 00009321 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  4315 00009325 E816F7FFFF          <1> 	call	find_first_file
  4316                              <1> 	;jc	loc_file_rw_cmd_failed
  4317                              <1> 	; 28/07/2022
  4318 0000932A 72EA                <1> 	jc	short loc_delfile_fff_failed
  4319                              <1> 
  4320                              <1> loc_delfile_ambgfn_check:
  4321 0000932C 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  4322 0000932F 740A                <1> 	jz	short loc_delfile_found
  4323                              <1> 
  4324                              <1> loc_file_not_found:
  4325                              <1> 	;mov	eax, 2 ; File not found sign
  4326                              <1> 	; 28/07/2022
  4327 00009331 31C0                <1> 	xor	eax, eax
  4328 00009333 B002                <1> 	mov	al, 2
  4329 00009335 F9                  <1> 	stc
  4330 00009336 E919FBFFFF          <1> 	jmp	loc_file_rw_cmd_failed   
  4331                              <1> 
  4332                              <1> loc_delfile_found:
  4333 0000933B 80E307              <1> 	and	bl, 07h ; Attributes
  4334                              <1> 	;jnz	loc_permission_denied
  4335                              <1> 	; 28/07/2022
  4336 0000933E 7405                <1> 	jz	short loc_delfile_attrb_ok
  4337 00009340 E919FBFFFF          <1> 	jmp	loc_permission_denied
  4338                              <1> 
  4339                              <1> loc_delfile_attrb_ok: ; 28/07/2022
  4340                              <1> 
  4341                              <1> ;loc_delfile_found_save_lnel:
  4342                              <1> ;	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
  4343                              <1> 
  4344                              <1> loc_delfile_ask_for_delete:
  4345 00009345 57                  <1> 	push	edi ; * (29/02/2016)
  4346                              <1> 
  4347 00009346 BE[69350100]        <1> 	mov	esi, Msg_DoYouWantDelete
  4348 0000934B E80AD9FFFF          <1> 	call	print_msg
  4349 00009350 8B35[A8810100]      <1> 	mov	esi, [DelFile_FNPointer]
  4350 00009356 E8FFD8FFFF          <1> 	call	print_msg
  4351 0000935B BE[1D350100]        <1> 	mov	esi, Msg_YesNo
  4352 00009360 E8F5D8FFFF          <1> 	call	print_msg
  4353                              <1> 
  4354                              <1> loc_delfile_ask_again:
  4355 00009365 30E4                <1> 	xor	ah, ah
  4356 00009367 E89C7BFFFF          <1> 	call	int16h
  4357 0000936C 3C1B                <1> 	cmp	al, 1Bh
  4358                              <1> 	;je	short loc_do_not_delete_file
  4359 0000936E 744C                <1> 	je	short loc_delfile_y_n_escape ; 06/03/2016
  4360 00009370 24DF                <1> 	and	al, 0DFh
  4361 00009372 A2[27350100]        <1> 	mov	[Y_N_nextline], al
  4362 00009377 3C59                <1> 	cmp	al, 'Y'
  4363 00009379 7404                <1> 	je	short loc_yes_delete_file
  4364 0000937B 3C4E                <1> 	cmp	al, 'N'
  4365 0000937D 75E6                <1> 	jne	short loc_delfile_ask_again
  4366                              <1> 
  4367                              <1> loc_do_not_delete_file:
  4368                              <1> loc_yes_delete_file:
  4369 0000937F E803FCFFFF          <1> 	call	y_n_answer ; 29/12/2017
  4370 00009384 5F                  <1> 	pop	edi ; * (29/02/2016)
  4371                              <1> 	;cmp	al, 'Y' ; 'yes'
  4372                              <1> 	;cmc
  4373                              <1>         ;jnc	loc_file_rw_restore_retn
  4374 00009385 3C4E                <1> 	cmp	al, 'N' ; 'no'
  4375                              <1>         ;je	loc_file_rw_restore_retn
  4376                              <1> 	; 28/07/2022
  4377 00009387 7505                <1> 	jne	short loc_delete_file
  4378 00009389 E9C6FAFFFF          <1> 	jmp	loc_file_rw_restore_retn
  4379                              <1> 
  4380                              <1> loc_delete_file:
  4381 0000938E 8A3D[EA800100]      <1> 	mov	bh, [FindFile_Drv]
  4382                              <1> 	;mov	bl, [DelFile_LNEL]
  4383 00009394 8A1D[39810100]      <1> 	mov	bl, [FindFile_LongNameEntryLength]
  4384                              <1> 	;mov	cx, [DirBuff_EntryCounter]
  4385 0000939A 668B0D[64810100]    <1> 	mov	cx, [FindFile_DirEntryNumber]
  4386                              <1> 	; (*) EDI = Directory buffer entry offset/address 
  4387 000093A1 E8CB1E0000          <1> 	call	remove_file ; (FILE.ASM, 'proc_delete_file')
  4388                              <1> 	;jnc	loc_print_deleted_message
  4389                              <1> 	; 28/07/2022
  4390 000093A6 7205                <1> 	jc	short loc_delete_file_err1
  4391 000093A8 E99DFAFFFF          <1> 	jmp	loc_print_deleted_message
  4392                              <1> 
  4393                              <1> loc_delete_file_err1:
  4394                              <1> 	;cmp	al, 05h
  4395 000093AD 3C0B                <1> 	cmp	al, ERR_PERM_DENIED  ; 29/12/2017 (5 -> 11)
  4396                              <1> 	;je	loc_permission_denied
  4397                              <1> 	; 28/07/2022
  4398 000093AF 7505                <1> 	jne	short loc_delete_file_err2
  4399 000093B1 E9A8FAFFFF          <1> 	jmp	loc_permission_denied
  4400                              <1> loc_delete_file_err2:
  4401 000093B6 F9                  <1> 	stc
  4402 000093B7 E998FAFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4403                              <1> 
  4404                              <1> loc_delfile_y_n_escape:
  4405 000093BC B04E                <1> 	mov	al, 'N' ; 'no'
  4406 000093BE EBBF                <1> 	jmp	short loc_do_not_delete_file
  4407                              <1> 
  4408                              <1> set_file_attributes:
  4409                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  4410                              <1> 	; 06/03/2016
  4411                              <1> 	; 04/03/2016 (TRDOS 386 = TRDOS v2.0)
  4412                              <1> 	; 10/07/2010 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_attrib')
  4413                              <1> 	; 23/05/2010 
  4414                              <1> 	; 17/12/2000 (P2000.ASM)
  4415                              <1> 
  4416                              <1> 	; esi = file or directory name
  4417                              <1> 	;xor	ax, ax
  4418                              <1> 	; 28/07/2022
  4419 000093C0 31C0                <1> 	xor	eax, eax
  4420 000093C2 66A3[BA350100]      <1> 	mov	[Attr_Chars], ax
  4421 000093C8 A2[00820100]        <1> 	mov	[Attributes], al
  4422                              <1> 
  4423                              <1> get_attrib_fchar:
  4424                              <1> 	; esi = file name
  4425 000093CD 8A06                <1> 	mov	al, [esi]
  4426 000093CF 3C20                <1> 	cmp	al, 20h
  4427 000093D1 7621                <1> 	jna	short loc_attr_file_nofilename_retn
  4428                              <1> 
  4429                              <1> loc_scan_attrib_params:
  4430 000093D3 3C2D                <1> 	cmp	al, '-'
  4431                              <1> 	;ja	loc_attr_file_parse_path_name
  4432                              <1> 	;je	short loc_attr_space
  4433                              <1> 	; 28/07/2022
  4434 000093D5 7207                <1> 	jb	short loc_sfa_1
  4435 000093D7 740E                <1> 	je	short loc_attr_space
  4436 000093D9 E911010000          <1> 	jmp	loc_attr_file_parse_path_name
  4437                              <1> 	
  4438                              <1> loc_sfa_1:
  4439                              <1> 	; 28/07/2022
  4440 000093DE 3C2B                <1> 	cmp	al, '+'
  4441                              <1> 	;jne	loc_cmd_failed
  4442 000093E0 7405                <1> 	je	short loc_attr_space
  4443                              <1> loc_sfa_2: 
  4444 000093E2 E972F1FFFF          <1> 	jmp	loc_cmd_failed	
  4445                              <1> loc_attr_space:
  4446 000093E7 8A6601              <1> 	mov	ah, [esi+1]
  4447 000093EA 80FC20              <1>  	cmp	ah, 20h
  4448 000093ED 7706                <1> 	ja	short pass_attr_space
  4449                              <1> 	;jb	loc_cmd_failed
  4450                              <1> 	; 28/07/2022
  4451 000093EF 72F1                <1> 	jb	short loc_sfa_2
  4452 000093F1 46                  <1> 	inc	esi
  4453 000093F2 EBF3                <1> 	jmp	short loc_attr_space
  4454                              <1> 
  4455                              <1> loc_attr_file_nofilename_retn:
  4456 000093F4 C3                  <1> 	retn
  4457                              <1> 
  4458                              <1> pass_attr_space:
  4459 000093F5 80E4DF              <1> 	and	ah, 0DFh
  4460 000093F8 80FC53              <1> 	cmp	ah, 'S'
  4461                              <1> 	;ja	loc_cmd_failed
  4462                              <1> 	; 28/07/2022
  4463 000093FB 77E5                <1> 	ja	short loc_sfa_2
  4464 000093FD 7204                <1> 	jb	short pass_attr_system
  4465 000093FF B404                <1> 	mov	ah, 04h	; System
  4466 00009401 EB1D                <1> 	jmp	short pass_attr_archive
  4467                              <1> 
  4468                              <1> pass_attr_system:
  4469 00009403 80FC48              <1> 	cmp	ah, 'H'
  4470 00009406 7706                <1> 	ja	short pass_attr_hidden
  4471 00009408 720F                <1> 	jb	short pass_attr_read_only
  4472 0000940A B402                <1> 	mov	ah, 02h	; Hidden
  4473 0000940C EB12                <1> 	jmp	short pass_attr_archive
  4474                              <1> 
  4475                              <1> pass_attr_hidden:
  4476 0000940E 80FC52              <1> 	cmp	ah, 'R'
  4477                              <1> 	;ja	loc_cmd_failed
  4478                              <1> 	; 28/07/2022
  4479 00009411 77CF                <1> 	ja	short loc_sfa_2
  4480 00009413 7204                <1> 	jb	short pass_attr_read_only ; Read only
  4481 00009415 B401                <1> 	mov	ah, 01h
  4482 00009417 EB07                <1> 	jmp	short pass_attr_archive
  4483                              <1> 
  4484                              <1> pass_attr_read_only:
  4485 00009419 80FC41              <1> 	cmp	ah, 'A'
  4486 0000941C 753B                <1> 	jne	short loc_chk_attr_enter
  4487 0000941E B420                <1> 	mov	ah, 20h	; Archive
  4488                              <1> 
  4489                              <1> pass_attr_archive:
  4490 00009420 3C2D                <1> 	cmp	al, '-'
  4491 00009422 7508                <1> 	jne	short pass_reducing_attributes
  4492 00009424 0825[BA350100]      <1> 	or	[Attr_Chars], ah
  4493 0000942A EB06                <1> 	jmp	short loc_change_attributes_inc
  4494                              <1> 
  4495                              <1> pass_reducing_attributes:
  4496 0000942C 0825[BB350100]      <1> 	or	[Attr_Chars+1], ah
  4497                              <1> 
  4498                              <1> loc_change_attributes_inc:
  4499 00009432 46                  <1> 	inc	esi
  4500 00009433 8A6601              <1> 	mov	ah, [esi+1]
  4501 00009436 80FC20              <1> 	cmp	ah, 20h
  4502 00009439 7228                <1> 	jb	short pass_change_attr
  4503 0000943B 74F5                <1> 	je	short loc_change_attributes_inc
  4504 0000943D 80FC2D              <1> 	cmp	ah, '-'
  4505 00009440 770D                <1> 	ja	short loc_chk_next_attr_char1
  4506 00009442 7405                <1> 	je	short loc_chk_next_attr_char0
  4507 00009444 80FC2B              <1> 	cmp	ah, '+'
  4508 00009447 7506                <1> 	jne	short loc_chk_next_attr_char1
  4509                              <1> 
  4510                              <1> loc_chk_next_attr_char0:
  4511 00009449 46                  <1> 	inc	esi
  4512 0000944A 668B06              <1> 	mov	ax, [esi]
  4513 0000944D EBA6                <1> 	jmp	short pass_attr_space
  4514                              <1> 
  4515                              <1> loc_chk_next_attr_char1:
  4516 0000944F 803E2D              <1> 	cmp	byte [esi], '-'
  4517 00009452 77A1                <1> 	ja	short pass_attr_space
  4518 00009454 E989000000          <1>         jmp     loc_attr_file_check_fname_fchar
  4519                              <1> 
  4520                              <1> loc_chk_attr_enter:
  4521 00009459 80FC0D              <1> 	cmp	ah, 0Dh
  4522                              <1> 	;jne	loc_cmd_failed
  4523                              <1> 	; 28/07/202
  4524 0000945C 7405                <1> 	je	short pass_change_attr
  4525 0000945E E9F6F0FFFF          <1> 	jmp	loc_cmd_failed
  4526                              <1> 
  4527                              <1> pass_change_attr:
  4528 00009463 A0[BA350100]        <1> 	mov	al, [Attr_Chars]
  4529 00009468 F6D0                <1> 	not	al
  4530 0000946A 2005[00820100]      <1> 	and	[Attributes], al
  4531 00009470 A0[BB350100]        <1> 	mov	al, [Attr_Chars+1]
  4532 00009475 0805[00820100]      <1> 	or	[Attributes], al
  4533                              <1> 
  4534                              <1> loc_show_attributes:
  4535 0000947B BE[1B3B0100]        <1> 	mov	esi, nextline
  4536 00009480 E8D5D7FFFF          <1> 	call	print_msg
  4537                              <1> 
  4538                              <1> loc_show_attributes_no_nextline:
  4539 00009485 C705[BA350100]4E4F- <1> 	mov	dword [Attr_Chars], 'NORM'
  4539 0000948D 524D                <1>
  4540 0000948F 66C705[BE350100]41- <1> 	mov	word [Attr_Chars+4], 'AL'
  4540 00009497 4C                  <1>
  4541 00009498 BE[BA350100]        <1> 	mov	esi, Attr_Chars
  4542 0000949D A0[00820100]        <1> 	mov	al, [Attributes]
  4543 000094A2 A804                <1> 	test	al, 04h
  4544 000094A4 7406                <1> 	jz	short pass_put_attr_s
  4545 000094A6 66C7065300          <1> 	mov	word [esi], 0053h     ; S
  4546 000094AB 46                  <1> 	inc	esi
  4547                              <1> 
  4548                              <1> pass_put_attr_s:
  4549 000094AC A802                <1> 	test	al, 02h
  4550 000094AE 7406                <1> 	jz	short pass_put_attr_h
  4551 000094B0 66C7064800          <1> 	mov	word [esi], 0048h     ; H
  4552 000094B5 46                  <1> 	inc	esi
  4553                              <1> 
  4554                              <1> pass_put_attr_h:
  4555 000094B6 A801                <1> 	test	al, 01h
  4556 000094B8 7406                <1> 	jz	short pass_put_attr_r
  4557 000094BA 66C7065200          <1> 	mov	word [esi], 0052h     ; R
  4558 000094BF 46                  <1> 	inc	esi
  4559                              <1> 
  4560                              <1> pass_put_attr_r:
  4561 000094C0 3C20                <1> 	cmp	al, 20h
  4562 000094C2 7205                <1> 	jb	short pass_put_attr_a
  4563 000094C4 66C7064100          <1> 	mov	word [esi], 0041h     ; A
  4564                              <1> 
  4565                              <1> pass_put_attr_a:
  4566 000094C9 BE[AD350100]        <1> 	mov	esi, Str_Attributes
  4567 000094CE E887D7FFFF          <1> 	call	print_msg
  4568 000094D3 BE[1B3B0100]        <1> 	mov	esi, nextline
  4569 000094D8 E87DD7FFFF          <1> 	call	print_msg
  4570 000094DD E972F9FFFF          <1> 	jmp	loc_file_rw_restore_retn 
  4571                              <1> 
  4572                              <1> loc_attr_file_check_fname_fchar:
  4573 000094E2 46                  <1> 	inc	esi
  4574 000094E3 803E20              <1> 	cmp	byte [esi], 20h
  4575 000094E6 74FA                <1> 	je	short loc_attr_file_check_fname_fchar
  4576                              <1>         ;jb	pass_change_attr
  4577                              <1> 	; 28/07/2022
  4578 000094E8 7705                <1> 	ja	short loc_attr_file_parse_path_name
  4579 000094EA E974FFFFFF          <1> 	jmp	pass_change_attr	
  4580                              <1> 	   
  4581                              <1> loc_attr_file_parse_path_name:
  4582 000094EF BF[EA800100]        <1> 	mov	edi, FindFile_Drv
  4583 000094F4 E80B160000          <1> 	call	parse_path_name
  4584                              <1> 	;jc	loc_cmd_failed
  4585                              <1> 	; 28/07/2022
  4586 000094F9 7305                <1> 	jnc	short loc_attr_file_check_filename_exists
  4587                              <1> loc_sfa_3:
  4588 000094FB E959F0FFFF          <1> 	jmp	loc_cmd_failed
  4589                              <1> 
  4590                              <1> loc_attr_file_check_filename_exists:
  4591 00009500 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  4592 00009505 803E20              <1> 	cmp	byte [esi], 20h
  4593                              <1> 	;jna	loc_cmd_failed
  4594                              <1> 	; 28/07/2022
  4595 00009508 76F1                <1> 	jna	short loc_sfa_3
  4596 0000950A 8935[A8810100]      <1> 	mov	[DelFile_FNPointer], esi 
  4597                              <1> 
  4598                              <1> loc_attr_file_drv:
  4599 00009510 8A35[4A780100]      <1> 	mov	dh, [Current_Drv]
  4600 00009516 8835[A77F0100]      <1> 	mov	[RUN_CDRV], dh
  4601                              <1> 
  4602 0000951C 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
  4603 00009522 38F2                <1> 	cmp	dl, dh
  4604 00009524 7407                <1> 	je	short loc_attr_file_change_directory
  4605                              <1> 
  4606 00009526 E867E2FFFF          <1> 	call	change_current_drive
  4607                              <1> 	;jc	loc_file_rw_cmd_failed
  4608                              <1> 	; 28/07/2022
  4609 0000952B 722E                <1> 	jc	short loc_sfa_4
  4610                              <1> 
  4611                              <1> loc_attr_file_change_directory:
  4612 0000952D 803D[EB800100]20    <1>         cmp     byte [FindFile_Directory], 20h
  4613 00009534 7614                <1> 	jna	short loc_attr_file_find
  4614                              <1> 
  4615 00009536 FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  4616                              <1> 	
  4617 0000953C BE[EB800100]        <1> 	mov	esi, FindFile_Directory
  4618 00009541 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  4619 00009543 E8D00F0000          <1> 	call	change_current_directory
  4620                              <1> 	;jc	loc_file_rw_cmd_failed
  4621                              <1> 	; 28/07/2022
  4622 00009548 7211                <1> 	jc	short loc_sfa_4
  4623                              <1> 
  4624                              <1> ;loc_attr_file_change_prompt_dir_string:
  4625                              <1> 	;call	change_prompt_dir_string
  4626                              <1> 
  4627                              <1> loc_attr_file_find:
  4628                              <1> 	;mov	esi, FindFile_Name
  4629 0000954A 8B35[A8810100]      <1> 	mov	esi, [DelFile_FNPointer]
  4630 00009550 66B80008            <1> 	mov	ax, 0800h ; Except volume labels
  4631 00009554 E8E7F4FFFF          <1> 	call	find_first_file
  4632                              <1> 	;jc	loc_file_rw_cmd_failed
  4633                              <1> 	; 28/07/2022
  4634 00009559 7305                <1> 	jnc	short loc_attr_file_ambgfn_check
  4635                              <1> loc_sfa_4:
  4636 0000955B E9F4F8FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4637                              <1> 
  4638                              <1> loc_attr_file_ambgfn_check:
  4639 00009560 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  4640                              <1> 	;	(Note: It was BX in TRDOS v1)
  4641                              <1> 	;;jz	short loc_attr_file_found
  4642                              <1> 	;jnz	loc_file_not_found ; 06/03/2016
  4643                              <1> 	; 28/07/2022 
  4644 00009563 7405                <1> 	jz	short loc_attr_file_found
  4645 00009565 E9C7FDFFFF          <1> 	jmp	loc_file_not_found	
  4646                              <1> 
  4647                              <1> 	;mov	eax, 2 ; File not found sign
  4648                              <1> 	;stc
  4649                              <1> 	;jmp	loc_file_rw_cmd_failed   
  4650                              <1> 
  4651                              <1> loc_attr_file_found:
  4652                              <1> 	; EDI = Directory buffer entry offset/address
  4653                              <1> 	; BL = File (or Directory) Attributes 
  4654                              <1> 	;	(Note: It was 'CL' in TRDOS v1)
  4655                              <1> 	; mov	bl, [EDI+0Bh]
  4656                              <1> 	
  4657 0000956A 66833D[BA350100]00  <1> 	cmp	word [Attr_Chars], 0
  4658 00009572 770B                <1> 	ja	short loc_attr_file_change_attributes
  4659 00009574 881D[00820100]      <1> 	mov	[Attributes], bl
  4660 0000957A E9FCFEFFFF          <1> 	jmp	loc_show_attributes
  4661                              <1> 
  4662                              <1> loc_attr_file_change_attributes:
  4663 0000957F A0[BA350100]        <1> 	mov	al, [Attr_Chars]
  4664 00009584 F6D0                <1> 	not	al
  4665 00009586 20C3                <1> 	and	bl, al
  4666 00009588 A0[BB350100]        <1> 	mov	al, [Attr_Chars+1]
  4667 0000958D 08C3                <1> 	or	bl, al
  4668                              <1> 
  4669 0000958F 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
  4670 00009595 741C                <1> 	je	short loc_attr_file_fs_check
  4671                              <1> 
  4672 00009597 881D[00820100]      <1> 	mov	[Attributes], bl
  4673 0000959D 885F0B              <1> 	mov	[edi+0Bh], bl    ; Attributes (New!)
  4674                              <1> 
  4675                              <1> 	; 04/03/2016
  4676                              <1> 	; TRDOS v1 has a bug here! it does not set
  4677                              <1> 	; 'DirBuff_ValidData' to 2; as result of this bug,
  4678                              <1> 	; 'save_directory_buffer' would not save the new attributes ! 
  4679                              <1> 	
  4680 000095A0 C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  4681                              <1> 
  4682 000095A7 E894190000          <1> 	call 	save_directory_buffer
  4683                              <1> 	;jc	loc_file_rw_cmd_failed
  4684                              <1> 	;jmp	short loc_print_attr_changed_message
  4685                              <1> 	; 28/07/2022
  4686 000095AC 7334                <1> 	jnc	short loc_print_attr_changed_message
  4687                              <1> loc_sfa_5:
  4688 000095AE E9A1F8FFFF          <1> 	jmp	loc_file_rw_cmd_failed 
  4689                              <1> 
  4690                              <1> loc_attr_file_fs_check:
  4691 000095B3 29C0                <1> 	sub	eax, eax
  4692 000095B5 8A25[6F7F0100]      <1>         mov     ah, [DirBuff_DRV]
  4693 000095BB BE00010900          <1> 	mov	esi, Logical_DOSDisks
  4694 000095C0 01C6                <1>         add     esi, eax
  4695 000095C2 807E04A1            <1>         cmp     byte [esi+LD_FSType], 0A1h
  4696 000095C6 7309                <1> 	jnc	short loc_attr_file_change_fs_file_attributes
  4697                              <1> 	; 29/12/2017 (0Dh -> 29)	
  4698 000095C8 66B81D00            <1> 	mov	ax, 29 ; Invalid Data
  4699 000095CC E983F8FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4700                              <1> 
  4701                              <1> loc_attr_file_change_fs_file_attributes:
  4702                              <1> 	; BL = New MS-DOS File Attributes
  4703 000095D1 88D8                <1> 	mov	al, bl ; File/Directory Attributes
  4704 000095D3 30E4                <1> 	xor	ah, ah ; Attributes in MS-DOS format sign	  
  4705 000095D5 E848050000          <1> 	call	change_fs_file_attributes
  4706                              <1> 	;jc	loc_file_rw_cmd_failed
  4707                              <1> 	; 28/07/2022
  4708 000095DA 72D2                <1> 	jc	short loc_sfa_5
  4709                              <1> 
  4710 000095DC 881D[00820100]      <1> 	mov	[Attributes], bl 
  4711                              <1> 
  4712                              <1> loc_print_attr_changed_message:
  4713 000095E2 BE[A8350100]        <1> 	mov	esi, Msg_New
  4714 000095E7 E86ED6FFFF          <1> 	call	print_msg
  4715 000095EC E994FEFFFF          <1> 	jmp	loc_show_attributes_no_nextline
  4716                              <1> 
  4717                              <1> rename_file:
  4718                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  4719                              <1> 	; 13/11/2017
  4720                              <1> 	; 06/11/2016
  4721                              <1> 	; 05/11/2016
  4722                              <1> 	; 16/10/2016
  4723                              <1> 	; 08/03/2016
  4724                              <1> 	; 06/03/2016 (TRDOS 386 = TRDOS v2.0)
  4725                              <1> 	; 20/11/2010 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_rename')
  4726                              <1> 	; 16/11/2010 
  4727                              <1> 
  4728                              <1> get_rename_source_fchar:
  4729                              <1> 	; esi = file name
  4730 000095F1 803E20              <1> 	cmp	byte [esi], 20h
  4731 000095F4 7613                <1>         jna	short loc_rename_nofilename_retn
  4732                              <1> 
  4733 000095F6 8935[28820100]      <1> 	mov	[SourceFilePath], esi
  4734                              <1> 
  4735                              <1> rename_scan_source_file:
  4736 000095FC 46                  <1> 	inc	esi
  4737 000095FD 803E20              <1> 	cmp	byte [esi], 20h
  4738 00009600 7408                <1> 	je	short rename_scan_destination_file_1
  4739                              <1> 	;;jb	short loc_rename_nofilename_retn
  4740                              <1> 	;jb	loc_cmd_failed
  4741                              <1> 	;jmp	short rename_scan_source_file
  4742                              <1> 	; 28/07/2022
  4743 00009602 77F8                <1> 	ja	short rename_scan_source_file
  4744                              <1> loc_rename_failed:
  4745 00009604 E950EFFFFF          <1> 	jmp	loc_cmd_failed
  4746                              <1> 
  4747                              <1> loc_rename_nofilename_retn: ; 08/03/2016
  4748 00009609 C3                  <1> 	retn
  4749                              <1> 
  4750                              <1> rename_scan_destination_file_1:
  4751 0000960A C60600              <1> 	mov	byte [esi], 0
  4752                              <1> 
  4753                              <1> rename_scan_destination_file_2:
  4754 0000960D 46                  <1> 	inc	esi  
  4755 0000960E 803E20              <1> 	cmp	byte [esi], 20h
  4756 00009611 74FA                <1> 	je	short rename_scan_destination_file_2
  4757                              <1> 	;;jb	short loc_rename_nofilename_retn
  4758                              <1> 	;jb	loc_cmd_failed
  4759                              <1> 	; 28/07/2022
  4760 00009613 72EF                <1> 	jb	short loc_rename_failed
  4761                              <1> 
  4762 00009615 8935[2C820100]      <1> 	mov	[DestinationFilePath], esi
  4763                              <1> 
  4764                              <1> rename_scan_destination_file_3:
  4765 0000961B 46                  <1> 	inc	esi  
  4766 0000961C 803E20              <1> 	cmp	byte [esi], 20h
  4767 0000961F 77FA                <1> 	ja	short rename_scan_destination_file_3
  4768                              <1> 
  4769 00009621 C60600              <1> 	mov	byte [esi], 0
  4770                              <1> 
  4771                              <1> loc_rename_save_current_drive:
  4772 00009624 8A35[4A780100]      <1> 	mov	dh, [Current_Drv]
  4773 0000962A 8835[A77F0100]      <1> 	mov	byte [RUN_CDRV], dh
  4774                              <1> 
  4775                              <1> loc_rename_sf_parse_path_name:
  4776 00009630 8B35[28820100]      <1> 	mov	esi, [SourceFilePath] 
  4777 00009636 BF[EA800100]        <1> 	mov	edi, FindFile_Drv
  4778 0000963B E8C4140000          <1> 	call	parse_path_name
  4779                              <1> 	;jc	loc_cmd_failed
  4780                              <1> 	; 28/07/2022
  4781 00009640 72C2                <1> 	jc	short loc_rename_failed
  4782                              <1> 
  4783                              <1> loc_rename_sf_check_filename_exists:
  4784 00009642 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  4785 00009647 803E20              <1> 	cmp	byte [esi], 20h
  4786                              <1> 	;jna	loc_cmd_failed
  4787                              <1> 	; 28/07/2022
  4788 0000964A 76B8                <1> 	jna	short loc_rename_failed
  4789                              <1> 
  4790                              <1> 	;mov	[DelFile_FNPointer], esi 
  4791                              <1> 
  4792                              <1> loc_rename_sf_drv:
  4793                              <1> 	;mov	dh, [Current_Drv]
  4794                              <1> 	;mov	[RUN_CDRV], dh
  4795                              <1> 
  4796 0000964C 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
  4797 00009652 38F2                <1> 	cmp	dl, dh ; dh = [Current_Drv]
  4798 00009654 7407                <1> 	je	short rename_sf_change_directory
  4799                              <1> 
  4800 00009656 E837E1FFFF          <1> 	call	change_current_drive
  4801                              <1>  	;jc	loc_file_rw_cmd_failed
  4802                              <1> 	; 28/07/2022
  4803 0000965B 722D                <1> 	jc	short loc_rename_fff_failed
  4804                              <1> 
  4805                              <1> rename_sf_change_directory:
  4806 0000965D 803D[EB800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  4807 00009664 7614                <1> 	jna	short rename_sf_find
  4808                              <1> 
  4809 00009666 FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  4810 0000966C BE[EB800100]        <1> 	mov	esi, FindFile_Directory
  4811 00009671 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  4812 00009673 E8A00E0000          <1> 	call	change_current_directory
  4813                              <1>  	;jc	loc_file_rw_cmd_failed
  4814                              <1> 	; 28/07/2022
  4815 00009678 7210                <1> 	jc	short loc_rename_fff_failed
  4816                              <1> 
  4817                              <1> ;rename_sf_change_prompt_dir_string:
  4818                              <1> 	;call	change_prompt_dir_string
  4819                              <1> 
  4820                              <1> rename_sf_find:
  4821                              <1> 	;mov	esi, [DelFile_FNPointer]
  4822 0000967A BE[2C810100]        <1> 	mov	esi, FindFile_Name
  4823                              <1> 
  4824 0000967F 66B80008            <1> 	mov	ax, 0800h ; Except volume labels
  4825 00009683 E8B8F3FFFF          <1> 	call	find_first_file
  4826                              <1> 	;jc	loc_file_rw_cmd_failed
  4827                              <1> 	; 28/07/2022
  4828 00009688 7305                <1> 	jnc	short loc_rename_sf_ambgfn_check
  4829                              <1> 
  4830                              <1> loc_rename_fff_failed:
  4831 0000968A E9C5F7FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4832                              <1> 
  4833                              <1> loc_rename_sf_ambgfn_check:
  4834 0000968F 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  4835                              <1> 	;	(Note: It was BX in TRDOS v1)
  4836                              <1> 	;;jz	short loc_rename_sf_found
  4837                              <1> 	;jnz	loc_file_not_found
  4838                              <1> 	; 28/07/2022
  4839 00009692 7405                <1> 	jz	short loc_rename_sf_found
  4840 00009694 E998FCFFFF          <1> 	jmp	loc_file_not_found
  4841                              <1> 
  4842                              <1> 	;mov	eax, 2 ; File not found sign
  4843                              <1> 	;stc
  4844                              <1> 	;jmp	loc_file_rw_cmd_failed   
  4845                              <1> 
  4846                              <1> loc_rename_sf_found:
  4847                              <1> 	; EDI = Directory buffer entry offset/address
  4848                              <1> 	; BL = File (or Directory) Attributes 
  4849                              <1> 	;	(Note: It was 'CL' in TRDOS v1)
  4850                              <1> 	; mov	bl, [EDI+0Bh]
  4851                              <1> 
  4852 00009699 F6C307              <1> 	test	bl, 07h ; Attributes, S-H-R
  4853                              <1> 	;jnz	loc_permission_denied
  4854                              <1> 	; 28/07/2022
  4855 0000969C 7405                <1> 	jz	short loc_rename_attrb_ok
  4856 0000969E E9BBF7FFFF          <1> 	jmp	loc_permission_denied
  4857                              <1> 
  4858                              <1> loc_rename_attrb_ok:	
  4859 000096A3 BE[EA800100]        <1>         mov     esi, FindFile_Drv
  4860 000096A8 BF[30820100]        <1>         mov     edi, SourceFile_Drv
  4861 000096AD B920000000          <1> 	mov	ecx, 32
  4862 000096B2 F3A5                <1> 	rep	movsd
  4863                              <1> 
  4864                              <1> loc_rename_df_parse_path_name:
  4865 000096B4 8B35[2C820100]      <1> 	mov	esi, [DestinationFilePath]
  4866 000096BA BF[EA800100]        <1> 	mov	edi, FindFile_Drv
  4867 000096BF E840140000          <1> 	call	parse_path_name
  4868 000096C4 7219                <1> 	jc	short loc_rename_df_cmd_failed
  4869                              <1> 
  4870                              <1> 	;mov	dh, [RUN_CDRV]
  4871 000096C6 8A35[4A780100]      <1> 	mov	dh, [Current_Drv]
  4872                              <1> 
  4873                              <1> 	; 'rename' command is valid only for same dos drive and same dir!
  4874                              <1> 	; ('move' command must be used if source file and destination file
  4875                              <1> 	; directories are not same!) 
  4876 000096CC 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
  4877 000096D2 38F2                <1> 	cmp	dl, dh ; are source and destination drives different ?!
  4878 000096D4 7509                <1> 	jne	short loc_rename_df_cmd_failed ; yes! 
  4879                              <1> 
  4880                              <1> rename_df_check_dirname_exists:
  4881 000096D6 803D[EB800100]00    <1> 	cmp	byte [FindFile_Directory], 0
  4882 000096DD 760B                <1> 	jna	short rename_df_check_filename_exists
  4883                              <1> 
  4884                              <1> 	; different source file and destination file directories !
  4885                              <1> loc_rename_df_cmd_failed:
  4886 000096DF B801000000          <1> 	mov	eax, 1 ; TRDOS 'Bad command or file name' error
  4887 000096E4 F9                  <1> 	stc
  4888 000096E5 E96AF7FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4889                              <1> 	  
  4890                              <1> rename_df_check_filename_exists:
  4891 000096EA BE[2C810100]        <1> 	mov	esi, FindFile_Name
  4892 000096EF E8F1F6FFFF          <1> 	call	check_filename
  4893                              <1> 	;jc	loc_mkdir_invalid_dir_name_chars
  4894                              <1> 	; 28/07/2022
  4895 000096F4 7305                <1> 	jnc	short loc_rename_file_name_ok
  4896 000096F6 E90BF8FFFF          <1> 	jmp	loc_mkdir_invalid_dir_name_chars
  4897                              <1> 
  4898                              <1> loc_rename_file_name_ok:
  4899                              <1> 	;mov	[DelFile_FNPointer], esi 
  4900                              <1> 	;cmp	byte [esi], 20h
  4901                              <1> 	;ja	short loc_rename_df_find
  4902                              <1> 
  4903                              <1> 	;mov	dh, [Current_Drv] ; dh has not been changed
  4904                              <1> 
  4905                              <1> rename_df_drv_check_writable:
  4906 000096FB 0FB6F6              <1> 	movzx	esi, dh
  4907                              <1> 	;movzx	esi, byte [Current_Drv]
  4908 000096FE 81C600010900        <1> 	add	esi, Logical_DOSDisks
  4909                              <1> 
  4910 00009704 88F2                <1> 	mov	dl, dh ; dl = [Current_Drv]
  4911 00009706 8A7601              <1> 	mov	dh, [esi+LD_DiskType]
  4912                              <1> 
  4913 00009709 80FE01              <1> 	cmp	dh, 1 ; 0 = Invalid
  4914 0000970C 7310                <1> 	jnb	short rename_df_compare_sf_df_name
  4915                              <1> 
  4916                              <1> 	; 16/10/2016 (13h -> 30)
  4917 0000970E B81E000000          <1> 	mov	eax, 30 ; 'Disk write-protected' error
  4918 00009713 8B1D[2C820100]      <1> 	mov	ebx, [DestinationFilePath] 
  4919 00009719 E936F7FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4920                              <1> 
  4921                              <1> rename_df_compare_sf_df_name:
  4922 0000971E BE[2C810100]        <1> 	mov	esi, FindFile_Name
  4923 00009723 BF[72820100]        <1> 	mov	edi, SourceFile_Name
  4924                              <1> 	;mov	ecx, 12
  4925                              <1> 	; 28/07/2022
  4926 00009728 29C9                <1> 	sub	ecx, ecx
  4927 0000972A B10C                <1> 	mov	cl, 12
  4928                              <1> rename_df_compare_sf_df_name_next: 
  4929 0000972C AC                  <1> 	lodsb
  4930 0000972D AE                  <1> 	scasb
  4931 0000972E 7506                <1> 	jne	short loc_rename_df_find
  4932 00009730 08C0                <1> 	or	al, al
  4933 00009732 74AB                <1> 	jz	short loc_rename_df_cmd_failed
  4934 00009734 E2F6                <1> 	loop	rename_df_compare_sf_df_name_next 
  4935                              <1> 
  4936                              <1> loc_rename_df_find:
  4937                              <1> 	;mov	esi, [DelFile_FNPointer]
  4938 00009736 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  4939                              <1> 
  4940                              <1> 	;xor	ax, ax ; Any
  4941                              <1> 	; 28/07/2022
  4942 0000973B 31C0                <1> 	xor	eax, eax ; 0 ; Any
  4943 0000973D E8FEF2FFFF          <1> 	call	find_first_file
  4944                              <1> 	;;jnc	short loc_rename_df_found
  4945                              <1> 	;; 29/12/2017
  4946                              <1> 	;jnc	loc_permission_denied
  4947                              <1> 	; 28/07/2022
  4948 00009742 7205                <1> 	jc	short loc_rename_df_check_error_code
  4949 00009744 E915F7FFFF          <1> 	jmp	loc_permission_denied	
  4950                              <1> 
  4951                              <1> loc_rename_df_check_error_code:
  4952                              <1> 	;cmp	eax, 2
  4953 00009749 3C02                <1> 	cmp	al, 2 ; Not found error
  4954 0000974B 7406                <1> 	je	short rename_df_move_find_struct_to_dest
  4955 0000974D F9                  <1> 	stc
  4956 0000974E E901F7FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4957                              <1> 
  4958                              <1> ;loc_rename_df_found:
  4959                              <1> 	; 05/11/2016
  4960                              <1> 	; Permission denied error
  4961                              <1> 	;mov	eax, ERR_PERM_DENIED ; 29/12/2017
  4962                              <1> 	;stc
  4963                              <1> 	;jmp	loc_permission_denied  ; 06/11/2016
  4964                              <1> 
  4965                              <1> rename_df_move_find_struct_to_dest:
  4966 00009753 BE[EA800100]        <1>         mov     esi, FindFile_Drv
  4967 00009758 BF[B0820100]        <1>         mov     edi, DestinationFile_Drv
  4968                              <1> 	;mov	ecx, 32
  4969                              <1> 	; 28/07/2022
  4970 0000975D 29C9                <1> 	sub	ecx, ecx
  4971 0000975F B120                <1> 	mov	cl, 32
  4972 00009761 F3A5                <1> 	rep	movsd
  4973                              <1> 
  4974                              <1> loc_rename_df_process_q_sf:
  4975                              <1> 	;mov	ecx, 12
  4976 00009763 B10C                <1> 	mov	cl, 12
  4977 00009765 BE[72820100]        <1>  	mov	esi, SourceFile_Name
  4978 0000976A BF[E9350100]        <1> 	mov	edi, Rename_OldName
  4979                              <1> rename_df_process_q_nml_1_sf:
  4980 0000976F AC                  <1> 	lodsb
  4981 00009770 3C20                <1>         cmp	al, 20h
  4982 00009772 7603                <1>         jna	short rename_df_process_q_nml_2_sf
  4983 00009774 AA                  <1> 	stosb
  4984 00009775 E2F8                <1> 	loop	rename_df_process_q_nml_1_sf
  4985                              <1> 
  4986                              <1> rename_df_process_q_nml_2_sf:
  4987 00009777 C60700              <1> 	mov	byte [edi], 0
  4988                              <1> 
  4989                              <1> loc_rename_df_process_q_df:
  4990                              <1> 	;mov	ecx, 12
  4991 0000977A B10C                <1> 	mov	cl, 12
  4992 0000977C BE[F2820100]        <1> 	mov	esi, DestinationFile_Name
  4993 00009781 BF[FA350100]        <1> 	mov	edi, Rename_NewName
  4994                              <1> rename_df_process_q_nml_1_df:
  4995 00009786 AC                  <1> 	lodsb
  4996 00009787 3C20                <1> 	cmp	al, 20h
  4997 00009789 7603                <1> 	jna	short loc_rename_df_process_q_nml_2_df
  4998 0000978B AA                  <1> 	stosb
  4999 0000978C E2F8                <1> 	loop	rename_df_process_q_nml_1_df
  5000                              <1> 
  5001                              <1> loc_rename_df_process_q_nml_2_df:
  5002 0000978E C60700              <1> 	mov	byte [edi], 0
  5003                              <1> 
  5004                              <1> loc_rename_confirmation_question:
  5005 00009791 BE[C1350100]        <1> 	mov	esi, Msg_DoYouWantRename
  5006 00009796 E8BFD4FFFF          <1> 	call	print_msg
  5007                              <1> 
  5008 0000979B A0[8D820100]        <1> 	mov	al, [SourceFile_DirEntry+11] ; Attributes
  5009 000097A0 2410                <1> 	and	al, 10h
  5010 000097A2 750C                <1> 	jnz	short rename_confirmation_question_dir
  5011                              <1> 
  5012                              <1> rename_confirmation_question_file:
  5013 000097A4 BE[D8350100]        <1> 	mov	esi, Rename_File
  5014 000097A9 E8ACD4FFFF          <1> 	call	print_msg 
  5015 000097AE EB0A                <1> 	jmp	short rename_confirmation_question_as 
  5016                              <1> 
  5017                              <1> rename_confirmation_question_dir:
  5018 000097B0 BE[DE350100]        <1> 	mov	esi, Rename_Directory
  5019 000097B5 E8A0D4FFFF          <1> 	call	print_msg
  5020                              <1> 
  5021                              <1> rename_confirmation_question_as:
  5022 000097BA BE[E9350100]        <1> 	mov	esi, Rename_OldName
  5023 000097BF E896D4FFFF          <1> 	call	print_msg
  5024 000097C4 BE[F6350100]        <1> 	mov	esi, Msg_File_rename_as
  5025 000097C9 E88CD4FFFF          <1> 	call	print_msg
  5026 000097CE BE[1D350100]        <1> 	mov	esi, Msg_YesNo
  5027 000097D3 E882D4FFFF          <1> 	call	print_msg
  5028                              <1> 
  5029                              <1> loc_rename_ask_again:
  5030 000097D8 30E4                <1> 	xor	ah, ah
  5031 000097DA E82977FFFF          <1> 	call	int16h
  5032 000097DF 3C1B                <1> 	cmp	al, 1Bh
  5033 000097E1 740F                <1> 	je	short loc_do_not_rename_file
  5034 000097E3 24DF                <1> 	and	al, 0DFh
  5035 000097E5 A2[27350100]        <1> 	mov	[Y_N_nextline], al
  5036 000097EA 3C59                <1> 	cmp	al, 'Y'
  5037 000097EC 7404                <1> 	je	short loc_yes_rename_file
  5038 000097EE 3C4E                <1> 	cmp	al, 'N'
  5039 000097F0 75E6                <1> 	jne	short loc_rename_ask_again
  5040                              <1> 
  5041                              <1> loc_do_not_rename_file:
  5042                              <1> loc_yes_rename_file:
  5043 000097F2 E890F7FFFF          <1> 	call	y_n_answer ; 29/12/2017
  5044                              <1> 	;cmp	al, 'Y' ; 'yes'
  5045                              <1> 	;cmc
  5046                              <1>         ;jnc	loc_file_rw_restore_retn
  5047 000097F7 3C4E                <1> 	cmp	al, 'N' ; 'no'
  5048                              <1> 	;je	loc_file_rw_restore_retn
  5049                              <1> 	; 28/07/2022
  5050 000097F9 7505                <1> 	jne	short loc_rename_file_yes
  5051 000097FB E954F6FFFF          <1> 	jmp	loc_file_rw_restore_retn
  5052                              <1> 
  5053                              <1> loc_rename_file_yes: ; 28/07/2022
  5054 00009800 BE[FA350100]        <1> 	mov	esi, Rename_NewName
  5055 00009805 668B0D[AA820100]    <1> 	mov	cx, [SourceFile_DirEntryNumber] 
  5056 0000980C 66A1[96820100]      <1> 	mov	ax, [SourceFile_DirEntry+20] ; First Cluster, HW 
  5057 00009812 C1E010              <1> 	shl	eax, 16 ; 13/11/2017
  5058 00009815 66A1[9C820100]      <1> 	mov	ax, [SourceFile_DirEntry+26] ; First Cluster, LW 
  5059                              <1> 
  5060 0000981B 0FB61D[7F820100]    <1>   	movzx	ebx, byte [SourceFile_LongNameEntryLength]  
  5061 00009822 E8E51A0000          <1>    	call	rename_directory_entry
  5062 00009827 E941F7FFFF          <1> 	jmp	loc_rename_file_ok	
  5063                              <1> ;loc_rename_file_ok:
  5064                              <1> ;	jc	loc_run_cmd_failed
  5065                              <1> ;	mov	esi, Msg_OK
  5066                              <1> ;	call	proc_printmsg
  5067                              <1> ;	jmp	loc_file_rw_restore_retn
  5068                              <1> 
  5069                              <1> move_file:
  5070                              <1> 	; 07/08/2022
  5071                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  5072                              <1> 	; 11/03/2016
  5073                              <1> 	; 09/03/2016
  5074                              <1> 	; 08/03/2016 (TRDOS 386 = TRDOS v2.0)
  5075                              <1> 	; 21/05/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_move')
  5076                              <1> 	; 23/04/2011
  5077                              <1> 
  5078                              <1> get_move_source_fchar:
  5079                              <1> 	; esi = file name
  5080 0000982C 803E20              <1> 	cmp	byte [esi], 20h
  5081 0000982F 7613                <1>         jna	short loc_move_nofilename_retn
  5082                              <1> 
  5083 00009831 8935[28820100]      <1> 	mov	[SourceFilePath], esi
  5084                              <1> 
  5085                              <1> move_scan_source_file:
  5086 00009837 46                  <1> 	inc	esi
  5087 00009838 803E20              <1> 	cmp	byte [esi], 20h
  5088 0000983B 7408                <1>         je      short move_scan_destination_1
  5089                              <1> 	;;jb	short loc_move_nofilename_retn
  5090                              <1> 	;jb	loc_cmd_failed
  5091                              <1> 	;jmp	short move_scan_source_file
  5092                              <1> 	; 28/07/2022
  5093 0000983D 77F8                <1> 	ja	short move_scan_source_file
  5094                              <1> loc_move_failed:
  5095 0000983F E915EDFFFF          <1> 	jmp	loc_cmd_failed
  5096                              <1> 
  5097                              <1> loc_move_nofilename_retn:
  5098 00009844 C3                  <1> 	retn
  5099                              <1> 
  5100                              <1> move_scan_destination_1:
  5101 00009845 C60600              <1> 	mov	byte [esi], 0
  5102                              <1> 
  5103                              <1> move_scan_destination_2:
  5104 00009848 46                  <1> 	inc	esi  
  5105 00009849 803E20              <1> 	cmp	byte [esi], 20h
  5106 0000984C 74FA                <1> 	je	short move_scan_destination_2
  5107                              <1> 	;;jb	short loc_move_nofilename_retn
  5108                              <1> 	;jb	loc_cmd_failed
  5109                              <1> 	; 28/07/2022
  5110 0000984E 72EF                <1> 	jb	short loc_move_failed	
  5111                              <1> 
  5112 00009850 8935[2C820100]      <1> 	mov	[DestinationFilePath], esi
  5113                              <1> 
  5114                              <1> move_scan_destination_3:
  5115 00009856 46                  <1> 	inc	esi  
  5116 00009857 803E20              <1> 	cmp	byte [esi], 20h
  5117 0000985A 77FA                <1> 	ja	short move_scan_destination_3
  5118 0000985C C60600              <1> 	mov	byte [esi], 0
  5119                              <1> 
  5120                              <1> loc_move_scan_destination_OK:
  5121 0000985F 8B35[28820100]      <1> 	mov	esi, [SourceFilePath]
  5122 00009865 8B3D[2C820100]      <1> 	mov	edi, [DestinationFilePath]
  5123                              <1> 
  5124 0000986B B001                <1> 	mov	al, 1  ; move procedure Phase 1
  5125 0000986D E8141B0000          <1> 	call	move_source_file_to_destination_file
  5126 00009872 7325                <1> 	jnc	short move_source_file_to_destination_question
  5127                              <1> 
  5128                              <1> loc_move_cmd_failed_1:
  5129 00009874 08C0                <1> 	or	al, al
  5130                              <1> 	;jz	loc_cmd_failed
  5131                              <1> 	; 28/07/2022
  5132 00009876 74C7                <1> 	jz	short loc_move_failed
  5133                              <1>  
  5134 00009878 3C11                <1> 	cmp	al, 11h
  5135 0000987A 7409                <1> 	je	short loc_msg_not_same_device   
  5136                              <1> 	;cmp	al, 05h
  5137                              <1> 	;cmp	al, ERR_PERM_DENIED ; 29/12/2017
  5138                              <1> 	;jne	loc_run_cmd_failed
  5139                              <1> 	;jmp	loc_permission_denied
  5140 0000987C 3C0B                <1> 	cmp	al, ERR_PERM_DENIED
  5141                              <1> 	;je	loc_permission_denied
  5142                              <1> 	; 28/07/2022
  5143 0000987E 7414                <1> 	je	short loc_move_perm_denied
  5144 00009880 E9FFECFFFF          <1> 	jmp	loc_run_cmd_failed
  5145                              <1> 
  5146                              <1> 	;mov	esi, Msg_Permission_denied
  5147                              <1> 	;call	print_msg
  5148                              <1> 	;jmp	loc_file_rw_restore_retn
  5149                              <1> 
  5150                              <1> loc_msg_not_same_device:
  5151 00009885 BE[07360100]        <1> 	mov	esi, msg_not_same_drv 
  5152 0000988A E8CBD3FFFF          <1> 	call	print_msg
  5153 0000988F E9C0F5FFFF          <1> 	jmp	loc_file_rw_restore_retn
  5154                              <1> 
  5155                              <1> 	; 28/07/2022
  5156                              <1> loc_move_perm_denied:
  5157 00009894 E9C5F5FFFF          <1> 	jmp	loc_permission_denied	
  5158                              <1> 
  5159                              <1> move_source_file_to_destination_question:
  5160 00009899 A0[30820100]        <1>         mov     al, [SourceFile_Drv]
  5161 0000989E 0441                <1> 	add	al, 'A'
  5162 000098A0 A2[69360100]        <1> 	mov	[msg_source_file_drv], al
  5163 000098A5 A0[B0820100]        <1>         mov     al, [DestinationFile_Drv]
  5164 000098AA 0441                <1> 	add	al, 'A'
  5165 000098AC A2[88360100]        <1> 	mov	[msg_destination_file_drv], al
  5166                              <1> 
  5167 000098B1 57                  <1> 	push	edi ; *
  5168                              <1> 
  5169 000098B2 BE[4D360100]        <1> 	mov	esi, msg_source_file
  5170 000098B7 E89ED3FFFF          <1> 	call	print_msg
  5171 000098BC BE[31820100]        <1> 	mov	esi, SourceFile_Directory
  5172 000098C1 803E20              <1> 	cmp	byte [esi], 20h
  5173 000098C4 7605                <1> 	jna	short msftdfq_sfn
  5174 000098C6 E88FD3FFFF          <1> 	call	print_msg
  5175                              <1> msftdfq_sfn:
  5176 000098CB BE[72820100]        <1> 	mov	esi, SourceFile_Name
  5177 000098D0 E885D3FFFF          <1> 	call	print_msg
  5178 000098D5 BE[6C360100]        <1> 	mov	esi, msg_destination_file
  5179 000098DA E87BD3FFFF          <1> 	call	print_msg
  5180 000098DF BE[B1820100]        <1> 	mov	esi, DestinationFile_Directory
  5181 000098E4 803E20              <1> 	cmp	byte [esi], 20h
  5182 000098E7 7605                <1> 	jna	short msftdfq_dfn
  5183 000098E9 E86CD3FFFF          <1> 	call	print_msg
  5184                              <1> msftdfq_dfn:
  5185 000098EE BE[F2820100]        <1> 	mov	esi, DestinationFile_Name
  5186 000098F3 E862D3FFFF          <1> 	call	print_msg
  5187 000098F8 BE[8B360100]        <1> 	mov	esi, msg_copy_nextline
  5188 000098FD E858D3FFFF          <1> 	call	print_msg
  5189 00009902 BE[8B360100]        <1> 	mov	esi, msg_copy_nextline
  5190 00009907 E84ED3FFFF          <1> 	call	print_msg
  5191                              <1> 
  5192                              <1> loc_move_ask_for_new_file_yes_no:
  5193 0000990C BE[19360100]        <1> 	mov	esi, Msg_DoYouWantMoveFile
  5194 00009911 E844D3FFFF          <1> 	call	print_msg
  5195 00009916 BE[1D350100]        <1> 	mov	esi, Msg_YesNo
  5196 0000991B E83AD3FFFF          <1> 	call	print_msg
  5197                              <1> loc_move_ask_for_new_file_again:
  5198 00009920 30E4                <1> 	xor	ah, ah
  5199 00009922 E8E175FFFF          <1> 	call	int16h
  5200 00009927 3C1B                <1> 	cmp	al, 1Bh
  5201                              <1> 	;je	short loc_do_not_move_file
  5202 00009929 743F                <1> 	je	short loc_move_y_n_escape
  5203 0000992B 24DF                <1> 	and	al, 0DFh
  5204 0000992D A2[27350100]        <1>         mov     [Y_N_nextline], al
  5205 00009932 3C59                <1> 	cmp	al, 'Y'
  5206 00009934 7404                <1> 	je	short loc_yes_move_file
  5207 00009936 3C4E                <1> 	cmp	al, 'N'
  5208 00009938 75E6                <1> 	jne	short loc_move_ask_for_new_file_again
  5209                              <1> 
  5210                              <1> loc_do_not_move_file:
  5211                              <1> loc_yes_move_file:
  5212 0000993A E848F6FFFF          <1> 	call	y_n_answer ; 29/12/2017
  5213 0000993F 5F                  <1> 	pop	edi ; *
  5214                              <1> 	;cmp	al, 'Y' ; 'yes'
  5215                              <1> 	;cmc
  5216                              <1>         ;jnc	loc_file_rw_restore_retn
  5217 00009940 3C4E                <1> 	cmp	al, 'N' ; 'no'
  5218                              <1>         ;je	loc_file_rw_restore_retn
  5219                              <1> 	; 28/07/2022
  5220 00009942 7421                <1> 	je	short loc_move_rw_restore_retn
  5221                              <1> 
  5222                              <1> loc_move_yes_move_file:
  5223 00009944 B002                <1> 	mov	al, 2 ; move procedure Phase 2
  5224 00009946 E83B1A0000          <1> 	call	move_source_file_to_destination_file
  5225                              <1> 	;;jc	short loc_move_cmd_failed_2
  5226                              <1>         ;jnc	move_source_file_to_dest_OK
  5227                              <1> 	; 28/07/2022
  5228 0000994B 7205                <1> 	jc	short loc_move_cmd_failed_2
  5229                              <1> 	; 07/08/2022
  5230 0000994D E922F6FFFF          <1> 	jmp	move_source_file_to_dest_OK
  5231                              <1> 
  5232                              <1> ;move_source_file_to_destination_OK:
  5233                              <1> ;	mov	esi, Msg_OK
  5234                              <1> ;	call	print_msg
  5235                              <1> ;	jmp	loc_file_rw_restore_retn
  5236                              <1> 
  5237                              <1> loc_move_cmd_failed_2:
  5238 00009952 3C27                <1> 	cmp	al, 27h
  5239                              <1> 	;jne	loc_run_cmd_failed
  5240                              <1> 	; 28/07/2022
  5241 00009954 7405                <1> 	je	short loc_move_ids_err
  5242 00009956 E929ECFFFF          <1> 	jmp	loc_run_cmd_failed
  5243                              <1> 
  5244                              <1> loc_move_ids_err: ; 28/07/2022
  5245 0000995B BE[32360100]        <1> 	mov	esi, msg_insufficient_disk_space
  5246 00009960 E8F5D2FFFF          <1> 	call	print_msg
  5247                              <1> 
  5248                              <1> loc_move_rw_restore_retn: ; 28/07/2022 
  5249 00009965 E9EAF4FFFF          <1> 	jmp	loc_file_rw_restore_retn
  5250                              <1> 
  5251                              <1> loc_move_y_n_escape:
  5252 0000996A B04E                <1> 	mov	al, 'N' ; 'no'
  5253 0000996C EBCC                <1> 	jmp	short loc_do_not_move_file
  5254                              <1> 
  5255                              <1> 
  5256                              <1> copy_file:
  5257                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
  5258                              <1> 	; 15/10/2016
  5259                              <1> 	; 24/03/2016
  5260                              <1> 	; 21/03/2016
  5261                              <1> 	; 15/03/2016 (TRDOS 386 = TRDOS v2.0)
  5262                              <1> 	; 21/05/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_copy')
  5263                              <1> 	; 01/08/2010
  5264                              <1> 
  5265                              <1> get_copy_source_fchar:
  5266                              <1> 	; esi = file name
  5267 0000996E 803E20              <1> 	cmp	byte [esi], 20h
  5268 00009971 7613                <1>         jna     short loc_copy_nofilename_retn
  5269                              <1> 
  5270 00009973 8935[28820100]      <1> 	mov	[SourceFilePath], esi
  5271                              <1> 
  5272                              <1> copy_scan_source_file:
  5273 00009979 46                  <1> 	inc	esi  
  5274 0000997A 803E20              <1> 	cmp	byte [esi], 20h
  5275 0000997D 7408                <1> 	je	short copy_scan_destination_1
  5276                              <1> 	;;jb	short loc_copy_nofilename_retn
  5277                              <1> 	;jb	loc_cmd_failed
  5278                              <1> 	;jmp	short copy_scan_source_file
  5279                              <1> 	; 25/07/2022
  5280 0000997F 73F8                <1> 	jnb	short copy_scan_source_file
  5281                              <1> copy_scan_destination_0:
  5282 00009981 E9D3EBFFFF          <1> 	jmp	loc_cmd_failed
  5283                              <1> 
  5284                              <1> loc_copy_nofilename_retn:
  5285 00009986 C3                  <1> 	retn
  5286                              <1> 
  5287                              <1> copy_scan_destination_1:
  5288 00009987 C60600              <1> 	mov	byte [esi], 0
  5289                              <1> 
  5290                              <1> copy_scan_destination_2:
  5291 0000998A 46                  <1> 	inc	esi  
  5292 0000998B 803E20              <1> 	cmp	byte [esi], 20h
  5293 0000998E 74FA                <1> 	je	short copy_scan_destination_2
  5294                              <1> 	;;jb	short loc_copy_nofilename_retn
  5295                              <1> 	;jb	loc_cmd_failed
  5296                              <1> 	; 25/07/2022
  5297 00009990 72EF                <1> 	jb	short copy_scan_destination_0	
  5298                              <1> 
  5299 00009992 8935[2C820100]      <1> 	mov	[DestinationFilePath], esi
  5300                              <1> 
  5301                              <1> copy_scan_destination_3:
  5302 00009998 46                  <1> 	inc	esi  
  5303 00009999 803E20              <1> 	cmp	byte [esi], 20h
  5304 0000999C 77FA                <1> 	ja	short copy_scan_destination_3
  5305 0000999E C60600              <1> 	mov	byte [esi], 0
  5306                              <1> 
  5307                              <1> loc_copy_save_current_drive:
  5308 000099A1 8A35[4A780100]      <1> 	mov	dh, [Current_Drv]
  5309 000099A7 8835[A77F0100]      <1> 	mov	[RUN_CDRV], dh
  5310                              <1> 
  5311                              <1> copy_source_file_to_destination_phase_1:
  5312 000099AD 8B35[28820100]      <1> 	mov	esi, [SourceFilePath]
  5313 000099B3 8B3D[2C820100]      <1> 	mov	edi, [DestinationFilePath]
  5314                              <1> 
  5315 000099B9 B001                <1> 	mov	al, 1  ; copy procedure Phase 1
  5316 000099BB E85F1C0000          <1> 	call	copy_source_file_to_destination_file
  5317 000099C0 7327                <1> 	jnc	short copy_source_file_to_destination_question
  5318                              <1> 
  5319                              <1> loc_copy_cmd_failed_1:
  5320                              <1> 	; 18/03/2016 (restore current drive and directory)
  5321 000099C2 08C0                <1> 	or	al, al
  5322 000099C4 7507                <1> 	jnz	short loc_copy_cmd_failed_2
  5323                              <1> 
  5324 000099C6 FEC0                <1>         inc     al ; mov al, 1 ; Bad command or file name !
  5325                              <1> loc_copy_cmd_failed_3:	; 25/07/2022
  5326 000099C8 E9B7EBFFFF          <1> 	jmp	loc_run_cmd_failed
  5327                              <1> 
  5328                              <1> loc_copy_cmd_failed_2:
  5329 000099CD 3C27                <1> 	cmp	al, 27h ; Insufficient disk space 
  5330 000099CF 7409                <1> 	je	short loc_file_write_insuff_disk_space_msg
  5331                              <1>  
  5332                              <1> 	; 29/12/2017
  5333                              <1> 	;cmp	al, 05h
  5334 000099D1 3C0B                <1> 	cmp	al, ERR_PERM_DENIED
  5335                              <1> 	;jne	loc_run_cmd_failed
  5336                              <1> 	; 25/07/2022
  5337 000099D3 75F3                <1> 	jne	short loc_copy_cmd_failed_3
  5338                              <1> 	
  5339 000099D5 E984F4FFFF          <1> 	jmp	loc_permission_denied
  5340                              <1> 
  5341                              <1> loc_file_write_insuff_disk_space_msg:
  5342 000099DA BE[32360100]        <1> 	mov	esi, msg_insufficient_disk_space
  5343 000099DF E876D2FFFF          <1> 	call	print_msg
  5344 000099E4 E96BF4FFFF          <1>         jmp     loc_file_rw_restore_retn 
  5345                              <1> 
  5346                              <1> copy_source_file_to_destination_question:
  5347 000099E9 57                  <1> 	push	edi ; *
  5348                              <1> 
  5349                              <1> 	; dh = source file attributes
  5350                              <1> 	; dl > 0 -> destination file found
  5351 000099EA 20D2                <1> 	and	dl, dl            
  5352 000099EC 7446                <1> 	jz	short copy_source_file_to_destination_pass_owrq
  5353                              <1> 
  5354                              <1> loc_copy_ask_for_owr_yes_no:
  5355 000099EE BE[8E360100]        <1> 	mov	esi, Msg_DoYouWantOverWriteFile
  5356 000099F3 E862D2FFFF          <1> 	call	print_msg
  5357 000099F8 BE[F2820100]        <1> 	mov	esi, DestinationFile_Name
  5358 000099FD E858D2FFFF          <1> 	call	print_msg
  5359 00009A02 BE[1D350100]        <1> 	mov	esi, Msg_YesNo
  5360 00009A07 E84ED2FFFF          <1> 	call	print_msg
  5361                              <1> 
  5362                              <1> loc_copy_ask_for_owr_again:
  5363 00009A0C 30E4                <1> 	xor	ah, ah
  5364 00009A0E E8F574FFFF          <1> 	call	int16h
  5365 00009A13 3C1B                <1> 	cmp	al, 1Bh
  5366                              <1>         ;je     loc_do_not_copy_file
  5367 00009A15 7419                <1>         je      short loc_copy_y_n_escape
  5368 00009A17 24DF                <1> 	and	al, 0DFh
  5369 00009A19 A2[27350100]        <1>         mov     [Y_N_nextline], al
  5370 00009A1E 3C59                <1> 	cmp	al, 'Y'
  5371                              <1> 	;je	loc_yes_copy_file
  5372                              <1> 	; 25/07/2022
  5373 00009A20 7505                <1> 	jne	short loc_copy_ask_for_owr_n
  5374 00009A22 E9AD000000          <1> 	jmp	loc_yes_copy_file
  5375                              <1> 
  5376                              <1> loc_copy_ask_for_owr_n: ; 25/07/2022
  5377 00009A27 3C4E                <1> 	cmp	al, 'N'
  5378                              <1>         ;je	loc_do_not_copy_file
  5379                              <1> 	;jmp	short loc_copy_ask_for_owr_again
  5380                              <1> 	; 25/07/2022
  5381 00009A29 75E1                <1> 	jne	short loc_copy_ask_for_owr_again
  5382                              <1> loc_do_not_copy_file_j:
  5383 00009A2B E9A4000000          <1> 	jmp	loc_do_not_copy_file
  5384                              <1> 
  5385                              <1> loc_copy_y_n_escape:
  5386 00009A30 B04E                <1> 	mov	al, 'N' ; 'no'
  5387                              <1> 	;jmp	loc_do_not_copy_file
  5388                              <1> 	; 25/07/2022
  5389 00009A32 EBF7                <1> 	jmp	short loc_do_not_copy_file_j
  5390                              <1> 
  5391                              <1> copy_source_file_to_destination_pass_owrq:
  5392 00009A34 A0[30820100]        <1> 	mov     al, [SourceFile_Drv]
  5393 00009A39 0441                <1> 	add	al, 'A'
  5394 00009A3B A2[69360100]        <1> 	mov	[msg_source_file_drv], al
  5395 00009A40 A0[B0820100]        <1>         mov     al, [DestinationFile_Drv]
  5396 00009A45 0441                <1> 	add	al, 'A'
  5397 00009A47 A2[88360100]        <1> 	mov	[msg_destination_file_drv], al
  5398                              <1> 
  5399 00009A4C BE[4D360100]        <1> 	mov	esi, msg_source_file
  5400 00009A51 E804D2FFFF          <1> 	call	print_msg
  5401 00009A56 BE[31820100]        <1> 	mov	esi, SourceFile_Directory
  5402 00009A5B 803E20              <1> 	cmp	byte [esi], 20h
  5403 00009A5E 7605                <1> 	jna	short csftdfq_sfn
  5404 00009A60 E8F5D1FFFF          <1> 	call	print_msg
  5405                              <1> csftdfq_sfn:
  5406 00009A65 BE[72820100]        <1> 	mov	esi, SourceFile_Name
  5407 00009A6A E8EBD1FFFF          <1> 	call	print_msg
  5408 00009A6F BE[6C360100]        <1> 	mov	esi, msg_destination_file
  5409 00009A74 E8E1D1FFFF          <1> 	call	print_msg
  5410 00009A79 BE[B1820100]        <1> 	mov	esi, DestinationFile_Directory
  5411 00009A7E 803E20              <1> 	cmp	byte [esi], 20h
  5412 00009A81 7605                <1> 	jna	short csftdfq_dfn
  5413 00009A83 E8D2D1FFFF          <1> 	call	print_msg
  5414                              <1> csftdfq_dfn:
  5415 00009A88 BE[F2820100]        <1> 	mov	esi, DestinationFile_Name
  5416 00009A8D E8C8D1FFFF          <1> 	call	print_msg
  5417 00009A92 BE[8B360100]        <1> 	mov	esi, msg_copy_nextline
  5418 00009A97 E8BED1FFFF          <1> 	call	print_msg
  5419 00009A9C BE[8B360100]        <1> 	mov	esi, msg_copy_nextline
  5420 00009AA1 E8B4D1FFFF          <1> 	call	print_msg
  5421                              <1> 
  5422                              <1> loc_copy_ask_for_new_file_yes_no:
  5423 00009AA6 BE[AD360100]        <1> 	mov	esi, Msg_DoYouWantCopyFile
  5424 00009AAB E8AAD1FFFF          <1> 	call	print_msg
  5425 00009AB0 BE[1D350100]        <1> 	mov	esi, Msg_YesNo
  5426 00009AB5 E8A0D1FFFF          <1> 	call	print_msg
  5427                              <1> 
  5428                              <1> loc_copy_ask_for_new_file_again:
  5429 00009ABA 30E4                <1> 	xor	ah, ah
  5430 00009ABC E84774FFFF          <1> 	call	int16h
  5431 00009AC1 3C1B                <1> 	cmp	al, 1Bh
  5432 00009AC3 740F                <1> 	je	short loc_do_not_copy_file
  5433 00009AC5 24DF                <1> 	and	al, 0DFh
  5434 00009AC7 A2[27350100]        <1>         mov     [Y_N_nextline], al
  5435 00009ACC 3C59                <1> 	cmp	al, 'Y'
  5436 00009ACE 7404                <1> 	je	short loc_yes_copy_file
  5437 00009AD0 3C4E                <1> 	cmp	al, 'N'
  5438 00009AD2 75E6                <1> 	jne	short loc_copy_ask_for_new_file_again
  5439                              <1> 
  5440                              <1> loc_do_not_copy_file:
  5441                              <1> loc_yes_copy_file:
  5442 00009AD4 E8AEF4FFFF          <1> 	call	y_n_answer ; 29/12/2017
  5443 00009AD9 5F                  <1> 	pop	edi ; *
  5444                              <1> 	;cmp	al, 'Y' ; 'yes'
  5445                              <1> 	;cmc
  5446                              <1>         ;jnc	loc_file_rw_restore_retn
  5447 00009ADA 3C4E                <1> 	cmp	al, 'N' ; 'no'
  5448                              <1> 	;je	loc_file_rw_restore_retn
  5449                              <1> 	; 25/07/2022
  5450 00009ADC 7505                <1> 	jne	short copy_source_file_to_destination_pass_q
  5451 00009ADE E971F3FFFF          <1> 	jmp	loc_file_rw_restore_retn	
  5452                              <1> 
  5453                              <1> copy_source_file_to_destination_pass_q:
  5454 00009AE3 B002                <1> 	mov	al, 2  ; copy procedure Phase 2
  5455 00009AE5 E8351B0000          <1> 	call	copy_source_file_to_destination_file
  5456                              <1> 	;jc	short loc_file_write_check_disk_space_err
  5457                              <1> 
  5458                              <1> 	; 24/03/2016
  5459                              <1> 	;push	cx
  5460 00009AEA 51                  <1> 	push	ecx ; 29/12/2017
  5461 00009AEB BE[8B360100]        <1> 	mov	esi, msg_copy_nextline
  5462 00009AF0 E865D1FFFF          <1> 	call	print_msg
  5463 00009AF5 58                  <1> 	pop	eax ; 29/12/2017
  5464                              <1> 	;;pop	cx
  5465                              <1> 	;pop	ax
  5466                              <1> 
  5467                              <1> 	;or	cl, cl
  5468 00009AF6 08C0                <1> 	or	al, al
  5469 00009AF8 7419                <1> 	jz	short copy_source_file_to_destination_OK
  5470                              <1> 	
  5471                              <1> 	; 15/10/2016 (1Dh -> 18)
  5472                              <1> 	; 18/03/2016 (1Dh)
  5473                              <1> 	;cmp	cl, 18 ; write error
  5474 00009AFA 3C12                <1> 	cmp	al, 18
  5475 00009AFC 7506                <1> 	jne	short copy_source_file_to_destination_not_OK
  5476                              <1> 	;
  5477                              <1> 	;mov	al, cl ; error number (write fault!)
  5478 00009AFE F9                  <1> 	stc
  5479 00009AFF E950F3FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  5480                              <1> 
  5481                              <1> copy_source_file_to_destination_not_OK:
  5482 00009B04 BE[C6360100]        <1> 	mov	esi, Msg_read_file_error_before_EOF
  5483 00009B09 E84CD1FFFF          <1> 	call	print_msg
  5484 00009B0E E941F3FFFF          <1> 	jmp	loc_file_rw_restore_retn	      
  5485                              <1>  
  5486                              <1> copy_source_file_to_destination_OK:
  5487 00009B13 BE[2B350100]        <1> 	mov	esi, Msg_OK
  5488 00009B18 E83DD1FFFF          <1> 	call	print_msg
  5489                              <1> 
  5490 00009B1D E932F3FFFF          <1> 	jmp	loc_file_rw_restore_retn
  5491                              <1> 
  5492                              <1> ;loc_file_write_check_disk_space_err:
  5493                              <1> 	;cmp	al, 27h ; Insufficient disk space 
  5494                              <1> 	;je	loc_file_write_insuff_disk_space_msg
  5495                              <1>         ;jb	loc_file_rw_cmd_failed
  5496                              <1> 
  5497                              <1> 	;call	print_misc_error_msg ; 15/03/2016
  5498                              <1>         ;jmp	loc_file_rw_restore_retn 
  5499                              <1> 
  5500                              <1> change_fs_file_attributes:
  5501                              <1> 	; 04/03/2016 ; Temporary
  5502                              <1> 	; AL = File or directory attributes
  5503                              <1> 	; AH = 0 -> Attributes are in MS-DOS format
  5504                              <1> 	; AH > 0 -> Attributes are in SINGLIX format
  5505                              <1> 	;push	ebx
  5506                              <1> 	; ... do somethings here ...
  5507                              <1> 	;pop	ebx
  5508                              <1> 	; BL = File or directory attributes
  5509 00009B22 C3                  <1> 	retn
  5510                              <1> 
  5511                              <1> set_get_env:
  5512                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
  5513                              <1> 	; 11/04/2016 (TRDOS 386 = TRDOS v2.0)
  5514                              <1> 	; 02/09/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_set')
  5515                              <1> 	; 2005 - 28/08/2011 
  5516                              <1> get_setenv_fchar:
  5517                              <1> 	; esi = environment variable/string
  5518 00009B23 8A06                <1> 	mov	al, [esi]
  5519 00009B25 3C20                <1> 	cmp	al, 20h
  5520 00009B27 771E                <1> 	ja	short loc_find_env
  5521                              <1> 
  5522 00009B29 BE00300900          <1> 	mov	esi, Env_Page
  5523                              <1> loc_print_setline:
  5524 00009B2E 803E00              <1> 	cmp	byte [esi], 0
  5525 00009B31 7613                <1> 	jna	short loc_setenv_retn
  5526 00009B33 E822D1FFFF          <1> 	call	print_msg
  5527 00009B38 56                  <1> 	push	esi
  5528 00009B39 BE[1B3B0100]        <1> 	mov	esi, nextline
  5529 00009B3E E817D1FFFF          <1> 	call	print_msg 
  5530 00009B43 5E                  <1> 	pop	esi
  5531 00009B44 EBE8                <1> 	jmp	short loc_print_setline   
  5532                              <1> 
  5533                              <1> loc_setenv_retn: 
  5534 00009B46 C3                  <1> 	retn
  5535                              <1> 
  5536                              <1> loc_find_env:
  5537 00009B47 3C3D                <1> 	cmp	al, '='
  5538                              <1> 	;je	loc_cmd_failed
  5539                              <1> 	; 25/07/2022
  5540 00009B49 7505                <1> 	jne	short loc_find_envr
  5541 00009B4B E909EAFFFF          <1> 	jmp	loc_cmd_failed
  5542                              <1> 
  5543                              <1> loc_find_envr:	; 25/07/2022
  5544 00009B50 56                  <1> 	push	esi
  5545                              <1> loc_repeat_env_equal_check:
  5546 00009B51 46                  <1> 	inc	esi
  5547 00009B52 803E3D              <1> 	cmp	byte [esi], '='
  5548 00009B55 7430                <1> 	je	short pass_env_equal_check
  5549 00009B57 803E20              <1> 	cmp	byte [esi], 20h
  5550 00009B5A 73F5                <1> 	jnb	short loc_repeat_env_equal_check
  5551 00009B5C C60600              <1> 	mov	byte [esi], 0 
  5552 00009B5F 5E                  <1> 	pop	esi
  5553                              <1> 	; 25/07/2022 (*)
  5554                              <1> loc_print_env_string:
  5555 00009B60 BF[4A790100]        <1> 	mov	edi, TextBuffer ; out buffer
  5556 00009B65 B9FF000000          <1> 	mov	ecx, 255 ; maximum size (limit)
  5557 00009B6A 30C0                <1> 	xor	al, al ; 0 -> use [ESI]
  5558 00009B6C E877000000          <1> 	call	get_environment_string
  5559 00009B71 72D3                <1> 	jc	short loc_setenv_retn
  5560                              <1> 	 ; 25/07/2022
  5561                              <1> ;loc_print_env_string:
  5562 00009B73 BE[4A790100]        <1> 	mov	esi, TextBuffer
  5563 00009B78 E8DDD0FFFF          <1> 	call	print_msg
  5564 00009B7D BE[1B3B0100]        <1> 	mov	esi, nextline
  5565                              <1> 	;call	print_msg
  5566                              <1> 	;retn
  5567                              <1> 	; 25/07/2022
  5568 00009B82 E9D3D0FFFF          <1> 	jmp	print_msg
  5569                              <1>               
  5570                              <1> pass_env_equal_check:
  5571 00009B87 46                  <1> 	inc	esi
  5572 00009B88 803E20              <1> 	cmp	byte [esi], 20h
  5573 00009B8B 73FA                <1> 	jnb	short pass_env_equal_check
  5574 00009B8D C60600              <1> 	mov	byte [esi], 0	
  5575                              <1> 
  5576                              <1> loc_call_set_env_string:
  5577 00009B90 5E                  <1> 	pop	esi
  5578 00009B91 E815010000          <1> 	call	set_environment_string
  5579 00009B96 73AE                <1> 	jnc	short loc_setenv_retn
  5580                              <1> 
  5581                              <1> loc_set_cmd_failed:
  5582 00009B98 3C08                <1> 	cmp	al, 08h
  5583                              <1> 	;jne	loc_cmd_failed
  5584                              <1> 	; 25/07/2022
  5585 00009B9A 7405                <1> 	je	short loc_set_cmd_failed_spc
  5586 00009B9C E9B8E9FFFF          <1> 	jmp	loc_cmd_failed
  5587                              <1> 
  5588                              <1> loc_set_cmd_failed_spc:
  5589 00009BA1 BE[06370100]        <1> 	mov	esi, Msg_No_Set_Space
  5590                              <1> 	;call	print_msg
  5591                              <1> 	;retn
  5592                              <1> 	; 25/07/2022
  5593 00009BA6 E9AFD0FFFF          <1> 	jmp	print_msg
  5594                              <1> 
  5595                              <1> set_get_path:
  5596                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
  5597                              <1> 	; 11/04/2016 (TRDOS 386 = TRDOS v2.0)
  5598                              <1> 	; 03/09/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_path')
  5599                              <1> 	; 2005
  5600                              <1> get_path_fchar:
  5601                              <1>  	; esi = path
  5602 00009BAB 803E20              <1> 	cmp	byte [esi], 20h
  5603 00009BAE 7711                <1> 	ja	short loc_set_path
  5604                              <1> 
  5605 00009BB0 BE00300900          <1> 	mov	esi, Env_Page
  5606                              <1> loc_print_path:
  5607 00009BB5 803E00              <1> 	cmp	byte [esi], 0
  5608 00009BB8 762D                <1> 	jna	short loc_path_retn
  5609                              <1> 
  5610 00009BBA BE[66310100]        <1> 	mov	esi, Cmd_Path ; 'PATH' address
  5611                              <1> 	; 25/07/2022 (*)
  5612 00009BBF EB9F                <1> 	jmp	short loc_print_env_string
  5613                              <1> ; 25/07/2022
  5614                              <1> ;	mov	edi, TextBuffer ; out buffer
  5615                              <1> ;	xor	al, al  ; use [ESI]
  5616                              <1> ;	mov	ecx, 255 ; maximum size (limit)
  5617                              <1> ;	call	get_environment_string
  5618                              <1> ;	;jc	short loc_path_retn
  5619                              <1> ;	; 25/07/2022
  5620                              <1> ;	jnc	short loc_print_env_string
  5621                              <1> ;	retn
  5622                              <1> 
  5623                              <1> ;	mov	esi, TextBuffer
  5624                              <1> ;	call	print_msg
  5625                              <1> ;	mov	esi, nextline
  5626                              <1> ;	;call	print_msg
  5627                              <1> ;loc_path_retn: 
  5628                              <1> ;	;retn
  5629                              <1> ;	; 25/07/2022
  5630                              <1> ;	jmp	print_msg
  5631                              <1> 
  5632                              <1> loc_set_path:
  5633 00009BC1 56                  <1> 	push	esi 
  5634                              <1> loc_set_path_find_end:
  5635 00009BC2 46                  <1> 	inc	esi
  5636 00009BC3 803E20              <1> 	cmp	byte [esi], 20h
  5637 00009BC6 73FA                <1> 	jnb	short loc_set_path_find_end
  5638 00009BC8 C60600              <1> 	mov	byte [esi], 0 
  5639                              <1> loc_set_path_header: 
  5640 00009BCB 5E                  <1> 	pop	esi
  5641                              <1> set_path_x: ; 31/12/2017 ('syspath')	  
  5642 00009BCC 4E                  <1> 	dec	esi
  5643 00009BCD C6063D              <1> 	mov	byte [esi], '='
  5644 00009BD0 4E                  <1> 	dec	esi
  5645 00009BD1 C60648              <1> 	mov	byte [esi], 'H'
  5646 00009BD4 4E                  <1> 	dec	esi
  5647 00009BD5 C60654              <1> 	mov	byte [esi], 'T'
  5648 00009BD8 4E                  <1> 	dec	esi
  5649 00009BD9 C60641              <1> 	mov	byte [esi], 'A'
  5650 00009BDC 4E                  <1> 	dec	esi
  5651 00009BDD C60650              <1> 	mov	byte [esi], 'P'   
  5652                              <1> 
  5653                              <1> loc_path_call_set_env_string:
  5654 00009BE0 E8C6000000          <1> 	call	set_environment_string
  5655 00009BE5 72B1                <1>         jc	short loc_set_cmd_failed
  5656                              <1> loc_path_retn:	; 25/07/2022
  5657 00009BE7 C3                  <1> 	retn              
  5658                              <1> 
  5659                              <1> get_environment_string:
  5660                              <1> 	; 12/04/2016
  5661                              <1> 	; 11/04/2016
  5662                              <1> 	; 05/04/2016 (TRDOS 386 = TRDOS v2.0)
  5663                              <1> 	; 02/09/2011 (TRDOS v1, MAINPROG.ASM)
  5664                              <1> 	; 28/08/2011
  5665                              <1> 	; INPUT->
  5666                              <1> 	;	EDI = Output buffer
  5667                              <1> 	;	CX = Buffer length (<= ENV_PAGE_SIZE)
  5668                              <1> 	;
  5669                              <1> 	;	AL > 0 = AL = String sequence number
  5670                              <1> 	;	AL = 0 -> ESI = ASCIIZ Set word 
  5671                              <1> 	;		(environment variable)
  5672                              <1> 	; OUTPUT ->
  5673                              <1> 	;	ESI is not changed
  5674                              <1> 	;	EDI is not changed
  5675                              <1> 	;	EAX = String length (with zero tail)
  5676                              <1> 	;	EDX = Environment variables page address
  5677                              <1> 	;	CF = 1 -> Not found (EAX not valid)
  5678                              <1> 	;
  5679                              <1> 	; (Modified registers: EAX, EDX) 
  5680                              <1> 
  5681 00009BE8 BA00300900          <1> 	mov	edx, Env_Page
  5682 00009BED 803A00              <1> 	cmp	byte [edx], 0
  5683 00009BF0 7474                <1> 	jz	short get_env_string_with_word_stc_retn
  5684                              <1> 
  5685 00009BF2 66890D[B4830100]    <1> 	mov	[env_var_length], cx
  5686                              <1> 
  5687 00009BF9 51                  <1> 	push	ecx ; *
  5688 00009BFA 56                  <1> 	push	esi ; **
  5689                              <1> 
  5690 00009BFB 08C0                <1> 	or	al, al
  5691 00009BFD 7449                <1> 	jz	short get_env_string_with_word
  5692                              <1> 
  5693                              <1> get_env_string_with_seq_number:
  5694 00009BFF B101                <1> 	mov	cl, 1
  5695 00009C01 88C5                <1> 	mov	ch, al
  5696 00009C03 31C0                <1> 	xor	eax, eax
  5697 00009C05 89D6                <1> 	mov	esi, edx ; Env_Page
  5698                              <1> 
  5699                              <1> get_env_string_seq_number_check:
  5700 00009C07 38CD                <1> 	cmp	ch, cl
  5701 00009C09 7726                <1> 	ja	short get_env_string_seq_number_next
  5702                              <1> 
  5703                              <1> get_env_string_move_to_buff:
  5704 00009C0B 57                  <1> 	push	edi ; ***
  5705                              <1> 
  5706 00009C0C 29D2                <1> 	sub	edx, edx
  5707                              <1> 
  5708                              <1> get_env_string_seq_number_repeat1:
  5709 00009C0E 42                  <1> 	inc	edx
  5710 00009C0F AC                  <1> 	lodsb
  5711 00009C10 AA                  <1> 	stosb
  5712                              <1> 
  5713 00009C11 66FF0D[B4830100]    <1> 	dec	word [env_var_length]
  5714 00009C18 7508                <1> 	jnz	short get_env_string_seq_number_repeat3
  5715                              <1> 
  5716                              <1> get_env_string_seq_number_repeat2:
  5717 00009C1A 20C0                <1> 	and	al, al
  5718 00009C1C 7408                <1> 	jz	short get_env_string_seq_number_ok
  5719 00009C1E 42                  <1> 	inc	edx
  5720 00009C1F AC                  <1> 	lodsb
  5721 00009C20 EBF8                <1> 	jmp	short get_env_string_seq_number_repeat2
  5722                              <1> 
  5723                              <1> get_env_string_seq_number_repeat3:
  5724 00009C22 08C0                <1> 	or	al, al
  5725 00009C24 75E8                <1> 	jnz	short get_env_string_seq_number_repeat1
  5726                              <1> 
  5727                              <1> get_env_string_seq_number_ok:
  5728 00009C26 5F                  <1> 	pop	edi ; ***
  5729 00009C27 89D0                <1> 	mov	eax, edx ; Length of the environment string
  5730                              <1> 			 ; (ASCIIZ, includes ZERO tail)
  5731 00009C29 BA00300900          <1> 	mov	edx, Env_Page
  5732                              <1> 
  5733                              <1> get_env_string_stc_retn:
  5734 00009C2E 5E                  <1> 	pop	esi ; **
  5735 00009C2F 59                  <1> 	pop	ecx ; *
  5736 00009C30 C3                  <1> 	retn   
  5737                              <1> 	
  5738                              <1> get_env_string_seq_number_next:
  5739 00009C31 AC                  <1> 	lodsb
  5740 00009C32 08C0                <1> 	or	al, al
  5741 00009C34 75FB                <1> 	jnz	short get_env_string_seq_number_next
  5742                              <1> 
  5743 00009C36 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; +512 (+4096)
  5744 00009C3C F5                  <1> 	cmc
  5745 00009C3D 72EF                <1> 	jc	short get_env_string_stc_retn
  5746                              <1> 
  5747 00009C3F AC                  <1> 	lodsb
  5748 00009C40 3C01                <1> 	cmp	al, 1
  5749 00009C42 72EA                <1> 	jb	short get_env_string_stc_retn
  5750 00009C44 FEC1                <1> 	inc	cl
  5751 00009C46 EBBF                <1> 	jmp	short get_env_string_seq_number_check
  5752                              <1> 
  5753                              <1> get_env_string_with_word:
  5754 00009C48 31C9                <1> 	xor	ecx, ecx
  5755                              <1> 
  5756                              <1> get_env_string_calc_word_length:
  5757 00009C4A AC                  <1> 	lodsb 
  5758 00009C4B 3C20                <1> 	cmp	al, 20h
  5759 00009C4D 7211                <1> 	jb	short get_env_string_calc_word_length_ok
  5760                              <1> 	;inc	cx
  5761 00009C4F FEC1                <1> 	inc	cl
  5762                              <1> 
  5763 00009C51 3C61                <1> 	cmp	al, 'a'
  5764 00009C53 72F5                <1> 	jb	short get_env_string_calc_word_length
  5765 00009C55 3C7A                <1> 	cmp	al, 'z'
  5766 00009C57 77F1                <1> 	ja	short get_env_string_calc_word_length
  5767 00009C59 24DF                <1> 	and	al, 0DFh
  5768 00009C5B 8846FF              <1> 	mov	[esi-1], al
  5769 00009C5E EBEA                <1> 	jmp	short get_env_string_calc_word_length
  5770                              <1> 	
  5771                              <1> get_env_string_calc_word_length_ok:
  5772 00009C60 08C9                <1> 	or	cl, cl
  5773 00009C62 7506                <1> 	jnz	short get_env_string_calc_word_length_save
  5774                              <1>      
  5775 00009C64 5E                  <1> 	pop	esi ; **
  5776                              <1> 
  5777                              <1> get_env_string_stc_retn1:
  5778 00009C65 59                  <1> 	pop	ecx ; *
  5779                              <1>         
  5780                              <1> get_env_string_with_word_stc_retn:
  5781 00009C66 31C0                <1> 	xor	eax, eax  
  5782 00009C68 F9                  <1> 	stc
  5783 00009C69 C3                  <1> 	retn
  5784                              <1>   
  5785                              <1> get_env_string_calc_word_length_save:
  5786 00009C6A 871C24              <1> 	xchg	ebx, [esp] ; **
  5787 00009C6D 89DE                <1> 	mov	esi, ebx 
  5788                              <1> 		; Start of the env string (to be searched)
  5789                              <1> 
  5790 00009C6F 57                  <1> 	push	edi ; ***
  5791 00009C70 89D7                <1> 	mov	edi, edx ; Env_Page
  5792                              <1> 
  5793                              <1> get_env_string_compare:
  5794 00009C72 57                  <1> 	push	edi ; ****
  5795 00009C73 51                  <1> 	push	ecx ; ***** ; Variable name length
  5796                              <1> 
  5797                              <1> get_env_string_compare_rep:
  5798 00009C74 AC                  <1> 	lodsb
  5799 00009C75 AE                  <1> 	scasb
  5800 00009C76 7511                <1> 	jne	short get_env_string_compare_next1
  5801 00009C78 E2FA                <1> 	loop	get_env_string_compare_rep
  5802                              <1> 	
  5803 00009C7A 803F3D              <1> 	cmp	byte [edi], '='
  5804 00009C7D 750A                <1> 	jne	short get_env_string_compare_next1
  5805                              <1>  
  5806 00009C7F 59                  <1> 	pop	ecx ; *****
  5807 00009C80 5F                  <1> 	pop	edi ; ****
  5808 00009C81 89FE                <1> 	mov	esi, edi
  5809 00009C83 5F                  <1> 	pop	edi ; ***
  5810 00009C84 871C24              <1> 	xchg	ebx, [esp] ; **
  5811 00009C87 EB82                <1> 	jmp	short get_env_string_move_to_buff
  5812                              <1> 
  5813                              <1> get_env_string_compare_next1:
  5814 00009C89 89FE                <1> 	mov	esi, edi
  5815 00009C8B 59                  <1> 	pop	ecx ; *****
  5816 00009C8C 5F                  <1> 	pop	edi ; ****
  5817                              <1> get_env_string_compare_next2:
  5818 00009C8D 81FEFF310900        <1> 	cmp	esi, Env_Page + Env_Page_Size - 1 ; +511 (+4095)
  5819 00009C93 7310                <1> 	jnb	short get_env_string_compare_not_ok
  5820 00009C95 20C0                <1> 	and	al, al
  5821 00009C97 AC                  <1> 	lodsb
  5822 00009C98 75F3                <1> 	jnz	short get_env_string_compare_next2
  5823 00009C9A 08C0                <1> 	or	al, al
  5824 00009C9C 7407                <1> 	jz	short get_env_string_compare_not_ok
  5825 00009C9E 4E                  <1> 	dec	esi ; 12/04/2016
  5826 00009C9F 89F7                <1> 	mov	edi, esi
  5827 00009CA1 89DE                <1> 	mov	esi, ebx
  5828 00009CA3 EBCD                <1> 	jmp	short get_env_string_compare
  5829                              <1> 
  5830                              <1> get_env_string_compare_not_ok:
  5831 00009CA5 5F                  <1> 	pop	edi ; ***
  5832 00009CA6 89DE                <1> 	mov	esi, ebx
  5833 00009CA8 5B                  <1> 	pop	ebx ; **
  5834 00009CA9 EBBA                <1> 	jmp	short get_env_string_stc_retn1
  5835                              <1> 
  5836                              <1> set_environment_string:
  5837                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
  5838                              <1> 	; 13/04/2016
  5839                              <1> 	; 12/04/2016
  5840                              <1> 	; 11/04/2016
  5841                              <1> 	; 06/04/2016
  5842                              <1> 	; 05/04/2016 (TRDOS 386 = TRDOS v2.0)
  5843                              <1> 	; 02/09/2011 (TRDOS v1, MAINPROG.ASM)
  5844                              <1> 	; 29/08/2011
  5845                              <1> 	; 29/08/2011
  5846                              <1> 	; INPUT->
  5847                              <1> 	;	ESI = ASCIIZ environment string
  5848                              <1> 	; OUTPUT ->
  5849                              <1> 	;	ESI is not changed
  5850                              <1> 	;	CF = 1 -> Could not set, 
  5851                              <1> 	;	     insufficient environment space
  5852                              <1> 	;
  5853                              <1> 	; (EAX, EDX will be changed) 
  5854                              <1> 	;
  5855                              <1> 	;    (EAX = Start address of the env string if > 0)	
  5856                              <1> 	;    (EDX = Environment string length)	
  5857                              <1> 
  5858 00009CAB 56                  <1> 	push 	esi ; *
  5859                              <1> 
  5860 00009CAC 31C0                <1> 	xor	eax, eax
  5861                              <1> 
  5862                              <1> set_env_chk_validation1:
  5863 00009CAE FEC4                <1> 	inc	ah ; variable (string) length
  5864 00009CB0 AC                  <1> 	lodsb
  5865 00009CB1 3C3D                <1> 	cmp	al, '='
  5866 00009CB3 7415                <1> 	je	short set_env_chk_validation2
  5867 00009CB5 3C20                <1> 	cmp	al, 20h
  5868 00009CB7 720F                <1> 	jb	short set_env_string_stc
  5869                              <1> 
  5870                              <1> 	; 06/04/2016
  5871 00009CB9 3C61                <1> 	cmp	al, 'a'
  5872 00009CBB 72F1                <1> 	jb	short set_env_chk_validation1
  5873 00009CBD 3C7A                <1> 	cmp	al, 'z'
  5874 00009CBF 77ED                <1> 	ja	short set_env_chk_validation1
  5875 00009CC1 2C20                <1> 	sub	al, 'a'-'A'
  5876 00009CC3 8846FF              <1> 	mov	[esi-1], al
  5877 00009CC6 EBE6                <1> 	jmp	short set_env_chk_validation1
  5878                              <1> 
  5879                              <1> set_env_string_stc:
  5880 00009CC8 5E                  <1> 	pop	esi ; *
  5881                              <1> 	;stc
  5882 00009CC9 C3                  <1> 	retn 
  5883                              <1> 	   
  5884                              <1> set_env_chk_validation2:
  5885 00009CCA 51                  <1> 	push	ecx ; **
  5886 00009CCB 53                  <1> 	push	ebx ; *** 
  5887 00009CCC 57                  <1> 	push	edi ; ****
  5888                              <1> 
  5889                              <1> 	; 12/04/2016
  5890                              <1> 	;mov	ebx, [esp+12]
  5891                              <1> 	; 25/07/2022
  5892 00009CCD 8B54240C            <1> 	mov	edx, [esp+12]
  5893                              <1> 
  5894                              <1> set_env_chk_validation2w:
  5895 00009CD1 89F7                <1> 	mov	edi, esi
  5896 00009CD3 4F                  <1> 	dec	edi
  5897                              <1> 
  5898 00009CD4 807FFF20            <1> 	cmp	byte [edi-1], 20h
  5899 00009CD8 771A                <1> 	ja	short set_env_chk_validation2z
  5900                              <1> 	
  5901 00009CDA 56                  <1> 	push	esi
  5902 00009CDB 89FE                <1> 	mov	esi, edi
  5903 00009CDD 4E                  <1> 	dec	esi
  5904                              <1> 
  5905                              <1> set_env_chk_validation2x:
  5906 00009CDE 4E                  <1> 	dec	esi
  5907                              <1> 
  5908                              <1> 	;cmp	esi, ebx
  5909 00009CDF 39D6                <1> 	cmp	esi, edx ; 25/07/2022
  5910 00009CE1 7207                <1> 	jb	short set_env_chk_validation2y
  5911                              <1> 
  5912 00009CE3 4F                  <1> 	dec	edi
  5913                              <1> 
  5914 00009CE4 8A06                <1> 	mov	al, [esi]
  5915 00009CE6 8807                <1> 	mov	[edi], al
  5916                              <1> 
  5917 00009CE8 EBF4                <1> 	jmp	short set_env_chk_validation2x
  5918                              <1> 
  5919                              <1> set_env_chk_validation2y:
  5920 00009CEA 5E                  <1> 	pop	esi
  5921                              <1> 
  5922                              <1> 	;;mov	byte [ebx], 20h
  5923                              <1> 	; 25/07/2022
  5924                              <1> 	;mov	byte [edx], 20h		
  5925                              <1> 
  5926                              <1> 	;inc 	ebx
  5927                              <1> 	;mov	[esp+12], ebx
  5928                              <1> 	; 25/07/2022
  5929 00009CEB 42                  <1> 	inc	edx
  5930 00009CEC 8954240C            <1> 	mov	[esp+12], edx
  5931                              <1> 
  5932 00009CF0 FECC                <1> 	dec 	ah ; 13/04/2016
  5933                              <1> 
  5934 00009CF2 EBDD                <1> 	jmp	short set_env_chk_validation2w
  5935                              <1> 	
  5936                              <1> set_env_chk_validation2z:	
  5937                              <1> 	;mov	edx, Env_Page
  5938                              <1> 	;mov	edi, edx
  5939                              <1> 	; 25/07/2022
  5940 00009CF4 BB00300900          <1> 	mov	ebx, Env_Page
  5941 00009CF9 89DF                <1> 	mov	edi, ebx
  5942                              <1> 
  5943                              <1> set_env_chk_validation3:
  5944 00009CFB AC                  <1> 	lodsb
  5945 00009CFC 3C20                <1> 	cmp	al, 20h
  5946 00009CFE 74FB                <1> 	je	short set_env_chk_validation3
  5947                              <1> 
  5948 00009D00 9C                  <1> 	pushf
  5949                              <1> 
  5950                              <1> 	; 12/04/2016
  5951                              <1> set_env_chk_validation3n:
  5952 00009D01 3C61                <1> 	cmp	al, 'a'
  5953 00009D03 720C                <1> 	jb	short set_env_chk_validation3c
  5954 00009D05 3C7A                <1> 	cmp	al, 'z'
  5955 00009D07 7705                <1> 	ja	short set_env_chk_validation3x
  5956 00009D09 2C20                <1> 	sub	al, 'a'-'A'
  5957 00009D0B 8846FF              <1> 	mov	[esi-1], al
  5958                              <1> 
  5959                              <1> set_env_chk_validation3x:
  5960 00009D0E AC                  <1> 	lodsb
  5961 00009D0F EBF0                <1> 	jmp	short set_env_chk_validation3n
  5962                              <1> 
  5963                              <1> set_env_chk_validation3c:
  5964 00009D11 3C20                <1> 	cmp	al, 20h
  5965 00009D13 73F9                <1> 	jnb	short set_env_chk_validation3x
  5966                              <1> 		
  5967 00009D15 803F00              <1> 	cmp	byte [edi], 0
  5968 00009D18 772B                <1> 	ja	short set_env_chk_validation4
  5969                              <1> 
  5970 00009D1A 9D                  <1> 	popf
  5971 00009D1B 7222                <1> 	jb	short set_env_string_nothing
  5972                              <1> 
  5973 00009D1D B900020000          <1> 	mov	ecx, Env_Page_Size ; 512 (4096)
  5974                              <1> 
  5975                              <1> 	;mov	esi, ebx ; 12/04/2016
  5976                              <1> 	; 25/07/2022
  5977 00009D22 89D6                <1> 	mov	esi, edx
  5978                              <1> 
  5979                              <1> 	; 25/07/2022
  5980 00009D24 89CA                <1> 	mov	edx, ecx
  5981                              <1> 
  5982                              <1> set_env_string_copy_to_envb:
  5983 00009D26 AC                  <1> 	lodsb
  5984 00009D27 3C20                <1> 	cmp	al, 20h
  5985 00009D29 7207                <1> 	jb	short set_env_string_copy_to_envb_z
  5986 00009D2B AA                  <1> 	stosb
  5987 00009D2C E2F8                <1> 	loop	set_env_string_copy_to_envb
  5988                              <1> 
  5989                              <1> 	; 11/04/2016
  5990                              <1> 	;mov	edi, edx ; Env_Page
  5991                              <1> 	; 25/07/2022
  5992 00009D2E 89DF                <1> 	mov	edi, ebx
  5993                              <1> 	; 25/07/2022
  5994                              <1> 	;mov	ecx, Env_Page_Size 
  5995 00009D30 89D1                <1> 	mov	ecx, edx
  5996                              <1> 
  5997                              <1> set_env_string_copy_to_envb_z:
  5998                              <1> 	; 25/07/2022
  5999                              <1> 	;push	edx  ; Start address of the variable
  6000                              <1> 	
  6001                              <1> 	;;mov	edx, Env_Page_Size
  6002                              <1> 	;; 25/07/2022
  6003 00009D32 29CA                <1> 	sub	edx, ecx ; variable (string) length
  6004                              <1> 
  6005 00009D34 28C0                <1> 	sub	al, al ; 0
  6006 00009D36 F3AA                <1>  	rep	stosb ; clear remain bytes of the env page
  6007                              <1> 
  6008                              <1> 	;pop	eax  ; Start address of the variable
  6009                              <1> 	; 25/07/2022
  6010 00009D38 89D8                <1> 	mov	eax, ebx
  6011                              <1> 
  6012                              <1> set_env_string_allocate_envb_retn:  ; stc or clc return
  6013 00009D3A 5F                  <1> 	pop	edi ; ****
  6014 00009D3B 5B                  <1> 	pop	ebx ; ***
  6015 00009D3C 59                  <1> 	pop	ecx ; **
  6016 00009D3D 5E                  <1> 	pop	esi ; *	
  6017 00009D3E C3                  <1> 	retn
  6018                              <1> 
  6019                              <1> set_env_string_nothing:
  6020 00009D3F 31C0                <1> 	xor	eax, eax
  6021 00009D41 31D2                <1> 	xor	edx, edx ; 11/04/2016
  6022 00009D43 EBF5                <1> 	jmp	short set_env_string_allocate_envb_retn
  6023                              <1> 
  6024                              <1> set_env_chk_validation4:
  6025                              <1> 	; 11/04/2016
  6026 00009D45 9D                  <1> 	popf
  6027                              <1> 
  6028                              <1> 	;mov	esi, edx  ; Env_Page
  6029                              <1> 	; 25/07/2022
  6030 00009D46 89DE                <1> 	mov	esi, ebx
  6031                              <1> 
  6032                              <1> set_env_chk_validation5:	
  6033                              <1> 	;mov	edi, ebx  ; ASCIIZ environment string address	
  6034                              <1> 	; 25/07/2022
  6035 00009D48 89D7                <1> 	mov	edi, edx
  6036 00009D4A 0FB6CC              <1> 	movzx	ecx, ah ; Variable (string) length (with '=')
  6037                              <1> 
  6038                              <1> set_env_chk_validation5_loop:
  6039 00009D4D AC                  <1> 	lodsb
  6040 00009D4E AE                  <1> 	scasb
  6041 00009D4F 7508                <1> 	jne	short set_env_chk_validation6
  6042 00009D51 E2FA                <1> 	loop	set_env_chk_validation5_loop
  6043                              <1> 
  6044 00009D53 3C3D                <1> 	cmp	al, '='
  6045                              <1>         ;je	set_env_change_variable
  6046                              <1> 	; 25/07/2022
  6047 00009D55 7502                <1> 	jne	short set_env_chk_validation6
  6048 00009D57 EB7E                <1> 	jmp	set_env_change_variable
  6049                              <1> 
  6050                              <1> set_env_chk_validation6:
  6051 00009D59 08C0                <1> 	or	al, al ; 0
  6052 00009D5B 7403                <1> 	jz	short set_env_chk_validation7
  6053                              <1> 
  6054 00009D5D AC                  <1> 	lodsb
  6055 00009D5E EBF9                <1> 	jmp	short set_env_chk_validation6
  6056                              <1> 
  6057                              <1> set_env_chk_validation7:
  6058 00009D60 88E1                <1> 	mov	cl, ah
  6059 00009D62 01F1                <1> 	add	ecx, esi
  6060 00009D64 81F9FF310900        <1> 	cmp	ecx, Env_Page + Env_Page_Size - 1 
  6061                              <1> 		; 511 (4095) 
  6062                              <1> 		; strlen + '=' + 0
  6063 00009D6A 72DC                <1> 	jb	short set_env_chk_validation5
  6064                              <1> 
  6065                              <1> set_env_chk_validation8: ; variable not found
  6066 00009D6C 0FB6F4              <1> 	movzx	esi, ah  ; variable name length (with '=') 
  6067                              <1> 	;add	esi, ebx ; position just after of the '='
  6068                              <1> 	; 25/07/2022
  6069 00009D6F 01D6                <1> 	add	esi, edx
  6070                              <1> 
  6071                              <1> set_env_chk_validation8_loop:
  6072 00009D71 AC                  <1> 	lodsb
  6073 00009D72 3C20                <1> 	cmp	al, 20h
  6074 00009D74 74FB                <1> 	je	short set_env_chk_validation8_loop	
  6075 00009D76 72C7                <1> 	jb	short set_env_string_nothing
  6076                              <1> 
  6077                              <1> set_env_chk_validation9:
  6078 00009D78 AC                  <1> 	lodsb
  6079 00009D79 3C20                <1> 	cmp	al, 20h
  6080 00009D7B 73FB                <1> 	jnb	short set_env_chk_validation9
  6081                              <1> 
  6082                              <1> 	; End of ASCIIZ environment string
  6083                              <1> 
  6084                              <1> set_env_add_variable:
  6085                              <1> 	;sub	esi, ebx ; variable+definition length
  6086                              <1> 	; 25/07/2022
  6087 00009D7D 29D6                <1> 	sub	esi, edx	
  6088                              <1> 
  6089 00009D7F 56                  <1> 	push	esi ; *****
  6090                              <1> 
  6091                              <1> 	;mov	esi, edx ; Environment page address
  6092                              <1> 	; 25/07/2022
  6093 00009D80 89DE                <1> 	mov	esi, ebx
  6094                              <1> 
  6095 00009D82 B900020000          <1> 	mov	ecx, Env_Page_Size ; 512 (4096)	
  6096                              <1> 
  6097                              <1> set_env_add_variable_loop:
  6098 00009D87 AC                  <1> 	lodsb
  6099 00009D88 20C0                <1> 	and	al, al		
  6100 00009D8A 7406                <1> 	jz	short set_env_add_variable_chk1 ; 0
  6101 00009D8C E2F9                <1> 	loop	set_env_add_variable_loop
  6102                              <1> 
  6103                              <1> 	; 11/04/2016
  6104 00009D8E 884EFF              <1> 	mov	[esi-1], cl ; 0
  6105 00009D91 41                  <1> 	inc	ecx
  6106                              <1> 	
  6107                              <1> set_env_add_variable_chk1: 
  6108 00009D92 49                  <1> 	dec	ecx
  6109 00009D93 7408                <1> 	jz	short set_env_add_variable_nspc
  6110 00009D95 AC                  <1> 	lodsb
  6111 00009D96 08C0                <1> 	or 	al, al
  6112 00009D98 740B                <1> 	jz	short set_env_add_variable_chk2 ; 00
  6113 00009D9A 49                  <1> 	dec	ecx
  6114 00009D9B 75EA                <1> 	jnz	short set_env_add_variable_loop
  6115                              <1> 
  6116                              <1> set_env_add_variable_nspc: ; no space on environment page
  6117 00009D9D 58                  <1> 	pop	eax ; *****
  6118                              <1> 	;mov	eax, 8 ; No space for new environment string
  6119                              <1> 	; 25/07/2022
  6120 00009D9E 29C0                <1> 	sub	eax, eax
  6121 00009DA0 B008                <1> 	mov	al, 8
  6122 00009DA2 F9                  <1> 	stc
  6123 00009DA3 EB95                <1>         jmp     short set_env_string_allocate_envb_retn
  6124                              <1> 
  6125                              <1> set_env_add_variable_chk2:
  6126 00009DA5 8B0C24              <1> 	mov	ecx, [esp] ; *****
  6127 00009DA8 4E                  <1> 	dec	esi ; beginning address of the new variable
  6128 00009DA9 89F0                <1> 	mov	eax, esi
  6129 00009DAB 01C8                <1> 	add	eax, ecx ; string length (with CR)
  6130                              <1> 	;add	edx, Env_Page_Size ; 512 (4096)
  6131                              <1> 	; 25/07/2022
  6132 00009DAD 81C300020000        <1> 	add	ebx, Env_Page_Size
  6133                              <1> 	;cmp	eax, edx 
  6134 00009DB3 39D8                <1> 	cmp	eax, ebx ; 25/07/2022
  6135 00009DB5 77E6                <1> 	ja	short set_env_add_variable_nspc
  6136 00009DB7 49                  <1> 	dec	ecx ; except CR at the end
  6137                              <1> 	;mov	edx, ecx ; 12/04/2016
  6138                              <1> 	; 25/07/2022
  6139 00009DB8 89CB                <1> 	mov	ebx, ecx
  6140 00009DBA 89F7                <1> 	mov	edi, esi
  6141 00009DBC 893C24              <1> 	mov	[esp], edi ; ***** ; Start address of new variable
  6142                              <1> 	;mov	esi, ebx ; ASCIIZ environment string address
  6143                              <1> 	; 25/07/2022
  6144 00009DBF 89D6                <1> 	mov	esi, edx
  6145 00009DC1 F3A4                <1> 	rep	movsb
  6146 00009DC3 28C0                <1> 	sub	al, al
  6147 00009DC5 AA                  <1> 	stosb
  6148 00009DC6 58                  <1> 	pop	eax ; ***** ; Beginning address of new variable			
  6149 00009DC7 81FF00320900        <1>         cmp     edi, Env_Page + Env_Page_Size ; 12/04/2016
  6150                              <1> 	;jnb	set_env_string_allocate_envb_retn ; OK !
  6151                              <1> 	; 25/07/2022
  6152 00009DCD 7303                <1>  	jnb	short set_env_add_variable_chk3
  6153 00009DCF 880F                <1> 	mov	[edi], cl ; 0
  6154 00009DD1 F8                  <1> 	clc	; 13/04/2016
  6155                              <1> set_env_add_variable_chk3:
  6156 00009DD2 E963FFFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  6157                              <1> 
  6158                              <1> set_env_change_variable:
  6159                              <1> 	; 06/04/2016
  6160                              <1> 	; esi = Variable's address in environment page (after '=')
  6161                              <1> 	; edi = ASCIIZ environment string address (after '=')
  6162                              <1> 
  6163                              <1> 	; ah = variable length from start to the '='
  6164 00009DD7 8825[B4830100]      <1> 	mov	[env_var_length], ah
  6165                              <1> 
  6166 00009DDD 28C9                <1> 	sub	cl, cl ; ecx = 0
  6167                              <1> 
  6168 00009DDF 57                  <1> 	push	edi ; *****
  6169                              <1> 
  6170 00009DE0 89F7                <1> 	mov	edi, esi ; 11/04/2016
  6171                              <1> 
  6172                              <1> set_env_change_variable_calc1:
  6173 00009DE2 AC                  <1> 	lodsb
  6174 00009DE3 08C0                <1> 	or	al, al
  6175 00009DE5 7403                <1> 	jz	short set_env_change_variable_calc2
  6176                              <1> 
  6177 00009DE7 41                  <1> 	inc	ecx ; length of environment string (after the '=')
  6178                              <1> 
  6179 00009DE8 EBF8                <1> 	jmp	short set_env_change_variable_calc1	
  6180                              <1> 
  6181                              <1> set_env_change_variable_calc2:
  6182 00009DEA 8B3424              <1> 	mov	esi, [esp] ; ASCIIZ environment string address
  6183                              <1> 	
  6184 00009DED 29D2                <1> 	sub	edx, edx
  6185                              <1> 
  6186                              <1> set_env_change_variable_calc3:
  6187 00009DEF AC                  <1> 	lodsb
  6188 00009DF0 3C20                <1> 	cmp	al, 20h
  6189 00009DF2 7203                <1> 	jb	short set_env_change_variable_calc4
  6190                              <1> 
  6191 00009DF4 42                  <1> 	inc	edx ; length of ASCIIZ string (after the '=')
  6192                              <1> 	
  6193 00009DF5 EBF8                <1> 	jmp	short set_env_change_variable_calc3
  6194                              <1> 	
  6195                              <1> set_env_change_variable_calc4:
  6196 00009DF7 C646FF00            <1> 	mov	byte [esi-1], 0  ; put ZERO instead of CR
  6197                              <1> 	
  6198 00009DFB 5E                  <1> 	pop	esi ; ***** ; ASCIIZ string address (after '=')
  6199                              <1> 
  6200                              <1> 	; EDI = Old variable's address (after '=')
  6201                              <1> 	
  6202                              <1> 	; compare the new string with the old string
  6203 00009DFC 39CA                <1> 	cmp	edx, ecx
  6204 00009DFE 7718                <1> 	ja	short set_env_change_variable_calc5 ; longer
  6205                              <1> 	;jb	set_env_change_variable_calc9 ; shorter
  6206                              <1> 	; 25/07/2022
  6207 00009E00 7405                <1> 	je	short set_env_change_variable_calc22
  6208 00009E02 E98C000000          <1> 	jmp	set_env_change_variable_calc9 
  6209                              <1> 
  6210                              <1> set_env_change_variable_calc22:	
  6211                              <1> 	;same length (simple copy)
  6212 00009E07 0FB6C4              <1> 	movzx	eax, ah
  6213 00009E0A 01C2                <1> 	add	edx, eax
  6214 00009E0C F7D8                <1> 	neg	eax
  6215 00009E0E 01F8                <1> 	add	eax, edi
  6216                              <1> 	; EAX = Start address of the variable
  6217                              <1> 	; EDX = Variable length (without ZERO at the end of variable)
  6218                              <1> 
  6219 00009E10 F3A4                <1> 	rep	movsb
  6220 00009E12 F8                  <1> 	clc	; 13/04/2016
  6221 00009E13 E922FFFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  6222                              <1> 
  6223                              <1> set_env_change_variable_calc5:
  6224                              <1> 	; 11/04/2016
  6225 00009E18 52                  <1> 	push	edx ; *****
  6226 00009E19 29CA                <1> 	sub	edx, ecx ; difference ; (the new string is longer)
  6227 00009E1B 89F3                <1> 	mov 	ebx, esi
  6228 00009E1D 89FE                <1> 	mov	esi, edi
  6229                              <1> 
  6230                              <1> set_env_change_variable_calc6:
  6231 00009E1F AC                  <1> 	lodsb 
  6232 00009E20 20C0                <1> 	and	al, al
  6233 00009E22 75FB                <1> 	jnz	short set_env_change_variable_calc6
  6234                              <1> 
  6235 00009E24 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; 512 (4096)
  6236 00009E2A 0F836DFFFFFF        <1>         jnb     set_env_add_variable_nspc
  6237                              <1> 
  6238 00009E30 89F9                <1> 	mov	ecx, edi  ; current (old) variable's address
  6239 00009E32 89F7                <1> 	mov	edi, esi  ; next variable's address 
  6240                              <1> 
  6241 00009E34 AC                  <1> 	lodsb
  6242 00009E35 08C0                <1> 	or	al, al
  6243 00009E37 7417                <1> 	jz	short set_env_change_variable_calc8 ; 00
  6244                              <1> 
  6245                              <1> set_env_change_variable_calc7:
  6246 00009E39 AC                  <1> 	lodsb
  6247 00009E3A 20C0                <1> 	and	al, al
  6248 00009E3C 75FB                <1> 	jnz	short set_env_change_variable_calc7
  6249                              <1> 
  6250 00009E3E 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; 512 (4096)
  6251                              <1> 	;jnb	set_env_add_variable_nspc
  6252                              <1> 	; 25/07/2022
  6253 00009E44 7205                <1> 	jb	short set_env_change_variable_calc24
  6254                              <1> set_env_change_variable_calc23:
  6255 00009E46 E952FFFFFF          <1> 	jmp	set_env_add_variable_nspc
  6256                              <1> 
  6257                              <1> set_env_change_variable_calc24:
  6258 00009E4B AC                  <1> 	lodsb
  6259 00009E4C 08C0                <1> 	or	al, al
  6260 00009E4E 75E9                <1> 	jnz	short set_env_change_variable_calc7
  6261                              <1> 
  6262                              <1> set_env_change_variable_calc8:
  6263 00009E50 4E                  <1> 	dec	esi ; address of the second (last) 0 of the 00
  6264                              <1> 
  6265 00009E51 01F2                <1> 	add	edx, esi ; final position of the last 0
  6266                              <1> 
  6267 00009E53 81FA00320900        <1> 	cmp	edx, Env_Page + Env_Page_Size ; 512 (4096)
  6268                              <1> 	;jnb     set_env_add_variable_nspc
  6269                              <1> 	; 25/07/2022
  6270 00009E59 73EB                <1> 	jnb	short set_env_change_variable_calc23
  6271                              <1> 
  6272 00009E5B 89C8                <1> 	mov	eax, ecx ; old variable's address (after '=')
  6273                              <1> 
  6274 00009E5D 89F1                <1> 	mov	ecx, esi 
  6275 00009E5F 29F9                <1> 	sub	ecx, edi ; count of bytes to move forward
  6276                              <1> 
  6277                              <1> 	; 13/04/2016
  6278 00009E61 C60200              <1> 	mov	byte [edx], 0
  6279 00009E64 89D7                <1> 	mov	edi, edx
  6280 00009E66 29F2                <1> 	sub	edx, esi ; difference (additional byte count)
  6281 00009E68 4F                  <1> 	dec	edi ; the last zero address (first byte of the 00)
  6282 00009E69 89FE                <1> 	mov	esi, edi
  6283 00009E6B 29D6                <1> 	sub	esi, edx ; - displacement
  6284                              <1> 	
  6285 00009E6D FA                  <1> 	cli	; disable interrupts
  6286 00009E6E FD                  <1> 	std	; backward
  6287                              <1> 
  6288 00009E6F F3A4                <1> 	rep	movsb ; move ECX bytes from DS:ESI to ES:EDI
  6289                              <1> 
  6290 00009E71 FC                  <1> 	cld	; forward (default)
  6291 00009E72 FB                  <1> 	sti	; enable interrupts
  6292                              <1> 	
  6293 00009E73 89C7                <1> 	mov	edi, eax
  6294 00009E75 59                  <1> 	pop	ecx ; ***** ; byte count (after '=')
  6295 00009E76 89CA                <1> 	mov	edx, ecx
  6296 00009E78 89DE                <1> 	mov	esi, ebx ; ASCIIZ string address (after '=')
  6297 00009E7A 89FB                <1> 	mov	ebx, edi
  6298                              <1> 
  6299 00009E7C F3A4                <1> 	rep	movsb
  6300                              <1> 
  6301 00009E7E 880F                <1> 	mov	[edi], cl ; 0 ; end of variable
  6302                              <1> 
  6303 00009E80 0FB605[B4830100]    <1> 	movzx	eax, byte [env_var_length]
  6304 00009E87 01C2                <1> 	add	edx, eax ; variable length (total)
  6305 00009E89 F7D8                <1> 	neg	eax
  6306 00009E8B 01D8                <1> 	add	eax, ebx ; start address of the variable
  6307 00009E8D F8                  <1> 	clc	; 13/04/2016
  6308 00009E8E E9A7FEFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  6309                              <1> 
  6310                              <1> set_env_change_variable_calc9:
  6311                              <1> 	; 11/04/2016
  6312 00009E93 21D2                <1> 	and	edx, edx ; is empty ?
  6313 00009E95 753B                <1> 	jnz	short set_env_change_variable_calc15
  6314                              <1> 	
  6315 00009E97 0FB6DC              <1> 	movzx	ebx, ah
  6316 00009E9A F7DB                <1> 	neg	ebx
  6317 00009E9C 01FB                <1> 	add	ebx, edi
  6318                              <1> 
  6319                              <1> 	; EBX = Start address of the variable (in env page)
  6320                              <1> 	; EDX = Variable length = 0
  6321                              <1> 	
  6322 00009E9E 89FE                <1> 	mov	esi, edi
  6323                              <1> 
  6324                              <1> set_env_change_variable_calc10:
  6325 00009EA0 AC                  <1> 	lodsb
  6326 00009EA1 08C0                <1> 	or	al, al
  6327 00009EA3 75FB                <1> 	jnz	short set_env_change_variable_calc10
  6328                              <1> 
  6329 00009EA5 B9FF310900          <1> 	mov	ecx, Env_Page + Env_Page_Size - 1
  6330                              <1> 
  6331 00009EAA 39CE                <1> 	cmp	esi, ecx ; +511 (+4095)
  6332 00009EAC 7604                <1> 	jna	short set_env_change_variable_calc11
  6333                              <1> 
  6334 00009EAE 89CE                <1> 	mov	esi, ecx
  6335 00009EB0 8806                <1> 	mov	[esi], al ; 0
  6336                              <1> 
  6337                              <1> set_env_change_variable_calc11:
  6338 00009EB2 89DF                <1> 	mov	edi, ebx ; old variable's start address
  6339                              <1> 
  6340                              <1> set_env_change_variable_calc12:
  6341 00009EB4 AC                  <1> 	lodsb
  6342 00009EB5 AA                  <1> 	stosb
  6343 00009EB6 20C0                <1> 	and	al, al
  6344 00009EB8 75FA                <1> 	jnz	short set_env_change_variable_calc12
  6345 00009EBA 39CE                <1> 	cmp	esi, ecx
  6346 00009EBC 7706                <1> 	ja	short set_env_change_variable_calc13
  6347 00009EBE AC                  <1> 	lodsb
  6348 00009EBF AA                  <1> 	stosb
  6349 00009EC0 20C0                <1> 	and	al, al
  6350 00009EC2 75F0                <1> 	jnz	short set_env_change_variable_calc12	
  6351                              <1> 
  6352                              <1> set_env_change_variable_calc13:
  6353 00009EC4 29F9                <1> 	sub	ecx, edi
  6354 00009EC6 7203                <1> 	jb	short set_env_change_variable_calc14
  6355 00009EC8 41                  <1> 	inc	ecx ; 1-512 (1-4096)
  6356 00009EC9 F3AA                <1> 	rep	stosb ; al = 0	
  6357                              <1> 
  6358                              <1> set_env_change_variable_calc14:
  6359 00009ECB 29C0                <1> 	sub	eax, eax ; Start address of the variable
  6360                              <1> 	; EAX = 0 -> Variable is removed
  6361                              <1> 	; EDX = Variable length = 0	
  6362                              <1> 
  6363 00009ECD E968FEFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  6364                              <1> 	    
  6365                              <1> set_env_change_variable_calc15:	
  6366 00009ED2 52                  <1> 	push	edx ; *****
  6367 00009ED3 F7DA                <1> 	neg	edx
  6368 00009ED5 01CA                <1> 	add	edx, ecx ; difference (the old string is longer)
  6369 00009ED7 89F3                <1> 	mov 	ebx, esi
  6370 00009ED9 89FE                <1> 	mov	esi, edi
  6371                              <1> 
  6372                              <1> set_env_change_variable_calc16:
  6373 00009EDB AC                  <1> 	lodsb 
  6374 00009EDC 20C0                <1> 	and	al, al
  6375 00009EDE 75FB                <1> 	jnz	short set_env_change_variable_calc16
  6376                              <1> 
  6377 00009EE0 B900320900          <1> 	mov	ecx, Env_Page + Env_Page_Size
  6378                              <1> 
  6379 00009EE5 39CE                <1> 	cmp	esi, ecx ; +512 (+4096)
  6380 00009EE7 7605                <1> 	jna	short set_env_change_variable_calc17
  6381                              <1> 
  6382 00009EE9 89CE                <1> 	mov	esi, ecx
  6383 00009EEB 8846FF              <1> 	mov	[esi-1], al ; 0
  6384                              <1> 
  6385                              <1> set_env_change_variable_calc17:
  6386 00009EEE 89F9                <1> 	mov	ecx, edi  ; current (old) variable's address
  6387 00009EF0 89F7                <1> 	mov	edi, esi  ; next variable's address 
  6388                              <1> 
  6389 00009EF2 AC                  <1> 	lodsb
  6390 00009EF3 08C0                <1> 	or	al, al
  6391 00009EF5 741D                <1> 	jz	short set_env_change_variable_calc20
  6392                              <1> 
  6393                              <1> set_env_change_variable_calc18:
  6394 00009EF7 AC                  <1> 	lodsb
  6395 00009EF8 20C0                <1> 	and	al, al
  6396 00009EFA 75FB                <1> 	jnz	short set_env_change_variable_calc18
  6397                              <1> 
  6398 00009EFC 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size
  6399 00009F02 720B                <1> 	jb	short set_env_change_variable_calc19
  6400 00009F04 740E                <1> 	je	short set_env_change_variable_calc20
  6401                              <1> 
  6402 00009F06 BEFF310900          <1> 	mov	esi, Env_Page + Env_Page_Size - 1
  6403 00009F0B 8806                <1> 	mov	[esi], al ; 0
  6404 00009F0D EB06                <1> 	jmp	short set_env_change_variable_calc21
  6405                              <1> 
  6406                              <1> set_env_change_variable_calc19:
  6407 00009F0F AC                  <1> 	lodsb
  6408 00009F10 08C0                <1> 	or	al, al
  6409 00009F12 75E3                <1> 	jnz	short set_env_change_variable_calc18
  6410                              <1> 
  6411                              <1> set_env_change_variable_calc20:
  6412 00009F14 4E                  <1> 	dec	esi ; address of the second (last) 0 of the 00
  6413                              <1> 
  6414                              <1> set_env_change_variable_calc21:
  6415                              <1> 	; edx = difference (byte count)
  6416                              <1> 	
  6417 00009F15 89C8                <1> 	mov	eax, ecx ; old variable's address (after '=')
  6418                              <1> 
  6419 00009F17 89F1                <1> 	mov	ecx, esi 
  6420 00009F19 29F9                <1> 	sub	ecx, edi ; count of bytes to move backward
  6421                              <1> 
  6422 00009F1B 89FE                <1> 	mov	esi, edi ; next variable's address
  6423 00009F1D 29D7                <1> 	sub	edi, edx ; (displacement)
  6424                              <1> 	
  6425 00009F1F F3A4                <1> 	rep	movsb
  6426                              <1> 
  6427 00009F21 880F                <1> 	mov	[edi], cl ; 0 ; 00 ; end of environment variables
  6428                              <1> 
  6429 00009F23 89C7                <1> 	mov	edi, eax
  6430 00009F25 5A                  <1> 	pop	edx ; ***** ; byte count (after '=')
  6431 00009F26 89D1                <1> 	mov	ecx, edx
  6432 00009F28 89DE                <1> 	mov	esi, ebx ; ASCIIZ string address (after '=')
  6433 00009F2A 89FB                <1> 	mov	ebx, edi
  6434                              <1> 	
  6435 00009F2C F3A4                <1> 	rep	movsb
  6436                              <1> 
  6437 00009F2E 880F                <1> 	mov	[edi], cl ; 0 ; end of variable
  6438                              <1> 
  6439 00009F30 0FB605[B4830100]    <1> 	movzx	eax, byte [env_var_length]
  6440 00009F37 01C2                <1> 	add	edx, eax ; variable length (total)
  6441 00009F39 F7D8                <1> 	neg	eax
  6442 00009F3B 01D8                <1> 	add	eax, ebx ; start address of the variable
  6443 00009F3D F8                  <1> 	clc	; 13/04/2016
  6444 00009F3E E9F7FDFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  6445                              <1> 
  6446                              <1> mainprog_startup_configuration:
  6447                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
  6448                              <1> 	; 22/11/2017
  6449                              <1> 	; 06/05/2016
  6450                              <1> 	; 14/04/2016 (TRDOS 386 = TRDOS v2.0)
  6451                              <1> 	; 17/09/2011 (TRDOS v1, MAINPROG.ASM)
  6452                              <1> 	;
  6453                              <1> loc_load_mainprog_cfg_file:
  6454 00009F43 BE[E0300100]        <1> 	mov	esi, MainProgCfgFile
  6455 00009F48 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  6456 00009F4C E8EFEAFFFF          <1> 	call	find_first_file
  6457 00009F51 7256                <1> 	jc	short loc_load_mainprog_cfg_exit
  6458                              <1> 
  6459                              <1> 	;or	eax, eax
  6460                              <1> 	;jz	short loc_load_mainprog_cfg_exit
  6461                              <1> 
  6462                              <1> loc_start_mainprog_configuration:
  6463                              <1> 	; ESI = FindFile_DirEntry Location
  6464                              <1> 	; EAX = File Size
  6465                              <1> 
  6466 00009F53 A3[38780100]        <1> 	mov	[MainProgCfg_FileSize], eax
  6467                              <1> 
  6468 00009F58 668B5614            <1> 	mov	dx, [esi+DirEntry_FstClusHI]
  6469 00009F5C C1E210              <1> 	shl	edx, 16
  6470 00009F5F 668B561A            <1> 	mov	dx, [esi+DirEntry_FstClusLO]
  6471 00009F63 8915[68830100]      <1> 	mov	[csftdf_sf_cluster], edx
  6472                              <1> 
  6473 00009F69 89C1                <1> 	mov	ecx, eax
  6474 00009F6B 29C0                <1> 	sub	eax, eax
  6475                              <1> 
  6476                              <1> 	; TRDOS 386 (TRDOS v2.0)
  6477                              <1> 	; Allocate contiguous memory block for loading the file
  6478                              <1> 	
  6479                              <1> 	; eax = 0 (Allocate memory from the beginning)
  6480                              <1> 	; ecx = File (Allocation) size in bytes
  6481                              <1> 	
  6482 00009F6D E87ABCFFFF          <1> 	call	allocate_memory_block
  6483 00009F72 7235                <1> 	jc	short loc_load_mainprog_cfg_exit
  6484                              <1> 
  6485 00009F74 A3[60830100]        <1> 	mov	[csftdf_sf_mem_addr], eax ; loading address
  6486 00009F79 890D[64830100]      <1> 	mov	[csftdf_sf_mem_bsize], ecx ; block size
  6487                              <1> 
  6488 00009F7F 31DB                <1> 	xor	ebx, ebx
  6489                              <1> 	;mov	[csftdf_sf_rbytes], ebx ; 0, reset
  6490                              <1> 
  6491 00009F81 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv] ; [FindFile_Drv]
  6492 00009F87 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  6493 00009F8C 01DE                <1> 	add	esi, ebx
  6494                              <1> 
  6495 00009F8E 8B1D[60830100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  6496                              <1> 
  6497 00009F94 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  6498 00009F98 7710                <1>         ja	short loc_mcfg_load_fat_file
  6499                              <1> 
  6500 00009F9A C705[70830100]0000- <1> 	mov	dword [csftdf_r_size], 65536
  6500 00009FA2 0100                <1>
  6501 00009FA4 E99A010000          <1>         jmp     loc_mcfg_load_fs_file
  6502                              <1> 
  6503                              <1> loc_load_mainprog_cfg_exit:
  6504 00009FA9 C3                  <1> 	retn 
  6505                              <1> 
  6506                              <1> loc_mcfg_load_fat_file:
  6507 00009FAA 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
  6508 00009FAE 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  6509 00009FB2 F7E1                <1> 	mul	ecx
  6510 00009FB4 A3[70830100]        <1> 	mov	[csftdf_r_size], eax
  6511                              <1> 
  6512                              <1> loc_mcfg_load_fat_file_next:
  6513 00009FB9 E81D010000          <1> 	call	mcfg_read_fat_file_sectors
  6514 00009FBE 7259                <1>         jc	short mcfg_deallocate_mem ; 25/07/2022
  6515                              <1> 
  6516 00009FC0 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  6517 00009FC2 74F5                <1> 	jz	short loc_mcfg_load_fat_file_next
  6518                              <1> 
  6519                              <1> loc_mcfg_load_fat_file_ok:
  6520                              <1> 	; 06/05/2016
  6521 00009FC4 C705[04840100]-     <1> 	mov	dword [mainprog_return_addr], loc_mcfg_ci_return_addr 
  6521 00009FCA [96A00000]          <1>
  6522                              <1> 	;
  6523 00009FCE 8B35[60830100]      <1> 	mov	esi, [csftdf_sf_mem_addr]
  6524 00009FD4 8935[3C780100]      <1> 	mov	[MainProgCfg_LineOffset], esi
  6525                              <1> 	
  6526 00009FDA A1[38780100]        <1> 	mov	eax, [MainProgCfg_FileSize]
  6527 00009FDF 89C2                <1> 	mov	edx, eax
  6528 00009FE1 01F2                <1> 	add	edx, esi
  6529                              <1> 
  6530                              <1> loc_mcfg_process_next_line_check:
  6531 00009FE3 89C1                <1> 	mov	ecx, eax
  6532                              <1> 
  6533 00009FE5 803E2A              <1> 	cmp	byte [esi], "*" ; Remark sign
  6534 00009FE8 7503                <1> 	jne	short loc_mcfg_process_next_line
  6535 00009FEA 46                  <1> 	inc	esi
  6536 00009FEB EB16                <1> 	jmp	short loc_move_mainprog_cfg_nl1
  6537                              <1> 
  6538                              <1> loc_mcfg_process_next_line:
  6539 00009FED 83F94F              <1> 	cmp	ecx, 79
  6540 00009FF0 7604                <1> 	jna	short loc_start_mainprog_cfg_process
  6541                              <1> 	
  6542                              <1> 	;mov	ecx, 79 
  6543                              <1> 	; 25/07/2022
  6544 00009FF2 29C9                <1> 	sub	ecx, ecx
  6545 00009FF4 B14F                <1> 	mov	cl, 79
  6546                              <1> 
  6547                              <1> loc_start_mainprog_cfg_process:
  6548 00009FF6 BF[FA780100]        <1> 	mov	edi, CommandBuffer
  6549                              <1> 
  6550                              <1> loc_move_mainprog_cfg_line:
  6551 00009FFB AC                  <1> 	lodsb
  6552 00009FFC 3C20                <1> 	cmp	al, 20h
  6553 00009FFE 720C                <1> 	jb	short loc_move_mainprog_cfg_nl2
  6554 0000A000 AA                  <1> 	stosb
  6555 0000A001 E2F8                <1> 	loop	loc_move_mainprog_cfg_line
  6556                              <1> 
  6557                              <1> loc_move_mainprog_cfg_nl1:
  6558 0000A003 39D6                <1> 	cmp	esi, edx ; + configuration file size
  6559 0000A005 7322                <1> 	jnb	short loc_end_of_mainprog_cfg_line
  6560 0000A007 AC                  <1> 	lodsb
  6561 0000A008 3C20                <1> 	cmp	al, 20h
  6562 0000A00A 73F7                <1> 	jnb	short loc_move_mainprog_cfg_nl1
  6563                              <1> 
  6564                              <1> loc_move_mainprog_cfg_nl2:
  6565 0000A00C 39D6                <1> 	cmp	esi, edx
  6566 0000A00E 7319                <1> 	jnb	short loc_end_of_mainprog_cfg_line
  6567 0000A010 8A06                <1> 	mov	al, [esi]
  6568 0000A012 3C20                <1> 	cmp	al, 20h
  6569 0000A014 7713                <1>  	ja	short loc_end_of_mainprog_cfg_line
  6570 0000A016 46                  <1> 	inc	esi
  6571 0000A017 EBF3                <1> 	jmp	short loc_move_mainprog_cfg_nl2	
  6572                              <1> 
  6573                              <1> 	; 25/07/2022
  6574                              <1> mcfg_deallocate_mem:
  6575 0000A019 A1[60830100]        <1> 	mov	eax, [csftdf_sf_mem_addr] ; start address
  6576 0000A01E 8B0D[64830100]      <1> 	mov	ecx, [csftdf_sf_mem_bsize] ; block size	
  6577                              <1> 	;call	deallocate_memory_block
  6578                              <1> 	;retn
  6579 0000A024 E9DFBDFFFF          <1> 	jmp	deallocate_memory_block               
  6580                              <1> 
  6581                              <1> loc_end_of_mainprog_cfg_line:
  6582 0000A029 C60700              <1> 	mov	byte [edi], 0
  6583                              <1> 
  6584 0000A02C 8935[3C780100]      <1> 	mov	[MainProgCfg_LineOffset], esi
  6585                              <1> 
  6586                              <1> 	; 22/11/2017
  6587 0000A032 BE[02790100]        <1> 	mov	esi, CommandBuffer + 8
  6588 0000A037 29FE                <1> 	sub	esi, edi
  6589 0000A039 7606                <1> 	jna	short loc_move_mainprog_cfg_command
  6590 0000A03B 30C0                <1> 	xor	al, al
  6591                              <1> loc_mainprog_cfg_clear_chrs:
  6592 0000A03D AA                  <1> 	stosb
  6593 0000A03E 4E                  <1> 	dec	esi
  6594 0000A03F 75FC                <1> 	jnz	short loc_mainprog_cfg_clear_chrs	
  6595                              <1> 
  6596                              <1> loc_move_mainprog_cfg_command:
  6597 0000A041 BE[FA780100]        <1> 	mov	esi, CommandBuffer
  6598 0000A046 89F7                <1> 	mov	edi, esi
  6599 0000A048 31DB                <1> 	xor	ebx, ebx
  6600                              <1> 	;xor	ecx, ecx
  6601 0000A04A 30C9                <1> 	xor	cl, cl
  6602                              <1> 
  6603                              <1> loc_move_mcfg_first_cmd_char:
  6604 0000A04C 8A041E              <1> 	mov	al, [esi+ebx]
  6605 0000A04F FEC3                <1> 	inc	bl 
  6606 0000A051 3C20                <1> 	cmp	al, 20h
  6607 0000A053 7712                <1> 	ja	short loc_move_mcfg_cmd_capitalizing
  6608 0000A055 7237                <1> 	jb	short loc_move_mcfg_cmd_arguments_ok
  6609 0000A057 80FB4F              <1> 	cmp	bl, 79
  6610 0000A05A 72F0                <1> 	jb	short loc_move_mcfg_first_cmd_char
  6611 0000A05C EB30                <1> 	jmp	short loc_move_mcfg_cmd_arguments_ok
  6612                              <1> 
  6613                              <1> loc_move_mcfg_next_cmd_char:
  6614 0000A05E 8A041E              <1> 	mov	al, [esi+ebx]
  6615 0000A061 FEC3                <1> 	inc	bl
  6616 0000A063 3C20                <1> 	cmp	al, 20h
  6617 0000A065 7614                <1> 	jna	short loc_move_mcfg_cmd_ok
  6618                              <1> 
  6619                              <1> loc_move_mcfg_cmd_capitalizing:
  6620 0000A067 3C61                <1> 	cmp	al, 61h ; 'a'
  6621 0000A069 7206                <1> 	jb	short loc_move_mcfg_cmd_caps_ok
  6622 0000A06B 3C7A                <1> 	cmp	al, 7Ah ; 'z'
  6623 0000A06D 7702                <1> 	ja	short loc_move_mcfg_cmd_caps_ok
  6624 0000A06F 24DF                <1> 	and	al, 0DFh ; sub	al, 'a'-'A'
  6625                              <1> 
  6626                              <1> loc_move_mcfg_cmd_caps_ok:
  6627 0000A071 AA                  <1> 	stosb 
  6628 0000A072 FEC1                <1> 	inc	cl
  6629 0000A074 80FB4F              <1> 	cmp	bl, 79
  6630 0000A077 72E5                <1> 	jb	short loc_move_mcfg_next_cmd_char
  6631 0000A079 EB13                <1> 	jmp	short loc_move_mcfg_cmd_arguments_ok
  6632                              <1> 
  6633                              <1> loc_move_mcfg_cmd_ok:
  6634 0000A07B 30C0                <1> 	xor	al, al ; 0
  6635                              <1> 
  6636                              <1> loc_move_mcfg_cmd_arguments:
  6637 0000A07D 8807                <1> 	mov	[edi], al
  6638 0000A07F 47                  <1> 	inc	edi
  6639 0000A080 80FB4F              <1> 	cmp	bl, 79
  6640 0000A083 7309                <1> 	jnb	short loc_move_mcfg_cmd_arguments_ok
  6641 0000A085 8A041E              <1> 	mov	al, [esi+ebx]
  6642 0000A088 FEC3                <1> 	inc	bl
  6643 0000A08A 3C20                <1> 	cmp	al, 20h
  6644 0000A08C 73EF                <1> 	jnb	short loc_move_mcfg_cmd_arguments
  6645                              <1> 	
  6646                              <1> loc_move_mcfg_cmd_arguments_ok:
  6647 0000A08E C60700              <1> 	mov	byte [edi], 0
  6648                              <1>        
  6649                              <1> loc_mcfg_process_cmd_interpreter:
  6650 0000A091 E8E8E0FFFF          <1> 	call    command_interpreter
  6651                              <1> 
  6652                              <1> loc_mcfg_ci_return_addr: 
  6653 0000A096 A1[38780100]        <1> 	mov	eax, [MainProgCfg_FileSize]
  6654 0000A09B 89C2                <1> 	mov	edx, eax
  6655 0000A09D 8B35[3C780100]      <1> 	mov	esi, [MainProgCfg_LineOffset]
  6656 0000A0A3 01F2                <1> 	add	edx, esi
  6657 0000A0A5 0305[60830100]      <1> 	add	eax, [csftdf_sf_mem_addr]
  6658 0000A0AB 29F0                <1> 	sub	eax, esi
  6659 0000A0AD 0F8730FFFFFF        <1>         ja      loc_mcfg_process_next_line_check
  6660                              <1> 
  6661 0000A0B3 E861FFFFFF          <1> 	call	mcfg_deallocate_mem
  6662                              <1>  
  6663 0000A0B8 B94F000000          <1>  	mov	ecx, 79 ; 80 ?
  6664 0000A0BD BF[FA780100]        <1> 	mov	edi, CommandBuffer
  6665 0000A0C2 30C0                <1> 	xor	al, al
  6666 0000A0C4 F3AA                <1> 	rep	stosb
  6667                              <1> 
  6668                              <1> 	; 06/05/2016
  6669 0000A0C6 BE[1B3B0100]        <1> 	mov	esi, nextline
  6670 0000A0CB E88ACBFFFF          <1> 	call	print_msg
  6671 0000A0D0 E9FAD7FFFF          <1> 	jmp	dos_prompt
  6672                              <1> 
  6673                              <1> mcfg_read_file_sectors:
  6674                              <1> 	; 14/04/2016
  6675 0000A0D5 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  6676 0000A0D9 7668                <1>         jna	short mcfg_read_fs_file_sectors
  6677                              <1> 
  6678                              <1> mcfg_read_fat_file_sectors:
  6679                              <1> 	; return:
  6680                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  6681                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  6682                              <1> 	;   CF = 1 -> read error (error code in AL)	
  6683                              <1> 
  6684                              <1> mcfg_read_fat_file_secs_0:
  6685 0000A0DB 8B15[38780100]      <1> 	mov	edx, [MainProgCfg_FileSize]
  6686 0000A0E1 2B15[78830100]      <1> 	sub	edx, [csftdf_sf_rbytes]
  6687 0000A0E7 3B15[70830100]      <1> 	cmp	edx, [csftdf_r_size]	
  6688 0000A0ED 7306                <1> 	jnb	short mcfg_read_fat_file_secs_1
  6689 0000A0EF 8915[70830100]      <1> 	mov	[csftdf_r_size], edx
  6690                              <1> 		
  6691                              <1> mcfg_read_fat_file_secs_1:
  6692 0000A0F5 A1[70830100]        <1> 	mov	eax, [csftdf_r_size]
  6693 0000A0FA 29D2                <1> 	sub	edx, edx
  6694 0000A0FC 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  6695 0000A100 01C8                <1> 	add	eax, ecx
  6696 0000A102 48                  <1> 	dec	eax
  6697 0000A103 F7F1                <1> 	div	ecx
  6698 0000A105 89C1                <1> 	mov	ecx, eax ; sector count
  6699 0000A107 A1[68830100]        <1> 	mov	eax, [csftdf_sf_cluster]
  6700                              <1> 
  6701                              <1> 	; EBX = memory block address (current)
  6702                              <1> 	
  6703 0000A10C E8A6220000          <1> 	call	read_fat_file_sectors
  6704 0000A111 7230                <1> 	jc	short mcfg_read_fat_file_secs_3
  6705                              <1> 
  6706                              <1> 	; EBX = next memory address
  6707                              <1> 
  6708 0000A113 A1[78830100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  6709 0000A118 0305[70830100]      <1> 	add	eax, [csftdf_r_size]
  6710 0000A11E 8B15[38780100]      <1> 	mov	edx, [MainProgCfg_FileSize]
  6711 0000A124 39D0                <1> 	cmp	eax, edx
  6712 0000A126 731B                <1> 	jnb	short mcfg_read_fat_file_secs_3 ; edx > 0
  6713 0000A128 A3[78830100]        <1> 	mov	[csftdf_sf_rbytes], eax
  6714                              <1> 
  6715 0000A12D 53                  <1> 	push	ebx ; *
  6716                              <1> 	; get next cluster (csftdf_r_size! bytes)
  6717 0000A12E A1[68830100]        <1> 	mov	eax, [csftdf_sf_cluster]
  6718 0000A133 E87F200000          <1> 	call	get_next_cluster
  6719 0000A138 5B                  <1> 	pop	ebx ; *
  6720 0000A139 7301                <1> 	jnc	short mcfg_read_fat_file_secs_2
  6721                              <1> 
  6722                              <1> 	;mov	eax, 17; Read error !
  6723 0000A13B C3                  <1> 	retn
  6724                              <1> 
  6725                              <1> mcfg_read_fat_file_secs_2:
  6726 0000A13C 29D2                <1> 	sub	edx, edx ; 0
  6727 0000A13E A3[68830100]        <1> 	mov	[csftdf_sf_cluster], eax ; next cluster
  6728                              <1> 
  6729                              <1> ; 25/07/2022 - TRDOS 386 Kernel v2.0.5
  6730                              <1> 
  6731                              <1> mcfg_read_fat_file_secs_3:
  6732                              <1> 	;retn
  6733                              <1> 
  6734                              <1> mcfg_read_fs_file_sectors:
  6735                              <1> 	;retn
  6736                              <1> 
  6737                              <1> loc_mcfg_load_fs_file:
  6738 0000A143 C3                  <1> 	retn
  6739                              <1> 
  6740                              <1> load_and_execute_file:
  6741                              <1> 	; 30/08/2023 - TRDOS 386 Kernel v2.0.6
  6742                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
  6743                              <1> 	; 04/01/2017
  6744                              <1> 	; 06/05/2016 - 07/05/2016 - 11/05/2016
  6745                              <1> 	; 23/04/2016 - 24/04/2016
  6746                              <1> 	; 22/04/2016 (TRDOS 386 = TRDOS v2.0)
  6747                              <1> 	; 05/11/2011 
  6748                              <1> 	; (TRDOS v1, CMDINTR.ASM, 'cmp_cmd_run', 'cmp_cmd_external')
  6749                              <1> 	; ('loc_run_check_filename')
  6750                              <1> 	; 29/08/2011
  6751                              <1> 	; 10/09/2011
  6752                              <1> 	; INPUT->
  6753                              <1> 	;	ESI = Path Name address (CommandBuffer address)
  6754                              <1> 	; OUTPUT ->
  6755                              <1> 	;	none (error message will be shown if an error will occur)
  6756                              <1> 	;
  6757                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI, EBP will be changed) 
  6758                              <1> 	;
  6759                              <1> loc_run_check_filename:
  6760 0000A144 803E20              <1> 	cmp	byte [esi], 20h
  6761                              <1> 	;jb	loc_cmd_failed
  6762                              <1> 	; 25/07/2022
  6763 0000A147 7237                <1> 	jb	short loc_run_ppn_failed
  6764 0000A149 7703                <1> 	ja	short loc_run_check_filename_ok
  6765 0000A14B 46                  <1> 	inc	esi
  6766 0000A14C EBF6                <1> 	jmp	short loc_run_check_filename
  6767                              <1> 
  6768                              <1> loc_run_check_filename_ok:
  6769 0000A14E C605[AB780100]00    <1> 	mov	byte [CmdArgStart], 0 ; reset
  6770 0000A155 56                  <1> 	push	esi ; *
  6771                              <1> loc_run_get_first_arg_pos:
  6772 0000A156 46                  <1> 	inc	esi
  6773 0000A157 8A06                <1> 	mov	al, [esi]
  6774 0000A159 3C20                <1> 	cmp	al, 20h
  6775 0000A15B 77F9                <1> 	ja	short loc_run_get_first_arg_pos
  6776 0000A15D C60600              <1> 	mov	byte [esi], 0
  6777                              <1> loc_run_get_external_arg_pos:
  6778                              <1> 	; 11/05/2016
  6779 0000A160 46                  <1> 	inc	esi
  6780 0000A161 8A06                <1> 	mov	al, [esi]
  6781 0000A163 3C20                <1> 	cmp	al, 20h
  6782 0000A165 760C                <1> 	jna	short loc_run_parse_path_name
  6783 0000A167 89F0                <1> 	mov	eax, esi
  6784 0000A169 2D[FA780100]        <1> 	sub	eax, CommandBuffer
  6785 0000A16E A2[AB780100]        <1> 	mov	byte [CmdArgStart], al
  6786                              <1> loc_run_parse_path_name:
  6787 0000A173 5E                  <1> 	pop	esi ; *
  6788 0000A174 BF[EA800100]        <1> 	mov	edi, FindFile_Drv
  6789 0000A179 E886090000          <1> 	call	parse_path_name
  6790                              <1> 	;jc	loc_cmd_failed
  6791                              <1> 	; 25/07/2022
  6792 0000A17E 7305                <1> 	jnc	short loc_run_check_filename_exists
  6793                              <1> loc_run_ppn_failed:
  6794 0000A180 E9D4E3FFFF          <1> 	jmp	loc_cmd_failed
  6795                              <1> 
  6796                              <1> loc_run_check_filename_exists:
  6797 0000A185 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  6798 0000A18A 803E20              <1> 	cmp	byte [esi], 20h
  6799                              <1> 	;jna	loc_cmd_failed
  6800                              <1> 	; 25/07/2022
  6801 0000A18D 76F1                <1> 	jna	short loc_run_ppn_failed
  6802                              <1> 
  6803                              <1> loc_run_check_exe_filename_ext:
  6804 0000A18F E877020000          <1> 	call	check_prg_filename_ext
  6805                              <1> 	;jc	loc_cmd_failed
  6806                              <1> 	; 25/07/2022
  6807 0000A194 72EA                <1> 	jc	short loc_run_ppn_failed
  6808                              <1> 	
  6809                              <1> loc_run_check_exe_filename_ext_ok:
  6810 0000A196 66A3[02840100]      <1> 	mov	word [EXE_ID], ax
  6811                              <1> 
  6812                              <1> loc_run_drv:
  6813 0000A19C C605[01840100]00    <1> 	mov	byte [Run_Manual_Path], 0
  6814 0000A1A3 A1[44780100]        <1> 	mov	eax, [Current_Dir_FCluster]
  6815 0000A1A8 A3[FC830100]        <1>         mov     [Run_CDirFC], eax
  6816                              <1> 	;
  6817 0000A1AD 8A35[4A780100]      <1> 	mov	dh, [Current_Drv]
  6818 0000A1B3 8835[A77F0100]      <1> 	mov	[RUN_CDRV], dh
  6819                              <1> 
  6820 0000A1B9 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
  6821 0000A1BF 38F2                <1> 	cmp	dl, dh
  6822 0000A1C1 7413                <1> 	je	short loc_run_change_directory
  6823                              <1>                
  6824 0000A1C3 8005[01840100]02    <1> 	add	byte [Run_Manual_Path], 2
  6825                              <1> 
  6826 0000A1CA E8C3D5FFFF          <1> 	call	change_current_drive
  6827                              <1> 	;jc	loc_run_cmd_failed
  6828                              <1> 	; 25/07/2022
  6829 0000A1CF 7305                <1> 	jnc	short loc_run_change_directory
  6830 0000A1D1 E9AEE3FFFF          <1> 	jmp	loc_run_cmd_failed
  6831                              <1> 
  6832                              <1> loc_run_change_directory:
  6833 0000A1D6 803D[EB800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  6834 0000A1DD 7624                <1> 	jna	short loc_run_find_executable_file
  6835                              <1> 
  6836 0000A1DF FE05[01840100]      <1> 	inc	byte [Run_Manual_Path]
  6837                              <1>      
  6838 0000A1E5 FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  6839                              <1> 
  6840 0000A1EB BE[EB800100]        <1> 	mov	esi, FindFile_Directory
  6841 0000A1F0 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  6842 0000A1F2 E821030000          <1> 	call	change_current_directory
  6843                              <1> 	;jc	loc_run_cmd_failed
  6844                              <1> 	; 25/07/2022
  6845 0000A1F7 7305                <1> 	jnc	short loc_run_change_prompt_dir_string
  6846 0000A1F9 E986E3FFFF          <1> 	jmp	loc_run_cmd_failed
  6847                              <1> 
  6848                              <1> loc_run_change_prompt_dir_string:
  6849 0000A1FE E83E020000          <1> 	call	change_prompt_dir_string
  6850                              <1> 
  6851                              <1> loc_run_find_executable_file:
  6852 0000A203 66C705[00840100]00- <1> 	mov	word [Run_Auto_Path], 0
  6852 0000A20B 00                  <1>
  6853                              <1> 
  6854                              <1> loc_run_find_executable_file_next:
  6855 0000A20C BE[2C810100]        <1> 	mov	esi, FindFile_Name
  6856                              <1> loc_run_find_program_file_next:
  6857 0000A211 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  6858 0000A215 E826E8FFFF          <1> 	call	find_first_file
  6859                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
  6860                              <1> 	; EDI = Directory Buffer Directory Entry Location
  6861                              <1> 	; EAX = File size
  6862                              <1> 	;jnc	loc_load_and_run_file
  6863                              <1> 	; 25/07/2022
  6864 0000A21A 7205                <1> 	jc	short loc_run_program_file_not_found
  6865 0000A21C E949010000          <1> 	jmp	loc_load_and_run_file
  6866                              <1> 
  6867                              <1> loc_run_program_file_not_found:	 
  6868 0000A221 3C02                <1> 	cmp	al, 2 ; file not found
  6869                              <1> 	;jne	loc_run_cmd_failed
  6870                              <1> 	; 25/07/2022
  6871 0000A223 7405                <1> 	je	short loc_run_progr_file_chk_prg_ext
  6872 0000A225 E95AE3FFFF          <1> 	jmp	loc_run_cmd_failed
  6873                              <1> 
  6874                              <1> loc_run_progr_file_chk_prg_ext: ; 25/07/2022
  6875 0000A22A 66A1[02840100]      <1> 	mov	ax, word [EXE_ID]
  6876 0000A230 80FC2E              <1> 	cmp	ah, '.' ; File name has extension sign
  6877 0000A233 7424                <1> 	je	short loc_run_check_auto_path
  6878                              <1> 
  6879 0000A235 08C0                <1> 	or	al, al
  6880 0000A237 7520                <1> 	jnz	short loc_run_check_auto_path
  6881                              <1> 
  6882 0000A239 80FC08              <1> 	cmp	ah, 8 ; count of file name chars
  6883 0000A23C 771B                <1> 	ja	short loc_run_check_auto_path
  6884                              <1> 
  6885                              <1> loc_run_change_file_ext_to_prg:
  6886 0000A23E 0FB6DC              <1> 	movzx	ebx, ah ; count of file name chars
  6887 0000A241 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  6888 0000A246 01F3                <1> 	add	ebx, esi	
  6889                              <1> 	; 07/05/2016
  6890 0000A248 C7032E505247        <1> 	mov	dword [ebx],  '.PRG'
  6891 0000A24E 66C705[02840100]50- <1> 	mov	word [EXE_ID], 'P.'
  6891 0000A256 2E                  <1>
  6892 0000A257 EBB8                <1> 	jmp	short loc_run_find_program_file_next	
  6893                              <1> 
  6894                              <1> loc_run_check_auto_path:
  6895                              <1> 	; NOTE: /// 07/05/2016 ///
  6896                              <1> 	; If the path is given, value of byte [Run_Manual_Path]
  6897                              <1> 	; will not be ZERO. If so, file searching by using
  6898                              <1> 	; Automatic Path (via 'PATH' environment variable)
  6899                              <1> 	; will not be applicable, because the program file 
  6900                              <1> 	; is already/absolutely not found.
  6901                              <1> 
  6902 0000A259 A0[01840100]        <1> 	mov	al, [Run_Manual_Path]
  6903 0000A25E 08C0                <1> 	or	al, al
  6904                              <1> 	;jnz	loc_cmd_failed
  6905                              <1> 	; 25/07/2022
  6906 0000A260 7524                <1> 	jnz	short loc_run_cap_failed
  6907                              <1> 
  6908                              <1> loc_run_check_auto_path_again:
  6909 0000A262 66833D[00840100]FF  <1> 	cmp	word [Run_Auto_Path], 0FFFFh		 
  6910                              <1> 		; 0FFFFh = Not a valid run path (in ENV block) 
  6911                              <1> 	;jnb	loc_cmd_failed
  6912                              <1> 	; 25/07/2022
  6913 0000A26A 731A                <1> 	jnb	short loc_run_cap_failed
  6914                              <1> 	;xor	al, al 
  6915 0000A26C BE[66310100]        <1> 	mov	esi, Cmd_Path ; 'PATH'
  6916 0000A271 BF[4A790100]        <1> 	mov	edi, TextBuffer
  6917 0000A276 E86DF9FFFF          <1> 	call	get_environment_string
  6918 0000A27B 7310                <1> 	jnc	short loc_run_chk_filename_ext_again
  6919 0000A27D 66C705[00840100]FF- <1> 	mov	word [Run_Auto_Path], 0FFFFh ; invalid
  6919 0000A285 FF                  <1>
  6920                              <1> loc_run_cap_failed: ; 25/07/2022	
  6921                              <1> 	;jmp	loc_cmd_failed
  6922                              <1> 	; 30/08/2023
  6923 0000A286 B001                <1> 	mov	al, 1 ; (force jump to loc_cmd_failed at the end)
  6924 0000A288 E9F7E2FFFF          <1> 	jmp	loc_run_cmd_failed ; (restore cdir if it is needed)
  6925                              <1> 
  6926                              <1> loc_run_chk_filename_ext_again:
  6927 0000A28D 89C1                <1> 	mov	ecx, eax ; string length (with zero tail)
  6928 0000A28F 49                  <1> 	dec	ecx ; without zero tail
  6929 0000A290 66A1[02840100]      <1> 	mov	ax, [EXE_ID]
  6930 0000A296 80FC2E              <1> 	cmp	ah, '.'
  6931 0000A299 740E                <1> 	je	short loc_run_chk_auto_path_pos
  6932                              <1> 	 
  6933                              <1> loc_run_change_file_ext_to_noext_again:
  6934 0000A29B 0FB6DC              <1> 	movzx	ebx, ah
  6935 0000A29E BE[2C810100]        <1> 	mov	esi, FindFile_Name
  6936 0000A2A3 01F3                <1> 	add 	ebx, esi
  6937 0000A2A5 29C0                <1> 	sub	eax, eax
  6938 0000A2A7 8903                <1> 	mov	[ebx], eax ; 0 ; erase extension (.PRG)
  6939                              <1> 
  6940                              <1> loc_run_chk_auto_path_pos:
  6941                              <1> 	;movzx	eax,  word [Run_Auto_Path]
  6942 0000A2A9 66A1[00840100]      <1> 	mov	ax, [Run_Auto_Path]
  6943 0000A2AF 39C8                <1> 	cmp	eax, ecx ; ecx = string length (except zero tail)
  6944                              <1> 	;jnb	loc_cmd_failed
  6945                              <1>  	; 25/07/2022
  6946 0000A2B1 73D3                <1> 	jnb	short loc_run_cap_failed
  6947                              <1> 
  6948                              <1> 	;or	eax, eax
  6949 0000A2B3 6609C0              <1> 	or	ax, ax
  6950 0000A2B6 7502                <1> 	jnz	short loc_run_auto_path_pos_move
  6951 0000A2B8 B005                <1> 	mov	al, 5
  6952                              <1> 
  6953                              <1> loc_run_auto_path_pos_move:
  6954 0000A2BA 89FE                <1> 	mov	esi, edi ; offset TextBuffer
  6955 0000A2BC 01C6                <1> 	add	esi, eax
  6956                              <1> 
  6957                              <1> loc_run_auto_path_pos_space_loop:
  6958 0000A2BE AC                  <1> 	lodsb
  6959 0000A2BF 3C20                <1> 	cmp	al, 20h 
  6960 0000A2C1 74FB                <1> 	je	short loc_run_auto_path_pos_space_loop
  6961                              <1> 	;jb	loc_cmd_failed
  6962                              <1>  	; 25/07/2022
  6963 0000A2C3 72C1                <1> 	jb	short loc_run_cap_failed
  6964                              <1> 	;
  6965 0000A2C5 AA                  <1> 	stosb
  6966                              <1> loc_run_auto_path_pos_move_next: 
  6967 0000A2C6 AC                  <1> 	lodsb
  6968 0000A2C7 3C3B                <1> 	cmp	al, ';'
  6969 0000A2C9 7414                <1> 	je	short loc_run_auto_path_pos_move_last_byte
  6970 0000A2CB 3C20                <1> 	cmp	al, 20h
  6971 0000A2CD 74F7                <1> 	je	short loc_run_auto_path_pos_move_next
  6972 0000A2CF 7203                <1> 	jb	short loc_byte_ptr_end_of_path
  6973 0000A2D1 AA                  <1> 	stosb
  6974 0000A2D2 EBF2                <1> 	jmp	short loc_run_auto_path_pos_move_next 
  6975                              <1> 
  6976                              <1> loc_byte_ptr_end_of_path: 
  6977 0000A2D4 66C705[00840100]FF- <1> 	mov	word [Run_Auto_Path], 0FFFFh ; end of path
  6977 0000A2DC FF                  <1>
  6978 0000A2DD EB0D                <1> 	jmp	short loc_run_auto_path_move_ok 
  6979                              <1> 
  6980                              <1> loc_run_auto_path_pos_move_last_byte:
  6981 0000A2DF 89F0                <1> 	mov	eax, esi
  6982 0000A2E1 2D[4A790100]        <1> 	sub	eax, TextBuffer 
  6983 0000A2E6 66A3[00840100]      <1> 	mov	[Run_Auto_Path], ax ; next path position
  6984                              <1> 
  6985                              <1> loc_run_auto_path_move_ok:
  6986 0000A2EC 4F                  <1> 	dec	edi
  6987 0000A2ED B02F                <1> 	mov	al, '/'
  6988 0000A2EF 3807                <1> 	cmp	[edi], al
  6989 0000A2F1 7403                <1> 	je	short loc_run_auto_path_move_file_name
  6990 0000A2F3 47                  <1> 	inc	edi
  6991 0000A2F4 8807                <1> 	mov	[edi], al
  6992                              <1> 
  6993                              <1> loc_run_auto_path_move_file_name:
  6994 0000A2F6 47                  <1> 	inc	edi   
  6995 0000A2F7 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  6996                              <1> 
  6997                              <1> loc_run_auto_path_move_fn_loop:
  6998 0000A2FC AC                  <1> 	lodsb
  6999 0000A2FD AA                  <1> 	stosb
  7000 0000A2FE 08C0                <1> 	or	al, al
  7001 0000A300 75FA                <1> 	jnz	short loc_run_auto_path_move_fn_loop
  7002                              <1> 
  7003 0000A302 BE[4A790100]        <1> 	mov	esi, TextBuffer
  7004 0000A307 BF[EA800100]        <1> 	mov	edi, FindFile_Drv
  7005 0000A30C E8F3070000          <1> 	call	parse_path_name
  7006                              <1> 	;jc	loc_run_cmd_failed
  7007                              <1> 	; 25/07/2022
  7008                              <1> 	;jnc	short loc_run_change_current_drive
  7009                              <1> 	;jmp	loc_run_cmd_failed
  7010 0000A311 7234                <1> 	jc	short loc_run_path_failed
  7011                              <1> 
  7012                              <1> loc_run_change_current_drive: 
  7013 0000A313 8A35[4A780100]      <1> 	mov	dh, [Current_Drv]
  7014 0000A319 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
  7015 0000A31F 38F2                <1> 	cmp	dl, dh
  7016 0000A321 7407                <1> 	je	short loc_run_change_directory_again
  7017                              <1>              
  7018 0000A323 E86AD4FFFF          <1> 	call	change_current_drive
  7019                              <1> 	;jc	loc_run_cmd_failed
  7020                              <1> 	; 25/07/2022
  7021                              <1> 	;jnc	short loc_run_change_directory_again
  7022                              <1> 	;jmp	loc_run_cmd_failed
  7023 0000A328 721D                <1> 	jc	short loc_run_path_failed
  7024                              <1> 
  7025                              <1> loc_run_change_directory_again:
  7026 0000A32A 803D[EB800100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  7027 0000A331 761E                <1> 	jna	short loc_load_executable_cdir_chk_again
  7028                              <1> 
  7029 0000A333 FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  7030 0000A339 BE[EB800100]        <1> 	mov	esi, FindFile_Directory
  7031 0000A33E 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  7032 0000A340 E8D3010000          <1> 	call	change_current_directory
  7033                              <1> 	;jc	loc_run_cmd_failed
  7034                              <1> 	; 25/07/2022
  7035 0000A345 7305                <1> 	jnc	short loc_run_chg_prompt_dir_str_again
  7036                              <1> loc_run_path_failed: ; 25/07/2022
  7037 0000A347 E938E2FFFF          <1> 	jmp	loc_run_cmd_failed
  7038                              <1> 
  7039                              <1> loc_run_chg_prompt_dir_str_again:
  7040 0000A34C E8F0000000          <1> 	call	change_prompt_dir_string
  7041                              <1> 
  7042                              <1> loc_load_executable_cdir_chk_again:
  7043 0000A351 A1[44780100]        <1> 	mov	eax, [Current_Dir_FCluster]
  7044 0000A356 3B05[FC830100]      <1> 	cmp	eax, [Run_CDirFC]
  7045                              <1> 	;jne	loc_run_find_executable_file_next
  7046                              <1> 	; 30/08/2023
  7047 0000A35C 7405                <1> 	je	short jmp_loc_run_check_auto_path_again
  7048 0000A35E E9A9FEFFFF          <1> 	jmp	loc_run_find_executable_file_next		
  7049                              <1> jmp_loc_run_check_auto_path_again:
  7050 0000A363 30C0                <1> 	xor	al, al ; 0
  7051 0000A365 E9F8FEFFFF          <1> 	jmp	loc_run_check_auto_path_again
  7052                              <1> 
  7053                              <1> loc_load_and_run_file:
  7054                              <1> 	; 25/07/2022 - TRDOS 386 Kernel v2.0.5
  7055                              <1> 	; 13/11/2017
  7056                              <1> 	; 04/01/2017
  7057                              <1> 	; 23/04/2016
  7058 0000A36A BE[2C810100]        <1> 	mov	esi, FindFile_Name
  7059 0000A36F BF[4A790100]        <1> 	mov	edi, TextBuffer
  7060                              <1> 
  7061                              <1>  	; 24/04/2016
  7062 0000A374 31D2                <1> 	xor	edx, edx
  7063                              <1> 	;mov	word [argc], dx ; 0
  7064                              <1> 	; 25/07/2022
  7065 0000A376 8915[14020300]      <1> 	mov	dword [argc], edx
  7066 0000A37C 8915[48010300]      <1> 	mov	dword [u.nread], edx ; 0
  7067                              <1> 
  7068                              <1> loc_load_and_run_file_1:
  7069 0000A382 AC                  <1> 	lodsb	
  7070 0000A383 AA                  <1> 	stosb
  7071 0000A384 FF05[48010300]      <1> 	inc	dword [u.nread]
  7072 0000A38A 20C0                <1> 	and	al, al
  7073 0000A38C 75F4                <1> 	jnz 	short loc_load_and_run_file_1
  7074                              <1> 	
  7075 0000A38E A0[AB780100]        <1> 	mov	al, [CmdArgStart]
  7076 0000A393 20C0                <1> 	and	al, al
  7077 0000A395 7442                <1> 	jz	short loc_load_and_run_file_7
  7078                              <1> 
  7079 0000A397 0FB6F0              <1> 	movzx	esi, al ; 11/05/2016
  7080                              <1> 	;mov	ecx, 80
  7081                              <1> 	; 25/07/2022
  7082 0000A39A 31C9                <1> 	xor	ecx, ecx
  7083 0000A39C B150                <1> 	mov	cl, 80
  7084                              <1> 	;sub	ecx, esi
  7085 0000A39E 28C1                <1> 	sub	cl, al
  7086 0000A3A0 81C6[FA780100]      <1> 	add	esi, CommandBuffer
  7087                              <1> 
  7088                              <1> 	;inc	word [argc] ; 11/05/2016
  7089                              <1> 	; 25/07/2022
  7090 0000A3A6 FF05[14020300]      <1> 	inc	dword [argc]
  7091                              <1> 
  7092                              <1> loc_load_and_run_file_2:
  7093 0000A3AC AC                  <1> 	lodsb
  7094 0000A3AD 3C20                <1> 	cmp	al, 20h
  7095 0000A3AF 7716                <1> 	ja	short loc_load_and_run_file_5	
  7096 0000A3B1 721D                <1> 	jb	short loc_load_and_run_file_6
  7097                              <1> 
  7098                              <1> loc_load_and_run_file_3:
  7099 0000A3B3 803E20              <1> 	cmp	byte [esi], 20h
  7100 0000A3B6 7707                <1> 	ja	short loc_load_and_run_file_4
  7101 0000A3B8 7216                <1> 	jb	short loc_load_and_run_file_6
  7102 0000A3BA 46                  <1> 	inc	esi
  7103 0000A3BB E2F6                <1> 	loop	loc_load_and_run_file_3
  7104 0000A3BD EB11                <1> 	jmp	short loc_load_and_run_file_6
  7105                              <1> 
  7106                              <1> loc_load_and_run_file_4:
  7107 0000A3BF 28C0                <1> 	sub	al, al ; 0
  7108                              <1> 	;inc	word [argc]
  7109                              <1> 	; 25/07/2022
  7110 0000A3C1 FF05[14020300]      <1> 	inc	dword [argc]
  7111                              <1> loc_load_and_run_file_5:
  7112 0000A3C7 AA                  <1> 	stosb
  7113 0000A3C8 FF05[48010300]      <1> 	inc	dword [u.nread]
  7114 0000A3CE E2DC                <1> 	loop	loc_load_and_run_file_2
  7115                              <1> 			
  7116                              <1> loc_load_and_run_file_6:
  7117 0000A3D0 30C0                <1> 	xor	al, al ; 0
  7118 0000A3D2 AA                  <1> 	stosb
  7119 0000A3D3 FF05[48010300]      <1> 	inc	dword [u.nread]
  7120                              <1> loc_load_and_run_file_7:
  7121 0000A3D9 8807                <1> 	mov 	[edi], al ; 0
  7122                              <1> 	;inc	word [argc] ; 24/04/2016
  7123                              <1> 	; 25/07/2022
  7124 0000A3DB FF05[14020300]      <1> 	inc	dword [argc]
  7125 0000A3E1 FF05[48010300]      <1> 	inc	dword [u.nread] ; 24/04/2016
  7126 0000A3E7 BE[4A790100]        <1> 	mov	esi, TextBuffer
  7127 0000A3EC 8B15[58810100]      <1> 	mov	edx, [FindFile_DirEntry+DirEntry_FileSize]
  7128 0000A3F2 66A1[50810100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusHI]
  7129 0000A3F8 C1E010              <1> 	shl	eax, 16 ; 13/11/2017
  7130 0000A3FB 66A1[56810100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusLO]
  7131                              <1> 	; EAX = First Cluster number
  7132                              <1> 	; EDX = File Size
  7133                              <1> 	; ESI = Argument list address
  7134                              <1> 	; [argc] = argument count
  7135                              <1> 	; [u.nread] = argument list length
  7136 0000A401 E8C5630000          <1> 	call	load_and_run_file ; trdosk6.s
  7137                              <1>         ;jc	loc_run_cmd_failed ; 04/01/2017
  7138                              <1> loc_load_and_run_file_8: ; 06/05/2016
  7139 0000A406 E949EAFFFF          <1> 	jmp	loc_file_rw_restore_retn
  7140                              <1> 
  7141                              <1> check_prg_filename_ext:
  7142                              <1> 	; 23/04/2016 (TRDOS 386 = TRDOS v2.0)
  7143                              <1> 	; 10/09/2011 
  7144                              <1> 	; (TRDOS v1, CMDINTR.ASM, 'proc_check_exe_filename_ext')
  7145                              <1> 	; 14/11/2009
  7146                              <1> 	; INPUT -> 
  7147                              <1> 	;	ESI = Dot File Name
  7148                              <1> 	; OUTPUT ->
  7149                              <1> 	;     cf = 0 -> EXE_ID in AL
  7150                              <1> 	;	ESI = Last char + 1 position
  7151                              <1> 	;     cf = 1 -> Invalid executable file name
  7152                              <1> 	;	or no file name extension if AH<=8
  7153                              <1> 	;	AL = Last file name char     
  7154                              <1> 	;     cf = 0 -> AL='P' (PRG), AL=0 (no extension)
  7155                              <1> 	;
  7156                              <1> 	; (Modified registers: EAX, ESI)
  7157                              <1>   
  7158 0000A40B 30E4                <1> 	xor	ah, ah
  7159                              <1> loc_run_check_filename_ext:	
  7160 0000A40D AC                  <1> 	lodsb
  7161 0000A40E 3C21                <1> 	cmp	al, 21h
  7162 0000A410 7229                <1> 	jb	short loc_check_exe_fn_retn 
  7163 0000A412 FEC4                <1> 	inc	ah
  7164 0000A414 3C2E                <1> 	cmp	al, '.'
  7165 0000A416 75F5                <1> 	jne	short loc_run_check_filename_ext	
  7166                              <1> 		 
  7167                              <1> loc_run_check_filename_ext_dot:
  7168 0000A418 80FC02              <1> 	cmp	ah, 2  ; .??? is not valid
  7169 0000A41B 88C4                <1> 	mov	ah, al ; '.' 
  7170 0000A41D 7219                <1> 	jb	short loc_check_prg_fn_retn
  7171                              <1> 
  7172                              <1> loc_run_check_filename_ext_dot_ok:
  7173 0000A41F AC                  <1> 	lodsb
  7174 0000A420 24DF                <1> 	and	al, 0DFh 
  7175                              <1> 
  7176                              <1> loc_run_check_filename_ext_prg:
  7177 0000A422 3C50                <1> 	cmp	al, 'P'
  7178 0000A424 7212                <1> 	jb	short loc_check_prg_fn_retn
  7179 0000A426 7711                <1> 	ja	short loc_check_prg_fn_stc
  7180 0000A428 AC                  <1> 	lodsb
  7181 0000A429 24DF                <1> 	and	al, 0DFh 
  7182 0000A42B 3C52                <1> 	cmp	al, 'R'
  7183 0000A42D 750A                <1> 	jne	short loc_check_prg_fn_stc
  7184 0000A42F AC                  <1> 	lodsb
  7185 0000A430 24DF                <1> 	and	al, 0DFh
  7186 0000A432 3C47                <1> 	cmp	al, 'G'
  7187 0000A434 7503                <1> 	jne	short loc_check_prg_fn_stc
  7188                              <1> 
  7189 0000A436 B050                <1> 	mov	al, 'P'
  7190                              <1> loc_check_prg_fn_retn:
  7191 0000A438 C3                  <1> 	retn
  7192                              <1> 
  7193                              <1> ; 25/07/2022 - TRDOS 386 Kernel v2.0.5
  7194                              <1> 
  7195                              <1> loc_check_prg_fn_stc:
  7196 0000A439 F9                  <1> 	stc
  7197 0000A43A C3                  <1> 	retn
  7198                              <1>  
  7199                              <1> loc_check_exe_fn_retn:
  7200 0000A43B 28C0                <1> 	sub	al, al ; 0
  7201                              <1> 	;retn
  7202                              <1>               
  7203                              <1> find_and_list_files:
  7204                              <1> 	;retn
  7205                              <1> set_exec_arguments:
  7206 0000A43D C3                  <1> 	retn
  7207                              <1> 
  7208                              <1> delete_fs_directory:
  7209 0000A43E 31C0                <1> 	xor	eax, eax
  7210 0000A440 C3                  <1> 	retn
  3240                                  %include 'trdosk4.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.6) - Directory Functions : trdosk4.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 29/08/2023  (Previous: 11/08/2022)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; DIR.ASM (09/10/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> 
    14                              <1> ; DIR.ASM  [ TRDOS KERNEL - COMMAND EXECUTER SECTION - DIRECTORY FUNCTIONS ]
    15                              <1> ; (c) 2004-2010  Erdogan TAN  [ 17/01/2004 ]  Last Update: 09/10/2011
    16                              <1> ; FILE.ASM [ FILE FUNCTIONS ] Last Update: 09/10/2011
    17                              <1> 
    18                              <1> change_prompt_dir_string:
    19                              <1> 	; 05/10/2016
    20                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
    21                              <1> 	; 27/03/2011
    22                              <1> 	; 09/10/2009
    23                              <1> 	; INPUT/OUTPUT => none
    24                              <1> 	; this procedure changes current directory string/text  
    25                              <1> 	; 2005
    26                              <1> 
    27 0000A441 BE[A87F0100]        <1> 	mov	esi, PATH_Array
    28                              <1> change_prompt_dir_str: ; 05/10/2016 (call from 'set_working_path')
    29 0000A446 BF[4E780100]        <1> 	mov	edi, Current_Directory
    30 0000A44B 8A25[48780100]      <1> 	mov	ah, [Current_Dir_Level]
    31 0000A451 E807000000          <1> 	call	set_current_directory_string
    32 0000A456 880D[A9780100]      <1> 	mov	[Current_Dir_StrLen], cl
    33                              <1> 
    34 0000A45C C3                  <1> 	retn
    35                              <1> 
    36                              <1> set_current_directory_string:
    37                              <1> 	; 11/08/2022 (TRDOS 386 Kernel v2.0.5)
    38                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
    39                              <1> 	; 27/03/2011
    40                              <1> 	; 09/10/2009
    41                              <1> 	; INPUT:
    42                              <1> 	;    ESI = Path Array Address 
    43                              <1> 	;    EDI = Current Directory String Buffer
    44                              <1> 	;    AH = Current Directory Level
    45                              <1> 	; OUTPUT => EAX, EBX, ESI will be changed
    46                              <1> 	;    EDI will be same with input
    47                              <1> 	;    ECX = Current Directory String Length 
    48                              <1> 
    49 0000A45D 57                  <1> 	push    edi
    50 0000A45E 80FC00              <1> 	cmp     ah, 0
    51 0000A461 7651                <1> 	jna	short pass_write_path
    52 0000A463 83C610              <1> 	add	esi, 16
    53 0000A466 89F3                <1> 	mov	ebx, esi
    54                              <1> loc_write_path:
    55                              <1> 	;mov	ecx, 8
    56                              <1> 	; 11/08/2022
    57 0000A468 29C9                <1> 	sub	ecx, ecx
    58 0000A46A B108                <1> 	mov	cl, 8
    59                              <1> path_write_dirname1:
    60 0000A46C AC                  <1> 	lodsb
    61 0000A46D 3C20                <1> 	cmp	al, 20h
    62 0000A46F 7612                <1> 	jna	short pass_write_dirname1
    63 0000A471 AA                  <1> 	stosb
    64 0000A472 81FF[A8780100]      <1> 	cmp	edi, End_Of_Current_Dir_Str
    65 0000A478 733A                <1> 	jnb	short pass_write_path
    66 0000A47A E2F0                <1> 	loop	path_write_dirname1
    67 0000A47C 803E20              <1> 	cmp	byte [esi], 20h
    68 0000A47F 7624                <1> 	jna	short pass_write_dirname2
    69 0000A481 EB0A                <1> 	jmp     short loc_put_dot_cont_ext
    70                              <1> pass_write_dirname1:
    71 0000A483 89DE                <1> 	mov	esi, ebx
    72 0000A485 83C608              <1> 	add	esi, 8
    73 0000A488 803E20              <1> 	cmp	byte [esi], 20h
    74 0000A48B 7618                <1> 	jna	short pass_write_dirname2
    75                              <1> loc_put_dot_cont_ext:
    76 0000A48D C6072E              <1> 	mov	byte [edi], "."
    77                              <1> 	;mov	ecx, 3
    78 0000A490 B103                <1> 	mov	cl, 3
    79                              <1> loc_check_dir_name_ext:
    80 0000A492 AC                  <1> 	lodsb
    81 0000A493 47                  <1> 	inc	edi
    82 0000A494 3C20                <1> 	cmp	al, 20h
    83 0000A496 760D                <1> 	jna	short pass_write_dirname2
    84 0000A498 8807                <1> 	mov	[edi], al
    85 0000A49A 81FF[A8780100]      <1> 	cmp	edi, End_Of_Current_Dir_Str
    86 0000A4A0 7312                <1> 	jnb	short pass_write_path
    87 0000A4A2 E2EE                <1> 	loop    loc_check_dir_name_ext
    88 0000A4A4 47                  <1> 	inc	edi
    89                              <1> pass_write_dirname2:
    90 0000A4A5 FECC                <1> 	dec	ah
    91 0000A4A7 740B                <1> 	jz      short pass_write_path
    92 0000A4A9 83C310              <1> 	add	ebx, 16
    93 0000A4AC 89DE                <1> 	mov	esi, ebx
    94 0000A4AE C6072F              <1> 	mov	byte [edi],"/"
    95 0000A4B1 47                  <1> 	inc	edi
    96 0000A4B2 EBB4                <1> 	jmp	short loc_write_path
    97                              <1> pass_write_path:
    98 0000A4B4 C60700              <1> 	mov	byte [edi], 0
    99 0000A4B7 47                  <1> 	inc	edi
   100 0000A4B8 89F9                <1> 	mov	ecx, edi
   101 0000A4BA 5F                  <1> 	pop	edi
   102 0000A4BB 29F9                <1> 	sub	ecx, edi
   103                              <1> 	; ECX = Current Directory String Length
   104 0000A4BD C3                  <1> 	retn
   105                              <1> 
   106                              <1> get_current_directory:
   107                              <1> 	; 29/08/2023 (TRDOS 386 Kernel v2.0.6)
   108                              <1> 	; 11/08/2022
   109                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
   110                              <1> 	; 15/10/2016
   111                              <1> 	; 14/02/2016
   112                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
   113                              <1> 	; 27/03/2011
   114                              <1> 	;
   115                              <1> 	; INPUT-> ESI = Current Directory Buffer
   116                              <1> 	;         DL = TRDOS Logical Dos Drive Number + 1
   117                              <1> 	;              (0 = Default/Current Drive)
   118                              <1> 	;           
   119                              <1> 	;   Note: Required dir buffer length may be <= 92 bytes
   120                              <1> 	;         for TRDOS (7*12 name chars + 7 slash + 0)
   121                              <1> 	; OUTPUT ->  ESI = Current Directory Buffer
   122                              <1> 	;            EAX, EBX, ECX, EDX, EDI will be changed
   123                              <1> 	;            CX/CL = Current Directory String Length
   124                              <1> 	;	     DL = Drive Number (0 based)
   125                              <1> 	;            (If input is 0, output is current drv number) 
   126                              <1> 	;            DH = same with input 
   127                              <1> 	;   cf = 0 -> AL = 0
   128                              <1> 	;   cf = 1 -> error code in AL 
   129                              <1>               
   130                              <1> loc_get_current_drive_0:
   131                              <1> 	; 29/08/2023
   132 0000A4BE 29C0                <1> 	sub	eax, eax ; 0
   133                              <1> 	;cmp	dl, 0
   134 0000A4C0 38C2                <1> 	cmp	dl, al
   135 0000A4C2 7724                <1> 	ja	short loc_get_current_drive_1
   136 0000A4C4 8A15[4A780100]      <1> 	mov	dl, [Current_Drv]
   137                              <1> 	; 29/08/2023
   138                              <1> 	;jmp	short loc_get_current_drive_2
   139                              <1>  
   140                              <1> loc_get_current_drive_2:
   141                              <1> 	; 29/08/2023
   142                              <1> 	;xor	eax, eax
   143                              <1> 	; eax = 0
   144 0000A4CA 88D4                <1> 	mov	ah, dl
   145 0000A4CC 56                  <1> 	push	esi ; (*)
   146 0000A4CD BE00010900          <1> 	mov	esi, Logical_DOSDisks
   147 0000A4D2 01C6                <1> 	add	esi, eax
   148 0000A4D4 8A06                <1> 	mov	al, [esi+LD_Name] 
   149 0000A4D6 3C41                <1> 	cmp	al, 'A'
   150 0000A4D8 721C                <1> 	jb	short loc_get_current_drive_not_ready_retn
   151                              <1> 
   152                              <1> 	; 28/07/2022
   153 0000A4DA 31C9                <1> 	xor	ecx, ecx
   154                              <1> 
   155 0000A4DC 8A667F              <1> 	mov	ah, [esi+LD_CDirLevel]
   156 0000A4DF 08E4                <1> 	or	ah, ah
   157 0000A4E1 7519                <1> 	jnz	short loc_get_current_drive_3
   158                              <1> 
   159                              <1> 	;xor	ah, ah ; mov ah, 0
   160                              <1> 	
   161                              <1> 	; 11/08/2022 - BugFix (*)
   162 0000A4E3 5E                  <1> 	pop	esi ; (*) Current Directory Buffer address
   163                              <1> 	
   164 0000A4E4 8826                <1> 	mov	[esi], ah
   165                              <1> 	; 28/07/2022
   166                              <1> 	;xor	ecx, ecx
   167 0000A4E6 EB2D                <1> 	jmp	short loc_get_current_drive_4
   168                              <1> 
   169                              <1> 	; 29/08/2023
   170                              <1> loc_get_current_drive_1:
   171 0000A4E8 FECA                <1> 	dec 	dl
   172 0000A4EA 3A15[91300100]      <1> 	cmp	dl, [Last_DOS_DiskNo]
   173 0000A4F0 76D8                <1> 	jna	short loc_get_current_drive_2
   174                              <1> 	;mov	eax, 0Fh ; Invalid drive (Drive not ready!)
   175                              <1> 	;cmc 	; stc
   176                              <1> 	; 28/07/2022
   177                              <1> 	;sub	eax, eax ; 29/08/2023
   178                              <1> 	; eax = 0
   179 0000A4F2 B00F                <1> 	mov	al, 0Fh
   180 0000A4F4 F9                  <1> 	stc
   181 0000A4F5 C3                  <1> 	retn
   182                              <1> 
   183                              <1> loc_get_current_drive_not_ready_retn:
   184 0000A4F6 5E                  <1> 	pop	esi
   185                              <1> 	;mov	eax, 15
   186 0000A4F7 66B80F00            <1> 	mov	ax, 15 ; Drive not ready
   187 0000A4FB C3                  <1> 	retn 
   188                              <1> 
   189                              <1> loc_get_current_drive_3:
   190 0000A4FC BF[A87F0100]        <1>         mov     edi, PATH_Array
   191 0000A501 57                  <1> 	push	edi
   192 0000A502 81C680000000        <1> 	add	esi, LD_CurrentDirectory
   193                              <1> 	;mov	ecx, 32
   194                              <1> 	; 28/07/2022
   195 0000A508 B120                <1> 	mov	cl, 32
   196 0000A50A F3A5                <1> 	rep	movsd
   197 0000A50C 5E                  <1> 	pop	esi ; Path Array Address
   198 0000A50D 5F                  <1> 	pop	edi ; pushed esi (current dir buffer offset) 
   199                              <1> 	;
   200 0000A50E E84AFFFFFF          <1> 	call	set_current_directory_string
   201 0000A513 89FE                <1> 	mov	esi, edi
   202                              <1> 
   203                              <1> loc_get_current_drive_4:
   204 0000A515 30C0                <1> 	xor	al, al
   205 0000A517 C3                  <1> 	retn
   206                              <1> 
   207                              <1> change_current_directory:
   208                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
   209                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
   210                              <1> 	; 19/02/2016
   211                              <1> 	; 11/02/2016
   212                              <1> 	; 10/02/2016
   213                              <1> 	; 08/02/2016
   214                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   215                              <1> 	; 18/09/2011 (DIR.ASM, 09/10/2011)	
   216                              <1> 	; 04/10/2009
   217                              <1> 	; 2005
   218                              <1> 	; INPUT -> 
   219                              <1> 	;	ESI = Directory string
   220                              <1> 	;	ah = CD command (CDh = save current dir string)
   221                              <1> 	; OUTPUT -> 
   222                              <1> 	; 	EDI = DOS Drive Description Table
   223                              <1> 	; 	cf = 1 -> error
   224                              <1> 	;	   EAX = Error code
   225                              <1> 	;	cf = 0 -> successful
   226                              <1> 	;	   ESI = PATH_Array
   227                              <1> 	;	   EAX = Current Directory First Cluster
   228                              <1> 	;
   229                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
   230                              <1> 	
   231 0000A518 8825[36800100]      <1> 	mov	[CD_COMMAND], ah
   232 0000A51E 803E2F              <1> 	cmp	byte [esi], '/'
   233 0000A521 7505                <1> 	jne	short loc_ccd_cdir_level
   234 0000A523 46                  <1> 	inc	esi
   235 0000A524 30C0                <1> 	xor	al, al
   236 0000A526 EB05                <1> 	jmp	short loc_ccd_parse_path_name
   237                              <1> loc_ccd_cdir_level:
   238 0000A528 A0[48780100]        <1> 	mov	al, [Current_Dir_Level]
   239                              <1> loc_ccd_parse_path_name:
   240 0000A52D 88C4                <1> 	mov	ah, al
   241 0000A52F BF[A87F0100]        <1> 	mov	edi, PATH_Array
   242                              <1> 
   243                              <1> ; Reset directory levels > cdir level
   244                              <1> 	; is this required !?
   245                              <1> 	;
   246                              <1> 	; Relations:
   247                              <1> 	; MAINPROG.ASM (pass_ccdrv_reset_cdir_FAT_fcluster)
   248                              <1> 	; proc_parse_dir_name,
   249                              <1> 	; proc_change_current_directory (this procedure)
   250                              <1> 	; proc_change_prompt_dir_string 
   251                              <1>  
   252 0000A534 0FB6C8              <1> 	movzx	ecx, al
   253 0000A537 FEC1                <1> 	inc	cl
   254 0000A539 C0E104              <1> 	shl	cl, 4
   255 0000A53C 01CF                <1> 	add	edi, ecx
   256 0000A53E B107                <1> 	mov	cl, 7
   257 0000A540 28C1                <1> 	sub	cl, al
   258 0000A542 C0E102              <1> 	shl	cl, 2
   259 0000A545 89C3                <1> 	mov	ebx, eax
   260 0000A547 31C0                <1> 	xor	eax, eax ; 0
   261 0000A549 F3AB                <1> 	rep	stosd
   262 0000A54B 89D8                <1> 	mov	eax, ebx
   263                              <1> 
   264 0000A54D BF[A87F0100]        <1> 	mov	edi, PATH_Array
   265                              <1> 
   266 0000A552 803E20              <1> 	cmp	byte [esi], 20h
   267 0000A555 F5                  <1> 	cmc
   268 0000A556 7305                <1> 	jnc	short pass_ccd_parse_dir_name
   269                              <1> 
   270                              <1> 		; ESI = Path name
   271                              <1> 		; AL = CCD_Level
   272 0000A558 E871010000          <1>         call    parse_dir_name
   273                              <1> 		; AL = CCD_Level 
   274                              <1> 		; AH = Last_Dir_Level
   275                              <1> 		; (EDI = PATH_Array)
   276                              <1> 
   277                              <1> pass_ccd_parse_dir_name:
   278 0000A55D 9C                  <1> 	pushf
   279                              <1> 
   280                              <1> 	;mov	[CCD_Level], al
   281                              <1>         ;mov	[Last_Dir_Level], ah
   282 0000A55E 66A3[2C800100]      <1> 	mov	[CCD_Level], ax
   283                              <1> 
   284 0000A564 31DB                <1> 	xor	ebx, ebx
   285 0000A566 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv]
   286 0000A56C BE00010900          <1> 	mov	esi, Logical_DOSDisks
   287 0000A571 01DE                <1> 	add	esi, ebx
   288                              <1> 
   289 0000A573 9D                  <1> 	popf 
   290 0000A574 720A                <1> 	jc	short loc_ccd_bad_path_name_retn
   291                              <1> 
   292 0000A576 8935[28800100]      <1> 	mov	[CCD_DriveDT], esi
   293                              <1> 
   294 0000A57C 3C07                <1> 	cmp	al, 7
   295 0000A57E 7208                <1> 	jb	short loc_ccd_load_child_dir
   296                              <1> 
   297                              <1> loc_ccd_bad_path_name_retn:
   298 0000A580 87F7                <1> 	xchg	esi, edi
   299                              <1> 	;mov	eax, 19 ; Bad directory/path name 
   300                              <1> 	; 28/07/2022
   301 0000A582 29C0                <1> 	sub	eax, eax
   302 0000A584 B013                <1> 	mov	al, 19
   303 0000A586 F9                  <1> 	stc
   304                              <1> loc_ccd_retn_p:
   305 0000A587 C3                  <1> 	retn
   306                              <1> 
   307                              <1> loc_ccd_load_child_dir:
   308                              <1> 	; AL = CCD_Level
   309 0000A588 08C0                <1> 	or	al, al
   310 0000A58A 7467                <1> 	jz	short loc_ccd_load_root_dir
   311                              <1> 
   312                              <1> 	;mov	cx, ax
   313                              <1> 	; 28/07/2022
   314 0000A58C 89C1                <1> 	mov	ecx, eax
   315 0000A58E C0E004              <1> 	shl	al, 4
   316 0000A591 0FB6F0              <1> 	movzx	esi, al
   317 0000A594 01FE                <1>      	add	esi, edi  ; offset PATH_Array
   318                              <1> 
   319 0000A596 8B460C              <1> 	mov	eax, [esi+12]
   320 0000A599 38E9                <1> 	cmp	cl, ch
   321                              <1> 	;je	loc_ccd_load_sub_directory
   322                              <1> 	; 28/07/2022
   323 0000A59B 7505                <1> 	jne	short loc_ccd_1
   324 0000A59D E9FA000000          <1> 	jmp	loc_ccd_load_sub_directory	
   325                              <1> 
   326                              <1> loc_ccd_1:	; 28/07/2022
   327 0000A5A2 A3[44780100]        <1> 	mov	[Current_Dir_FCluster], eax
   328                              <1> 
   329                              <1> loc_ccd_load_child_dir_next:
   330 0000A5A7 83C610              <1> 	add	esi, 16 ; DOS DirEntry Format FileName Address
   331                              <1> 
   332                              <1>  	; Directory attribute : 10h
   333 0000A5AA B010                <1> 	mov	al, 00010000b ; 10h (Attrib AND mask)
   334                              <1> 	;mov	ah, 11001000b ; C8h
   335                              <1> 	; Volume name attribute: 8h
   336 0000A5AC B408                <1> 	mov	ah, 00001000b ; 08h (Attrib NAND, AND --> zero mask)
   337                              <1> 
   338                              <1> 	;xor	cx, cx  
   339 0000A5AE 31C9                <1> 	xor	ecx, ecx ; 02/03/2021
   340 0000A5B0 E8B6010000          <1> 	call	locate_current_dir_file
   341 0000A5B5 7353                <1> 	jnc	short loc_ccd_set_dir_cluster_ptr
   342                              <1> 
   343                              <1> 	; 19/02/2016
   344                              <1> 	;mov	edi, [CCD_DriveDT]
   345 0000A5B7 8A25[2C800100]      <1> 	mov	ah, [CCD_Level]
   346 0000A5BD 803D[36800100]CD    <1> 	cmp	byte [CD_COMMAND], 0CDh ;'CD' command or another
   347 0000A5C4 7509                <1> 	jne	short loc_ccd_load_child_dir_err
   348                              <1> 	; It is better to save recent successful part 
   349                              <1> 	; of the (requested) path as current directory.
   350                              <1> 	; (Otherwise the path would be reset to back
   351                              <1> 	; on the next 'CD' command.)
   352 0000A5C6 88E1                <1> 	mov	cl, ah
   353 0000A5C8 50                  <1> 	push	eax
   354 0000A5C9 E8E4000000          <1> 	call	loc_ccd_save_current_dir
   355 0000A5CE 58                  <1> 	pop	eax
   356                              <1> loc_ccd_load_child_dir_err:            
   357 0000A5CF 3C03                <1> 	cmp	al, 3	; AL = 2 => File not found error
   358 0000A5D1 7202                <1> 	jb	short loc_ccd_path_not_found_retn
   359 0000A5D3 F9                  <1> 	stc
   360 0000A5D4 C3                  <1> 	retn
   361                              <1> 
   362                              <1> loc_ccd_path_not_found_retn:
   363 0000A5D5 B003                <1> 	mov	al, 3	; Path not found
   364 0000A5D7 C3                  <1> 	retn
   365                              <1> 
   366                              <1> loc_ccd_load_FAT_root_dir:
   367 0000A5D8 803D[49780100]02    <1> 	cmp	byte [Current_FATType], 2
   368 0000A5DF 776B                <1> 	ja	short loc_ccd_load_FAT32_root_dir
   369                              <1> 
   370                              <1> 	;mov	esi, [CCD_DriveDT]
   371                              <1> 	;push	esi
   372 0000A5E1 E80F1D0000          <1> 	call	load_FAT_root_directory
   373                              <1> 	;pop	edi ; Dos Drv Description Table
   374                              <1> 
   375 0000A5E6 89F7                <1> 	mov	edi, esi
   376 0000A5E8 BE[A87F0100]        <1> 	mov	esi, PATH_Array
   377 0000A5ED 7298                <1> 	jc	short loc_ccd_retn_p
   378                              <1> 
   379 0000A5EF 31C0                <1> 	xor	eax, eax
   380 0000A5F1 EB78                <1>         jmp	short loc_ccd_set_cdfc
   381                              <1> 
   382                              <1> loc_ccd_load_root_dir:
   383 0000A5F3 803D[49780100]01    <1> 	cmp	byte [Current_FATType], 1
   384 0000A5FA 73DC                <1> 	jnb	short loc_ccd_load_FAT_root_dir
   385                              <1> 
   386                              <1> loc_ccd_load_FS_root_dir:
   387 0000A5FC E8AC1D0000          <1> 	call	load_FS_root_directory
   388 0000A601 EB5C                <1> 	jmp	short pass_ccd_load_FAT_sub_directory
   389                              <1> 
   390                              <1> loc_ccd_load_FS_sub_directory_next:
   391 0000A603 E8A51D0000          <1> 	call	load_FS_sub_directory
   392 0000A608 EB1F                <1> 	jmp	short pass_ccd_set_dir_cluster_ptr  
   393                              <1> 
   394                              <1> loc_ccd_set_dir_cluster_ptr:
   395                              <1> 	; EDI = Directory Entry
   396 0000A60A 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
   397 0000A60E C1E010              <1> 	shl	eax, 16
   398 0000A611 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
   399                              <1> 
   400 0000A615 8B35[28800100]      <1> 	mov	esi, [CCD_DriveDT]
   401 0000A61B 803D[49780100]01    <1> 	cmp	byte [Current_FATType], 1
   402 0000A622 72DF                <1> 	jb	short loc_ccd_load_FS_sub_directory_next
   403                              <1> 	;push	esi
   404 0000A624 E84A1D0000          <1> 	call	load_FAT_sub_directory
   405                              <1> 	;pop	edi ; Dos Drv Description Table
   406                              <1> 
   407                              <1> pass_ccd_set_dir_cluster_ptr:
   408                              <1> 	;mov	edi, esi
   409 0000A629 BE[A87F0100]        <1> 	mov	esi, PATH_Array
   410 0000A62E 7265                <1> 	jc	short loc_ccd_retn_c
   411                              <1> 
   412 0000A630 A1[767F0100]        <1> 	mov	eax, [DirBuff_Cluster]
   413                              <1> 
   414 0000A635 FE05[2C800100]      <1> 	inc	byte [CCD_Level]
   415 0000A63B 0FB61D[2C800100]    <1> 	movzx	ebx, byte [CCD_Level]
   416 0000A642 C0E304              <1> 	shl	bl, 4 ; * 16 (<= 128)   
   417 0000A645 01DE                <1> 	add	esi, ebx ; 19/02/2016
   418 0000A647 89460C              <1> 	mov	[esi+12], eax
   419 0000A64A EB1F                <1> 	jmp	short loc_ccd_set_cdfc
   420                              <1> 
   421                              <1> loc_ccd_load_FAT32_root_dir:
   422 0000A64C BE[A87F0100]        <1> 	mov	esi, PATH_Array
   423 0000A651 8B460C              <1> 	mov	eax, [esi+12]
   424 0000A654 8B35[28800100]      <1> 	mov	esi, [CCD_DriveDT]
   425                              <1>  
   426                              <1> loc_ccd_load_FAT_sub_directory:
   427                              <1> 	;push	esi
   428 0000A65A E8141D0000          <1> 	call	load_FAT_sub_directory
   429                              <1> 	;pop	edi ; Dos Drv Description Table
   430                              <1> 
   431                              <1> pass_ccd_load_FAT_sub_directory:
   432                              <1> 	;mov	edi, esi
   433 0000A65F BE[A87F0100]        <1> 	mov	esi, PATH_Array
   434 0000A664 722F                <1> 	jc	short loc_ccd_retn_c
   435                              <1> 
   436 0000A666 A1[767F0100]        <1> 	mov	eax, [DirBuff_Cluster]
   437                              <1> 
   438                              <1> loc_ccd_set_cdfc:
   439 0000A66B 8A0D[2C800100]      <1> 	mov	cl, [CCD_Level]
   440 0000A671 880D[48780100]      <1> 	mov	[Current_Dir_Level], cl
   441 0000A677 A3[44780100]        <1> 	mov	[Current_Dir_FCluster], eax
   442                              <1> 
   443 0000A67C 8A2D[2D800100]      <1> 	mov	ch, [Last_Dir_Level]
   444 0000A682 38E9                <1> 	cmp	cl, ch 
   445                              <1> 	;jb	loc_ccd_load_child_dir_next
   446                              <1> 	; 28/07/2022
   447 0000A684 7305                <1> 	jnb	short loc_ccd_2	
   448 0000A686 E91CFFFFFF          <1> 	jmp	loc_ccd_load_child_dir_next
   449                              <1> loc_ccd_2:
   450 0000A68B 803D[36800100]CD    <1> 	cmp	byte [CD_COMMAND], 0CDh ;'CD' command or another
   451 0000A692 741E                <1> 	je	short loc_ccd_save_current_dir
   452                              <1> 
   453                              <1>         ; jne -> don't save, restore (the previous cdir) later !
   454                              <1>         ; (saving the cdir would prevent previous cdir restoration!)
   455                              <1> 
   456 0000A694 F8                  <1> 	clc
   457                              <1> 
   458                              <1> loc_ccd_retn_c:
   459 0000A695 8B3D[28800100]      <1> 	mov	edi, [CCD_DriveDT]
   460 0000A69B C3                  <1> 	retn
   461                              <1> 
   462                              <1> loc_ccd_load_sub_directory:
   463 0000A69C 8B35[28800100]      <1> 	mov	esi, [CCD_DriveDT]
   464 0000A6A2 803D[49780100]01    <1> 	cmp	byte [Current_FATType], 1
   465 0000A6A9 73AF                <1> 	jnb	short loc_ccd_load_FAT_sub_directory 
   466 0000A6AB E8FD1C0000          <1> 	call	load_FS_sub_directory
   467 0000A6B0 EBAD                <1> 	jmp	short pass_ccd_load_FAT_sub_directory 
   468                              <1> 
   469                              <1> loc_ccd_save_current_dir:
   470                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
   471                              <1> 	; ('find_directory_entry' has been fixed to prevent large
   472                              <1> 	; ECX value > 65535)
   473                              <1> 	; 
   474 0000A6B2 BE[A87F0100]        <1> 	mov	esi, PATH_Array ; 19/02/2016
   475 0000A6B7 8B3D[28800100]      <1> 	mov	edi, [CCD_DriveDT]
   476 0000A6BD 57                  <1> 	push	edi
   477 0000A6BE 83C77F              <1>         add     edi, LD_CDirLevel
   478 0000A6C1 880F                <1> 	mov	[edi], cl
   479 0000A6C3 47                  <1> 	inc	edi ; LD_CurrentDirectory 
   480 0000A6C4 56                  <1> 	push	esi
   481                              <1> 	;;mov	ecx, 32  ; always < 65536 (in this procedure)
   482 0000A6C5 66B92000            <1> 	mov	cx, 32
   483                              <1> 	; 02/03/2021
   484                              <1> 	;mov	ecx, 32
   485 0000A6C9 F3A5                <1> 	rep	movsd
   486                              <1> 	; Current directory has been saved to 
   487                              <1> 	; the DOS drive description table, cdir area !
   488 0000A6CB 5E                  <1> 	pop	esi  ; PATH_Array
   489 0000A6CC 5F                  <1> 	pop	edi  ; Dos Drv Description Table
   490                              <1> 
   491 0000A6CD C3                  <1> 	retn
   492                              <1> 
   493                              <1> parse_dir_name:
   494                              <1> 	; 11/02/2016
   495                              <1> 	; 10/02/2016
   496                              <1> 	; 07/02/2016 (TRDOS 386 = TRDOS v2.0)
   497                              <1> 	; 18/09/2011
   498                              <1> 	; 17/10/2009
   499                              <1> 	; INPUT ->
   500                              <1> 	;	ESI = ASCIIZ Directory String Address
   501                              <1> 	;	AL = Current Directory Level
   502                              <1> 	;	EDI = Destination Adress
   503                              <1> 	;	     (8 levels, each one 12+4 byte)
   504                              <1> 	; OUTPUT ->
   505                              <1> 	;	EDI = Dir Entry Formatted Array
   506                              <1> 	;	     with zero cluster pointer at the last level
   507                              <1> 	;	AH = Last Dir Level
   508                              <1> 	;	AL = Current Dir Level
   509                              <1> 	;
   510                              <1> 	; (esi, ebx, ecx will be changed) 
   511                              <1> 
   512                              <1> 	;mov	[PATH_Array_Ptr], edi
   513 0000A6CE 88C4                <1> 	mov	ah, al
   514 0000A6D0 66A3[CC800100]      <1> 	mov	[PATH_CDLevel], ax
   515                              <1> repeat_ppdn_check_slash:
   516 0000A6D6 AC                  <1> 	lodsb
   517 0000A6D7 3C2F                <1> 	cmp	al, '/'
   518 0000A6D9 74FB                <1> 	je	short repeat_ppdn_check_slash
   519 0000A6DB 3C21                <1> 	cmp	al, 21h
   520 0000A6DD 7219                <1> 	jb	short loc_ppdn_retn
   521 0000A6DF 57                  <1> 	push	edi
   522                              <1> loc_ppdn_get_dir_name:
   523 0000A6E0 B90C000000          <1> 	mov	ecx, 12
   524 0000A6E5 BF[CE800100]        <1> 	mov	edi, Dir_File_Name
   525                              <1> repeat_ppdn_get_dir_name:
   526 0000A6EA AA                  <1> 	stosb
   527 0000A6EB AC                  <1> 	lodsb
   528 0000A6EC 3C2F                <1> 	cmp	al, '/'
   529 0000A6EE 740A                <1> 	je	short loc_check_level_dot_conv_dir_name
   530 0000A6F0 3C20                <1> 	cmp	al, 20h
   531 0000A6F2 7605                <1> 	jna	short loc_ppdn_end_of_path_scan
   532 0000A6F4 E2F4                <1> 	loop	repeat_ppdn_get_dir_name
   533 0000A6F6 5F                  <1> 	pop	edi
   534 0000A6F7 F9                  <1> 	stc
   535                              <1> loc_ppdn_retn:
   536 0000A6F8 C3                  <1> 	retn
   537                              <1> 
   538                              <1> loc_ppdn_end_of_path_scan:
   539 0000A6F9 4E                  <1> 	dec	esi
   540                              <1> loc_check_level_dot_conv_dir_name:
   541 0000A6FA 31C0                <1> 	xor	eax, eax
   542 0000A6FC AA                  <1> 	stosb
   543 0000A6FD 89F3                <1> 	mov	ebx, esi
   544 0000A6FF BE[CE800100]        <1> 	mov	esi, Dir_File_Name
   545 0000A704 AC                  <1> 	lodsb
   546                              <1> repeat_ppdn_name_check_dot:
   547 0000A705 3C2E                <1> 	cmp	al, '.'
   548 0000A707 7509                <1> 	jne	short loc_ppdn_convert_sub_dir_name
   549                              <1> repeat_ppdn_name_dot_dot:
   550 0000A709 AC                  <1> 	lodsb
   551 0000A70A 3C2E                <1> 	cmp	al, '.'
   552 0000A70C 743E                <1> 	je	short loc_ppdn_dot_dot
   553 0000A70E 3C21                <1> 	cmp	al, 21h
   554 0000A710 7226                <1> 	jb	short pass_ppdn_convert_sub_dir_name
   555                              <1> loc_ppdn_convert_sub_dir_name:
   556 0000A712 8A25[CD800100]      <1> 	mov	ah, [PATH_Level]
   557 0000A718 80FC07              <1> 	cmp	ah, 7
   558 0000A71B 731B                <1> 	jnb	short pass_ppdn_convert_sub_dir_name
   559 0000A71D FEC4                <1> 	inc	ah  
   560 0000A71F 8825[CD800100]      <1> 	mov	[PATH_Level], ah
   561 0000A725 BE[CE800100]        <1> 	mov	esi, Dir_File_Name
   562                              <1> 	;mov	edi, [PATH_Array_Ptr]
   563 0000A72A B010                <1> 	mov	al, 16
   564 0000A72C F6E4                <1> 	mul	ah
   565 0000A72E 8B3C24              <1> 	mov	edi, [esp]
   566                              <1> 	;push	edi 
   567 0000A731 01C7                <1> 	add	edi, eax
   568 0000A733 E802030000          <1> 	call	convert_file_name
   569                              <1> 	;pop	edi
   570                              <1> pass_ppdn_convert_sub_dir_name:
   571 0000A738 89DE                <1> 	mov	esi, ebx
   572                              <1> repeat_ppdn_check_last_slash:
   573 0000A73A AC                  <1> 	lodsb
   574 0000A73B 3C2F                <1> 	cmp	al, '/'
   575 0000A73D 74FB                <1> 	je	short repeat_ppdn_check_last_slash
   576 0000A73F 3C21                <1> 	cmp	al, 21h
   577 0000A741 739D                <1> 	jnb	short loc_ppdn_get_dir_name
   578                              <1> end_of_parse_dir_name:
   579 0000A743 5F                  <1> 	pop	edi
   580 0000A744 F5                  <1> 	cmc  
   581                              <1> 	;mov	al, [PATH_CDLevel]
   582                              <1> 	;mov	ah, [PATH_Level]
   583 0000A745 66A1[CC800100]      <1> 	mov	ax, [PATH_CDLevel]
   584 0000A74B C3                  <1> 	retn
   585                              <1> 
   586                              <1> loc_ppdn_dot_dot:
   587 0000A74C AC                  <1> 	lodsb
   588 0000A74D 3C21                <1> 	cmp	al, 21h
   589 0000A74F 73F2                <1> 	jnb	short end_of_parse_dir_name 
   590                              <1> loc_ppdn_dot_dot_prev_level:
   591 0000A751 66A1[CC800100]      <1> 	mov	ax, [PATH_CDLevel]
   592 0000A757 80EC01              <1> 	sub	ah, 1
   593 0000A75A 80D400              <1> 	adc	ah, 0
   594 0000A75D 38E0                <1> 	cmp	al, ah
   595 0000A75F 7602                <1> 	jna	short pass_ppdn_set_al_to_ah
   596 0000A761 88E0                <1> 	mov	al, ah
   597                              <1> pass_ppdn_set_al_to_ah:
   598 0000A763 66A3[CC800100]      <1> 	mov	[PATH_CDLevel], ax
   599 0000A769 EBCD                <1> 	jmp	short pass_ppdn_convert_sub_dir_name
   600                              <1> 
   601                              <1> locate_current_dir_file:
   602                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
   603                              <1> 	; 20/11/2017
   604                              <1> 	; 14/02/2016
   605                              <1> 	; 13/02/2016
   606                              <1> 	; 10/02/2016
   607                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   608                              <1> 	; 14/08/2010
   609                              <1> 	; 19/09/2009
   610                              <1>         ; 2005
   611                              <1> 	; INPUT ->
   612                              <1> 	;	ESI = DOS DirEntry Format FileName Address
   613                              <1> 	;	AL = Attributes Mask 
   614                              <1> 	;	(<AL AND EntryAttrib> must be equal to AL)
   615                              <1> 	;	AH = Negative Attributes Mask (If AH>0)
   616                              <1> 	;	(<AH AND EntryAttrib> must be ZERO)
   617                              <1> 	;	CH > 0 Find First Free Dir Entry or Deleted Entry
   618                              <1> 	;	CL = 0 -> Return the First Free Dir Entry
   619                              <1> 	;	CL = E5h -> Return the 1st deleted entry
   620                              <1> 	;	CL = FFh -> Return the 1st deleted or free entry
   621                              <1> 	;	CL > 0 and CL <> E5h and CL <> FFh -> Return the first 
   622                              <1> 	;	     proper entry (which fits with Atributes Masks)
   623                              <1> 	;	CX = 0 Find Valid File/Directory/VolumeName
   624                              <1> 	;	? = Any One Char
   625                              <1> 	;	* = Every Chars
   626                              <1> 	; OUTPUT ->
   627                              <1> 	;	EDI = Directory Entry Address (in Directory Buffer)
   628                              <1> 	;	ESI = DOS DirEntry Format FileName Address
   629                              <1> 	;	CF = 0 -> No Error, Proper Entry,
   630                              <1> 	;	DL = Attributes
   631                              <1> 	;	DH = Previous Entry Attr (LongName Check)
   632                              <1> 	;	AL > 0 -> Ambiguous filename wildcard "?" used
   633                              <1> 	;	AH > 0 -> Ambiguous filename wildcard "*" used
   634                              <1> 	;	AX = 0 -> Filename full fits with directory entry
   635                              <1> 	;	CH = The 1st Name Char of Current Dir Entry
   636                              <1> 	;	CF = 1 -> Proper entry not found, Error Code in EAX/AL
   637                              <1> 	;	CL = 0 and CH = 0 -> Free Entry (End Of Dir)
   638                              <1> 	;	CL = 0 and CH = E5h -> Deleted Entry fits with filters
   639                              <1> 	;	CL > 0 -> Entry not found, CH invalid
   640                              <1> 	;	CF = 0 -> 
   641                              <1> 	;	EBX = Current Directory Entry Index/Number (BX)
   642                              <1> 
   643                              <1> 	;mov	word [DirBuff_EntryCounter], 0 ; Zero Based
   644                              <1> 
   645 0000A76B 8935[30800100]      <1> 	mov	[CDLF_FNAddress], esi
   646 0000A771 66A3[2E800100]      <1> 	mov	[CDLF_AttributesMask], ax
   647 0000A777 66890D[34800100]    <1> 	mov	[CDLF_DEType], cx
   648                              <1> 
   649 0000A77E 31DB                <1> 	xor	ebx, ebx
   650 0000A780 881D[44800100]      <1> 	mov	[PreviousAttr], bl ; 0  ; 13/02/2016
   651                              <1> 
   652 0000A786 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv]
   653 0000A78C 381D[717F0100]      <1> 	cmp	byte [DirBuff_ValidData], bl ; 0
   654 0000A792 761D                <1> 	jna	short loc_lcdf_reload_current_dir2
   655 0000A794 8A1D[6F7F0100]      <1>         mov     bl, [DirBuff_DRV]
   656 0000A79A 80EB41              <1> 	sub	bl, 'A'
   657 0000A79D 38DF                <1> 	cmp	bh, bl
   658 0000A79F 750E                <1> 	jne	short loc_lcdf_reload_current_dir1
   659 0000A7A1 8B15[767F0100]      <1> 	mov	edx, [DirBuff_Cluster]
   660 0000A7A7 3B15[44780100]      <1> 	cmp	edx, [Current_Dir_FCluster]
   661 0000A7AD 7412                <1> 	je	short loc_cdir_locatefile_search
   662                              <1> 
   663                              <1> loc_lcdf_reload_current_dir1:
   664 0000A7AF 30DB                <1> 	xor	bl, bl
   665                              <1> loc_lcdf_reload_current_dir2:
   666 0000A7B1 89DE                <1> 	mov	esi, ebx
   667 0000A7B3 81C600010900        <1>         add     esi, Logical_DOSDisks
   668 0000A7B9 E872000000          <1> 	call	reload_current_directory 
   669 0000A7BE 735B                <1> 	jnc	short loc_locatefile_search_again 
   670 0000A7C0 C3                  <1> 	retn  
   671                              <1> 
   672                              <1> loc_cdir_locatefile_search:
   673 0000A7C1 31DB                <1> 	xor	ebx, ebx
   674 0000A7C3 55                  <1> 	push	ebp ; 20/11/2017
   675 0000A7C4 E8A0000000          <1> 	call	find_directory_entry
   676 0000A7C9 5D                  <1> 	pop	ebp ; 20/11/2017
   677 0000A7CA 7347                <1> 	jnc	short loc_cdir_locate_file_retn
   678                              <1> 
   679                              <1> loc_locatefile_check_stc_reason:
   680 0000A7CC 08ED                <1> 	or	ch, ch
   681 0000A7CE 7442                <1> 	jz	short loc_cdir_locate_file_stc_retn
   682                              <1> 
   683                              <1> loc_locatefile_check_next_entryblock:
   684                              <1> 	;mov	bh, [Current_Drv]
   685                              <1> 	;sub	bl, bl
   686                              <1> 	;movzx	esi, bx
   687                              <1> 	; 28/07/2022
   688 0000A7D0 31DB                <1>         xor	ebx, ebx
   689 0000A7D2 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv]
   690 0000A7D8 89DE                <1> 	mov	esi, ebx
   691 0000A7DA 81C600010900        <1> 	add     esi, Logical_DOSDisks
   692                              <1> 
   693 0000A7E0 803D[48780100]00    <1> 	cmp	byte [Current_Dir_Level], 0
   694 0000A7E7 760A                <1> 	jna	short loc_locatefile_check_FAT_type
   695                              <1>             
   696 0000A7E9 803D[49780100]01    <1> 	cmp	byte [Current_FATType], 1
   697 0000A7F0 730A                <1> 	jnb	short loc_locatefile_load_subdir_cluster
   698 0000A7F2 C3                  <1> 	retn  
   699                              <1> 
   700                              <1> loc_locatefile_check_FAT_type:
   701 0000A7F3 803D[49780100]03    <1> 	cmp	byte [Current_FATType], 3
   702 0000A7FA 7217                <1> 	jb	short loc_cdir_locate_file_retn
   703                              <1> 
   704                              <1> loc_locatefile_load_subdir_cluster:
   705 0000A7FC A1[767F0100]        <1> 	mov	eax, [DirBuff_Cluster]
   706 0000A801 E8B1190000          <1> 	call	get_next_cluster
   707 0000A806 730C                <1> 	jnc	short loc_locatefile_next_cluster
   708 0000A808 09C0                <1> 	or	eax, eax
   709 0000A80A 7506                <1> 	jnz	short loc_locatefile_drive_not_ready_read_err
   710                              <1> 	;stc
   711                              <1> 	; 28/07/2022
   712                              <1> ;loc_locatefile_file_notfound:
   713                              <1> 	;mov	eax, 2 ; File/Directory/VolName not found
   714 0000A80C 31C0                <1> 	xor	eax, eax
   715 0000A80E B002                <1> 	mov	al, 2
   716 0000A810 F9                  <1> 	stc
   717 0000A811 C3                  <1> 	retn
   718                              <1> 
   719                              <1> loc_locatefile_drive_not_ready_read_err:
   720                              <1> 	;mov	eax, 17 ;Drive not ready or read error
   721                              <1> loc_cdir_locate_file_stc_retn:
   722 0000A812 F5                  <1> 	cmc ;stc
   723                              <1> loc_cdir_locate_file_retn:
   724 0000A813 C3                  <1> 	retn
   725                              <1> 
   726                              <1> loc_locatefile_next_cluster:
   727 0000A814 E85A1B0000          <1> 	call	load_FAT_sub_directory
   728                              <1> 	;jc	short loc_locatefile_drive_not_ready_read_err
   729 0000A819 72F8                <1> 	jc	short loc_cdir_locate_file_retn 
   730                              <1> 
   731                              <1> loc_locatefile_search_again:
   732 0000A81B 8B35[30800100]      <1> 	mov	esi, [CDLF_FNAddress] 
   733 0000A821 66A1[2E800100]      <1> 	mov	ax, [CDLF_AttributesMask]
   734 0000A827 668B0D[34800100]    <1> 	mov	cx, [CDLF_DEType] 
   735 0000A82E EB91                <1> 	jmp	short loc_cdir_locatefile_search
   736                              <1> 
   737                              <1> reload_current_directory:
   738                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
   739                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   740                              <1> 	; 13/06/2010
   741                              <1> 	; 22/09/2009
   742                              <1>         ;
   743                              <1> 	; INPUT ->
   744                              <1> 	;	ESI = Dos drive description table address
   745                              <1> 	
   746                              <1> 	;mov	al, [esi+LD_FATType]
   747 0000A830 A0[49780100]        <1> 	mov	al, [Current_FATType]
   748 0000A835 3C02                <1> 	cmp	al, 2
   749 0000A837 7726                <1> 	ja	short loc_reload_FAT_sub_directory
   750 0000A839 8A25[48780100]      <1> 	mov	ah, [Current_Dir_Level]
   751 0000A83F 08C0                <1> 	or	al, al
   752 0000A841 7409                <1> 	jz	short loc_reload_FS_directory
   753 0000A843 08E4                <1> 	or	ah, ah
   754 0000A845 7518                <1> 	jnz	short loc_reload_FAT_sub_directory
   755                              <1> loc_reload_FAT_12_16_root_directory:
   756                              <1> 	;call	load_FAT_root_directory
   757                              <1> 	;retn
   758                              <1> 	; 28/07/2022
   759 0000A847 E9A91A0000          <1> 	jmp	load_FAT_root_directory
   760                              <1> loc_reload_FS_directory:
   761 0000A84C 20E4                <1> 	and	ah, ah
   762 0000A84E 7505                <1> 	jnz	short loc_reload_FS_sub_directory 
   763                              <1> loc_reload_FS_root_directory: 
   764                              <1> 	;call	load_FS_root_directory
   765                              <1> 	;retn
   766                              <1> 	; 28/07/2022
   767 0000A850 E9581B0000          <1> 	jmp	load_FS_root_directory
   768                              <1> loc_reload_FS_sub_directory:
   769 0000A855 A1[44780100]        <1> 	mov	eax, [Current_Dir_FCluster]
   770                              <1> 	;call	load_FS_sub_directory
   771                              <1> 	;retn
   772 0000A85A E94E1B0000          <1> 	jmp	load_FS_sub_directory 
   773                              <1> loc_reload_FAT_sub_directory:
   774 0000A85F A1[44780100]        <1> 	mov	eax, [Current_Dir_FCluster]
   775                              <1> 	;call	load_FAT_sub_directory
   776                              <1> 	;retn
   777                              <1> 	; 28/07/2022
   778 0000A864 E90A1B0000          <1> 	jmp	load_FAT_sub_directory
   779                              <1> 
   780                              <1> find_directory_entry:
   781                              <1> 	; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
   782                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
   783                              <1> 	; 14/02/2016
   784                              <1> 	; 13/02/2016
   785                              <1> 	; 10/02/2016
   786                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   787                              <1> 	; 14/08/2010 (DIR.ASM, "proc_find_direntry")
   788                              <1> 	; 19/09/2009
   789                              <1> 	; 2005
   790                              <1> 	; INPUT ->
   791                              <1> 	;	ESI = Sub Dir or File Name Address
   792                              <1> 	;	AL = Attributes Mask 
   793                              <1> 	;	(<AL AND EntryAttrib> must be equal to AL)
   794                              <1> 	;	AH = Negative Attributes Mask (If AH>0)
   795                              <1> 	;	(<AH AND EntryAttrib> must be ZERO)
   796                              <1> 	;	CH > 0 Find First Free Dir Entry or Deleted Entry
   797                              <1> 	;	CL = 0 -> Return the First Free Dir Entry
   798                              <1> 	;	CL = E5h -> Return the 1st deleted entry
   799                              <1> 	;	CL = FFh -> Return the 1st deleted or free entry
   800                              <1> 	;	CL > 0 and CL <> E5h and CL <> FFh -> Return the first 
   801                              <1> 	;            proper entry (which fits with Atributes Masks)
   802                              <1> 	;	CX = 0 -> Find Valid File/Directory/VolumeName
   803                              <1> 	;	? = Any One Char
   804                              <1> 	;	* = Every Chars
   805                              <1> 	;	EBX = Current Dir Entry (BX)
   806                              <1> 	;
   807                              <1> 	; OUTPUT -> 
   808                              <1> 	;	EDI = Directory Entry Address (in DirectoryBuffer)
   809                              <1> 	;	ESI = Sub Dir or File Name Address
   810                              <1> 	;	CF = 0 -> No Error, Proper Entry,
   811                              <1> 	;	DL = Attributes
   812                              <1> 	;	DH = Previous Entry Attr (LongName Check)
   813                              <1> 	;	AL > 0 -> Ambiguous filename wildcard "?" used
   814                              <1> 	;	AH > 0 -> Ambiguous filename wildcard "*" used
   815                              <1> 	;	AX = 0 -> Filename full fits with directory entry
   816                              <1> 	;	EBX = CurrentDirEntry (BX)
   817                              <1> 	;	CH = The 1st Name Char of Current Dir Entry
   818                              <1> 	;	CF = 1 -> Proper entry not found, Error Code in AX/AL
   819                              <1> 	;	CL = 0 and CH = 0 -> Free Entry (End Of Dir)
   820                              <1> 	;	CL = 0 and CH = E5h -> Deleted Entry fits with filters
   821                              <1> 	;	CL > 0 -> Entry not found, CH invalid
   822                              <1> 	;
   823                              <1> 	; (EAX, EBX, ECX, EDX, EDI, EBP will be changed)	 
   824                              <1> 
   825 0000A869 663B1D[747F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
   826 0000A870 7728                <1> 	ja      short loc_ffde_stc_retn_255 ; 28/07/2022
   827                              <1> 
   828                              <1> 	;mov    [DirBuff_CurrentEntry], bx  
   829                              <1> 
   830 0000A872 BF00000800          <1>   	mov	edi, Directory_Buffer
   831 0000A877 66A3[40800100]      <1> 	mov	[FDE_AttrMask], ax
   832                              <1> 
   833 0000A87D 29C0                <1> 	sub	eax, eax
   834                              <1>             
   835                              <1> 	;;mov	[PreviousAttr], al ; 0 ;; 13/02/2016
   836 0000A87F 66A3[42800100]      <1> 	mov	[AmbiguousFileName], ax ; 0
   837                              <1> 
   838 0000A885 6689D8              <1> 	mov	ax, bx
   839                              <1> 	;shl	ax, 5 ; ; * 32 ; Directory entry size
   840                              <1> 	; 28/07/2022
   841 0000A888 C1E005              <1> 	shl	eax, 5
   842 0000A88B 01C7                <1> 	add     edi, eax
   843                              <1> 
   844 0000A88D 08ED                <1> 	or	ch, ch
   845                              <1> 	;jnz	loc_find_free_deleted_entry_0
   846                              <1> 	; 28/07/2022
   847 0000A88F 7405                <1> 	jz	short loc_fde_any_valid_entry_opt
   848 0000A891 E911010000          <1> 	jmp	loc_find_free_deleted_entry_0
   849                              <1> 
   850                              <1> loc_fde_any_valid_entry_opt:
   851 0000A896 08C9                <1> 	or      cl, cl
   852                              <1>         ;jnz	loc_ffde_stc_retn_255
   853                              <1> 	; 28/07/2022
   854 0000A898 742E                <1> 	jz	short check_find_dir_entry
   855                              <1> 
   856                              <1> 	; 28/07/2022
   857                              <1> loc_ffde_stc_retn_255:
   858                              <1> 	; 02/03/2021 (TRDOS 386 v2.0.3) ((BugFix))
   859                              <1> 	; (ECX must not be > 65535)
   860                              <1> 	; ((because 'loc_ccd_save_current_dir'
   861                              <1> 	;  sets CX to 32 for 'rep movsd')) 
   862 0000A89A 66B9FFFF            <1> 	mov	cx, 0FFFFh
   863                              <1> 	;xor	ecx, ecx
   864                              <1> 	;dec	ecx ; 0FFFFFFFFh
   865                              <1> 	;xor	eax, eax
   866                              <1> loc_find_direntry_stc_retn:
   867                              <1> loc_check_ffde_retn_1:
   868                              <1> 	;mov	ax, 2
   869                              <1> 	;mov	eax, 2 ; File Not Found
   870                              <1> 	; 28/07/2022
   871 0000A89E 29C0                <1> 	sub	eax, eax
   872 0000A8A0 B002                <1> 	mov	al, 2
   873 0000A8A2 8A35[44800100]      <1> 	mov	dh, [PreviousAttr]
   874 0000A8A8 66891D[727F0100]    <1> 	mov	[DirBuff_CurrentEntry], bx
   875 0000A8AF F9                  <1> 	stc
   876 0000A8B0 C3                  <1> 	retn
   877                              <1> 
   878                              <1> 	; 28/07/2022
   879                              <1> loc_find_dir_next_entry_prevdeleted:
   880 0000A8B1 80CA80              <1> 	or	dl, 80h  ; Bit 7 -> deleted entry sign
   881                              <1> 	;jmp	short loc_find_dir_next_entry
   882                              <1> 
   883                              <1> 	; 28/07/2022
   884                              <1> loc_find_dir_next_entry:
   885 0000A8B4 8815[44800100]      <1> 	mov	byte [PreviousAttr], dl ; LongName check
   886                              <1> loc_find_dir_next_entry_1:
   887 0000A8BA 5E                  <1> 	pop	esi
   888 0000A8BB 83C720              <1> 	add	edi, 32
   889                              <1> 	;;inc	word [DirBuff_EntryCounter]
   890                              <1> 	;inc	bx
   891                              <1> 	; 28/07/2022
   892 0000A8BE 43                  <1> 	inc	ebx
   893 0000A8BF 663B1D[747F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
   894 0000A8C6 77D2                <1> 	ja	short loc_ffde_stc_retn_255
   895                              <1>         ; 28/07/2022
   896                              <1> 	;jmp	short check_find_dir_entry 
   897                              <1>  
   898                              <1> check_find_dir_entry:
   899 0000A8C8 66A1[40800100]      <1> 	mov	ax, [FDE_AttrMask]
   900 0000A8CE 8A2F                <1> 	mov	ch, [edi]
   901 0000A8D0 80FD00              <1> 	cmp     ch, 0 ; Is it never used entry?
   902                              <1> 	;jna	loc_find_direntry_stc_retn
   903                              <1> 	; 28/07/2022
   904 0000A8D3 7702                <1> 	ja	short loc_fde_check_attrib
   905                              <1> 	; end of directory entries
   906 0000A8D5 EBC7                <1> 	jmp	loc_find_direntry_stc_retn
   907                              <1> loc_fde_check_attrib: 
   908 0000A8D7 56                  <1> 	push	esi
   909 0000A8D8 8A570B              <1> 	mov	dl, [edi+0Bh] ; File attributes
   910 0000A8DB 80FDE5              <1> 	cmp	ch, 0E5h ; Is it a deleted file?
   911 0000A8DE 74D1                <1> 	je	short loc_find_dir_next_entry_prevdeleted
   912                              <1> 
   913 0000A8E0 80FA0F              <1> 	cmp     dl, 0Fh ; longname sub component check
   914 0000A8E3 7505                <1> 	jne     short loc_check_attributes_mask
   915 0000A8E5 E8A6010000          <1> 	call	save_longname_sub_component
   916                              <1> 
   917                              <1> loc_check_attributes_mask:
   918 0000A8EA 88C6                <1> 	mov	dh, al
   919 0000A8EC 20D6                <1> 	and	dh, dl 
   920                              <1> 	; 28/07/2022   
   921 0000A8EE 38F0                <1> 	cmp	al, dh
   922 0000A8F0 75C2                <1> 	jne	short loc_find_dir_next_entry
   923 0000A8F2 20D4                <1> 	and	ah, dl
   924 0000A8F4 75BE                <1>         jnz	short loc_find_dir_next_entry
   925 0000A8F6 80FA0F              <1> 	cmp	dl, 0Fh
   926 0000A8F9 7515                <1> 	jne	short pass_direntry_attr_check
   927                              <1> 
   928 0000A8FB 3C0F                <1> 	cmp	al, 0Fh ; AL = 0Fh -> find long name
   929 0000A8FD 75B5                <1> 	jne	short loc_find_dir_next_entry
   930                              <1> 
   931 0000A8FF 5E                  <1> 	pop	esi
   932                              <1> 	;xor	ax, ax
   933                              <1> 	; 28/07/2022
   934                              <1> 	;sub	eax, eax
   935 0000A900 30C0                <1> 	xor	al, al
   936 0000A902 8A35[44800100]      <1> 	mov	dh, [PreviousAttr]
   937 0000A908 66891D[727F0100]    <1> 	mov	[DirBuff_CurrentEntry], bx
   938 0000A90F C3                  <1> 	retn
   939                              <1> 
   940                              <1> pass_direntry_attr_check:
   941 0000A910 89FD                <1> 	mov	ebp, edi ; 14/02/2016
   942                              <1> 	;mov	ecx, 8
   943                              <1> 	; 28/07/2022
   944 0000A912 29C9                <1> 	sub	ecx, ecx
   945 0000A914 B108                <1> 	mov	cl, 8
   946                              <1> loc_lodsb_find_dir:
   947 0000A916 AC                  <1> 	lodsb
   948 0000A917 3C2A                <1> 	cmp	al, '*'
   949 0000A919 7508                <1> 	jne	short pass_fde_ambiguous1_check
   950 0000A91B FE05[43800100]      <1>         inc     byte [AmbiguousFileName+1]
   951 0000A921 EB23                <1> 	jmp	short loc_check_direntry_extension
   952                              <1> 
   953                              <1> pass_fde_ambiguous1_check:
   954 0000A923 3C3F                <1> 	cmp	al, '?'
   955 0000A925 750D                <1> 	jne	short pass_fde_ambiguous2_check
   956 0000A927 FE05[42800100]      <1> 	inc	byte [AmbiguousFileName]
   957 0000A92D 803F20              <1> 	cmp	byte [edi], 20h
   958 0000A930 763E                <1> 	jna	short loc_find_dir_next_entry_ebp
   959 0000A932 EB0F                <1> 	jmp	short loc_scasb_find_dir_inc_di
   960                              <1> 
   961                              <1> pass_fde_ambiguous2_check:
   962 0000A934 3C20                <1> 	cmp	al, 20h
   963 0000A936 7507                <1> 	jne	short loc_scasb_find_dir
   964 0000A938 803F20              <1> 	cmp	byte [edi], 20h
   965 0000A93B 7533                <1> 	jne	short loc_find_dir_next_entry_ebp
   966 0000A93D EB07                <1> 	jmp	short loc_check_direntry_extension
   967                              <1> 
   968                              <1> loc_scasb_find_dir:
   969 0000A93F 3A07                <1> 	cmp	al, [edi]
   970 0000A941 752D                <1> 	jne	short loc_find_dir_next_entry_ebp
   971                              <1> loc_scasb_find_dir_inc_di:
   972 0000A943 47                  <1> 	inc	edi
   973 0000A944 E2D0                <1> 	loop	loc_lodsb_find_dir
   974                              <1> 
   975                              <1> loc_check_direntry_extension:
   976 0000A946 BE08000000          <1> 	mov	esi, 8
   977 0000A94B 89F7                <1> 	mov	edi, esi ; 8
   978 0000A94D 033424              <1> 	add	esi, [esp] ; Sub Dir or File Name Address
   979 0000A950 01EF                <1> 	add	edi, ebp
   980 0000A952 B103                <1> 	mov	cl, 3
   981                              <1> loc_lodsb_find_dir_ext:
   982 0000A954 AC                  <1> 	lodsb
   983 0000A955 3C2A                <1> 	cmp	al, '*'
   984 0000A957 7508                <1> 	jne	short pass_fde_ambiguous3_check
   985 0000A959 FE05[43800100]      <1> 	inc	byte [AmbiguousFileName+1]
   986 0000A95F EB1F                <1> 	jmp	short loc_find_dir_proper_direntry
   987                              <1> 
   988                              <1> pass_fde_ambiguous3_check:
   989 0000A961 3C3F                <1> 	cmp	al, '?'
   990 0000A963 7512                <1> 	jne	short pass_fde_ambiguous4_check
   991 0000A965 FE05[42800100]      <1> 	inc	byte [AmbiguousFileName]
   992 0000A96B 803F20              <1> 	cmp	byte [edi], 20h
   993                              <1> 	;jna	short loc_find_dir_next_entry_ebp
   994                              <1> 	;jmp	short loc_scasb_find_dir_ext_inc_di
   995                              <1> 	; 28/07/2022
   996 0000A96E 7732                <1> 	ja	short loc_scasb_find_dir_ext_inc_di 
   997                              <1> 
   998                              <1> loc_find_dir_next_entry_ebp:
   999 0000A970 89EF                <1> 	mov	edi, ebp ; 14/02/2016
  1000 0000A972 E93DFFFFFF          <1> 	jmp	loc_find_dir_next_entry ; 28/07/2022
  1001                              <1> 
  1002                              <1> pass_fde_ambiguous4_check:
  1003 0000A977 3C20                <1> 	cmp	al, 20h
  1004 0000A979 7523                <1> 	jne	short loc_scasb_find_dir_ext
  1005 0000A97B 803F20              <1> 	cmp	byte [edi], 20h
  1006                              <1> 	; 28/07/2022
  1007 0000A97E 75F0                <1> 	jne	short loc_find_dir_next_entry_ebp
  1008                              <1> 	;jmp	short loc_find_dir_proper_direntry
  1009                              <1> 
  1010                              <1> loc_find_dir_proper_direntry:
  1011 0000A980 30C9                <1> 	xor	cl, cl
  1012                              <1> loc_find_dir_proper_direntry_1:
  1013 0000A982 5E                  <1> 	pop	esi
  1014 0000A983 89EF                <1>         mov     edi, ebp
  1015 0000A985 8A2F                <1> 	mov	ch, [edi]
  1016 0000A987 8A570B              <1> 	mov     dl, [edi+0Bh] ; Dir entry attributes
  1017 0000A98A 66A1[42800100]      <1> 	mov	ax, [AmbiguousFileName]
  1018                              <1> loc_find_dir_proper_direntry_2:
  1019 0000A990 8A35[44800100]      <1> 	mov     dh, [PreviousAttr]
  1020 0000A996 66891D[727F0100]    <1> 	mov	[DirBuff_CurrentEntry], bx
  1021 0000A99D C3                  <1> 	retn
  1022                              <1> 
  1023                              <1> loc_scasb_find_dir_ext:
  1024 0000A99E 3A07                <1> 	cmp	al, [edi]
  1025 0000A9A0 75CE                <1> 	jne	short loc_find_dir_next_entry_ebp
  1026                              <1> loc_scasb_find_dir_ext_inc_di:
  1027 0000A9A2 47                  <1> 	inc	edi
  1028 0000A9A3 E2AF                <1> 	loop    loc_lodsb_find_dir_ext
  1029 0000A9A5 EBDB                <1> 	jmp	short loc_find_dir_proper_direntry_1
  1030                              <1> 
  1031                              <1> loc_find_free_deleted_entry_0:
  1032 0000A9A7 66A1[40800100]      <1> 	mov	ax, [FDE_AttrMask]
  1033 0000A9AD 8A2F                <1> 	mov	ch, [edi]
  1034 0000A9AF 8A570B              <1> 	mov	dl, [edi+0Bh] ; File attributes
  1035 0000A9B2 08C9                <1> 	or	cl, cl 
  1036 0000A9B4 7407                <1> 	jz	short loc_check_ffde_0_repeat
  1037                              <1> 	;cmp	cl, 0E5h
  1038                              <1> 	;je	short pass_loc_check_ffde_0_err
  1039 0000A9B6 80F9FF              <1> 	cmp	cl, 0FFh
  1040 0000A9B9 7430                <1> 	je	short loc_find_free_deleted_entry_1
  1041 0000A9BB EB4A                <1> 	jmp	short pass_loc_check_ffde_0_err
  1042                              <1> 
  1043                              <1> loc_check_ffde_0_repeat:
  1044 0000A9BD 08ED                <1> 	or	ch, ch
  1045 0000A9BF 7510                <1> 	jnz	short loc_check_ffde_0_next
  1046                              <1> 
  1047                              <1> loc_check_ffde_retn_2:
  1048                              <1> 	;sub	ax, ax
  1049                              <1> 	; 28/07/2022
  1050 0000A9C1 29C0                <1> 	sub	eax, eax
  1051 0000A9C3 8A35[44800100]      <1> 	mov	dh, [PreviousAttr]
  1052 0000A9C9 66891D[727F0100]    <1> 	mov	[DirBuff_CurrentEntry], bx
  1053 0000A9D0 C3                  <1> 	retn
  1054                              <1>  
  1055                              <1> loc_check_ffde_0_next:
  1056                              <1> 	;inc	bx
  1057                              <1> 	; 28/07/2022
  1058 0000A9D1 43                  <1> 	inc	ebx
  1059 0000A9D2 83C720              <1> 	add	edi, 32
  1060                              <1> 	;inc	word [DirBuff_EntryCounter]
  1061                              <1> 	 
  1062 0000A9D5 663B1D[747F0100]    <1>         cmp	bx, [DirBuff_LastEntry]
  1063                              <1> 	;ja	short loc_ffde_stc_retn_255
  1064                              <1> 	; 07/08/2022
  1065 0000A9DC 773A                <1> 	ja	short jmp_ffde_stc_retn_255
  1066                              <1> 
  1067 0000A9DE 8815[44800100]      <1> 	mov	[PreviousAttr], dl
  1068 0000A9E4 8A2F                <1> 	mov	ch, [edi]
  1069 0000A9E6 8A570B              <1> 	mov	dl, [edi+0Bh] ; file attributes
  1070 0000A9E9 EBD2                <1> 	jmp	short loc_check_ffde_0_repeat
  1071                              <1> 
  1072                              <1> loc_find_free_deleted_entry_1:
  1073 0000A9EB 28D2                <1> 	sub	dl, dl      
  1074                              <1> loc_find_free_deleted_entry_2:
  1075 0000A9ED 20ED                <1> 	and	ch, ch  
  1076 0000A9EF 74D0                <1> 	jz	short loc_check_ffde_retn_2
  1077 0000A9F1 80FDE5              <1> 	cmp	ch, 0E5h
  1078 0000A9F4 74CB                <1> 	je	short loc_check_ffde_retn_2
  1079                              <1> 	;inc	bx
  1080                              <1> 	; 28/07/2022
  1081 0000A9F6 43                  <1> 	inc	ebx
  1082 0000A9F7 83C720              <1> 	add	edi, 32
  1083 0000A9FA 663B1D[747F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  1084                              <1> 	;ja	short loc_ffde_stc_retn_255
  1085                              <1> 	; 07/08/2022
  1086 0000AA01 7715                <1> 	ja	short jmp_ffde_stc_retn_255
  1087                              <1> 
  1088 0000AA03 8A2F                <1> 	mov	ch, [edi]
  1089 0000AA05 EBE6                <1> 	jmp	short loc_find_free_deleted_entry_2
  1090                              <1> 
  1091                              <1> pass_loc_check_ffde_0_err:
  1092 0000AA07 38CD                <1> 	cmp	ch, cl
  1093 0000AA09 741F                <1> 	je	short loc_check_ffde_attrib 
  1094                              <1> 
  1095                              <1> 	;inc	bx
  1096                              <1> 	; 28/07/2022
  1097 0000AA0B 43                  <1> 	inc	ebx
  1098 0000AA0C 83C720              <1> 	add	edi, 32
  1099 0000AA0F 663B1D[747F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  1100                              <1>         ;ja	loc_ffde_stc_retn_255
  1101                              <1> 	; 28/07/2022
  1102 0000AA16 7605                <1> 	jna	short loc_ffe_save_prev_attr
  1103                              <1> jmp_ffde_stc_retn_255:	; 07/08/2022
  1104 0000AA18 E97DFEFFFF          <1> 	jmp	loc_ffde_stc_retn_255
  1105                              <1> 
  1106                              <1> loc_ffe_save_prev_attr: ; 28/07/2022
  1107 0000AA1D 8815[44800100]      <1> 	mov	[PreviousAttr], dl
  1108 0000AA23 8A2F                <1> 	mov	ch, [edi]
  1109 0000AA25 8A570B              <1> 	mov	dl, [edi+0Bh]
  1110 0000AA28 EBDD                <1> 	jmp	short pass_loc_check_ffde_0_err
  1111                              <1> 
  1112                              <1> loc_check_ffde_attrib:
  1113 0000AA2A 88C6                <1> 	mov	dh, al
  1114 0000AA2C 20D6                <1> 	and	dh, dl    
  1115 0000AA2E 38F0                <1> 	cmp	al, dh
  1116 0000AA30 759F                <1> 	jne	short loc_check_ffde_0_next
  1117 0000AA32 20D4                <1> 	and	ah, dl
  1118 0000AA34 759B                <1> 	jnz	short loc_check_ffde_0_next
  1119 0000AA36 30C9                <1> 	xor	cl, cl 
  1120 0000AA38 EB87                <1>         jmp	short loc_check_ffde_retn_2
  1121                              <1> 
  1122                              <1> convert_file_name:
  1123                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  1124                              <1> 	; 06/03/2016
  1125                              <1> 	; 11/02/2016
  1126                              <1> 	; 07/02/2016 (TRDOS 386 = TRDOS v2.0)
  1127                              <1> 	; 06/10/2009
  1128                              <1> 	; 2005
  1129                              <1> 	;
  1130                              <1> 	; INPUT  ->
  1131                              <1> 	;	ESI = Dot File Name Location
  1132                              <1> 	;	EDI = Dir Entry Format File Name Location
  1133                              <1> 	; OUTPUT ->
  1134                              <1> 	;	EDI = Dir Entry Format File Name Location
  1135                              <1> 	;	ESI = Dot File Name Location (capitalized)
  1136                              <1> 	;
  1137                              <1> 	; (ECX, AL will be changed) 
  1138                              <1>      
  1139 0000AA3A 56                  <1> 	push	esi  
  1140 0000AA3B 57                  <1> 	push	edi
  1141                              <1> 
  1142                              <1> 	;mov	ecx, 11
  1143                              <1> 	; 29/07 2022
  1144 0000AA3C 29C9                <1> 	sub	ecx, ecx
  1145 0000AA3E B10B                <1> 	mov	cl, 11
  1146 0000AA40 B020                <1> 	mov	al, 20h
  1147 0000AA42 F3AA                <1> 	rep	stosb
  1148                              <1> 
  1149 0000AA44 8B3C24              <1> 	mov	edi, [esp]
  1150                              <1> 
  1151 0000AA47 B10C                <1> 	mov	cl, 12 ; file name length (max.)
  1152                              <1> 	; 06/03/2016
  1153                              <1> 	; Directory entry name limit (11 bytes) check for
  1154                              <1> 	; 'rename_directory_entry' procedure.
  1155                              <1> 	; (EDI points to Directory Entry)
  1156                              <1> 	; (If the file name would not contain a dot
  1157                              <1> 	; and file name length would be 12, this would cause to
  1158                              <1> 	; overwrite the attributes byte of the directory entry.)
  1159                              <1> 	;
  1160 0000AA49 B50B                <1> 	mov	ch, 11 ; directory entry's name length
  1161                              <1> loc_check_first_dot:
  1162 0000AA4B 8A06                <1> 	mov	al, [esi]
  1163 0000AA4D 3C2E                <1> 	cmp	al, 2Eh
  1164 0000AA4F 750C                <1> 	jne	short pass_check_first_dot
  1165 0000AA51 8807                <1> 	mov	[edi], al
  1166 0000AA53 47                  <1> 	inc	edi
  1167 0000AA54 46                  <1> 	inc	esi
  1168 0000AA55 FEC9                <1> 	dec	cl
  1169 0000AA57 75F2                <1> 	jnz	short loc_check_first_dot
  1170                              <1> 	;;(ecx <= 12)
  1171                              <1> 	;;loop	loc_check_first_dot 
  1172 0000AA59 EB30                <1> 	jmp	short stop_convert_file
  1173                              <1> 
  1174                              <1> loc_get_fchar:
  1175 0000AA5B 8A06                <1> 	mov	al, [esi]
  1176                              <1> pass_check_first_dot:
  1177 0000AA5D 3C61                <1> 	cmp	al, 61h ; 'a'
  1178 0000AA5F 7208                <1> 	jb	short pass_name_capitalize
  1179 0000AA61 3C7A                <1> 	cmp	al, 7Ah ; 'z'
  1180 0000AA63 7704                <1> 	ja	short pass_name_capitalize
  1181 0000AA65 24DF                <1> 	and	al, 0DFh
  1182 0000AA67 8806                <1> 	mov	[esi], al
  1183                              <1> pass_name_capitalize:
  1184 0000AA69 3C21                <1> 	cmp	al, 21h
  1185 0000AA6B 721E                <1> 	jb	short stop_convert_file
  1186 0000AA6D 3C2E                <1> 	cmp	al, 2Eh ; '.'
  1187 0000AA6F 750C                <1> 	jne	short pass_dot_space
  1188                              <1> add_dot_space: 
  1189 0000AA71 80F904              <1> 	cmp	cl, 4
  1190 0000AA74 760E                <1> 	jna	short inc_and_loop
  1191 0000AA76 47                  <1> 	inc	edi
  1192 0000AA77 FECD                <1> 	dec	ch ; 06/03/2016
  1193 0000AA79 FEC9                <1> 	dec	cl
  1194 0000AA7B EBF4                <1> 	jmp	short add_dot_space
  1195                              <1> 	
  1196                              <1> 	;mov	al, 4
  1197                              <1> 	;cmp	cl, al
  1198                              <1> 	;jna	short inc_and_loop
  1199                              <1> 	;sub	cl, al
  1200                              <1> 	;add	edi, ecx
  1201                              <1> 	;mov	cl, al
  1202                              <1> 	;jmp	short inc_and_loop	
  1203                              <1> 
  1204                              <1> pass_dot_space:
  1205 0000AA7D 8807                <1> 	mov	[edi], al
  1206                              <1> loc_after_double_dot:
  1207                              <1> 	; 06/03/2016
  1208 0000AA7F FECD                <1> 	dec	ch ; count down for 11 bytes dir entry limit
  1209 0000AA81 740A                <1> 	jz	short stop_convert_file_x
  1210 0000AA83 47                  <1> 	inc	edi
  1211                              <1> inc_and_loop:
  1212 0000AA84 FEC9                <1> 	dec	cl ; count down for 12 bytes filename limit 
  1213 0000AA86 7403                <1> 	jz	short stop_convert_file	
  1214 0000AA88 46                  <1> 	inc	esi
  1215                              <1> 	;;(ecx <= 12)
  1216                              <1> 	;;loop	loc_get_fchar
  1217 0000AA89 EBD0                <1> 	jmp	short loc_get_fchar
  1218                              <1> 
  1219                              <1> stop_convert_file:
  1220                              <1> 	; 06/03/2016
  1221 0000AA8B 30ED                <1> 	xor	ch, ch
  1222                              <1> 	; ECX < 256 ; 'find_first_file' -> xor cl, cl
  1223                              <1> stop_convert_file_x:
  1224 0000AA8D 5F                  <1> 	pop	edi
  1225 0000AA8E 5E                  <1> 	pop	esi
  1226 0000AA8F C3                  <1> 	retn
  1227                              <1>  
  1228                              <1> save_longname_sub_component:
  1229                              <1> 	; 13/02/2016
  1230                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
  1231                              <1> 	; 28/02/2010
  1232                              <1> 	; 17/10/2009
  1233                              <1> 	; INPUT ->
  1234                              <1> 	;	EDI = Directory Entry    
  1235                              <1> 	;     	// This procedure is called
  1236                              <1> 	;	// from 'find_directory_entry' procedure.
  1237                              <1> 	;	// If the last entry returns with
  1238                              <1> 	;	// a non-zero LongnameFound value and
  1239                              <1> 	;	// if LFN_CheckSum value is equal to
  1240                              <1> 	;	// the next shortname checksum,
  1241                              <1> 	;	// long name is valid.
  1242                              <1> 	;	// If a longname is longer than 65 bytes,
  1243                              <1> 	;	// it is invalid for trdos. (>45h)
  1244                              <1>  
  1245 0000AA90 57                  <1> 	push	edi
  1246 0000AA91 56                  <1> 	push	esi
  1247                              <1> 	;push	ebx
  1248                              <1> 	;push	ecx
  1249                              <1> 	;push	edx
  1250 0000AA92 50                  <1> 	push	eax
  1251                              <1>            
  1252 0000AA93 29C9                <1> 	sub	ecx, ecx
  1253                              <1> 	;sub	eax, eax
  1254 0000AA95 B11A                <1> 	mov	cl, 26
  1255                              <1> 
  1256 0000AA97 0FB607              <1> 	movzx	eax, byte [edi] ; LDIR_Order
  1257 0000AA9A 3C41                <1> 	cmp	al, 41h  ; 40h (last long entry sign) + 1
  1258 0000AA9C 722B                <1> 	jb	short pass_pslnsc_last_long_entry
  1259                              <1> 
  1260 0000AA9E 88C4                <1> 	mov	ah, al
  1261 0000AAA0 80EC40              <1> 	sub	ah, 40h
  1262 0000AAA3 8825[46800100]      <1> 	mov	[LFN_EntryLength], ah
  1263                              <1> 	
  1264 0000AAA9 3C45                <1> 	cmp	al, 45h  ; 40h (last long entry sign) + 5
  1265                              <1>  		; Max 130 byte length is usable in TRDOS
  1266                              <1> ; 26*5 = 130
  1267 0000AAAB 7753                <1> 	ja	short loc_pslnsc_retn
  1268                              <1> 
  1269 0000AAAD 2407                <1> 	and	al, 07h ; 0Fh
  1270 0000AAAF A2[45800100]        <1> 	mov	[LongNameFound], al
  1271                              <1> 
  1272 0000AAB4 FEC8                <1> 	dec	al
  1273                              <1> 	;mov	cl, 26
  1274 0000AAB6 F6E1                <1> 	mul	cl
  1275                              <1> 
  1276 0000AAB8 89C6                <1> 	mov	esi, eax
  1277 0000AABA 01CE                <1> 	add	esi, ecx
  1278                              <1> 		; to make is an ASCIIZ string
  1279                              <1> 		; with ax+26 bytes length
  1280 0000AABC 81C6[48800100]      <1> 	add	esi, LongFileName
  1281 0000AAC2 66C7060000          <1> 	mov	word [esi], 0   
  1282 0000AAC7 EB16                <1> 	jmp	short loc_pslsc_move_ldir_name2 
  1283                              <1> 
  1284                              <1> pass_pslnsc_last_long_entry:
  1285 0000AAC9 3C04                <1> 	cmp	al, 04h
  1286 0000AACB 7733                <1> 	ja	short loc_pslnsc_retn
  1287 0000AACD FE0D[45800100]      <1> 	dec	byte [LongNameFound]
  1288 0000AAD3 3A05[45800100]      <1> 	cmp	al, [LongNameFound]
  1289 0000AAD9 7525                <1> 	jne	short loc_pslnsc_retn
  1290                              <1> 
  1291                              <1> loc_pslsc_move_ldir_name1:
  1292 0000AADB FEC8                <1> 	dec	al
  1293                              <1> 	;mov	cl, 26
  1294 0000AADD F6E1                <1> 	mul	cl
  1295                              <1> 
  1296                              <1> loc_pslsc_move_ldir_name2:
  1297 0000AADF 8A4F0D              <1> 	mov	cl, [edi+0Dh] ; long name checksum
  1298 0000AAE2 880D[47800100]      <1> 	mov	[LFN_CheckSum], cl 
  1299 0000AAE8 89FE                <1> 	mov	esi, edi ; LDIR_Order
  1300 0000AAEA BF[48800100]        <1> 	mov	edi, LongFileName
  1301 0000AAEF 01C7                <1> 	add	edi, eax
  1302 0000AAF1 46                  <1> 	inc	esi
  1303 0000AAF2 B105                <1> 	mov	cl, 5 ; chars 1 to 5
  1304 0000AAF4 F366A5              <1> 	rep	movsw
  1305 0000AAF7 83C603              <1> 	add	esi, 3
  1306 0000AAFA A5                  <1> 	movsd	; char 6 & 7 
  1307 0000AAFB A5                  <1> 	movsd	; char 8 & 9
  1308 0000AAFC A5                  <1> 	movsd	; char 10 & 11
  1309 0000AAFD 46                  <1> 	inc	esi
  1310 0000AAFE 46                  <1> 	inc	esi 
  1311 0000AAFF A5                  <1> 	movsd   ; char 12 & 13 
  1312                              <1> 
  1313                              <1> loc_pslnsc_retn:
  1314 0000AB00 58                  <1>  	pop	eax
  1315                              <1> 	;pop	edx
  1316                              <1> 	;pop	ecx
  1317                              <1> 	;pop	ebx
  1318 0000AB01 5E                  <1> 	pop	esi  
  1319 0000AB02 5F                  <1> 	pop	edi
  1320                              <1>  
  1321 0000AB03 C3                  <1>     	retn
  1322                              <1> 
  1323                              <1> parse_path_name:
  1324                              <1> 	; 09/08/2022
  1325                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  1326                              <1> 	; 10/02/2016
  1327                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  1328                              <1> 	; 10/009/2011 ('proc_parse_pathname')
  1329                              <1> 	; 27/11/2009
  1330                              <1> 	; 05/12/2004
  1331                              <1> 	;
  1332                              <1> 	; INPUT ->
  1333                              <1> 	;	ESI = Beginning of ASCIIZ pathname string
  1334                              <1> 	;       EDI = Destination Address
  1335                              <1> 	;	      (which is TR-DOS FindFile data buffer)
  1336                              <1> 	; OUTPUT ->
  1337                              <1> 	;	CF = 1 -> Error
  1338                              <1> 	;	     EAX = Error Code (AL)
  1339                              <1> 	;
  1340                              <1> 	; (Modified registers: eax, ecx, esi, edi) 
  1341                              <1> 	
  1342                              <1> 	; Clear the pathname bytes in TR-DOS Findfile data buffer 
  1343 0000AB04 57                  <1> 	push	edi
  1344                              <1> 	;mov	ecx, 20  ; 80 bytes
  1345                              <1> 	; 29/07/2022
  1346 0000AB05 29C9                <1> 	sub	ecx, ecx
  1347 0000AB07 B114                <1> 	mov	cl, 20
  1348 0000AB09 31C0                <1> 	xor	eax, eax
  1349 0000AB0B F3AB                <1> 	rep	stosd 
  1350 0000AB0D 5F                  <1> 	pop	edi
  1351                              <1> 
  1352 0000AB0E 668B06              <1> 	mov	ax, [esi]
  1353 0000AB11 80FC3A              <1> 	cmp	ah, ':'
  1354 0000AB14 741C                <1> 	je	short loc_ppn_change_drive
  1355 0000AB16 A0[4A780100]        <1> 	mov	al, [Current_Drv]
  1356 0000AB1B EB33                <1> 	jmp	short pass_ppn_change_drive
  1357                              <1> 
  1358                              <1> pass_ppn_cdir:
  1359 0000AB1D 8B35[6A810100]      <1> 	mov	esi, [First_Path_Pos]
  1360 0000AB23 AC                  <1> 	lodsb
  1361                              <1> loc_ppn_get_filename:
  1362 0000AB24 83C741              <1> 	add	edi, 65 ; FindFile_Name location
  1363                              <1> 	; TRDOS Filename length must not be more than 12 bytes
  1364                              <1> 	;mov	ecx, 12
  1365 0000AB27 B10C                <1> 	mov	cl, 12
  1366                              <1> loc_ppn_get_fnchar_next:
  1367 0000AB29 AA                  <1> 	stosb
  1368 0000AB2A AC                  <1> 	lodsb
  1369 0000AB2B 3C21                <1> 	cmp	al, 21h
  1370 0000AB2D 726F                <1> 	jb	short loc_ppn_clc_return 
  1371 0000AB2F E2F8                <1>         loop    loc_ppn_get_fnchar_next
  1372                              <1> loc_ppn_return:
  1373 0000AB31 C3                  <1> 	retn
  1374                              <1> 
  1375                              <1> loc_ppn_change_drive:
  1376                              <1> 	; 29/07/2022
  1377                              <1> 	; ecx = 0
  1378 0000AB32 24DF                <1> 	and	al, 0DFh
  1379 0000AB34 2C41                <1> 	sub	al, 'A'; A:
  1380 0000AB36 726A                <1> 	jc	short loc_ppn_invalid_drive
  1381 0000AB38 3805[91300100]      <1> 	cmp	[Last_DOS_DiskNo], al
  1382 0000AB3E 7262                <1> 	jb	short loc_ppn_invalid_drive
  1383                              <1> 
  1384 0000AB40 46                  <1> 	inc	esi
  1385 0000AB41 46                  <1> 	inc	esi
  1386 0000AB42 8A26                <1> 	mov	ah, [esi]
  1387 0000AB44 80FC21              <1> 	cmp	ah, 21h
  1388 0000AB47 7307                <1> 	jnb	short pass_ppn_change_drive
  1389                              <1> 
  1390                              <1> loc_ppn_cmd_failed:
  1391                              <1> 	; File or directory name is not existing
  1392 0000AB49 8807                <1> 	mov	[edi], al ; Drv 
  1393 0000AB4B 66B80100            <1> 	mov	ax, 1 ; eax = 1
  1394                              <1> 	; TR-DOS Error Code 01h = Bad Command Argument
  1395                              <1> 	; MS-DOS Error Code 01h : Invalid Function Number
  1396                              <1> 	;stc
  1397                              <1> 	; (MainProg ErrMsg: "Bad command or file name!")
  1398 0000AB4F C3                  <1> 	retn
  1399                              <1> 
  1400                              <1> pass_ppn_change_drive:
  1401 0000AB50 8935[6A810100]      <1> 	mov	[First_Path_Pos], esi
  1402                              <1> 	;mov	dword [Last_Slash_Pos], 0
  1403                              <1> 	; 29/07/2022
  1404 0000AB56 890D[6E810100]      <1> 	mov	[Last_Slash_Pos], ecx ; 0
  1405 0000AB5C AA                  <1> 	stosb
  1406 0000AB5D 8A06                <1> 	mov	al, [esi]
  1407                              <1> loc_scan_ppn_dslash:
  1408 0000AB5F 3C2F                <1> 	cmp	al, '/'
  1409 0000AB61 7506                <1>   	jne	short loc_scan_next_slash_pos
  1410 0000AB63 8935[6E810100]      <1> 	mov	[Last_Slash_Pos], esi
  1411                              <1> loc_scan_next_slash_pos:
  1412 0000AB69 46                  <1> 	inc	esi
  1413 0000AB6A 8A06                <1> 	mov	al, [esi]
  1414 0000AB6C 3C20                <1> 	cmp	al, 20h
  1415 0000AB6E 77EF                <1> 	ja	short loc_scan_ppn_dslash
  1416                              <1> 	;cmp	dword [Last_Slash_Pos], 0
  1417                              <1> 	; 09/08/2022
  1418 0000AB70 390D[6E810100]      <1> 	cmp	[Last_Slash_Pos], ecx ; 0 ?
  1419 0000AB76 76A5                <1> 	jna	short pass_ppn_cdir
  1420                              <1> 	
  1421 0000AB78 8B0D[6E810100]      <1> 	mov	ecx, [Last_Slash_Pos]
  1422 0000AB7E 8B35[6A810100]      <1> 	mov	esi, [First_Path_Pos]
  1423 0000AB84 29F1                <1> 	sub	ecx, esi
  1424 0000AB86 41                  <1> 	inc	ecx
  1425                              <1> 	;cmp	ecx, 64
  1426 0000AB87 80F940              <1> 	cmp	cl, 64
  1427 0000AB8A 7715                <1> 	ja	short loc_ppn_invalid_drive_stc
  1428                              <1> 
  1429 0000AB8C 89F8                <1> 	mov	eax, edi ; Dest Dir String Location (65 byte)
  1430 0000AB8E F3A4                <1> 	rep	movsb
  1431                              <1> 	;mov	[edi], cl ; 0, End of Dir String
  1432 0000AB90 8B35[6E810100]      <1> 	mov	esi, [Last_Slash_Pos]
  1433 0000AB96 46                  <1> 	inc	esi
  1434 0000AB97 89C7                <1> 	mov	edi, eax
  1435 0000AB99 AC                  <1> 	lodsb
  1436 0000AB9A 3C21                <1> 	cmp	al, 21h
  1437 0000AB9C 7386                <1> 	jnb	short loc_ppn_get_filename
  1438                              <1> loc_ppn_clc_return:
  1439                              <1> 	;clc
  1440 0000AB9E 31C0                <1> 	xor	eax, eax
  1441 0000ABA0 C3                  <1> 	retn
  1442                              <1> 
  1443                              <1> loc_ppn_invalid_drive_stc:
  1444 0000ABA1 F5                  <1> 	cmc	 ; stc
  1445                              <1> loc_ppn_invalid_drive:
  1446                              <1> 	; cf = 1
  1447                              <1> 	; The Drive Letter/Char < "A" or > "Z"
  1448 0000ABA2 66B80F00            <1> 	mov	ax, 0Fh
  1449                              <1> 	; MS-DOS Error Code 0Fh = Disk Drive Invalid 
  1450                              <1> 	; (MainProg ErrMsg: "Drive not ready or read error!")
  1451 0000ABA6 C3                  <1> 	retn
  1452                              <1> 
  1453                              <1> find_longname:
  1454                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  1455                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
  1456                              <1> 	; 24/01/2010 (DIR.ASM, 'proc_find_longname')
  1457                              <1> 	; 17/10/2009
  1458                              <1> 	
  1459                              <1> 	; INPUT -> 
  1460                              <1> 	;	ESI = DOS short file name address
  1461                              <1> 	; 	for example: "filename.ext"
  1462                              <1> 	;
  1463                              <1> 	; OUTPUT ->
  1464                              <1> 	; 	ESI = ASCIIZ longname address (cf = 0)
  1465                              <1> 	;	cf = 1 -> error number returns in EAX (AL)
  1466                              <1> 	;	AL = 0 & CF=1 -> longname not found
  1467                              <1> 	;	     the file/directory has no longname
  1468                              <1> 	; 	cf = 0 -> AL = FAT Type 
  1469                              <1>  
  1470                              <1> 	; 17/10/2009
  1471                              <1> 	; ASCIIZ string will be returned
  1472                              <1> 	; as LongFileName
  1473                              <1> 	; clearing/reset is not needed
  1474                              <1> 	;mov	ecx, 33
  1475                              <1> 	;mov	edi, LongFileName
  1476                              <1> 	;sub	ax, ax ; 0
  1477                              <1> 	;rep	stosw
  1478                              <1> 
  1479                              <1> 	;mov	byte [LongNameFound], 0
  1480                              <1> 
  1481                              <1> 	; ESI = ASCIIZ file/directory name address
  1482                              <1> 	;   AL = Attributes AND mask 
  1483                              <1> 	;	(Result of AND must be equal to AL)
  1484                              <1> 	;   AH = Negative attributes mask 
  1485                              <1> 	;	(Result of AND must be ZERO)
  1486 0000ABA7 66B80008            <1> 	mov	ax, 0800h 
  1487                              <1> 		; it must not be volume name or longname
  1488 0000ABAB E890DEFFFF          <1> 	call	find_first_file
  1489 0000ABB0 7212                <1> 	jc	short loc_fln_retn
  1490                              <1>  
  1491                              <1> loc_fln_check_FAT_Type:
  1492 0000ABB2 803D[49780100]01    <1> 	cmp	byte [Current_FATType], 1
  1493 0000ABB9 7302                <1> 	jnb	short loc_fln_check_longname_yes_sign
  1494                              <1> 
  1495                              <1> 	;call	get_fs_longname
  1496                              <1> 	;retn
  1497                              <1> 	; 29/07/2022
  1498 0000ABBB EB37                <1> 	jmp	get_fs_longname
  1499                              <1> 
  1500                              <1> loc_fln_check_longname_yes_sign:
  1501 0000ABBD 08FF                <1> 	or	bh, bh
  1502 0000ABBF 7504                <1> 	jnz	short loc_fln_check_longnamefound_number
  1503                              <1> loc_fln_longname_not_found_retn:
  1504 0000ABC1 31C0                <1> 	xor	eax, eax 
  1505                              <1> 	; cf = 1 & al = 0 -> longname not found
  1506 0000ABC3 F9                  <1> 	stc
  1507                              <1> loc_fln_retn:
  1508 0000ABC4 C3                  <1> 	retn
  1509                              <1> 
  1510                              <1> loc_fln_check_longnamefound_number:
  1511                              <1> 	; 'LongNameFound' is set by
  1512                              <1>         ; by 'save_longname_sub_component'
  1513                              <1> 	; which is called from
  1514                              <1> 	; 'find_directory_entry' 
  1515                              <1> 	; which is called from 
  1516                              <1> 	; 'find_first_file'
  1517                              <1> 	; It must 1 if the longname is valid
  1518 0000ABC5 803D[45800100]01    <1>         cmp     byte [LongNameFound], 1
  1519 0000ABCC 75F3                <1> 	jne	short loc_fln_longname_not_found_retn
  1520                              <1>              
  1521                              <1> loc_fln_calculate_checksum: 
  1522 0000ABCE E813000000          <1> 	call	calculate_checksum
  1523                              <1> 	; AL = shortname checksum
  1524                              <1> 
  1525                              <1> loc_fln_longname_validation:
  1526                              <1> 	; 'LFN_CheckSum' has been set already
  1527                              <1> 	; by 'save_longname_sub_component'
  1528                              <1> 	; which is called from
  1529                              <1> 	; 'find_directory_entry' 
  1530                              <1> 	; which is called from 
  1531                              <1> 	; 'find_first_file'
  1532 0000ABD3 3805[47800100]      <1> 	cmp	[LFN_CheckSum], al
  1533 0000ABD9 75E6                <1> 	jne	short loc_fln_longname_not_found_retn
  1534                              <1> 
  1535 0000ABDB BE[48800100]        <1> 	mov	esi, LongFileName
  1536 0000ABE0 A0[49780100]        <1> 	mov	al, [Current_FATType]
  1537 0000ABE5 C3                  <1> 	retn
  1538                              <1> 
  1539                              <1> calculate_checksum:
  1540                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  1541                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
  1542                              <1> 	; 17/10/2009 (DIR.ASM, 'proc_calculate_checksum')
  1543                              <1>         ;    
  1544                              <1> 	; INPUT ->
  1545                              <1> 	;	ESI = 11 byte DOS File Name location
  1546                              <1> 	;	(in DOS Directory Entry Format)
  1547                              <1> 	; OUTPUT ->
  1548                              <1> 	;	 AL = 8 bit checksum (CRC) value
  1549                              <1> 	;
  1550                              <1> 	; (Modified registers: EAX, ECX, ESI)
  1551                              <1> 
  1552                              <1> 	; Erdogan Tan [ 17-10-2009 ]
  1553                              <1> 	;  'ror al, 1' instruction
  1554                              <1> 
  1555                              <1> 	; Erdogan Tan [ 20-06-2004 ]
  1556                              <1> 	; This 8086 assembly code is an original code
  1557                              <1> 	; which is adapted from C code in
  1558                              <1> 	; Microsoft FAT32 File System Specification
  1559                              <1> 	; Version 1.03, December 6, 2000
  1560                              <1> 	; Page 28
  1561                              <1> 
  1562 0000ABE6 30C0                <1> 	xor	al, al
  1563                              <1> 	;mov	ecx, 11
  1564                              <1> 	; 29/07/2022
  1565 0000ABE8 29C9                <1> 	sub	ecx, ecx
  1566 0000ABEA B10B                <1> 	mov	cl, 11
  1567                              <1> loc_next_sum:
  1568                              <1> 	;xor	ah, ah
  1569                              <1> 	;test	al, 1
  1570                              <1> 	;jz	short pass_ah_80h
  1571                              <1> 	;mov	ah, 80h
  1572                              <1> ;pass_ah_80h:
  1573                              <1> 	;shr	al, 1
  1574 0000ABEC D0C8                <1> 	ror	al, 1 ; 17/10/2009  
  1575 0000ABEE 0206                <1> 	add	al, [esi]
  1576 0000ABF0 46                  <1> 	inc	esi
  1577                              <1> 	;add	al, ah
  1578 0000ABF1 E2F9                <1> 	loop	loc_next_sum
  1579 0000ABF3 C3                  <1> 	retn
  1580                              <1> 
  1581                              <1> get_fs_longname:
  1582                              <1> 	; temporary (13/02/2016)
  1583 0000ABF4 31C0                <1> 	xor	eax, eax
  1584 0000ABF6 F9                  <1> 	stc
  1585 0000ABF7 C3                  <1> 	retn
  1586                              <1> 
  1587                              <1> make_sub_directory:
  1588                              <1> 	; 07/08/2022
  1589                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  1590                              <1> 	; 16/10/2016
  1591                              <1> 	; 02/03/2016, 03/03/2016
  1592                              <1> 	; 26/02/2016, 27/02/2016
  1593                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  1594                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_make_directory')
  1595                              <1> 	; 10/07/2010
  1596                              <1> 	; INPUT ->
  1597                              <1> 	; 	ESI = ASCIIZ Directory Name
  1598                              <1> 	;	CL = Directory Attributes
  1599                              <1> 	; OUTPUT ->
  1600                              <1> 	;	EAX = New sub dir's first cluster
  1601                              <1> 	;	ESI = Logical Dos Drv Descr. Table Addr.
  1602                              <1> 	;	CF = 1 -> error code in AL (EAX)
  1603                              <1> 
  1604                              <1> 	;test	cl, 10h  ; directory
  1605                              <1> 	;jz	short loc_make_directory_access_denied
  1606                              <1> 	;test	cl, 08h ; volume name
  1607                              <1> 	;jnz	short loc_make_directory_access_denied
  1608                              <1> 
  1609 0000ABF8 80E107              <1> 	and	cl, 07h
  1610 0000ABFB 880D[C4810100]      <1> 	mov	byte [mkdir_attrib], cl
  1611                              <1> 
  1612 0000AC01 56                  <1> 	push	esi
  1613 0000AC02 31DB                <1> 	xor	ebx, ebx
  1614 0000AC04 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv]
  1615 0000AC0A BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1616 0000AC0F 01DE                <1> 	add	esi, ebx
  1617 0000AC11 5B                  <1> 	pop	ebx
  1618                              <1> 
  1619                              <1> 	; 10/07/2010 -> 1st writable disk check for trdos
  1620                              <1> 	; LD_DiskType = 0 for write protection (read only) 
  1621 0000AC12 807E0101            <1> 	cmp	byte [esi+LD_DiskType], 1 ; 0 = Invalid
  1622 0000AC16 7308                <1> 	jnb	short loc_mkdir_check_file_sytem
  1623                              <1> 	; 16/10/2016 (13h -> 30)
  1624                              <1> 	;mov	eax, 30 ; 'Disk write-protected' error
  1625                              <1> 	;mov	edx, 0
  1626                              <1> 	; 29/07/2022
  1627 0000AC18 29C0                <1> 	sub	eax, eax
  1628 0000AC1A B01E                <1> 	mov	al, 30
  1629 0000AC1C 29D2                <1> 	sub	edx, edx ; 0
  1630 0000AC1E F9                  <1> 	stc
  1631                              <1> 	; err retn: EDX = 0, EBX = Dir name offset
  1632                              <1> 	;ESI = Logical DOS drive description table address
  1633 0000AC1F C3                  <1> 	retn
  1634                              <1> 
  1635                              <1> ;loc_make_directory_access_denied:
  1636                              <1> 	;mov	ax, 05h ; access denied (invalid attributes input)
  1637                              <1> 	;stc
  1638                              <1> 	;retn
  1639                              <1> 
  1640                              <1> loc_mkdir_check_file_sytem:
  1641 0000AC20 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  1642 0000AC24 730A                <1> 	jnb	short loc_mkdir_check_free_sectors
  1643                              <1> 
  1644                              <1> loc_make_fs_directory:
  1645 0000AC26 A1[44780100]        <1> 	mov	eax, [Current_Dir_FCluster]
  1646                              <1> 	
  1647                              <1> 	; EAX = Parent directory DDT Address
  1648                              <1> 	; ESI = Logical DOS Drive DT Address
  1649                              <1> 	; EBX = Directory name offset (as ASCIIZ name)
  1650                              <1> 	
  1651                              <1> 	;call	make_fs_directory
  1652                              <1> 	;retn
  1653                              <1> 	; 29/07/2022
  1654 0000AC2B E986150000          <1> 	jmp	make_fs_directory  
  1655                              <1> 
  1656                              <1> loc_mkdir_check_free_sectors:
  1657 0000AC30 0FB64613            <1>         movzx   eax, byte [esi+LD_BPB+SecPerClust]
  1658 0000AC34 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  1659 0000AC37 39C1                <1> 	cmp	ecx, eax
  1660 0000AC39 7254                <1> 	jb	short loc_mkdir_insufficient_disk_space
  1661                              <1> 
  1662                              <1> loc_make_fat_directory:
  1663 0000AC3B 891D[B4810100]      <1> 	mov	[mkdir_DirName_Offset], ebx
  1664 0000AC41 890D[C0810100]      <1> 	mov	[mkdir_FreeSectors], ecx
  1665                              <1> 
  1666                              <1> 	;mov	al, [esi+LD_BPB+SecPerClust]
  1667 0000AC47 A2[C6810100]        <1> 	mov	byte [mkdir_SecPerClust], al
  1668                              <1> 
  1669                              <1> loc_mkdir_gffc_1:
  1670 0000AC4C E888170000          <1> 	call	get_first_free_cluster
  1671 0000AC51 722A                <1> 	jc	short loc_mkdir_gffc_retn
  1672                              <1> 
  1673                              <1> ;loc_mkdir_gffc_1_cont: 
  1674                              <1> 	;cmp	eax, 2
  1675                              <1> 	;jb	short loc_mkdir_gffc_insufficient_disk_space
  1676                              <1> 
  1677                              <1> ;loc_mkdir_gffc_1_save_fcluster:  
  1678 0000AC53 A3[B8810100]        <1> 	mov	[mkdir_FFCluster], eax
  1679                              <1> 
  1680                              <1> loc_mkdir_locate_ffe:
  1681                              <1> 	; Current directory fcluster <> Directory buffer cluster
  1682                              <1> 	; Current directory will be reloaded by
  1683                              <1> 	; 'locate_current_dir_file' procedure
  1684                              <1> 	;
  1685                              <1> 	; ESI = Logical DOS Drive Description Table Address 
  1686                              <1> 	;push	esi ; 27/02/2016
  1687 0000AC58 31C0                <1> 	xor	eax, eax
  1688 0000AC5A 89C1                <1>         mov	ecx, eax
  1689 0000AC5C 6649                <1> 	dec	cx ; FFFFh  
  1690                              <1> 	; CX = FFFFh -> find first deleted or free entry
  1691                              <1> 	; ESI would be ASCIIZ filename address if the call
  1692                              <1> 	; would not be for first free or deleted dir entry
  1693 0000AC5E E808FBFFFF          <1> 	call	locate_current_dir_file
  1694 0000AC63 734A                <1> 	jnc	short loc_mkdir_set_ff_dir_entry_1
  1695                              <1> 	;pop	esi 
  1696                              <1> 	; ESI = Logical DOS Drive Description Table Address 
  1697 0000AC65 83F802              <1> 	cmp	eax, 2  ; cmp al, 2 ; File/Dir not found !
  1698 0000AC68 7529                <1> 	jne	short loc_mkdir_stc_return
  1699                              <1> 
  1700                              <1> loc_mkdir_add_new_cluster:
  1701 0000AC6A 3805[49780100]      <1> 	cmp	byte [Current_FATType], al ; 2
  1702                              <1> 	;cmp	byte ptr [esi+LD_FATType], 2
  1703 0000AC70 770C                <1> 	ja	short loc_mkdir_add_new_cluster_check_fsc
  1704 0000AC72 803D[48780100]01    <1> 	cmp	byte [Current_Dir_Level], 1
  1705                              <1> 	;cmp	byte [esi+LD_CDirLevel], 1
  1706 0000AC79 7303                <1> 	jnb	short loc_mkdir_add_new_cluster_check_fsc
  1707                              <1> 
  1708 0000AC7B B00C                <1> 	mov	al, 12 ; No more files 
  1709                              <1> loc_mkdir_gffc_retn:
  1710 0000AC7D C3                  <1> 	retn
  1711                              <1> 
  1712                              <1> loc_mkdir_add_new_cluster_check_fsc:
  1713 0000AC7E 8B0D[C0810100]      <1> 	mov	ecx, [mkdir_FreeSectors]
  1714                              <1> 	;movzx	eax, byte [mkdir_SecPerClust]
  1715 0000AC84 A0[C6810100]        <1> 	mov	al, [mkdir_SecPerClust]
  1716                              <1> 	;shl	ax, 1 ; AX = 2 * AX
  1717                              <1> 	; 29/07/2022
  1718 0000AC89 D1E0                <1> 	shl	eax, 1
  1719 0000AC8B 39C1                <1> 	cmp	ecx, eax
  1720 0000AC8D 7350                <1> 	jnb	short loc_mkdir_add_new_subdir_cluster
  1721                              <1> 
  1722                              <1> loc_mkdir_insufficient_disk_space:
  1723                              <1> 	;mov	edx, ecx
  1724                              <1> ;loc_mkdir_gffc_insufficient_disk_space:
  1725                              <1> 	; 29/07/2022
  1726                              <1> 	;mov	ax, 27h ; MSDOS err => insufficient disk space
  1727                              <1> 	
  1728                              <1> 	; err retn: EDX = Free sectors, EBX = Dir name offset
  1729                              <1>         ; ESI -> Dos drive description table address
  1730                              <1> 	;; ecx = edx
  1731                              <1> 	
  1732                              <1> 	;retn
  1733                              <1> 	
  1734                              <1> 	; 29/07/2022
  1735 0000AC8F 30E4                <1> 	xor	ah, ah
  1736 0000AC91 B027                <1> 	mov	al, 27h
  1737                              <1> 
  1738                              <1> loc_mkdir_stc_return:
  1739 0000AC93 F9                  <1> 	stc
  1740 0000AC94 C3                  <1> 	retn 
  1741                              <1> 
  1742                              <1> loc_mkdir_gffc_2:
  1743 0000AC95 E83F170000          <1> 	call	get_first_free_cluster
  1744 0000AC9A 72E1                <1> 	jc	short loc_mkdir_gffc_retn
  1745                              <1> 
  1746                              <1> ;loc_mkdir_gffc_1_cont: 
  1747                              <1> 	;cmp	eax, 2
  1748                              <1> 	;jb	short loc_mkdir_gffc_insufficient_disk_space
  1749                              <1> 
  1750                              <1> ;loc_mkdir_gffc_2_save_fcluster:  
  1751 0000AC9C A3[B8810100]        <1> 	mov	[mkdir_FFCluster], eax
  1752                              <1> 
  1753 0000ACA1 A1[BC810100]        <1> 	mov	eax, [mkdir_LastDirCluster]
  1754                              <1> 
  1755 0000ACA6 E8C8160000          <1> 	call	load_FAT_sub_directory 
  1756 0000ACAB 72D0                <1> 	jc	short loc_mkdir_gffc_retn
  1757                              <1> 
  1758 0000ACAD 31FF                <1> 	xor	edi, edi
  1759                              <1> loc_mkdir_set_ff_dir_entry_1:
  1760                              <1> 	; 27/02/2016
  1761 0000ACAF 56                  <1> 	push	esi ; Logical DOS Drv Desc. Tbl. address
  1762                              <1> 	; EDI = Directory Entry Address
  1763 0000ACB0 8B35[B4810100]      <1> 	mov	esi, [mkdir_DirName_Offset]
  1764 0000ACB6 A1[B8810100]        <1> 	mov	eax, [mkdir_FFCluster]
  1765                              <1> 
  1766 0000ACBB 66B91000            <1> 	mov	cx, 10h	; CL = Directory attribute
  1767                              <1> 			; CH = 0 -> File size is 0
  1768 0000ACBF 0A0D[C4810100]      <1> 	or	cl, [mkdir_attrib] ; S, H, R  
  1769 0000ACC5 E8A3010000          <1> 	call	make_directory_entry
  1770                              <1> 
  1771 0000ACCA 5E                  <1> 	pop	esi
  1772                              <1> 
  1773 0000ACCB C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  1774 0000ACD2 E869020000          <1> 	call	save_directory_buffer
  1775                              <1>         ;jnc	loc_mkdir_set_ff_dir_entry_2
  1776                              <1> 	; 29/07/2022
  1777 0000ACD7 7205                <1> 	jc	short loc_mkdir_return
  1778 0000ACD9 E9CA000000          <1> 	jmp	loc_mkdir_set_ff_dir_entry_2
  1779                              <1> 
  1780                              <1> loc_mkdir_return:
  1781 0000ACDE C3                  <1> 	retn
  1782                              <1> 
  1783                              <1> loc_mkdir_add_new_subdir_cluster:
  1784 0000ACDF 8B15[767F0100]      <1> 	mov	edx, [DirBuff_Cluster]
  1785 0000ACE5 8915[BC810100]      <1> 	mov	[mkdir_LastDirCluster], edx       
  1786                              <1> 
  1787 0000ACEB A1[B8810100]        <1> 	mov	eax, [mkdir_FFCluster]
  1788 0000ACF0 E87E160000          <1> 	call	load_FAT_sub_directory 
  1789 0000ACF5 72E7                <1> 	jc	short loc_mkdir_return
  1790                              <1> 	; eax = 0
  1791                              <1> 	; ecx = directory buffer sector count (<= 128)
  1792                              <1> 
  1793                              <1> pass_mkdir_add_new_subdir_cluster:
  1794                              <1> 
  1795                              <1> ; 29/07/2022
  1796                              <1> ;	;sub	edi, edi ; 0
  1797                              <1> ;	; 29/07/2022 - BUGFIX !
  1798                              <1> ;	mov	edi, Directory_Buffer
  1799                              <1> ;
  1800                              <1> ;	;mov	al, 128 ; double word
  1801                              <1> ;	;mul	ecx ; ecx =  directory buffer sector count
  1802                              <1> ;	;mov	ecx, eax
  1803                              <1> ;	;shl	cx, 7 ; 128 * sector count	
  1804                              <1> ;	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
  1805                              <1> ;	;shr	ax, 2 ; 'byte count / 4' for 'stosd'
  1806                              <1> ;	; 29/07/2022
  1807                              <1> ;	shr	eax, 2
  1808                              <1> ;	;mul	cx ; max = 128*(512/4) -> 16384 (stosd)
  1809                              <1> ;	;mov	cx, ax
  1810                              <1> ;	;sub	ax, ax ; 0
  1811                              <1> ;	; 29/07/2022
  1812                              <1> ;	mul	ecx
  1813                              <1> ;	mov	ecx, eax
  1814                              <1> ;	sub	eax, eax
  1815                              <1> ;	rep	stosd ; clear directory buffer
  1816                              <1> 
  1817                              <1> 	; 29/07/2022
  1818 0000ACF7 E85C010000          <1> 	call	clear_directory_buffer
  1819                              <1> 
  1820 0000ACFC C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  1821 0000AD03 E838020000          <1> 	call	save_directory_buffer 
  1822 0000AD08 72D4                <1> 	jc	short loc_mkdir_return
  1823                              <1> 
  1824                              <1> loc_mkdir_save_added_cluster:
  1825 0000AD0A A1[BC810100]        <1> 	mov	eax, [mkdir_LastDirCluster]
  1826 0000AD0F 8B0D[B8810100]      <1> 	mov	ecx, [mkdir_FFCluster]
  1827                              <1> 	; 01/03/2016
  1828 0000AD15 31D2                <1> 	xor	edx, edx
  1829 0000AD17 8915[667F0100]      <1> 	mov	[FAT_ClusterCounter], edx ; 0 ; reset
  1830 0000AD1D E884170000          <1> 	call	update_cluster
  1831 0000AD22 7304                <1> 	jnc	short loc_mkdir_save_fat_buffer_0
  1832 0000AD24 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  1833 0000AD26 7518                <1> 	jnz	short loc_mkdir_save_fat_buffer_stc_retn
  1834                              <1> 
  1835                              <1> loc_mkdir_save_fat_buffer_0:
  1836 0000AD28 A1[B8810100]        <1> 	mov	eax, [mkdir_FFCluster]
  1837 0000AD2D A3[BC810100]        <1> 	mov	[mkdir_LastDirCluster], eax
  1838                              <1> 
  1839 0000AD32 31C9                <1> 	xor	ecx, ecx
  1840 0000AD34 49                  <1> 	dec	ecx ; FFFFFFFFh
  1841                              <1> 	; ESI = Logical DOS Drive Description Table address 
  1842 0000AD35 E86C170000          <1> 	call	update_cluster
  1843 0000AD3A 731A                <1> 	jnc	short loc_mkdir_save_fat_buffer_1
  1844 0000AD3C 09C0                <1> 	or	eax, eax
  1845 0000AD3E 7416                <1> 	jz	short loc_mkdir_save_fat_buffer_1
  1846                              <1> 
  1847                              <1> loc_mkdir_save_fat_buffer_stc_retn:
  1848                              <1> 	; 01/03/2016
  1849 0000AD40 803D[667F0100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  1850 0000AD47 720C                <1> 	jb	short loc_mkdir_save_fat_buffer_retn
  1851                              <1> 
  1852 0000AD49 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space (BL = 0)
  1853                              <1> 			   ; (BH = FFh -> Use ESI as Drv Param. Tbl.)
  1854 0000AD4D 50                  <1> 	push	eax
  1855 0000AD4E E8671A0000          <1> 	call	calculate_fat_freespace
  1856 0000AD53 58                  <1> 	pop	eax
  1857 0000AD54 F9                  <1> 	stc
  1858                              <1> loc_mkdir_save_fat_buffer_retn:
  1859 0000AD55 C3                  <1> 	retn
  1860                              <1> 
  1861                              <1> loc_mkdir_save_fat_buffer_1:
  1862                              <1> 	; byte [FAT_BuffValidData] = 2 
  1863 0000AD56 E8CE190000          <1> 	call	save_fat_buffer
  1864 0000AD5B 72E3                <1> 	jc	short loc_mkdir_save_fat_buffer_stc_retn
  1865                              <1> 
  1866                              <1> 	; 01/03/2016
  1867 0000AD5D 803D[667F0100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  1868 0000AD64 721B                <1> 	jb	short loc_mkdir_save_fat_buffer_2
  1869                              <1> 
  1870                              <1> 	; ESI = Logical DOS Drive Description Table address 
  1871 0000AD66 A1[667F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
  1872 0000AD6B 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  1873 0000AD6F E8461A0000          <1> 	call	calculate_fat_freespace
  1874                              <1> 
  1875                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  1876                              <1> 	;jnz	short loc_mkdir_save_fat_buffer_2
  1877                              <1> 
  1878                              <1> 	; ecx > 0 -> Recalculation is needed
  1879 0000AD74 09C9                <1> 	or	ecx, ecx 
  1880 0000AD76 7409                <1> 	jz	short loc_mkdir_save_fat_buffer_2
  1881                              <1> 
  1882 0000AD78 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  1883 0000AD7C E8391A0000          <1> 	call	calculate_fat_freespace
  1884                              <1> 
  1885                              <1> loc_mkdir_save_fat_buffer_2:
  1886 0000AD81 C605[C7810100]01    <1> 	mov	byte [mkdir_add_new_cluster], 1
  1887 0000AD88 E9B0000000          <1> 	jmp	loc_mkdir_upd_parent_dir_lmdt
  1888                              <1> 
  1889                              <1> loc_mkdir_update_sub_dir_cluster:
  1890 0000AD8D A1[B8810100]        <1> 	mov	eax, [mkdir_FFCluster]
  1891 0000AD92 29C9                <1> 	sub	ecx, ecx ; 0
  1892                              <1> 	; 01/03/2016
  1893 0000AD94 890D[667F0100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; Reset
  1894 0000AD9A 49                  <1> 	dec	ecx ; 0FFFFFFFFh
  1895                              <1> 
  1896                              <1> 	; ESI = Logical DOS Drive Descisption Table address  
  1897 0000AD9B E806170000          <1> 	call	update_cluster
  1898 0000ADA0 7364                <1> 	jnc	short loc_mkdir_save_fat_buffer_3
  1899 0000ADA2 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  1900 0000ADA4 7460                <1> 	jz	short loc_mkdir_save_fat_buffer_3
  1901                              <1> 	; 01/03/2016
  1902 0000ADA6 EB98                <1> 	jmp	short loc_mkdir_save_fat_buffer_stc_retn
  1903                              <1> 
  1904                              <1> loc_mkdir_set_ff_dir_entry_2:
  1905                              <1> 	; ESI = Logical DOS Drive Description Table address  
  1906 0000ADA8 A1[B8810100]        <1> 	mov	eax, [mkdir_FFCluster]
  1907                              <1> 	; Load disk sectors as a directory cluster
  1908 0000ADAD E8C1150000          <1> 	call	load_FAT_sub_directory 
  1909 0000ADB2 7251                <1> 	jc	short retn_make_fat_directory
  1910                              <1> 	
  1911                              <1> 	; eax = 0
  1912                              <1> 	; ecx = directory buffer sector count (<= 128)
  1913                              <1> 
  1914                              <1> ; 29/07/2022
  1915                              <1> ;	mov	edi, Directory_Buffer + 64 ; 26/02/2016
  1916                              <1> ;
  1917                              <1> ;	; 02/03/2016
  1918                              <1> ;	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
  1919                              <1> ;	;shr	ax, 2 ; 'byte count / 4' for 'stosd'
  1920                              <1> ;	; 29/07/2022
  1921                              <1> ;	shr	eax, 2
  1922                              <1> ;	mul 	ecx
  1923                              <1> ;	mov	ecx, eax
  1924                              <1> ;	;
  1925                              <1> ;	; 29/07/2022 - BUGFIX !
  1926                              <1> ;	sub	ecx, 16 ; - 64 bytes
  1927                              <1> ;			; (space for '.' & '..' entries)
  1928                              <1> ;	;sub	ax, ax
  1929                              <1> ;	sub	eax, eax
  1930                              <1> ;	rep	stosd
  1931                              <1> ;
  1932                              <1> ;	;;mov	al, 128 ; double word (count in sector)
  1933                              <1> ;	;;mul	ecx ; ecx = directory buffer sector count
  1934                              <1> ;	;;mov	ecx, eax
  1935                              <1> ;	;shl	cx, 7 ; 128 * sector count
  1936                              <1> ;	;sub	ecx, 64 ; 29/07/2022
  1937                              <1> ;	;;sub	eax, eax
  1938                              <1> ;	;;sub	al, al ; 0
  1939                              <1> ;	;rep	stosd ; clear directory buffer
  1940                              <1> 
  1941                              <1> 	; 29/07/2022
  1942 0000ADB4 E89F000000          <1> 	call	clear_directory_buffer
  1943                              <1> 
  1944 0000ADB9 BF00000800          <1> 	mov	edi, Directory_Buffer ; 26/02/2016
  1945                              <1> 	
  1946 0000ADBE 56                  <1> 	push	esi
  1947                              <1> 
  1948 0000ADBF BE[C8810100]        <1> 	mov	esi, mkdir_Name
  1949 0000ADC4 66C7062E00          <1> 	mov	word [esi], 2Eh ; db '.', '0'
  1950                              <1> 
  1951 0000ADC9 A1[B8810100]        <1> 	mov	eax, [mkdir_FFCluster]
  1952                              <1> 	;mov	cx, 10h ; CL = Directory attribute
  1953                              <1> 			; CH = 0 -> File size is 0
  1954                              <1> 	; 29/07/2022
  1955 0000ADCE B110                <1> 	mov	cl, 10h
  1956 0000ADD0 E898000000          <1> 	call	make_directory_entry
  1957                              <1> 
  1958 0000ADD5 BF20000800          <1> 	mov	edi, Directory_Buffer + 32 ; 26/02/2016
  1959                              <1> 
  1960                              <1> 	; 03/03/2016
  1961                              <1> 	; Following modification has been done according to 
  1962                              <1> 	; 'Microsoft Extensible Firmware Initiative
  1963                              <1> 	; FAT32 File System Specification' document,
  1964                              <1> 	; 'FAT: General Overview of On-Disk FormatPage 25'.
  1965                              <1> 	; "Finally, you set DIR_FstClusLO and DIR_FstClusHI
  1966                              <1> 	; for the dotdot entry (the second entry) to the
  1967                              <1> 	; first cluster number of the directory in which you 
  1968                              <1> 	; just created the directory (value is 0 if this directory
  1969                              <1> 	; is the root directory even for FAT32 volumes)."
  1970                              <1> 	; (Correctness of this modification has been verified
  1971                              <1> 	;  by using Windows 98 'scandisk.exe'.)
  1972                              <1> 
  1973 0000ADDA 29C0                <1> 	sub	eax, eax
  1974 0000ADDC 3805[48780100]      <1> 	cmp	byte [Current_Dir_Level], al ; 0
  1975 0000ADE2 7605                <1> 	jna	short loc_mkdir_set_ff_dir_entry_3
  1976 0000ADE4 A1[44780100]        <1> 	mov	eax, [Current_Dir_FCluster] ; parent dir
  1977                              <1> loc_mkdir_set_ff_dir_entry_3:
  1978 0000ADE9 66C746012E00        <1> 	mov	word [esi+1], 2Eh ; db '.', '0'
  1979                              <1> 
  1980                              <1> 	;mov	cx, 10h
  1981 0000ADEF E879000000          <1> 	call	make_directory_entry
  1982                              <1> 
  1983 0000ADF4 5E                  <1> 	pop	esi
  1984                              <1> 
  1985 0000ADF5 C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  1986 0000ADFC E83F010000          <1> 	call	save_directory_buffer
  1987                              <1> 	;jnc	loc_mkdir_update_sub_dir_cluster
  1988                              <1> 	; 29/07/2022
  1989 0000AE01 7202                <1> 	jc	short retn_make_fat_directory
  1990 0000AE03 EB88                <1> 	jmp	loc_mkdir_update_sub_dir_cluster
  1991                              <1> 
  1992                              <1> retn_make_fat_directory:
  1993 0000AE05 C3                  <1> 	retn
  1994                              <1> 
  1995                              <1> loc_mkdir_save_fat_buffer_3:
  1996                              <1> 	; 01/03/2016
  1997                              <1> 	; byte [FAT_BuffValidData] = 2 
  1998 0000AE06 E81E190000          <1> 	call	save_fat_buffer
  1999                              <1> 	;jc	short loc_mkdir_save_fat_buffer_stc_retn
  2000                              <1> 	; 07/08/2022
  2001 0000AE0B 7305                <1> 	jnc	short loc_mkdir_save_fat_buffer_4
  2002 0000AE0D E92EFFFFFF          <1> 	jmp	loc_mkdir_save_fat_buffer_stc_retn
  2003                              <1> 
  2004                              <1> loc_mkdir_save_fat_buffer_4:
  2005 0000AE12 803D[667F0100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  2006 0000AE19 721B                <1> 	jb	short loc_mkdir_save_fat_buffer_5
  2007                              <1> 
  2008                              <1> 	; ESI = Logical DOS Drive Description Table address 
  2009 0000AE1B A1[667F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
  2010 0000AE20 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  2011 0000AE24 E891190000          <1> 	call	calculate_fat_freespace
  2012                              <1> 
  2013                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  2014                              <1>         ;jnz    short loc_mkdir_save_fat_buffer_5
  2015                              <1> 
  2016                              <1> 	; ecx > 0 -> Recalculation is needed
  2017 0000AE29 09C9                <1> 	or	ecx, ecx 
  2018 0000AE2B 7409                <1>         jz      short loc_mkdir_save_fat_buffer_5
  2019                              <1> 
  2020 0000AE2D 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space
  2021 0000AE31 E884190000          <1> 	call	calculate_fat_freespace
  2022                              <1> 
  2023                              <1> loc_mkdir_save_fat_buffer_5:	
  2024 0000AE36 C605[C7810100]00    <1> 	mov	byte [mkdir_add_new_cluster], 0
  2025                              <1> 
  2026                              <1> loc_mkdir_upd_parent_dir_lmdt:
  2027 0000AE3D E896010000          <1> 	call	update_parent_dir_lmdt
  2028                              <1> 
  2029                              <1> 	; 01/03/2016
  2030 0000AE42 803D[C7810100]00    <1> 	cmp	byte [mkdir_add_new_cluster], 0
  2031                              <1> 	;ja	loc_mkdir_gffc_2
  2032                              <1> 	; 29/07/2022
  2033 0000AE49 7605                <1> 	jna	short loc_mkdir_retn_new_dir_cluster
  2034 0000AE4B E945FEFFFF          <1> 	jmp	loc_mkdir_gffc_2
  2035                              <1> 
  2036                              <1> loc_mkdir_retn_new_dir_cluster:
  2037 0000AE50 A1[B8810100]        <1> 	mov	eax, [mkdir_FFCluster]
  2038 0000AE55 31D2                <1> 	xor	edx, edx
  2039                              <1> loc_mkdir_retn:
  2040 0000AE57 C3                  <1> 	retn
  2041                              <1> 
  2042                              <1> clear_directory_buffer:
  2043                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  2044                              <1> 	;
  2045                              <1> 	; eax = 0
  2046                              <1> 	; ecx = directory buffer sector count (<= 128)
  2047                              <1> 	;
  2048 0000AE58 BF00000800          <1> 	mov	edi, Directory_Buffer
  2049                              <1> 	;mov	al, 128 ; double word
  2050                              <1> 	;mul	ecx ; ecx = directory buffer sector count
  2051                              <1> 	;mov	ecx, eax
  2052                              <1> 	;shl	cx, 7 ; 128 * sector count	
  2053 0000AE5D 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
  2054 0000AE61 C1E802              <1> 	shr	eax, 2 ; 'byte count / 4' for 'stosd'
  2055 0000AE64 F7E1                <1> 	mul	ecx ; max = 128*(512/4) -> 16384 (stosd)
  2056 0000AE66 89C1                <1> 	mov	ecx, eax
  2057 0000AE68 29C0                <1> 	sub	eax, eax
  2058 0000AE6A F3AB                <1> 	rep	stosd ; clear directory buffer
  2059 0000AE6C C3                  <1> 	retn
  2060                              <1> 
  2061                              <1> make_directory_entry:
  2062                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  2063                              <1> 	; 02/03/2016
  2064                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  2065                              <1> 	; 09/08/2010 (DIR.ASM, 'proc_make_directory_entry')
  2066                              <1> 	; 17/07/2010
  2067                              <1> 	; INPUT ->
  2068                              <1> 	; 	EDI = Directory Entry Address
  2069                              <1> 	;	ESI = Dot File Name Location
  2070                              <1> 	;	EAX = First Cluster
  2071                              <1> 	;	File Size = 0 (Must be set later)
  2072                              <1> 	;	CL = Attributes
  2073                              <1> 	;	CH = 0 (File size = 0) 
  2074                              <1> 	;	(If CH>0, File size is in dword [EBX]) (*)
  2075                              <1> 	; OUTPUT -> 
  2076                              <1> 	;	EDI = Directory Entry Address
  2077                              <1> 	;	ESI = Dot File Name Location (Capitalized)
  2078                              <1> 	;	If CH input = 0, File Size = 0
  2079                              <1> 	;	Otherwise file size is as dword [EBX] (*)
  2080                              <1> 	;	DX = Date, AX = Time in DOS Dir Entry format
  2081                              <1> 	;	EBX = same
  2082                              <1> 	;	ECX = same
  2083                              <1> 
  2084 0000AE6D 51                  <1> 	push	ecx
  2085                              <1> 
  2086 0000AE6E 884F0B              <1> 	mov	[edi+11], cl ; Attributes
  2087 0000AE71 6689471A            <1> 	mov	[edi+26], ax ; FClusterLw, 26
  2088 0000AE75 C1E810              <1> 	shr	eax, 16
  2089 0000AE78 66894714            <1> 	mov	[edi+20], ax ; FClusterHw, 20
  2090                              <1> 	;xor	ax, ax 
  2091                              <1> 	; 29/07/2022
  2092 0000AE7C 31C0                <1> 	xor	eax, eax
  2093 0000AE7E 6689470C            <1> 	mov	[edi+12], ax ; NTReserved, 12
  2094                              <1> 			     ; CrtTimeTenth, 13
  2095 0000AE82 08ED                <1> 	or	ch, ch
  2096 0000AE84 7402                <1> 	jz	short loc_make_direntry_set_filesize
  2097                              <1> 
  2098 0000AE86 8B03                <1> 	mov	eax, [ebx]
  2099                              <1>         
  2100                              <1> loc_make_direntry_set_filesize:
  2101 0000AE88 89471C              <1> 	mov	[edi+28], eax ; FileSize, 28
  2102                              <1> 	
  2103 0000AE8B E8AAFBFFFF          <1> 	call	convert_file_name
  2104                              <1> 	;EDI = Dir Entry Format File Name Location
  2105                              <1> 	;ESI = Dot File Name Location (capitalized)
  2106                              <1> 
  2107 0000AE90 E816000000          <1> 	call	convert_current_date_time
  2108                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
  2109                              <1>         ; 	    AX = Time in dos dir entry format
  2110 0000AE95 6689470E            <1> 	mov	[edi+14], ax ; CrtTime, 14
  2111 0000AE99 66895710            <1> 	mov	[edi+16], dx ; CrtDate, 16
  2112 0000AE9D 66895712            <1> 	mov	[edi+18], dx ; LastAccDate, 18
  2113 0000AEA1 66894716            <1> 	mov	[edi+22], ax ; WrtTime, 14
  2114 0000AEA5 66895718            <1> 	mov	[edi+24], dx ; WrtDate, 16
  2115 0000AEA9 59                  <1> 	pop	ecx
  2116                              <1> 
  2117 0000AEAA C3                  <1> 	retn
  2118                              <1> 
  2119                              <1> convert_current_date_time:
  2120                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  2121                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  2122                              <1> 	; 13/06/2010 (DIR.ASM, 'proc_convert_current_date_time')
  2123                              <1> 	; converts date&time to dos dir entry format
  2124                              <1> 	; INPUT -> none
  2125                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
  2126                              <1> 	;           AX = Time in dos dir entry format
  2127                              <1>  
  2128 0000AEAB B404                <1> 	mov	ah, 04h ; Return Current Date
  2129 0000AEAD E8DAB2FFFF          <1> 	call	int1Ah 
  2130                              <1> 
  2131 0000AEB2 88E8                <1> 	mov	al, ch ; <- century BCD
  2132 0000AEB4 240F                <1> 	and	al, 0Fh
  2133 0000AEB6 88EC                <1> 	mov	ah, ch
  2134 0000AEB8 C0EC04              <1> 	shr	ah, 4
  2135 0000AEBB D50A                <1> 	aad
  2136 0000AEBD 88C5                <1> 	mov	ch, al ; -> century 
  2137                              <1> 
  2138 0000AEBF 88C8                <1> 	mov	al, cl ; <- year BCD
  2139 0000AEC1 240F                <1> 	and	al, 0Fh
  2140 0000AEC3 88CC                <1> 	mov	ah, cl
  2141 0000AEC5 C0EC04              <1> 	shr	ah, 4
  2142 0000AEC8 D50A                <1> 	aad
  2143 0000AECA 88C1                <1> 	mov	cl, al ; -> year
  2144                              <1> 
  2145                              <1> 	;mov	al, ch
  2146                              <1> 	;mov	ah, 100
  2147                              <1> 	;mul	ah
  2148                              <1> 	; 29/07/2022
  2149 0000AECC B064                <1> 	mov	al, 100
  2150 0000AECE F6E5                <1> 	mul	ch	
  2151                              <1> 
  2152                              <1> 	;xor	ch, ch
  2153                              <1> 	;add	ax, cx
  2154                              <1> 	; 29/07/2022
  2155 0000AED0 00C8                <1> 	add	al, cl
  2156 0000AED2 80D400              <1> 	adc	ah, 0
  2157 0000AED5 662DBC07            <1> 	sub	ax, 1980 ; ms-dos epoch
  2158                              <1> 	;mov	cx, ax
  2159                              <1> 	; 29/07/2022
  2160 0000AED9 88C1                <1> 	mov	cl, al
  2161                              <1> 	;mov	ecx, eax
  2162                              <1> 
  2163 0000AEDB 88F0                <1> 	mov	al, dh ; <- month in bcd
  2164 0000AEDD 240F                <1> 	and	al, 0Fh
  2165 0000AEDF 88F4                <1> 	mov	ah, dh
  2166 0000AEE1 C0EC04              <1> 	shr	ah, 4
  2167 0000AEE4 D50A                <1> 	aad
  2168 0000AEE6 88C6                <1> 	mov	dh, al ; -> month
  2169                              <1> 
  2170 0000AEE8 88D0                <1> 	mov	al, dl ; <- day BCD
  2171 0000AEEA 240F                <1> 	and	al, 0Fh
  2172 0000AEEC 88D4                <1> 	mov	ah, dl
  2173 0000AEEE C0EC04              <1> 	shr	ah, 4
  2174 0000AEF1 D50A                <1> 	aad
  2175 0000AEF3 88C2                <1> 	mov	dl, al ; -> day
  2176                              <1> 
  2177 0000AEF5 88C8                <1> 	mov	al, cl ; count of years from 1980
  2178                              <1> 	;shl	ax, 4
  2179                              <1> 	; 29/07/2022
  2180                              <1> 	;mov	eax, ecx
  2181 0000AEF7 C1E004              <1> 	shl	eax, 4
  2182                              <1> 
  2183 0000AEFA 08F0                <1> 	or	al, dh ; month of year, 1 to 12
  2184                              <1> 	;shl	ax, 5
  2185                              <1> 	; 29/07/2022
  2186 0000AEFC C1E005              <1> 	shl	eax, 5
  2187 0000AEFF 08D0                <1> 	or	al, dl ; day of year, 1 to 31
  2188                              <1> 	
  2189                              <1> 	;push	ax ; push date
  2190                              <1> 	; 29/07/2022
  2191 0000AF01 50                  <1> 	push	eax
  2192                              <1> 
  2193 0000AF02 B402                <1> 	mov	ah, 02h ; Return Current Time
  2194 0000AF04 E883B2FFFF          <1> 	call	int1Ah
  2195                              <1> 
  2196 0000AF09 88E8                <1> 	mov	al, ch ; <- hours BCD
  2197 0000AF0B 240F                <1> 	and	al, 0Fh
  2198 0000AF0D 88EC                <1> 	mov	ah, ch
  2199 0000AF0F C0EC04              <1> 	shr	ah, 4
  2200 0000AF12 D50A                <1> 	aad
  2201 0000AF14 88C5                <1> 	mov	ch, al ; -> hours
  2202                              <1> 
  2203 0000AF16 88C8                <1> 	mov	al, cl ; <- minutes BCD
  2204 0000AF18 240F                <1> 	and	al, 0Fh
  2205 0000AF1A 88CC                <1> 	mov	ah, cl
  2206 0000AF1C C0EC04              <1> 	shr	ah, 4
  2207 0000AF1F D50A                <1> 	aad
  2208 0000AF21 88C1                <1> 	mov	cl, al ; -> minutes
  2209                              <1> 
  2210 0000AF23 88F0                <1> 	mov	al, dh ; <- seconds BCD
  2211 0000AF25 240F                <1> 	and	al, 0Fh
  2212 0000AF27 88F4                <1> 	mov	ah, dh
  2213 0000AF29 C0EC04              <1> 	shr	ah, 4
  2214 0000AF2C D50A                <1> 	aad
  2215 0000AF2E 88C6                <1> 	mov	dh, al ; -> seconds
  2216                              <1> 
  2217 0000AF30 88E8                <1> 	mov	al, ch ; hours
  2218                              <1> 	;shl	ax, 6
  2219                              <1> 	; 29/07/2022
  2220 0000AF32 C1E006              <1> 	shl	eax, 6
  2221 0000AF35 08C8                <1> 	or	al, cl ; minutes
  2222                              <1> 	;shl	ax, 5
  2223                              <1> 	; 29/07/2022
  2224 0000AF37 C1E005              <1> 	shl	eax, 5
  2225 0000AF3A D0EE                <1> 	shr	dh, 1 ; 2 seconds
  2226                              <1> 	; There is a bug in TRDOS v1 here !
  2227                              <1> 	; it was 'or al, dl' ! 
  2228 0000AF3C 08F0                <1> 	or	al, dh ; seconds
  2229                              <1> 
  2230                              <1> 	;pop	dx ; pop date
  2231                              <1> 	; 29/07/2022
  2232 0000AF3E 5A                  <1> 	pop	edx	
  2233                              <1> 
  2234 0000AF3F C3                  <1> 	retn
  2235                              <1> 
  2236                              <1> save_directory_buffer:
  2237                              <1> 	; 30/07/2022
  2238                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  2239                              <1> 	; 15/10/2016
  2240                              <1> 	; 23/03/2016
  2241                              <1> 	; 26/02/2016
  2242                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
  2243                              <1> 	; 01/08/2011
  2244                              <1> 	; 14/03/2010
  2245                              <1> 	; INPUT ->
  2246                              <1> 	; 	 none
  2247                              <1> 	; OUTPUT ->
  2248                              <1> 	;  cf = 0 -> write OK...
  2249                              <1> 	;  cf = 1 -> error code in AL (EAX)
  2250                              <1> 	;  cf = 1 & AL = 0Dh => CH & CL = FS & FAT type
  2251                              <1> 	;  EBX = Directory Buffer Address
  2252                              <1> 	;
  2253                              <1> 	;  (EAX, ECX, EDX will be modified)
  2254                              <1>  
  2255 0000AF40 BB00000800          <1> 	mov	ebx, Directory_Buffer
  2256 0000AF45 803D[717F0100]02    <1> 	cmp	byte [DirBuff_ValidData], 2
  2257 0000AF4C 7403                <1> 	je	short loc_save_dir_buffer
  2258 0000AF4E 31C0                <1> 	xor	eax, eax
  2259 0000AF50 C3                  <1> 	retn            
  2260                              <1> 
  2261                              <1> loc_save_dir_buffer:
  2262 0000AF51 56                  <1> 	push	esi
  2263 0000AF52 31DB                <1> 	xor	ebx, ebx 
  2264 0000AF54 8A3D[6F7F0100]      <1>         mov     bh, [DirBuff_DRV]
  2265 0000AF5A 80EF41              <1> 	sub	bh, 'A'
  2266 0000AF5D BE00010900          <1>         mov     esi, Logical_DOSDisks
  2267 0000AF62 01DE                <1> 	add	esi, ebx
  2268 0000AF64 668B4E03            <1>         mov     cx, [esi+LD_FATType]
  2269                              <1> 	; CH = FS Type (A1h for FS)
  2270                              <1> 	; CL = FAT Type (0 for FS)
  2271 0000AF68 08C9                <1> 	or	cl, cl
  2272 0000AF6A 7431                <1> 	jz	short loc_save_dir_buff_stc_retn
  2273                              <1> 
  2274                              <1> loc_save_dir_buffer_check_cluster_no:    
  2275 0000AF6C A1[767F0100]        <1> 	mov	eax, [DirBuff_Cluster]
  2276 0000AF71 28FF                <1> 	sub	bh, bh ; ebx = 0
  2277 0000AF73 09C0                <1> 	or	eax, eax
  2278 0000AF75 753E                <1> 	jnz	short loc_save_sub_dir_buffer
  2279 0000AF77 8A25[707F0100]      <1> 	mov	ah, [DirBuff_FATType]
  2280 0000AF7D FEC3                <1> 	inc	bl ;  bl = 1
  2281 0000AF7F 38DC                <1> 	cmp	ah, bl
  2282 0000AF81 721B                <1> 	jb	short loc_save_dir_buff_inv_data_retn
  2283 0000AF83 FEC3                <1> 	inc	bl ; bl = 2
  2284 0000AF85 38E3                <1> 	cmp	bl, ah
  2285 0000AF87 7215                <1> 	jb	short loc_save_dir_buff_inv_data_retn
  2286                              <1> 
  2287                              <1> loc_save_root_dir_buffer:
  2288 0000AF89 668B5E17            <1> 	mov	bx, [esi+LD_BPB+RootDirEnts]
  2289 0000AF8D 6683C30F            <1> 	add	bx, 15
  2290                              <1> 	;shr	bx, 4 ; 16 dir entries per sector
  2291                              <1> 	; 29/07/2022
  2292 0000AF91 C1EB04              <1> 	shr	ebx, 4
  2293                              <1> 	;or	bx, bx
  2294 0000AF94 09DB                <1> 	or	ebx, ebx
  2295 0000AF96 7405                <1> 	jz	short loc_save_dir_buff_stc_retn
  2296                              <1> 	;mov	ecx, ebx 
  2297 0000AF98 8B4664              <1> 	mov	eax, [esi+LD_ROOTBegin] ; 26/02/2016
  2298 0000AF9B EB22                <1> 	jmp	short loc_write_directory_to_disk
  2299                              <1> 
  2300                              <1> loc_save_dir_buff_stc_retn:
  2301 0000AF9D F9                  <1> 	stc
  2302                              <1> loc_save_dir_buff_inv_data_retn:
  2303                              <1> 	; 15/10/2016 (0Dh -> 29)
  2304 0000AF9E B01D                <1> 	mov	al, 29 ; Invalid data !
  2305 0000AFA0 C605[717F0100]00    <1> 	mov	byte [DirBuff_ValidData], 0
  2306 0000AFA7 EB05                <1> 	jmp	short loc_save_dir_buff_retn 
  2307                              <1> 
  2308                              <1> loc_write_directory_to_disk_err:
  2309                              <1> 	; 15/10/2016 (disk write error code, 1Dh -> 18)
  2310 0000AFA9 B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error 
  2311                              <1> 
  2312                              <1> loc_save_dir_buff_retn:
  2313 0000AFAE BB00000800          <1> 	mov	ebx, Directory_Buffer
  2314 0000AFB3 5E                  <1> 	pop	esi
  2315 0000AFB4 C3                  <1> 	retn
  2316                              <1>  
  2317                              <1> loc_save_sub_dir_buffer:
  2318                              <1> 	; ebx  = 0
  2319                              <1> 	;sub	eax, 2
  2320                              <1> 	; 30/07/2022
  2321 0000AFB5 48                  <1> 	dec	eax
  2322 0000AFB6 48                  <1> 	dec	eax
  2323 0000AFB7 8A5E13              <1> 	mov	bl, [esi+LD_BPB+SecPerClust]
  2324 0000AFBA F7E3                <1> 	mul	ebx
  2325 0000AFBC 034668              <1>         add     eax, [esi+LD_DATABegin]
  2326                              <1>  	;mov	ecx, ebx
  2327                              <1> 
  2328                              <1> loc_write_directory_to_disk:
  2329 0000AFBF 89D9                <1>  	mov	ecx, ebx
  2330 0000AFC1 BB00000800          <1> 	mov	ebx, Directory_Buffer
  2331 0000AFC6 E87B6D0000          <1> 	call	disk_write
  2332 0000AFCB 72DC                <1> 	jc	short loc_write_directory_to_disk_err
  2333                              <1> 
  2334                              <1> loc_save_dir_buff_validate_retn:
  2335 0000AFCD C605[717F0100]01    <1> 	mov	byte [DirBuff_ValidData], 1
  2336 0000AFD4 31C0                <1> 	xor	eax, eax
  2337                              <1> 	; 26/02/2016
  2338 0000AFD6 EBD6                <1> 	jmp	short loc_save_dir_buff_retn
  2339                              <1> 
  2340                              <1> update_parent_dir_lmdt:
  2341                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  2342                              <1> 	; 29/12/2017
  2343                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
  2344                              <1> 	; 01/08/2011
  2345                              <1> 	; 16/10/2010 
  2346                              <1> 	; 
  2347                              <1> 	; INPUT -> 
  2348                              <1> 	;	none
  2349                              <1>  	; OUTPUT ->
  2350                              <1> 	;	(last modification date & time of the parent dir
  2351                              <1> 	;	will be changed/updated)
  2352                              <1> 	;
  2353                              <1> 	; (EAX, EBX, ECX, EDX, EDI will be changed)
  2354                              <1> 
  2355 0000AFD8 29C0                <1> 	sub	eax, eax
  2356 0000AFDA 8A25[48780100]      <1> 	mov	ah, [Current_Dir_Level]
  2357 0000AFE0 A0[49780100]        <1> 	mov	al, [Current_FATType]
  2358 0000AFE5 3C01                <1> 	cmp	al, 1
  2359 0000AFE7 7239                <1> 	jb	short loc_UPDLMDT_proc_retn
  2360                              <1>     
  2361                              <1> loc_update_parent_dir_lm_date_time:
  2362 0000AFE9 08E4                <1> 	or	ah, ah
  2363 0000AFEB 7435                <1> 	jz	short loc_UPDLMDT_proc_retn
  2364                              <1> 
  2365 0000AFED 56                  <1> 	push	esi ; *
  2366 0000AFEE 8825[E8810100]      <1> 	mov	[UPDLMDT_CDirLevel], ah
  2367 0000AFF4 8B15[44780100]      <1> 	mov	edx, [Current_Dir_FCluster]
  2368 0000AFFA 8915[E9810100]      <1> 	mov	[UPDLMDT_CDirFCluster], edx
  2369                              <1> 
  2370 0000B000 FECC                <1> 	dec	ah
  2371                              <1> 	;mov	ecx, 12
  2372                              <1>         ; 29/07/2022
  2373 0000B002 29C9                <1> 	sub	ecx, ecx
  2374 0000B004 B10C                <1> 	mov	cl, 12
  2375                              <1> 	;
  2376 0000B006 BE[A87F0100]        <1> 	mov     esi, PATH_Array
  2377                              <1> 
  2378 0000B00B 8825[48780100]      <1> 	mov	[Current_Dir_Level], ah
  2379 0000B011 08E4                <1> 	or	ah, ah
  2380 0000B013 750E                <1> 	jnz	short loc_update_parent_dir_lmdt_load_sub_dir_1
  2381 0000B015 803D[49780100]02    <1> 	cmp	byte [Current_FATType], 2
  2382 0000B01C 770B                <1> 	ja	short loc_update_parent_dir_lmdt_load_sub_dir_2
  2383 0000B01E 28C0                <1> 	sub	al, al ; eax = 0
  2384 0000B020 EB0A                <1> 	jmp	short loc_update_parent_dir_lmdt_load_sub_dir_3
  2385                              <1> 
  2386                              <1> loc_UPDLMDT_proc_retn:
  2387 0000B022 C3                  <1> 	retn
  2388                              <1>          
  2389                              <1> loc_update_parent_dir_lmdt_load_sub_dir_1:
  2390 0000B023 B010                <1> 	mov	al, 16
  2391 0000B025 F6E4                <1> 	mul	ah 
  2392 0000B027 01C6                <1> 	add	esi, eax
  2393                              <1> 
  2394                              <1> loc_update_parent_dir_lmdt_load_sub_dir_2:  
  2395 0000B029 8B460C              <1> 	mov	eax, [esi+12] ; Parent Dir First Cluster
  2396                              <1> 
  2397                              <1> loc_update_parent_dir_lmdt_load_sub_dir_3:
  2398 0000B02C A3[44780100]        <1> 	mov	[Current_Dir_FCluster], eax
  2399                              <1> 
  2400 0000B031 83C610              <1> 	add	esi, 16
  2401 0000B034 66BF[CE80]          <1> 	mov	di, Dir_File_Name  
  2402 0000B038 F3A4                <1> 	rep	movsb
  2403                              <1> 	
  2404 0000B03A BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2405 0000B03F 29DB                <1> 	sub	ebx, ebx
  2406 0000B041 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv]
  2407 0000B047 01DE                <1> 	add	esi, ebx
  2408 0000B049 E8E2F7FFFF          <1> 	call	reload_current_directory
  2409 0000B04E 722F                <1> 	jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
  2410                              <1> 
  2411                              <1> loc_update_parent_dir_lmdt_locate_dir: 
  2412 0000B050 BE[CE800100]        <1> 	mov	esi, Dir_File_Name        
  2413                              <1> 	;xor	cx, cx
  2414                              <1> 	; 29/07/2022
  2415 0000B055 31C9                <1> 	xor	ecx, ecx
  2416 0000B057 66B81008            <1> 	mov	ax, 0810h ; Only directories
  2417 0000B05B E80BF7FFFF          <1>         call    locate_current_dir_file
  2418                              <1> 	; EDI = DirBuff Directory Entry Address
  2419 0000B060 721D                <1> 	jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
  2420                              <1> 
  2421 0000B062 E844FEFFFF          <1> 	call	convert_current_date_time
  2422 0000B067 66895712            <1> 	mov	[edi+18], dx ; Last Access Date
  2423 0000B06B 66895718            <1> 	mov	[edi+24], dx ; Last Write Date
  2424 0000B06F 66894716            <1> 	mov	[edi+22], ax ; Last Write Time
  2425                              <1> 
  2426 0000B073 C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  2427 0000B07A E8C1FEFFFF          <1> 	call	save_directory_buffer
  2428                              <1> 	; 29/12/2017
  2429                              <1> 	;jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
  2430                              <1> 	;xor	al, al 
  2431                              <1> loc_update_parent_dir_lmdt_restore_cdirlevel:
  2432                              <1>  	;current directory level restoration
  2433 0000B07F 8A25[E8810100]      <1> 	mov	ah, [UPDLMDT_CDirLevel]
  2434 0000B085 8825[48780100]      <1> 	mov	[Current_Dir_Level], ah
  2435 0000B08B 8B15[E9810100]      <1>         mov     edx, [UPDLMDT_CDirFCluster]
  2436 0000B091 8915[44780100]      <1> 	mov	[Current_Dir_FCluster], edx
  2437                              <1> 
  2438 0000B097 5E                  <1> 	pop	esi ; *
  2439 0000B098 C3                  <1> 	retn
  2440                              <1> 
  2441                              <1> delete_longname:
  2442                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  2443                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
  2444                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_delete_longname')
  2445                              <1> 	; 14/03/2010
  2446                              <1> 	; INPUT ->
  2447                              <1> 	; 	EAX = Directory Entry (Index) Number (< 65536)
  2448                              <1> 	; OUTPUT ->
  2449                              <1> 	;	cf = 0 -> OK  (EAX = 0)
  2450                              <1> 	; 	cf = 1 -> error code in EAX (AL)
  2451                              <1> 	;
  2452                              <1> 	; (Modified registers: EAX, EDX, ECX, EBX, EDI) 
  2453                              <1> 
  2454 0000B099 66A3[18820100]      <1> 	mov	[DLN_EntryNumber], ax
  2455 0000B09F C605[1A820100]40    <1>         mov     byte [DLN_40h], 40h
  2456                              <1> 
  2457 0000B0A6 E857000000          <1> 	call	locate_current_dir_entry
  2458 0000B0AB 7307                <1> 	jnc	short loc_dln_check_attributes
  2459 0000B0AD C3                  <1> 	retn
  2460                              <1> 
  2461                              <1> loc_dln_longname_not_found:
  2462                              <1> 	;mov	eax, 2
  2463                              <1> 	; 29/07/2022
  2464 0000B0AE 29C0                <1> 	sub	eax, eax
  2465 0000B0B0 B002                <1> 	mov	al, 2
  2466 0000B0B2 F9                  <1> 	stc
  2467 0000B0B3 C3                  <1> 	retn
  2468                              <1> 
  2469                              <1> loc_dln_check_attributes:
  2470 0000B0B4 B00F                <1> 	mov	al, 0Fh  ; long name
  2471 0000B0B6 8A670B              <1> 	mov	ah, [edi+0Bh] ; dir entry attributes
  2472 0000B0B9 38C4                <1> 	cmp	ah, al
  2473 0000B0BB 75F1                <1> 	jne	short loc_dln_longname_not_found
  2474 0000B0BD 8A27                <1> 	mov	ah, [edi]
  2475 0000B0BF 2A25[1A820100]      <1> 	sub	ah, [DLN_40h]
  2476 0000B0C5 76E7                <1> 	jna	short loc_dln_longname_not_found         
  2477 0000B0C7 80FC14              <1> 	cmp	ah, 14h ; 84-64=20 -> 20*13=260 bytes
  2478 0000B0CA 77E2                <1> 	ja	short loc_dln_longname_not_found
  2479                              <1>              
  2480 0000B0CC C607E5              <1> 	mov	byte [edi], 0E5h  ; deleted sign
  2481 0000B0CF C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; changed/write sign
  2482 0000B0D6 C605[1A820100]00    <1> 	mov	byte [DLN_40h], 0 ; 40h -> 0
  2483                              <1> 	  
  2484                              <1> loc_dln_delete_next_ln_entry:
  2485 0000B0DD 80FC01              <1> 	cmp	ah, 1
  2486 0000B0E0 7616                <1> 	jna	short loc_dln_longname_retn
  2487                              <1> loc_dln_delete_next_ln_entry_0:
  2488 0000B0E2 66FF05[18820100]    <1> 	inc	word [DLN_EntryNumber]
  2489 0000B0E9 0FB705[18820100]    <1> 	movzx	eax, word [DLN_EntryNumber] 
  2490 0000B0F0 E80D000000          <1> 	call	locate_current_dir_entry
  2491 0000B0F5 73BD                <1> 	jnc	short loc_dln_check_attributes
  2492                              <1> 
  2493                              <1> loc_dln_longname_stc_retn:
  2494 0000B0F7 C3                  <1> 	retn 
  2495                              <1> 	   
  2496                              <1> loc_dln_longname_retn:
  2497                              <1> 	;cmp	byte [DirBuff_ValidData], 2
  2498                              <1> 	;jne	short loc_dln_longname_retn_xor_eax
  2499 0000B0F8 E843FEFFFF          <1> 	call	save_directory_buffer
  2500 0000B0FD 72F8                <1> 	jc	short loc_dln_longname_stc_retn
  2501                              <1> 
  2502                              <1> loc_dln_longname_retn_xor_eax:
  2503 0000B0FF 31C0                <1> 	xor	eax, eax
  2504 0000B101 C3                  <1> 	retn
  2505                              <1> 
  2506                              <1> locate_current_dir_entry:
  2507                              <1> 	; 30/07/2022
  2508                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  2509                              <1> 	; 16/10/2016
  2510                              <1> 	; 15/10/2016
  2511                              <1> 	; 23/03/2016
  2512                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
  2513                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_locate_current_dir_entry')
  2514                              <1> 	; 07/03/2010
  2515                              <1> 	; INPUT ->
  2516                              <1> 	;	EAX = Directory Entry (Index) Number (< 65536) 
  2517                              <1> 	; OUTPUT ->
  2518                              <1> 	;	EDI = Directory Entry Address
  2519                              <1> 	; 	EAX = Cluster Number of Directory Buffer
  2520                              <1> 	;	EBX = Directory Buffer Entry Offset
  2521                              <1> 	;	ECX = DirBuff Valid Data identifier (CL)
  2522                              <1> 	;   	If CF = 0 and CL = 2 then
  2523                              <1> 	;	   directory buffer modified and
  2524                              <1> 	;	   must be written to disk.
  2525                              <1> 	; 	If CF = 0  and CL = 1 then
  2526                              <1> 	;	   dir buffer has been written to disk, already.
  2527                              <1> 	;	CF = 1 -> Error code in EAX (AL)
  2528                              <1> 	;
  2529                              <1> 	; (Modified registers: EAX, EDX, ECX, EBX, EDI) 
  2530                              <1> 
  2531                              <1> loc_locate_current_dir_entry:
  2532 0000B102 56                  <1> 	push	esi
  2533 0000B103 89C1                <1> 	mov	ecx, eax
  2534                              <1> 	;mov	edx, 32
  2535                              <1> 	; 29/07/2022
  2536 0000B105 29D2                <1> 	sub	edx, edx
  2537 0000B107 B220                <1> 	mov	dl, 32
  2538 0000B109 F7E2                <1> 	mul	edx 
  2539 0000B10B A3[24820100]        <1> 	mov	[LCDE_ByteOffset], eax
  2540 0000B110 31DB                <1> 	xor	ebx, ebx
  2541 0000B112 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv]
  2542 0000B118 A0[6F7F0100]        <1>         mov     al, [DirBuff_DRV]
  2543 0000B11D 2C41                <1> 	sub	al, 'A'
  2544 0000B11F BE00010900          <1>         mov     esi, Logical_DOSDisks
  2545 0000B124 01DE                <1> 	add	esi, ebx
  2546 0000B126 38C7                <1> 	cmp	bh, al
  2547                              <1> 	;jne	loc_lcde_reload_current_directory
  2548                              <1> 	; 29/07/2022
  2549 0000B128 7405                <1> 	je	short loc_lcde_cdl_check
  2550 0000B12A E986000000          <1> 	jmp	loc_lcde_reload_current_directory
  2551                              <1> loc_lcde_cdl_check:
  2552                              <1> 	; 29/07/2022
  2553 0000B12F 31C0                <1> 	xor	eax, eax
  2554 0000B131 803D[48780100]00    <1> 	cmp	byte [Current_Dir_Level], 0
  2555 0000B138 7728                <1> 	ja	short loc_lcde_calc_dirbuff_cluster_offset
  2556                              <1> 	; 27/02/2016
  2557                              <1> 	; TRDOS v1 has bug here for FAT32 fs !
  2558                              <1> 	; (Root Directory Entries for FAT32 = 0)
  2559 0000B13A 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3  ; FAT32
  2560 0000B13E 7322                <1> 	jnb	short loc_lcde_calc_dirbuff_cluster_offset
  2561                              <1> 
  2562                              <1> loc_lcde_cdl_check_FAT12_16:
  2563                              <1> 	; 29/07/2022
  2564                              <1> 	;xor	eax, eax
  2565 0000B140 668B4617            <1> 	mov	ax, [esi+LD_BPB+RootDirEnts]
  2566                              <1> 	;dec	ax
  2567 0000B144 48                  <1> 	dec	eax
  2568                              <1> 	;xor	dx, dx  
  2569                              <1> 	;cmp	ax, cx ; cx = Directory Entry (Index) Number
  2570                              <1> 	; 29/07/2022
  2571 0000B145 39C8                <1> 	cmp	eax, ecx
  2572 0000B147 720E                <1> 	jb	short loc_lcde_stc_12h_retn
  2573 0000B149 66890D[1C820100]    <1> 	mov	[LCDE_EntryIndex], cx
  2574 0000B150 31C0                <1> 	xor	eax, eax
  2575 0000B152 E985000000          <1>         jmp     loc_lcde_check_dir_buffer_cluster
  2576                              <1> 
  2577                              <1> loc_lcde_stc_12h_retn:
  2578 0000B157 5E                  <1> 	pop	esi
  2579 0000B158 89CB                <1> 	mov	ebx, ecx
  2580 0000B15A 89D1                <1> 	mov	ecx, edx
  2581                              <1> 	; 16/10/2016 (12h -> 12)
  2582 0000B15C B80C000000          <1> 	mov	eax, 12 ; No more files
  2583 0000B161 C3                  <1> 	retn 
  2584                              <1> 
  2585                              <1> loc_lcde_calc_dirbuff_cluster_offset:
  2586                              <1> 	;mov	bl, [esi+LD_BPB+SecPerClust]
  2587                              <1> 	;xor	bh, bh
  2588                              <1> 	;mov	ax, [esi+LD_BPB+BytesPerSec]
  2589                              <1> 	;mul	bx
  2590                              <1>  	;;or	dx, dx ; If bytes per cluster > 32KB it is invalid
  2591                              <1> 	;; 29/07/2022
  2592                              <1> 	;or	dl, dl
  2593                              <1> 	;jnz	short loc_lcde_invalid_format
  2594                              <1> 	; 29/07/2022
  2595 0000B162 31DB                <1> 	xor	ebx, ebx
  2596 0000B164 8A5E13              <1> 	mov	bl, [esi+LD_BPB+SecPerClust]
  2597 0000B167 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec]
  2598 0000B16B F7E3                <1> 	mul	ebx
  2599 0000B16D 89C1                <1> 	mov	ecx, eax
  2600                              <1> 	;mov	cx, ax ; BYTES PER CLUSTER
  2601 0000B16F A1[24820100]        <1> 	mov	eax, [LCDE_ByteOffset]
  2602                              <1> 	;sub	edx, edx
  2603 0000B174 F7F1                <1> 	div	ecx
  2604 0000B176 3DFFFF0000          <1> 	cmp	eax, 65535
  2605 0000B17B 7746                <1> 	ja	short loc_lcde_invalid_format
  2606                              <1> 
  2607                              <1> 	; cluster sequence number of directory (< 65536)
  2608 0000B17D 66A3[1E820100]      <1> 	mov	[LCDE_ClusterSN], ax 
  2609                              <1> 
  2610                              <1> 	;mov	ax, dx ; byte offset in cluster (directory buffer)
  2611                              <1> 	; 29/07/2022
  2612 0000B183 89D0                <1> 	mov	eax, edx
  2613                              <1> 	;mov	bx, 32	; 1 dir entry = 32 bytes
  2614 0000B185 B320                <1>         mov	bl, 32
  2615                              <1> 	;sub	dx, dx	; 0
  2616                              <1> 	;div	bx 
  2617 0000B187 29D2                <1> 	sub	edx, edx
  2618 0000B189 F7F3                <1> 	div	ebx
  2619 0000B18B 66A3[1C820100]      <1> 	mov	[LCDE_EntryIndex], ax ; dir entry index/sequence number
  2620                              <1> 				      ; (in directory buffer/cluster)	  
  2621                              <1> loc_lcde_get_current_sub_dir_fcluster:
  2622 0000B191 A1[44780100]        <1> 	mov	eax, [Current_Dir_FCluster]
  2623                              <1> 
  2624                              <1> loc_lcde_get_next_cluster:
  2625 0000B196 66833D[1E820100]00  <1> 	cmp	word [LCDE_ClusterSN], 0
  2626 0000B19E 763C                <1> 	jna	short loc_lcde_check_dir_buffer_cluster
  2627 0000B1A0 A3[20820100]        <1> 	mov	[LCDE_Cluster], eax
  2628 0000B1A5 E80D100000          <1> 	call	get_next_cluster
  2629 0000B1AA 721E                <1> 	jc	short loc_lcde_check_gnc_error
  2630 0000B1AC 66FF0D[1E820100]    <1>   	dec	word [LCDE_ClusterSN]
  2631 0000B1B3 EBE1                <1> 	jmp	short loc_lcde_get_next_cluster
  2632                              <1> 
  2633                              <1> loc_lcde_reload_current_directory:
  2634 0000B1B5 51                  <1> 	push	ecx
  2635 0000B1B6 E875F6FFFF          <1> 	call	reload_current_directory
  2636 0000B1BB 59                  <1> 	pop	ecx
  2637                              <1> 	;jnc	loc_lcde_cdl_check
  2638                              <1> 	;pop	esi
  2639                              <1> 	;retn
  2640                              <1> 	; 09/08/2022
  2641 0000B1BC 727E                <1> 	jc	short loc_lcde_retn
  2642 0000B1BE E96CFFFFFF          <1> 	jmp	loc_lcde_cdl_check
  2643                              <1> 
  2644                              <1> loc_lcde_invalid_format:
  2645                              <1> 	; 15/10/2016 (0Bh -> 28)
  2646                              <1> 	;mov	eax, 28 ; Invalid Format !
  2647                              <1> 	; 29/07/2022
  2648 0000B1C3 29C0                <1> 	sub	eax, eax
  2649 0000B1C5 B01C                <1> 	mov	al, 28
  2650                              <1> loc_lcde_drive_not_ready_read_err:
  2651 0000B1C7 F9                  <1> 	stc
  2652 0000B1C8 5E                  <1> 	pop	esi 
  2653 0000B1C9 C3                  <1> 	retn  
  2654                              <1> 
  2655                              <1> loc_lcde_check_gnc_error:
  2656 0000B1CA 09C0                <1> 	or	eax, eax
  2657 0000B1CC 75F9                <1> 	jnz	short loc_lcde_drive_not_ready_read_err
  2658 0000B1CE 66FF0D[1E820100]    <1> 	dec	word [LCDE_ClusterSN]
  2659 0000B1D5 75EC                <1> 	jnz	short loc_lcde_invalid_format 
  2660 0000B1D7 A1[20820100]        <1> 	mov	eax, [LCDE_Cluster]
  2661                              <1> 
  2662                              <1> loc_lcde_check_dir_buffer_cluster:
  2663 0000B1DC 3B05[767F0100]      <1> 	cmp	eax, [DirBuff_Cluster]
  2664 0000B1E2 755A                <1> 	jne	short loc_lcde_load_dir_cluster
  2665 0000B1E4 803D[717F0100]00    <1> 	cmp	byte [DirBuff_ValidData], 0
  2666 0000B1EB 7726                <1> 	ja	short lcde_check_dir_buffer_cluster_next
  2667 0000B1ED 803D[48780100]00    <1> 	cmp	byte [Current_Dir_Level], 0    
  2668 0000B1F4 775D                <1> 	ja	short loc_lcde_load_dir_cluster_0
  2669                              <1> 	; 27/02/2016
  2670                              <1> 	; TRDOS v1 has bug here for FAT32 fs !
  2671 0000B1F6 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3  ; FAT32
  2672 0000B1FA 7357                <1> 	jnb	short loc_lcde_load_dir_cluster_0
  2673                              <1> 	;
  2674 0000B1FC 0FB74E17            <1> 	movzx	ecx, word [esi+LD_BPB+RootDirEnts]
  2675 0000B200 6683C10F            <1> 	add	cx, 15 ; round up (16 entries per sector)
  2676                              <1> 	;shr	cx, 4 ; 1 sector contains 16 dir entries	
  2677                              <1> 	; 29/07/2022
  2678 0000B204 C1E904              <1> 	shr	ecx, 4
  2679 0000B207 8B4664              <1>         mov     eax, [esi+LD_ROOTBegin]
  2680 0000B20A EB52                <1> 	jmp	short loc_lcde_load_dir_cluster_1 
  2681                              <1> 
  2682                              <1> loc_lcde_validate_dirBuff:
  2683 0000B20C C605[717F0100]01    <1> 	mov	byte [DirBuff_ValidData], 1
  2684                              <1> 
  2685                              <1> lcde_check_dir_buffer_cluster_next:
  2686 0000B213 0FB71D[1C820100]    <1> 	movzx	ebx, word [LCDE_EntryIndex]
  2687 0000B21A 663B1D[747F0100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  2688 0000B221 77A0                <1> 	ja	short loc_lcde_invalid_format 
  2689                              <1> 	;mov	eax, 32
  2690                              <1> 	; 29/07/2022
  2691 0000B223 31C0                <1> 	xor	eax, eax
  2692 0000B225 B020                <1> 	mov	al, 32
  2693 0000B227 F7E3                <1> 	mul	ebx
  2694                              <1> 	;or	edx, edx
  2695                              <1> 	;jnz	short loc_lcde_invalid_format
  2696                              <1> 
  2697 0000B229 BF00000800          <1> 	mov	edi, Directory_Buffer  
  2698 0000B22E 01C7                <1> 	add	edi, eax ; add entry offset to buffer address
  2699                              <1> 
  2700                              <1> loc_lcde_dir_buffer_last_check:
  2701 0000B230 A1[767F0100]        <1> 	mov	eax, [DirBuff_Cluster]
  2702 0000B235 0FB60D[717F0100]    <1> 	movzx	ecx, byte [DirBuff_ValidData]
  2703                              <1> 
  2704                              <1> loc_lcde_retn:
  2705 0000B23C 5E                  <1> 	pop	esi
  2706 0000B23D C3                  <1> 	retn
  2707                              <1> 
  2708                              <1> loc_lcde_load_dir_cluster:
  2709                              <1> 	;cmp	byte [DirBuff_ValidData], 2
  2710                              <1> 	;jne	short loc_lcde_load_dir_cluster_n2
  2711 0000B23E 50                  <1> 	push	eax
  2712 0000B23F E8FCFCFFFF          <1> 	call	save_directory_buffer
  2713 0000B244 58                  <1> 	pop	eax
  2714 0000B245 72F5                <1> 	jc	short loc_lcde_retn
  2715                              <1> 
  2716                              <1> loc_lcde_load_dir_cluster_n2:
  2717 0000B247 C605[717F0100]00    <1> 	mov	byte [DirBuff_ValidData], 0
  2718 0000B24E A3[767F0100]        <1> 	mov	[DirBuff_Cluster], eax
  2719                              <1> 
  2720                              <1> loc_lcde_load_dir_cluster_0:
  2721                              <1> 	;sub	eax, 2
  2722                              <1> 	; 30/07/2022
  2723 0000B253 48                  <1> 	dec	eax
  2724 0000B254 48                  <1> 	dec	eax
  2725 0000B255 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  2726 0000B259 F7E1                <1> 	mul	ecx
  2727 0000B25B 034668              <1>         add     eax, [esi+LD_DATABegin]
  2728                              <1> 
  2729                              <1> loc_lcde_load_dir_cluster_1:
  2730 0000B25E BB00000800          <1> 	mov	ebx, Directory_Buffer
  2731                              <1> 	; ecx = sector count
  2732 0000B263 E8ED6A0000          <1> 	call	disk_read
  2733 0000B268 73A2                <1> 	jnc	short loc_lcde_validate_dirBuff
  2734                              <1> 
  2735                              <1> 	; 15/10/2016 
  2736                              <1> 	; (Disk read error instead of drv not ready err)
  2737 0000B26A B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
  2738 0000B26F EBCB                <1> 	jmp	short loc_lcde_retn
  2739                              <1> 
  2740                              <1> 
  2741                              <1> remove_file:
  2742                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  2743                              <1> 	; 15/10/2016
  2744                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  2745                              <1> 	; 10/04/2011 (FILE.ASM, 'proc_delete_file')
  2746                              <1> 	; 09/08/2010
  2747                              <1> 	; INPUT ->
  2748                              <1> 	;	EDI = Directory Buffer Entry Address
  2749                              <1> 	;	 CX = Directory Buffer Entry Counter/Index
  2750                              <1> 	;	 BL = Longname Entry Length
  2751                              <1> 	;	 BH = Logical DOS Drive Number 
  2752                              <1> 
  2753 0000B271 29C0                <1> 	sub	eax, eax
  2754 0000B273 88FC                <1> 	mov	ah, bh
  2755 0000B275 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2756 0000B27A 01C6                <1> 	add	esi, eax
  2757                              <1> 
  2758 0000B27C 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  2759 0000B280 7311                <1> 	jnb	short loc_del_fat_file 
  2760                              <1>               
  2761 0000B282 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  2762 0000B286 7406                <1> 	je	short loc_del_fs_file
  2763                              <1> 
  2764                              <1> loc_del_file_invalid_format:
  2765 0000B288 30E4                <1> 	xor	ah, ah
  2766                              <1> 	; 15/10/2016 (0Bh -> 28)
  2767 0000B28A B01C                <1> 	mov	al, 28  ; Invalid Format
  2768 0000B28C F9                  <1> 	stc 
  2769 0000B28D C3                  <1> 	retn
  2770                              <1> 
  2771                              <1> loc_del_fs_file:
  2772                              <1> 	;call	delete_fs_file
  2773                              <1> 	;retn
  2774                              <1> 	; 29/07/2022
  2775 0000B28E E9230F0000          <1> 	jmp	delete_fs_file	
  2776                              <1> 
  2777                              <1> loc_del_fat_file:
  2778 0000B293 E808000000          <1> 	call	delete_directory_entry
  2779 0000B298 7205                <1> 	jc	short loc_del_file_err_retn 
  2780                              <1> 
  2781                              <1> loc_delfile_unlink_cluster_chain:
  2782 0000B29A E8C8160000          <1> 	call	truncate_cluster_chain
  2783                              <1> 	;jc	short loc_del_file_err_retn
  2784                              <1> 
  2785                              <1> loc_delfile_return:
  2786                              <1> loc_del_file_err_retn:
  2787 0000B29F C3                  <1> 	retn
  2788                              <1> 
  2789                              <1> delete_directory_entry:
  2790                              <1> 	; 15/10/2016
  2791                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  2792                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_delete_directory_entry')
  2793                              <1> 	; 10/04/2011 
  2794                              <1> 	; INPUT ->
  2795                              <1> 	; 	ESI = Logical Dos Drive Descripton Table Address 
  2796                              <1> 	;	EDI = Directory Buffer Entry Address
  2797                              <1> 	;	 CX = Directory Buffer Entry Counter/Index
  2798                              <1> 	;	 BL = Longname Entry Length
  2799                              <1> 	; OUTPUT ->
  2800                              <1> 	; 	ESI = Logical dos drive descripton table address 
  2801                              <1> 	;	EAX = First cluster to be truncated/unlinked
  2802                              <1> 	;       CF = 1 -> Error code in EAX (AL)
  2803                              <1> 	;       CF = 0 & BH <> 0 -> LMDT write error  (BH = 1)
  2804                              <1> 	;       CF = 0 & BL <> 0 -> Long name delete error (BL = FFh) 
  2805                              <1> 	;
  2806                              <1> 	;  (EDI, EBX, ECX register contents will be changed)
  2807                              <1> 
  2808 0000B2A0 881D[B2810100]      <1> 	mov	[DelFile_LNEL], bl
  2809 0000B2A6 66890D[B0810100]    <1> 	mov	[DelFile_EntryCounter], cx
  2810                              <1> 
  2811 0000B2AD 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  2812 0000B2B1 C1E010              <1> 	shl	eax, 16
  2813 0000B2B4 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  2814                              <1> 
  2815 0000B2B8 A3[AC810100]        <1> 	mov	[DelFile_FCluster], eax
  2816                              <1> 
  2817                              <1> loc_del_short_name:
  2818 0000B2BD C607E5              <1> 	mov	byte [edi], 0E5h  ; Deleted sign
  2819                              <1> 
  2820 0000B2C0 C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  2821 0000B2C7 E874FCFFFF          <1> 	call	save_directory_buffer
  2822 0000B2CC 723D                <1> 	jc	short loc_delete_direntry_err_return
  2823                              <1>  
  2824                              <1> loc_del_long_name:
  2825 0000B2CE 0FB615[B2810100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  2826 0000B2D5 08D2                <1> 	or	dl, dl
  2827 0000B2D7 7416                <1> 	jz	short loc_del_dir_entry_update_parent_dir_lm_date
  2828                              <1> 
  2829 0000B2D9 8835[B2810100]      <1> 	mov	[DelFile_LNEL], dh ; 0              
  2830                              <1>   
  2831 0000B2DF 0FB705[B0810100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
  2832 0000B2E6 29D0                <1> 	sub	eax, edx
  2833                              <1> 	;jnc	short loc_del_long_name_continue
  2834 0000B2E8 7205                <1> 	jc	short loc_del_dir_entry_update_parent_dir_lm_date   
  2835                              <1> 
  2836                              <1> ;loc_del_direntry_inv_data_return: ; 15/10/2016 (0Dh -> 29)
  2837                              <1> ;	mov	eax, 29 ; 0Dh (TRDOS 8086) ; Invalid data
  2838                              <1> ;	retn
  2839                              <1> 
  2840                              <1> loc_del_long_name_continue: 
  2841                              <1> 	; AX = Directory Entry Number of the long name last entry
  2842 0000B2EA E8AAFDFFFF          <1> 	call	delete_longname
  2843                              <1> 	;jc	short loc_delete_direntry_err_return
  2844                              <1> 
  2845                              <1> loc_del_dir_entry_update_parent_dir_lm_date:
  2846 0000B2EF 801D[B2810100]00    <1> 	sbb	byte [DelFile_LNEL], 0 ; 0FFh if cf = 1
  2847                              <1> 
  2848 0000B2F6 E8DDFCFFFF          <1> 	call	update_parent_dir_lmdt
  2849 0000B2FB B700                <1> 	mov	bh, 0
  2850 0000B2FD 80D700              <1> 	adc	bh, 0
  2851                              <1> 
  2852 0000B300 8A1D[B2810100]      <1> 	mov	bl, byte [DelFile_LNEL]
  2853                              <1>  
  2854                              <1> loc_delete_direntry_return:
  2855 0000B306 A1[AC810100]        <1> 	mov	eax, [DelFile_FCluster]
  2856                              <1> loc_delete_direntry_err_return:
  2857 0000B30B C3                  <1> 	retn
  2858                              <1> 
  2859                              <1> rename_directory_entry:
  2860                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  2861                              <1> 	; 13/11/2017
  2862                              <1> 	; 15/10/2016
  2863                              <1> 	; 06/03/2016 (TRDOS 386 = TRDOS v2.0)
  2864                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_rename_directory_entry')
  2865                              <1> 	; 19/11/2010
  2866                              <1> 	; INPUT -> (Current Directory)
  2867                              <1> 	;	CX = Directory Entry Number
  2868                              <1> 	;      EAX = First Cluster number of file or directory
  2869                              <1> 	;      EBX = Longname Length (dir entry count) (< 256)
  2870                              <1> 	;      ESI = New file (or directory) name (no path).
  2871                              <1> 	;           (ASCIIZ string)  
  2872                              <1> 	; OUTPUT -> 
  2873                              <1> 	;      CF = 0 -> successfull
  2874                              <1> 	;      CF = 1 -> error code in EAX (AL)
  2875                              <1> 	;
  2876                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  2877                              <1> 
  2878 0000B30C 803D[49780100]00    <1> 	cmp	byte [Current_FATType], 0
  2879 0000B313 7705                <1> 	ja	short loc_rename_directory_entry
  2880                              <1> 
  2881                              <1> 	;call	rename_fs_file_or_directory
  2882                              <1> 	;retn
  2883                              <1> 	; 29/07/2022
  2884 0000B315 E99C0E0000          <1>  	jmp	rename_fs_file_or_directory	
  2885                              <1> 	
  2886                              <1> loc_rename_directory_entry:
  2887 0000B31A 881D[B2810100]      <1> 	mov	[DelFile_LNEL], bl
  2888 0000B320 66890D[B0810100]    <1> 	mov	[DelFile_EntryCounter], cx
  2889 0000B327 A3[AC810100]        <1> 	mov	[DelFile_FCluster], eax
  2890                              <1> 
  2891 0000B32C 0FB7C1              <1> 	movzx	eax, cx
  2892 0000B32F E8CEFDFFFF          <1> 	call	locate_current_dir_entry
  2893 0000B334 7307                <1> 	jnc	short loc_rename_direntry_check_fcluster
  2894                              <1> 
  2895                              <1> loc_rename_direntry_pop_retn:
  2896 0000B336 C3                  <1> 	retn
  2897                              <1> 
  2898                              <1> loc_rename_direntry_pop_invd_retn:
  2899                              <1> 	; 29/07/2022
  2900                              <1> 	;stc
  2901                              <1> loc_rename_direntry_invd_retn:
  2902                              <1> 	; 15/10/2016 (0Dh -> 29)
  2903                              <1> 	;mov	eax, 29 ; Invalid data
  2904                              <1> 	; 29/07/2022
  2905 0000B337 29C0                <1> 	sub	eax, eax
  2906 0000B339 B01D                <1> 	mov	al, 29
  2907 0000B33B F9                  <1> 	stc
  2908                              <1> loc_rename_retn:
  2909 0000B33C C3                  <1> 	retn 
  2910                              <1> 
  2911                              <1> loc_rename_direntry_check_fcluster:
  2912 0000B33D 668B5714            <1> 	mov	dx, [edi+20] ; First Cluster HW
  2913 0000B341 C1E210              <1> 	shl	edx, 16 ; 13/11/2017
  2914 0000B344 668B571A            <1> 	mov	dx, [edi+26] ; First Cluster LW
  2915 0000B348 3B15[AC810100]      <1> 	cmp	edx, [DelFile_FCluster]
  2916 0000B34E 75E7                <1> 	jne	short loc_rename_direntry_pop_invd_retn
  2917                              <1> 	; ESI = New file (or directory) name. (ASCIIZ string)
  2918                              <1> 	; 06/03/2016
  2919                              <1> 	; TRDOS v2 - NOTE: 'convert_file_name' procedure
  2920                              <1> 	; has been modified for eliminating following situation.
  2921                              <1> 	; 
  2922                              <1> 	; TRDOS v1 - NOTE: If file/dir name is more than 11 bytes
  2923                              <1> 	; without a dot, attributes (edi+11) byte will be overwritten !
  2924                              <1> 	; (Dot file name input must be proper for 11 byte dir entry
  2925                              <1> 	;  type file name output.) 
  2926 0000B350 E8E5F6FFFF          <1> 	call	convert_file_name
  2927                              <1> 
  2928 0000B355 C605[717F0100]02    <1>         mov     byte [DirBuff_ValidData], 2
  2929 0000B35C E8DFFBFFFF          <1> 	call	save_directory_buffer
  2930 0000B361 72D9                <1> 	jc	short loc_rename_retn
  2931                              <1> 
  2932                              <1> loc_rename_direntry_del_ln:
  2933 0000B363 0FB615[B2810100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  2934 0000B36A 08D2                <1> 	or	dl, dl
  2935 0000B36C 7410                <1> 	jz	short loc_rename_direntry_update_parent_dir_lm_date
  2936                              <1> 
  2937 0000B36E 0FB705[B0810100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
  2938 0000B375 29D0                <1> 	sub	eax, edx
  2939 0000B377 72BE                <1> 	jc	short loc_rename_direntry_invd_retn
  2940                              <1> 
  2941                              <1> loc_rename_direntry_del_ln_continue: 
  2942                              <1> 	; EAX = Directory Entry Number of the long name last entry
  2943 0000B379 E81BFDFFFF          <1> 	call	delete_longname
  2944                              <1> 
  2945                              <1> loc_rename_direntry_update_parent_dir_lm_date:
  2946 0000B37E E855FCFFFF          <1> 	call	update_parent_dir_lmdt
  2947 0000B383 31C0                <1> 	xor	eax, eax 
  2948 0000B385 C3                  <1> 	retn
  2949                              <1> 
  2950                              <1> move_source_file_to_destination_file:
  2951                              <1> 	; 07/08/2022
  2952                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  2953                              <1> 	; 15/10/2016
  2954                              <1> 	; 11/03/2016
  2955                              <1> 	; 10/03/2016 (TRDOS 386 = TRDOS v2.0)
  2956                              <1> 	; 01/08/2011 (FILE.ASM)
  2957                              <1> 	; 04/08/2010
  2958                              <1> 	;
  2959                              <1> 	;   Phase 1 -> Check destination file, 
  2960                              <1> 	;              'not found' is required
  2961                              <1> 	;   Phase 2 -> Check source file
  2962                              <1> 	;              'found' and proper attributes is required
  2963                              <1> 	;   Phase 3 -> Make destination directory entry,
  2964                              <1> 	;           add new dir cluster or section if it is required
  2965                              <1> 	;   Phase 4 -> Delete source directory entry.
  2966                              <1> 	;       cf = 1 causes to return before the phase 4.
  2967                              <1> 	;    (source file protection against any possible errors)    
  2968                              <1> 	;
  2969                              <1> 	; 08/05/2011 major modification
  2970                              <1> 	;            -> destination file deleting is removed   
  2971                              <1> 	;            for msdos move/rename compatibility.
  2972                              <1> 	;            (Access denied error will return if
  2973                              <1> 	;            the destination file is found...)
  2974                              <1> 	; INPUT ->
  2975                              <1> 	;	 ESI = Source File Pathname (Asciiz)
  2976                              <1> 	;        EDI = Destination File Pathname (Asciiz)
  2977                              <1> 	;        AL = 0 --> Interrupt (System call)
  2978                              <1> 	;        AL > 0 --> Command Interpreter (Question)
  2979                              <1> 	;        AL = 1 --> Question Phase
  2980                              <1> 	;        AL = 2 --> Progress Phase        
  2981                              <1> 	; OUTPUT -> 
  2982                              <1> 	;	 cf = 0 -> OK
  2983                              <1> 	;        EAX = Destination directory first cluster
  2984                              <1> 	;        ESI = Logical DOS drive description table 
  2985                              <1> 	;        EBX = Destination file structure offset
  2986                              <1> 	;        CX = 0 (CX > 0 --> calculate free space error)
  2987                              <1> 	;        cf = 1 -> Error code in EAX (AL) 
  2988                              <1> 	;
  2989                              <1> 	;  (EDX, ECX, EBX, ESI, EDI will be changed)
  2990                              <1> 
  2991 0000B386 3C02                <1> 	cmp	al, 2
  2992                              <1> 	;je	msftdf_df2_check_directory
  2993                              <1> 	; 29/07/2022
  2994 0000B388 7505                <1> 	jne	short msftdf
  2995 0000B38A E97B010000          <1> 	jmp	msftdf_df2_check_directory
  2996                              <1> msftdf:
  2997 0000B38F A2[32830100]        <1> 	mov	[move_cmd_phase], al
  2998                              <1> 
  2999                              <1> msftdf_parse_sf_path:
  3000                              <1> 	; ESI = ASCIIZ pathname (Source)
  3001 0000B394 57                  <1> 	push	edi 
  3002 0000B395 BF[30820100]        <1> 	mov	edi, SourceFile_Drv
  3003 0000B39A E865F7FFFF          <1> 	call	parse_path_name
  3004 0000B39F 5E                  <1> 	pop	esi
  3005 0000B3A0 7211                <1> 	jc	short msftdf_psf_retn
  3006                              <1> 
  3007                              <1> msftdf_parse_df_path:
  3008                              <1> 	; ESI = ASCIIZ pathname	(Destination)
  3009 0000B3A2 BF[B0820100]        <1> 	mov	edi, DestinationFile_Drv
  3010 0000B3A7 E858F7FFFF          <1> 	call	parse_path_name
  3011 0000B3AC 7306                <1> 	jnc	short msftdf_check_sf_drv
  3012                              <1> 
  3013 0000B3AE 3C01                <1> 	cmp	al, 1 ; File or directory name is not existing
  3014 0000B3B0 7602                <1> 	jna	short msftdf_check_sf_drv
  3015                              <1> 
  3016                              <1> msftdf_stc_retn:
  3017 0000B3B2 F9                  <1> 	stc
  3018                              <1> msftdf_psf_retn:
  3019 0000B3B3 C3                  <1> 	retn 
  3020                              <1> 
  3021                              <1> msftdf_check_sf_drv:
  3022 0000B3B4 A0[30820100]        <1> 	mov	al, [SourceFile_Drv]
  3023                              <1> 
  3024                              <1> msftdf_check_df_drv:
  3025 0000B3B9 8A15[B0820100]      <1> 	mov	dl, [DestinationFile_Drv]
  3026                              <1> 
  3027                              <1> msftdf_compare_sf_df_drv:
  3028 0000B3BF 29DB                <1> 	sub	ebx, ebx
  3029 0000B3C1 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv]
  3030 0000B3C7 38C2                <1> 	cmp	dl, al
  3031 0000B3C9 7408                <1> 	je	short msftdf_check_sf_df_drv_ok
  3032                              <1> 
  3033                              <1> msftdf_not_same_drv:
  3034                              <1>         ; DL = source file's drive number
  3035 0000B3CB 88C6                <1> 	mov	dh, al ; destination file's drive number
  3036                              <1> 	; 15/10/2016 (11h -> 21)
  3037                              <1> 	;mov	eax, 21 ; Not the same drive
  3038                              <1> 	; 29/07/2022
  3039 0000B3CD 29C0                <1> 	sub	eax, eax
  3040 0000B3CF B015                <1> 	mov	al, 21
  3041 0000B3D1 F9                  <1> 	stc
  3042 0000B3D2 C3                  <1> 	retn 
  3043                              <1> 
  3044                              <1> msftdf_check_sf_df_drv_ok:
  3045 0000B3D3 8815[33830100]      <1> 	mov	[msftdf_sf_df_drv], dl
  3046                              <1> 
  3047 0000B3D9 29C0                <1>         sub	eax, eax
  3048 0000B3DB 88D4                <1> 	mov	ah, dl
  3049 0000B3DD 0500010900          <1> 	add	eax, Logical_DOSDisks
  3050 0000B3E2 A3[34830100]        <1> 	mov	[msftdf_drv_offset], eax
  3051                              <1> 
  3052 0000B3E7 38FA                <1> 	cmp	dl, bh ; byte [Current_Drv]
  3053 0000B3E9 7407                <1> 	je	short msftdf_df_check_directory
  3054                              <1> 
  3055                              <1> msftdf_change_drv:
  3056 0000B3EB E8A2C3FFFF          <1> 	call 	change_current_drive
  3057 0000B3F0 726D                <1> 	jc	short msftdf_df_error_retn
  3058                              <1> 	  
  3059                              <1> msftdf_check_destination_file:
  3060                              <1> msftdf_df_check_directory:
  3061 0000B3F2 BE[B1820100]        <1> 	mov	esi, DestinationFile_Directory
  3062 0000B3F7 803E20              <1> 	cmp	byte [esi], 20h
  3063 0000B3FA 760F                <1> 	jna	short msftdf_df_find_1
  3064                              <1> 
  3065                              <1> msftdf_df_change_directory:
  3066 0000B3FC FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  3067 0000B402 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3068 0000B404 E80FF1FFFF          <1> 	call	change_current_directory
  3069 0000B409 7254                <1> 	jc	short msftdf_df_error_retn
  3070                              <1> 
  3071                              <1> ;msftdf_df_change_prompt_dir_string:
  3072                              <1> ;	call 	change_prompt_dir_string
  3073                              <1> 
  3074                              <1> msftdf_df_find_1:
  3075 0000B40B BE[F2820100]        <1>         mov     esi, DestinationFile_Name
  3076 0000B410 803E20              <1> 	cmp	byte [esi], 20h
  3077 0000B413 7632                <1> 	jna	short msftdf_df_copy_sf_name
  3078                              <1> 
  3079                              <1> msftdf_df_find_2:
  3080 0000B415 6631C0              <1> 	xor	ax, ax ; DestinationFile_AttributesMask -> any/zero
  3081 0000B418 E823D6FFFF          <1> 	call	find_first_file
  3082                              <1> 	;jnc	msftdf_permission_denied_retn
  3083                              <1> 	; 29/07/2022
  3084 0000B41D 7205                <1> 	jc	short msftdf_df_check_error_code
  3085 0000B41F E98B000000          <1> 	jmp	msftdf_permission_denied_retn 
  3086                              <1> 
  3087                              <1> msftdf_df_check_error_code:
  3088                              <1> 	;cmp	eax, 2 ; File not found error
  3089 0000B424 3C02                <1> 	cmp	al, 2
  3090 0000B426 7536                <1> 	jne	short msftdf_df_stc_retn
  3091                              <1>               
  3092                              <1> msftdf_df_check_fname:
  3093                              <1> 	; 15/10/2016
  3094 0000B428 BE[F2820100]        <1> 	mov	esi, DestinationFile_Name ; *
  3095 0000B42D E8B3D9FFFF          <1> 	call	check_filename
  3096 0000B432 7307                <1> 	jnc	short msftdf_convert_df_direntry_name
  3097                              <1> 	; invalid file name chars !
  3098 0000B434 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME  ; 26
  3099 0000B439 EB23                <1> 	jmp	short msftdf_df_stc_retn
  3100                              <1> 
  3101                              <1> msftdf_convert_df_direntry_name:
  3102                              <1> 	; mov	esi, DestinationFile_Name ; *
  3103 0000B43B BF[02830100]        <1> 	mov	edi, DestinationFile_DirEntry
  3104 0000B440 E8F5F5FFFF          <1> 	call	convert_file_name
  3105 0000B445 EB19                <1>   	jmp	short msftdf_restore_current_dir_1
  3106                              <1> 
  3107                              <1> msftdf_df_copy_sf_name:
  3108 0000B447 89F7                <1> 	mov	edi, esi
  3109 0000B449 57                  <1> 	push	edi 
  3110 0000B44A BE[72820100]        <1>         mov     esi, SourceFile_Name
  3111                              <1> 	;mov	ecx, 12
  3112                              <1> 	; 29/07/2022
  3113 0000B44F 29C9                <1> 	sub	ecx, ecx
  3114 0000B451 B10C                <1> 	mov	cl, 12
  3115                              <1> msftdf_df_copy_sf_name_loop:
  3116 0000B453 AC                  <1> 	lodsb
  3117 0000B454 AA                  <1>         stosb
  3118 0000B455 08C0                <1> 	or	al, al
  3119 0000B457 7402                <1> 	jz	short msftdf_df_copy_sf_name_ok	
  3120 0000B459 E2F8                <1>         loop    msftdf_df_copy_sf_name_loop
  3121                              <1> msftdf_df_copy_sf_name_ok:	
  3122 0000B45B 5E                  <1> 	pop	esi  
  3123 0000B45C EBB7                <1> 	jmp	short msftdf_df_find_2
  3124                              <1> 
  3125                              <1> msftdf_df_stc_retn:
  3126 0000B45E F9                  <1> 	stc
  3127                              <1> msftdf_restore_cdir_failed:
  3128                              <1> msftdf_df_error_retn:
  3129 0000B45F C3                  <1> 	retn
  3130                              <1> 
  3131                              <1> msftdf_restore_current_dir_1:
  3132 0000B460 803D[92300100]00    <1> 	cmp	byte [Restore_CDIR], 0
  3133 0000B467 760D                <1> 	jna	short msftdf_sf_check_directory
  3134 0000B469 8B35[34830100]      <1> 	mov	esi, [msftdf_drv_offset] 
  3135 0000B46F E8D4C3FFFF          <1> 	call	restore_current_directory
  3136 0000B474 72E9                <1> 	jc	short msftdf_restore_cdir_failed
  3137                              <1> 
  3138                              <1> msftdf_sf_check_directory:
  3139 0000B476 BE[31820100]        <1> 	mov	esi, SourceFile_Directory
  3140 0000B47B 803E20              <1> 	cmp	byte [esi], 20h
  3141 0000B47E 760F                <1> 	jna	short msftdf_sf_find
  3142                              <1> msftdf_sf_change_directory:
  3143 0000B480 FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  3144 0000B486 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3145 0000B488 E88BF0FFFF          <1> 	call	change_current_directory
  3146 0000B48D 7225                <1> 	jc	short msftdf_return
  3147                              <1> 
  3148                              <1> ;msftdf_sf_change_prompt_dir_string:
  3149                              <1> ;	call	change_prompt_dir_string
  3150                              <1> 
  3151                              <1> msftdf_sf_find:
  3152 0000B48F BE[72820100]        <1>         mov     esi, SourceFile_Name  ; Offset 66
  3153 0000B494 66B80018            <1> 	mov	ax, 1800h ; Only files
  3154 0000B498 E8A3D5FFFF          <1> 	call	find_first_file
  3155 0000B49D 7215                <1> 	jc	short msftdf_return
  3156                              <1> 
  3157                              <1> msftdf_sf_ambgfn_check:
  3158 0000B49F 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3159 0000B4A2 7406                <1> 	jz	short msftdf_sf_found
  3160                              <1> 
  3161                              <1> msftdf_ambiguous_file_name_error:
  3162                              <1> 	;mov	eax, 2 ; File not found error
  3163                              <1> 	; 29/07/2022
  3164 0000B4A4 29C0                <1> 	sub	eax, eax
  3165 0000B4A6 B002                <1> 	mov	al, 2
  3166 0000B4A8 F9                  <1> 	stc
  3167 0000B4A9 C3                  <1> 	retn
  3168                              <1> 
  3169                              <1> msftdf_sf_found:
  3170 0000B4AA 80E31F              <1> 	and	bl, 1Fh ; Attributes, D-V-S-H-R
  3171 0000B4AD 7415                <1> 	jz	short msftdf_save_sf_structure
  3172                              <1> 
  3173                              <1> msftdf_permission_denied_retn:
  3174                              <1> 	;mov	eax, 05h ; Access (Permission) denied !
  3175                              <1> 	; 29/07/2022
  3176 0000B4AF 29C0                <1> 	sub	eax, eax
  3177 0000B4B1 B005                <1> 	mov	al, 5
  3178 0000B4B3 F9                  <1> 	stc
  3179                              <1> msftdf_rest_cdir_err_retn:
  3180                              <1> msftdf_return:
  3181 0000B4B4 C3                  <1> 	retn
  3182                              <1> 
  3183                              <1> msftdf_phase_1_return:
  3184 0000B4B5 31C0                <1> 	xor	eax, eax
  3185 0000B4B7 A2[32830100]        <1> 	mov	[move_cmd_phase], al ; 0
  3186 0000B4BC FEC0                <1> 	inc	al ; mov al, 1
  3187 0000B4BE BB[0AB50000]        <1> 	mov	ebx, msftdf_df2_check_directory
  3188                              <1> 	;mov	edx, 0FFFFFFFFh 
  3189 0000B4C3 C3                  <1> 	retn
  3190                              <1> 
  3191                              <1> msftdf_save_sf_structure:
  3192 0000B4C4 BE[3C810100]        <1> 	mov	esi, FindFile_DirEntry
  3193 0000B4C9 BF[82820100]        <1> 	mov	edi, SourceFile_DirEntry
  3194                              <1> 	;mov	ecx, 8
  3195                              <1> 	; 29/07/2022
  3196 0000B4CE 29C9                <1> 	sub	ecx, ecx
  3197 0000B4D0 B108                <1> 	mov	cl, 8
  3198 0000B4D2 F3A5                <1> 	rep	movsd
  3199                              <1> 
  3200                              <1> msftdf_df_copy_sf_parameters:
  3201 0000B4D4 BE0B000000          <1> 	mov	esi, 11
  3202 0000B4D9 89F7                <1> 	mov	edi, esi
  3203 0000B4DB 81C6[82820100]      <1> 	add	esi, SourceFile_DirEntry
  3204 0000B4E1 81C7[02830100]      <1> 	add	edi, DestinationFile_DirEntry
  3205                              <1> 	;mov	ecx, 21
  3206 0000B4E7 B115                <1> 	mov	cl, 21
  3207 0000B4E9 F3A4                <1> 	rep	movsb
  3208                              <1> 
  3209                              <1> msftdf_restore_current_dir_2:
  3210 0000B4EB 803D[92300100]00    <1> 	cmp	byte [Restore_CDIR], 0
  3211 0000B4F2 760D                <1> 	jna	short msftdf_df2_check_move_cmd_phase
  3212 0000B4F4 8B35[34830100]      <1>  	mov	esi, [msftdf_drv_offset]
  3213 0000B4FA E849C3FFFF          <1> 	call	restore_current_directory
  3214 0000B4FF 72B3                <1> 	jc	short msftdf_rest_cdir_err_retn
  3215                              <1> 
  3216                              <1> msftdf_df2_check_move_cmd_phase:
  3217 0000B501 803D[32830100]01    <1> 	cmp	byte [move_cmd_phase], 1
  3218 0000B508 74AB                <1> 	je	short msftdf_phase_1_return
  3219                              <1> 
  3220                              <1> msftdf_df2_check_directory:
  3221 0000B50A BE[B1820100]        <1> 	mov	esi, DestinationFile_Directory
  3222 0000B50F 803E20              <1> 	cmp	byte [esi], 20h
  3223 0000B512 760F                <1> 	jna	short msftdf_make_dfde_locate_ffe_on_directory
  3224                              <1> msftdf_df2_change_directory:
  3225 0000B514 FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  3226 0000B51A 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3227 0000B51C E8F7EFFFFF          <1> 	call	change_current_directory
  3228 0000B521 7291                <1> 	jc	short msftdf_return
  3229                              <1> 
  3230                              <1> ;msftdf_df2_change_prompt_dir_string:
  3231                              <1> ;	call	change_prompt_dir_string
  3232                              <1> 
  3233                              <1> msftdf_make_dfde_locate_ffe_on_directory:
  3234                              <1> 	; Current directory fcluster <> Directory buffer cluster
  3235                              <1> 	; Current directory will be reloaded by
  3236                              <1> 	; 'locate_current_dir_file' procedure
  3237                              <1> 	;
  3238                              <1> 	;xor	ax, ax
  3239 0000B523 31C0                <1> 	xor	eax, eax
  3240 0000B525 89C1                <1> 	mov	ecx, eax
  3241 0000B527 6649                <1> 	dec	cx ; FFFFh  
  3242                              <1> 		; CX = FFFFh -> find first deleted or free entry
  3243                              <1> 		; ESI would be ASCIIZ filename address if the call
  3244                              <1> 		; would not be for first free or deleted dir entry  
  3245 0000B529 E83DF2FFFF          <1> 	call	locate_current_dir_file
  3246                              <1> 	; 07/08/2022
  3247 0000B52E 733F                <1> 	jnc	short msftdf_make_dfde_set_ff_dir_entry
  3248                              <1> 	
  3249                              <1> 	;cmp	eax, 2
  3250 0000B530 3C02                <1>         cmp	al, 2
  3251 0000B532 7537                <1> 	jne	short msftdf_error_retn
  3252                              <1> 
  3253                              <1> msftdf_add_new_dir_entry_check_fs:
  3254 0000B534 8B35[34830100]      <1> 	mov	esi, [msftdf_drv_offset]
  3255 0000B53A A1[767F0100]        <1> 	mov 	eax, [DirBuff_Cluster]
  3256 0000B53F 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3257 0000B543 7711                <1> 	ja	short msftdf_add_new_subdir_cluster
  3258                              <1> 
  3259                              <1> msftdf_add_new_fs_subdir_section:
  3260                              <1> 	;CL=0, CH=E5h --> deleted entry, CH=0 --> free entry
  3261                              <1>         ;xor	cx, cx
  3262 0000B545 30ED                <1> 	xor	ch, ch ; cx = 0 --> add a new subdir section
  3263 0000B547 E86A0C0000          <1> 	call	add_new_fs_section
  3264 0000B54C 721E                <1>         jc	short msftdf_dsfde_error_retn
  3265                              <1> 	;mov	[createfile_LastDirCluster], eax
  3266                              <1> 
  3267 0000B54E E85A0E0000          <1> 	call	load_FS_sub_directory 
  3268                              <1> 	;mov	ebx, Directory_Buffer 
  3269 0000B553 7318                <1> 	jnc	short msftdf_add_new_fs_subdir_section_ok
  3270 0000B555 C3                  <1> 	retn	 
  3271                              <1> 
  3272                              <1> msftdf_add_new_subdir_cluster:
  3273 0000B556 E8E8140000          <1> 	call	add_new_cluster
  3274 0000B55B 720F                <1> 	jc	short msftdf_dsfde_error_retn
  3275                              <1> 	
  3276                              <1> 	;mov	[createfile_LastDirCluster], eax
  3277                              <1> 
  3278 0000B55D E8110E0000          <1> 	call	load_FAT_sub_directory
  3279 0000B562 7309                <1> 	jnc	short msftdf_add_new_subdir_cluster_ok
  3280                              <1> 	; EBX = Directory buffer address
  3281                              <1> 
  3282                              <1> msftdf_ansdc_update_parent_dir_lmdt:
  3283                              <1> msftdf_make_dfde_err_upd_pdir_lmdt:
  3284 0000B564 50                  <1> 	push	eax
  3285 0000B565 E86EFAFFFF          <1> 	call	update_parent_dir_lmdt
  3286 0000B56A 58                  <1> 	pop	eax
  3287                              <1> 
  3288                              <1> msftdf_error_retn:
  3289 0000B56B F9                  <1> 	stc
  3290                              <1> msftdf_dsfde_restore_cdir_failed:
  3291                              <1> msftdf_dsfde_error_retn:
  3292 0000B56C C3                  <1> 	retn
  3293                              <1> 
  3294                              <1> msftdf_add_new_fs_subdir_section_ok:
  3295                              <1> msftdf_add_new_subdir_cluster_ok:
  3296 0000B56D 89DF                <1> 	mov	edi, ebx ; Directory buffer address
  3297                              <1> 
  3298                              <1> msftdf_make_dfde_set_ff_dir_entry:
  3299 0000B56F 8B15[44780100]      <1> 	mov	edx, [Current_Dir_FCluster]
  3300 0000B575 8915[98830100]      <1> 	mov	[createfile_FFCluster], edx
  3301                              <1> 	; EDI = Directory entry offset
  3302 0000B57B BE[02830100]        <1> 	mov	esi, DestinationFile_DirEntry
  3303                              <1> 	;mov	ecx, 8
  3304                              <1> 	; 29/07/2022
  3305 0000B580 29C9                <1> 	sub	ecx, ecx
  3306 0000B582 B108                <1> 	mov	cl, 8
  3307 0000B584 F3A5                <1> 	rep	movsd
  3308                              <1> 
  3309 0000B586 C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  3310 0000B58D E8AEF9FFFF          <1> 	call	save_directory_buffer
  3311 0000B592 72D0                <1> 	jc	short msftdf_make_dfde_err_upd_pdir_lmdt
  3312                              <1> 
  3313                              <1> msftdf_make_dfde_update_pdir_lmdt:
  3314 0000B594 E83FFAFFFF          <1> 	call	update_parent_dir_lmdt
  3315                              <1> 
  3316                              <1> msftdf_dsfde_restore_current_dir_1:
  3317 0000B599 803D[92300100]00    <1> 	cmp	byte [Restore_CDIR], 0
  3318 0000B5A0 760D                <1> 	jna	short msftdf_dsfde_check_directory
  3319 0000B5A2 8B35[34830100]      <1>  	mov	esi, [msftdf_drv_offset]
  3320 0000B5A8 E89BC2FFFF          <1> 	call	restore_current_directory
  3321 0000B5AD 72BD                <1> 	jc	short msftdf_dsfde_restore_cdir_failed
  3322                              <1> 
  3323                              <1> msftdf_dsfde_check_directory:
  3324 0000B5AF BE[31820100]        <1> 	mov	esi, SourceFile_Directory
  3325 0000B5B4 803E20              <1> 	cmp	byte [esi], 20h
  3326 0000B5B7 760F                <1> 	jna	short msftdf_dsfde_find_file
  3327                              <1> 
  3328                              <1> msftdf_dsfde_change_directory:
  3329 0000B5B9 FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  3330 0000B5BF 28E4                <1> 	sub	ah, ah ; CD_COMMAND sign -> 0 
  3331 0000B5C1 E852EFFFFF          <1> 	call	change_current_directory
  3332 0000B5C6 72A4                <1> 	jc	short msftdf_dsfde_error_retn
  3333                              <1> 
  3334                              <1> ;msftdf_dsfde_sf_change_prompt_dir_string:
  3335                              <1> ;	call	change_prompt_dir_string
  3336                              <1> 
  3337                              <1> msftdf_dsfde_find_file:
  3338 0000B5C8 BE[72820100]        <1> 	mov	esi, SourceFile_Name  ; Offset 66
  3339 0000B5CD 668B460E            <1> 	mov	ax, [esi+14] ; 80 -> SourceFile_AttributesMask
  3340 0000B5D1 E86AD4FFFF          <1> 	call	find_first_file
  3341 0000B5D6 7294                <1> 	jc	short msftdf_dsfde_error_retn
  3342                              <1> 
  3343                              <1> msftdf_dsfde_delete_direntry:
  3344 0000B5D8 8B35[34830100]      <1> 	mov	esi, [msftdf_drv_offset]
  3345                              <1> 	
  3346 0000B5DE 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3347 0000B5E2 770A                <1> 	ja	short msftdf_delete_FAT_direntry
  3348                              <1> 	
  3349 0000B5E4 30DB                <1> 	xor	bl, bl
  3350                              <1> 	; BL = 0 -> File
  3351                              <1> 	; EDI -> Directory buffer entry offset/address 
  3352 0000B5E6 E8CB0B0000          <1> 	call	delete_fs_directory_entry
  3353 0000B5EB 7315                <1> 	jnc	short msftdf_dsfde_restore_current_dir_2
  3354 0000B5ED C3                  <1> 	retn
  3355                              <1> 
  3356                              <1> msftdf_delete_FAT_direntry:	
  3357 0000B5EE 8A1D[39810100]      <1> 	mov	bl, [FindFile_LongNameEntryLength]
  3358 0000B5F4 668B0D[64810100]    <1> 	mov	cx, [FindFile_DirEntryNumber]
  3359                              <1> 	; ESI = Logical DOS drive description table address
  3360                              <1> 	; EDI = Directory buffer entry offset/address 
  3361 0000B5FB E8A0FCFFFF          <1> 	call	delete_directory_entry
  3362 0000B600 721C                <1> 	jc	short msftdf_retn
  3363                              <1> 
  3364                              <1> msftdf_dsfde_restore_current_dir_2:
  3365 0000B602 803D[92300100]00    <1> 	cmp	byte [Restore_CDIR], 0
  3366 0000B609 7607                <1> 	jna	short msftdf_new_dir_fcluster_retn
  3367                              <1> 	;mov	esi, [msftdf_drv_offset]
  3368 0000B60B E838C2FFFF          <1> 	call	restore_current_directory
  3369 0000B610 720C                <1> 	jc	short msftdf_retn
  3370                              <1> 
  3371                              <1> msftdf_new_dir_fcluster_retn:
  3372 0000B612 31C9                <1> 	xor	ecx, ecx 
  3373 0000B614 A1[98830100]        <1> 	mov	eax, [createfile_FFCluster]
  3374 0000B619 BB[B0820100]        <1> 	mov	ebx, DestinationFile_Drv
  3375                              <1> 
  3376                              <1> msftdf_retn:
  3377 0000B61E C3                  <1> 	retn
  3378                              <1> 
  3379                              <1> 
  3380                              <1> copy_source_file_to_destination_file:
  3381                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  3382                              <1> 	; 17/10/2016
  3383                              <1> 	; 16/10/2016
  3384                              <1> 	; 15/10/2016
  3385                              <1> 	; 30/03/2016, 31/03/2016
  3386                              <1> 	; 24/03/2016, 25/03/2016, 28/03/2016
  3387                              <1> 	; 21/03/2016, 22/03/2016, 23/03/2016
  3388                              <1> 	; 16/03/2016, 17/03/2016, 18/03/2016
  3389                              <1> 	; 15/03/2016 (TRDOS 386 = TRDOS v2.0)
  3390                              <1> 	; 02/09/2011 (FILE.ASM 'copy_source_file_to_destination_file')
  3391                              <1> 	; 01/08/2010 - 18/05/2011
  3392                              <1> 	;
  3393                              <1> 	;   Command Interpreter phase 1 enter ->
  3394                              <1> 	;           AL = 1 -> Caller is command interpreter
  3395                              <1> 	;           AL = 2 -> The second call, re-enter/continue
  3396                              <1> 	;   Phase 1 -> Check source file
  3397                              <1> 	;              'found' is required
  3398                              <1> 	;   Phase 2 -> Check destination file, 
  3399                              <1> 	;              save 'found' or 'not found' status
  3400                              <1> 	;              'permission denied' error will be return
  3401                              <1> 	;              if attributes have not for ordinary file 
  3402                              <1> 	;              without readonly attribute
  3403                              <1> 	;   Command Interpreter phase 1 return ->
  3404                              <1> 	;              DH = Source file attributes
  3405                              <1> 	;              DL = Destination file found status
  3406                              <1> 	;              EAX = 0 
  3407                              <1> 	;   Command Interpreter phase 2 enter ->
  3408                              <1> 	;              AL = 2 -> Continue from the last position
  3409                              <1> 	;              AH = 
  3410                              <1> 	;   Phase 3 -> Load source file or use read/write cluster method
  3411                              <1> 	;   Phase 4 -> Create destination file if it is not found
  3412                              <1> 	;   Phase 5 -> Open destination file
  3413                              <1> 	;   Phase 6 -> Read from source and write to destination
  3414                              <1> 	;   Phase 7 -> Unload source file, if it is loaded at memory
  3415                              <1> 	;       cf = 1 causes to return before the phase 7
  3416                              <1> 	;              but loaded file will be unloaded
  3417                              <1> 	;	       (allocated memory block will be deallocated) 
  3418                              <1> 	;
  3419                              <1> 	; INPUT -> 
  3420                              <1> 	;	 ESI = Source File Pathname (Asciiz)
  3421                              <1> 	;        EDI = Destination File Pathname (Asciiz)
  3422                              <1> 	;        AL = 0 --> Interrupt (System call)
  3423                              <1> 	;        AL > 0 --> Command Interpreter (Question)
  3424                              <1> 	;        AL = 1 --> Question Phase
  3425                              <1> 	;        AL = 2 --> Progress Phase        
  3426                              <1> 	;
  3427                              <1> 	; OUTPUT -> 
  3428                              <1> 	;	cf = 0 -> OK
  3429                              <1> 	;	EAX = Destination file first cluster
  3430                              <1> 	;
  3431                              <1> 	;        CL > 0 if there is file reading error before EOF
  3432                              <1> 	;	        (incomplete copy) 
  3433                              <1> 	;        CH > 0 if file is (full) loaded at memory
  3434                              <1> 	;
  3435                              <1> 	;	cf = 1 -> Error code in AL (EAX) 
  3436                              <1> 	;
  3437                              <1> 	; (EBX, ECX, ESI, EDI register contents will be changed)           
  3438                              <1> 
  3439                              <1> 
  3440 0000B61F 3C02                <1> 	cmp	al, 2
  3441                              <1> 	;je	csftdf2_check_cdrv
  3442                              <1> 	; 29/07/2022
  3443 0000B621 7205                <1> 	jb	short csftdf_ph1
  3444                              <1> 	;jmp	csftdf2_check_cdrv
  3445 0000B623 E94F020000          <1> 	jmp	csftdf_ph2
  3446                              <1> 
  3447                              <1> ; Phase 1
  3448                              <1> 	; 29/07/2022
  3449                              <1> csftdf_ph1:
  3450 0000B628 A2[58830100]        <1> 	mov	byte [copy_cmd_phase], al
  3451                              <1> 
  3452 0000B62D 57                  <1> 	push	edi ; *
  3453                              <1> 
  3454                              <1> csftdf_parse_sf_path:
  3455 0000B62E BF[30820100]        <1> 	mov	edi, SourceFile_Drv
  3456 0000B633 E8CCF4FFFF          <1> 	call	parse_path_name
  3457 0000B638 721C                <1> 	jc	short csftdf_parse_sf_path_failed
  3458                              <1> 
  3459                              <1> csftdf_parse_df_path:	
  3460 0000B63A 5E                  <1> 	pop	esi ; * (pushed edi) 
  3461                              <1> 
  3462                              <1> csftdf_sf_check_filename_exists:
  3463 0000B63B 803D[72820100]21    <1> 	cmp	byte [SourceFile_Name], 21h
  3464 0000B642 7215                <1> 	jb	short csftdf_sf_file_not_found_error
  3465                              <1> 
  3466 0000B644 BF[B0820100]        <1> 	mov	edi, DestinationFile_Drv
  3467 0000B649 E8B6F4FFFF          <1> 	call	parse_path_name
  3468 0000B64E 7310                <1> 	jnc	short csftdf_check_sf_cdrv
  3469                              <1> 	
  3470 0000B650 3C01                <1> 	cmp	al, 1 ; File or directory name is not existing
  3471 0000B652 760C                <1> 	jna	short csftdf_check_sf_cdrv
  3472                              <1> 
  3473                              <1> csftdf_parse_df_path_failed:
  3474 0000B654 F9                  <1> 	stc 
  3475                              <1> csftdf_sf_error_retn: 
  3476 0000B655 C3                  <1> 	retn
  3477                              <1> 
  3478                              <1> csftdf_parse_sf_path_failed:	
  3479 0000B656 5F                  <1> 	pop	edi ; *
  3480 0000B657 EBFC                <1> 	jmp	short csftdf_sf_error_retn
  3481                              <1> 
  3482                              <1> csftdf_sf_file_not_found_error:
  3483 0000B659 B802000000          <1> 	mov	eax, 2 ; File not found 
  3484 0000B65E EBF5                <1> 	jmp	short csftdf_sf_error_retn
  3485                              <1> 
  3486                              <1> csftdf_check_sf_cdrv:
  3487 0000B660 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv]
  3488                              <1> 
  3489 0000B666 883D[5B830100]      <1> 	mov	[csftdf_cdrv], bh ; 23/03/2016
  3490                              <1> 
  3491 0000B66C 8A15[30820100]      <1> 	mov	dl, [SourceFile_Drv]
  3492 0000B672 38FA                <1> 	cmp	dl, bh ; byte [Current_Drv]
  3493 0000B674 7407                <1> 	je	short csftdf_sf_check_directory
  3494                              <1> 
  3495 0000B676 E817C1FFFF          <1> 	call	change_current_drive
  3496 0000B67B 72D8                <1> 	jc	short csftdf_sf_error_retn
  3497                              <1> 
  3498                              <1> csftdf_sf_check_directory:
  3499 0000B67D BE[31820100]        <1> 	mov	esi, SourceFile_Directory
  3500 0000B682 803E20              <1> 	cmp	byte [esi], 20h
  3501 0000B685 760F                <1> 	jna	short csftdf_find_sf
  3502                              <1> 
  3503                              <1> csftdf_sf_change_directory:
  3504 0000B687 FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  3505 0000B68D 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3506 0000B68F E884EEFFFF          <1> 	call	change_current_directory
  3507 0000B694 72BF                <1> 	jc	short csftdf_sf_error_retn
  3508                              <1> 
  3509                              <1> ;csftdf_sf_change_prompt_dir_string:
  3510                              <1> ;	call	change_prompt_dir_string
  3511                              <1> 
  3512                              <1> csftdf_find_sf:
  3513 0000B696 BE[72820100]        <1> 	mov	esi, SourceFile_Name
  3514 0000B69B 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  3515 0000B69F E89CD3FFFF          <1> 	call	find_first_file
  3516 0000B6A4 72AF                <1> 	jc	short csftdf_sf_error_retn
  3517                              <1> 
  3518                              <1> csftdf_sf_ambgfn_check:
  3519 0000B6A6 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3520 0000B6A9 7406                <1> 	jz	short csftdf_sf_found
  3521                              <1> 
  3522                              <1> csftdf_ambiguous_file_name_error:
  3523                              <1> 	;mov	eax, 2 ; File not found error
  3524                              <1> 	; 29/07/2022
  3525 0000B6AB 29C0                <1> 	sub	eax, eax
  3526 0000B6AD B002                <1> 	mov	al, 2
  3527 0000B6AF F9                  <1> 	stc
  3528 0000B6B0 C3                  <1> 	retn
  3529                              <1> 
  3530                              <1> csftdf_sf_found:
  3531 0000B6B1 A3[5C830100]        <1> 	mov	[csftdf_filesize], eax
  3532                              <1> 
  3533 0000B6B6 09C0                <1> 	or	eax, eax
  3534 0000B6B8 7506                <1> 	jnz	short csftdf_set_source_file_direntry
  3535                              <1> 
  3536                              <1> csftdf_sf_file_size_zero:
  3537                              <1> 	;mov	eax, 20 ; TRDOS zero length (file size) error
  3538                              <1> 	; 29/07/2022
  3539 0000B6BA 29C0                <1> 	sub	eax, eax
  3540 0000B6BC B014                <1> 	mov	al, 20
  3541 0000B6BE F9                  <1> 	stc
  3542 0000B6BF C3                  <1> 	retn
  3543                              <1> 
  3544                              <1> csftdf_set_source_file_direntry:
  3545 0000B6C0 BE[3C810100]        <1> 	mov	esi, FindFile_DirEntry
  3546 0000B6C5 BF[82820100]        <1> 	mov	edi, SourceFile_DirEntry
  3547                              <1> 	;mov	ecx, 8
  3548                              <1> 	; 29/07/2022
  3549 0000B6CA 31C9                <1> 	xor	ecx, ecx
  3550 0000B6CC B108                <1> 	mov	cl, 8
  3551 0000B6CE F3A5                <1> 	rep	movsd
  3552                              <1> 
  3553                              <1> csftdf_sf_restore_cdrv:
  3554                              <1> 	; 22/03/2016
  3555 0000B6D0 8A15[5B830100]      <1> 	mov	dl, [csftdf_cdrv]
  3556 0000B6D6 3A15[4A780100]      <1> 	cmp	dl, [Current_Drv]
  3557 0000B6DC 7407                <1> 	je	short csftdf_sf_restore_cdir
  3558 0000B6DE E8AFC0FFFF          <1> 	call	change_current_drive 
  3559 0000B6E3 724F                <1> 	jc	short csftdf_df_error_retn ; 30/03/2016
  3560                              <1> 
  3561                              <1> csftdf_sf_restore_cdir:
  3562 0000B6E5 803D[92300100]00    <1> 	cmp	byte [Restore_CDIR], 0
  3563 0000B6EC 7612                <1> 	jna	short csftdf_df_check_filename_exists
  3564 0000B6EE 29C0                <1> 	sub	eax, eax
  3565 0000B6F0 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3566 0000B6F5 88D4                <1> 	mov	ah, dl ; byte [csftdf_cdrv]
  3567 0000B6F7 01C6                <1> 	add	esi, eax
  3568 0000B6F9 E84AC1FFFF          <1> 	call	restore_current_directory
  3569 0000B6FE 7234                <1> 	jc	short csftdf_df_error_retn
  3570                              <1>   
  3571                              <1> csftdf_df_check_filename_exists:
  3572 0000B700 803D[F2820100]20    <1> 	cmp	byte [DestinationFile_Name], 20h
  3573 0000B707 7716                <1> 	ja	short csftdf_check_df_cdrv
  3574                              <1> 
  3575                              <1> csftdf_copy_sf_name:
  3576 0000B709 BF[F2820100]        <1> 	mov	edi, DestinationFile_Name
  3577 0000B70E BE[72820100]        <1> 	mov	esi, SourceFile_Name
  3578 0000B713 B10C                <1> 	mov	cl, 12
  3579                              <1> 
  3580                              <1> csftdf_df_copy_sf_name_loop:
  3581 0000B715 AC                  <1> 	lodsb
  3582 0000B716 AA                  <1> 	stosb
  3583 0000B717 08C0                <1> 	or	al, al
  3584 0000B719 7404                <1> 	jz	short csftdf_check_df_cdrv             
  3585 0000B71B FEC9                <1> 	dec	cl
  3586 0000B71D 75F6                <1> 	jnz	csftdf_df_copy_sf_name_loop
  3587                              <1> 
  3588                              <1> csftdf_check_df_cdrv:
  3589 0000B71F 8A15[B0820100]      <1> 	mov	dl, [DestinationFile_Drv]
  3590 0000B725 3A15[4A780100]      <1> 	cmp	dl, [Current_Drv]
  3591 0000B72B 7408                <1> 	je	short csftdf_df_check_directory
  3592                              <1> 
  3593 0000B72D E860C0FFFF          <1> 	call	change_current_drive
  3594 0000B732 7301                <1> 	jnc	short csftdf_df_check_directory
  3595                              <1> 
  3596                              <1> csftdf_df_error_retn:
  3597 0000B734 C3                  <1> 	retn
  3598                              <1> 
  3599                              <1> csftdf_df_check_directory:
  3600 0000B735 BE[B1820100]        <1> 	mov	esi, DestinationFile_Directory
  3601 0000B73A 803E20              <1>         cmp     byte [esi], 20h
  3602 0000B73D 760F                <1> 	jna	short csftdf_find_df
  3603                              <1> 
  3604                              <1> csftdf_df_change_directory:
  3605 0000B73F FE05[92300100]      <1> 	inc	byte [Restore_CDIR]
  3606 0000B745 28E4                <1> 	sub	ah, ah ; CD_COMMAND sign -> 0 
  3607 0000B747 E8CCEDFFFF          <1> 	call	change_current_directory
  3608 0000B74C 72E6                <1> 	jc	short csftdf_df_error_retn
  3609                              <1> 
  3610                              <1> ;csftdf_df_change_prompt_dir_string:
  3611                              <1> ;	call	change_prompt_dir_string
  3612                              <1> 
  3613                              <1> csftdf_find_df:
  3614                              <1> 	; 23/03/2016
  3615 0000B74E 29DB                <1> 	sub	ebx, ebx
  3616 0000B750 8A3D[B0820100]      <1> 	mov	bh,  [DestinationFile_Drv]
  3617 0000B756 81C300010900        <1> 	add	ebx, Logical_DOSDisks
  3618 0000B75C 891D[88830100]      <1> 	mov	[csftdf_df_drv_dt], ebx
  3619                              <1> 
  3620 0000B762 BE[F2820100]        <1> 	mov	esi, DestinationFile_Name
  3621 0000B767 6631C0              <1> 	xor	ax, ax 
  3622                              <1> 		; DestinationFile_AttributesMask -> any/zero
  3623 0000B76A E8D1D2FFFF          <1> 	call	find_first_file
  3624 0000B76F 7217                <1> 	jc	short csftdf_df_check_error_code
  3625                              <1> 
  3626                              <1> csftdf_df_ambgfn_check:
  3627 0000B771 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3628 0000B774 7529                <1> 	jnz	short csftdf_df_error_inv_fname
  3629                              <1> 	
  3630                              <1> csftdf_df_found:
  3631 0000B776 C605[5A830100]01    <1> 	mov	byte [DestinationFileFound], 1
  3632                              <1> 	; 17/10/2016 (cl -> bl)
  3633 0000B77D 80E31F              <1> 	and	bl, 1Fh ; Attributes, D-V-S-H-R
  3634 0000B780 7459                <1> 	jz	short csftdf_df_save_first_cluster
  3635                              <1> 
  3636                              <1> csftdf_df_permission_denied_retn:	 
  3637                              <1> 	;mov	eax, 05h ; Access/Permission denied.
  3638                              <1> 	; 29/07/2022
  3639 0000B782 29C0                <1> 	sub	eax, eax
  3640 0000B784 B005                <1> 	mov	al, 5
  3641                              <1> csftdf_df_error_stc_retn:
  3642 0000B786 F9                  <1> 	stc
  3643 0000B787 C3                  <1> 	retn
  3644                              <1> 
  3645                              <1> csftdf_df_check_error_code:
  3646                              <1> 	;cmp	eax, 2
  3647 0000B788 3C02                <1> 	cmp	al, 2
  3648 0000B78A 75FA                <1> 	jne	short csftdf_df_error_stc_retn
  3649                              <1> 
  3650 0000B78C C605[5A830100]00    <1> 	mov	byte [DestinationFileFound], 0
  3651                              <1> 
  3652                              <1> 	; 15/10/2016
  3653 0000B793 BE[2C810100]        <1> 	mov	esi, FindFile_Name ; *
  3654 0000B798 E848D6FFFF          <1> 	call	check_filename
  3655 0000B79D 7306                <1> 	jnc	short csftdf_df_valid_fname
  3656                              <1> csftdf_df_error_inv_fname: ; 'invalid file name !'
  3657                              <1> 	;mov 	eax, ERR_INV_FILE_NAME  ; 26
  3658                              <1> 	; 29/07/2022
  3659 0000B79F 29C0                <1> 	sub	eax, eax
  3660 0000B7A1 B01A                <1> 	mov	al, ERR_INV_FILE_NAME ; 26
  3661 0000B7A3 F9                  <1> 	stc	
  3662 0000B7A4 C3                  <1> 	retn
  3663                              <1> 
  3664                              <1> csftdf_df_valid_fname:	
  3665                              <1> 	; 21/03/2016
  3666                              <1> 	; (Capitalized file name)
  3667                              <1> 	;mov	esi, FindFile_Name ; * ; 15/10/2016
  3668 0000B7A5 BF[F2820100]        <1> 	mov	edi, DestinationFile_Name
  3669 0000B7AA A5                  <1> 	movsd
  3670 0000B7AB A5                  <1> 	movsd	
  3671 0000B7AC A5                  <1> 	movsd
  3672                              <1> 	;movsb
  3673                              <1> 
  3674                              <1> csftdf_check_disk_free_size_0:
  3675 0000B7AD A1[9E820100]        <1> 	mov	eax, [SourceFile_DirEntry+DirEntry_FileSize]
  3676                              <1> 
  3677                              <1> csftdf_check_disk_free_size_1:
  3678                              <1> 	;sub	ebx, ebx
  3679                              <1> 	;mov 	esi, Logical_DOSDisks
  3680                              <1> 	;mov	bh,  [DestinationFile_Drv]
  3681                              <1> 	;add	esi, ebx
  3682                              <1> 	
  3683 0000B7B2 8B35[88830100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 23/03/2016
  3684                              <1> 
  3685 0000B7B8 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 17, LD_BPB + 0Bh
  3686 0000B7BC 01C8                <1> 	add	eax, ecx
  3687 0000B7BE 48                  <1> 	dec	eax  ; file size (additional bytes) + 511 (round up)
  3688                              <1> csftdf_check_disk_free_size_3: ; 16/03/2016
  3689 0000B7BF 29D2                <1> 	sub	edx, edx
  3690 0000B7C1 F7F1                <1> 	div	ecx ; bytes per sector
  3691                              <1> 
  3692                              <1> csftdf_check_disk_free_size:
  3693 0000B7C3 3B4674              <1> 	cmp	eax, [esi+LD_FreeSectors]
  3694                              <1>         ;jb	csftdf_check_disk_free_size_ok
  3695                              <1> 	; 29/07/2022
  3696 0000B7C6 7208                <1> 	jb	short csftdf_check_dfs_ok
  3697 0000B7C8 770B                <1> 	ja	short csftdf_df_insufficient_disk_space
  3698                              <1> 
  3699 0000B7CA 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0 ; FS needs FDT sector also.
  3700                              <1> 	;ja	csftdf_check_disk_free_size_ok 
  3701                              <1> 	; 29/07/2022
  3702 0000B7CE 7605                <1> 	jna	short csftdf_df_insufficient_disk_space
  3703                              <1> csftdf_check_dfs_ok:
  3704 0000B7D0 E985000000          <1> 	jmp	csftdf_check_disk_free_size_ok 
  3705                              <1> 
  3706                              <1> csftdf_df_insufficient_disk_space:
  3707                              <1> 	;mov	eax, 27h ; insufficient disk space
  3708                              <1> 	; 29/07/2022
  3709 0000B7D5 29C0                <1> 	sub	eax, eax
  3710 0000B7D7 B027                <1> 	mov	al, 27h
  3711 0000B7D9 EBAB                <1> 	jmp	short csftdf_df_error_stc_retn
  3712                              <1> 
  3713                              <1> csftdf_df_save_first_cluster:
  3714                              <1> 	; ESI = FindFile_DirEntry (for the old destination file)
  3715                              <1> 	; EAX = Old destination file size
  3716                              <1> 	; 24/03/2016
  3717                              <1> 	; EDI = Directory entry address (within Dir Buffer boundaries)
  3718 0000B7DB 81EF00000800        <1> 	sub	edi, Directory_Buffer  ; (<65536)
  3719                              <1> 	;shr	di, 5 ; Convert entry offset to entry index/number
  3720                              <1> 	; 29/07/2022
  3721 0000B7E1 C1EF05              <1> 	shr	edi, 5
  3722 0000B7E4 66893D[2A830100]    <1> 	mov	[DestinationFile_DirEntryNumber], di ; (<2048)
  3723                              <1> 
  3724                              <1> csftdf_df_check_sf_df_fcluster:
  3725 0000B7EB 668B5614            <1> 	mov	dx, [esi+DirEntry_FstClusHI]
  3726 0000B7EF C1E210              <1> 	shl	edx, 16
  3727 0000B7F2 668B561A            <1> 	mov	dx, [esi+DirEntry_FstClusLO]
  3728 0000B7F6 8915[6C830100]      <1> 	mov	[csftdf_df_cluster], edx
  3729                              <1> csftdf_df_check_sf_df_fcluster_1:
  3730 0000B7FC 668B15[96820100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusHI]
  3731 0000B803 C1E210              <1> 	shl	edx, 16
  3732 0000B806 668B15[9C820100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusLO]
  3733 0000B80D 3B15[6C830100]      <1> 	cmp	edx, [csftdf_df_cluster]
  3734 0000B813 7512                <1> 	jne	short csftdf_df_check_sf_df_fcluster_ok
  3735                              <1> csftdf_df_check_sf_df_drv:
  3736 0000B815 8A15[30820100]      <1> 	mov	dl, [SourceFile_Drv]
  3737 0000B81B 3A15[B0820100]      <1> 	cmp	dl, [DestinationFile_Drv]
  3738 0000B821 7504                <1> 	jne	short csftdf_df_check_sf_df_fcluster_ok
  3739                              <1> 
  3740                              <1> 	; source and destination files are same !
  3741                              <1> 	; (they have same first cluster value on same logical disk)
  3742                              <1> 
  3743 0000B823 31C0                <1> 	xor	eax, eax ; mov eax, 0 -> Bad command or file name !
  3744 0000B825 F9                  <1> 	stc
  3745 0000B826 C3                  <1> 	retn 
  3746                              <1>    
  3747                              <1> csftdf_df_check_sf_df_fcluster_ok:
  3748                              <1> csftdf_df_move_findfile_struct:
  3749                              <1> 	; mov	esi, FindFile_DirEntry
  3750 0000B827 BF[02830100]        <1> 	mov	edi, DestinationFile_DirEntry
  3751                              <1> 	;mov	ecx, 8
  3752 0000B82C 31C9                <1> 	xor	ecx, ecx
  3753 0000B82E B108                <1> 	mov	cl, 8
  3754 0000B830 F3A5                <1> 	rep	movsd
  3755                              <1> 	
  3756                              <1> csftdf_check_disk_free_size_2:
  3757 0000B832 89C2                <1> 	mov	edx, eax ; Old destination file size
  3758                              <1> 
  3759                              <1> 	;mov	eax, [SourceFile_DirEntry+DirEntry_FileSize]
  3760 0000B834 A1[5C830100]        <1> 	mov	eax, [csftdf_filesize] ; 23/03/2016
  3761                              <1> 
  3762                              <1> 	;;sub	ecx, ecx ; 0
  3763                              <1> 	;mov 	esi, Logical_DOSDisks
  3764                              <1> 	;mov	ch,  [DestinationFile_Drv]
  3765                              <1> 	;add	esi, ecx
  3766                              <1> 	;
  3767                              <1> 	;mov	[csftdf_df_drv_dt], esi
  3768                              <1> 
  3769 0000B839 8B35[88830100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 23/03/2016
  3770                              <1> 
  3771 0000B83F 668B4E11            <1> 	mov	cx, [esi+LD_BPB+BytesPerSec] ; 17, LD_BPB + 0Bh
  3772 0000B843 01CA                <1> 	add	edx, ecx ; + 512
  3773 0000B845 01C8                <1> 	add	eax, ecx ; + 512
  3774 0000B847 4A                  <1> 	dec	edx ; old file size + 511 (round up)
  3775 0000B848 48                  <1> 	dec	eax ; new file size + 511 (round up)
  3776 0000B849 F7D9                <1> 	neg	ecx ; -512 ; 0FFFFFE00h
  3777 0000B84B 21CA                <1> 	and	edx, ecx ; = old sector count * 512 
  3778 0000B84D 21C8                <1> 	and	eax, ecx ; = new sector count * 512 
  3779                              <1> 
  3780 0000B84F 29D0                <1> 	sub	eax, edx ; new file size - old file size (on disk)
  3781 0000B851 7607                <1> 	jna	short csftdf_check_disk_free_size_ok
  3782                              <1> 
  3783 0000B853 F7D9                <1> 	neg	ecx ; 512 (bytes per sector) ; 200h
  3784                              <1> 	; check free space for additional sectors
  3785                              <1> 	; eax = number of additional sectors * bytes per sector
  3786                              <1> 	; esi = Logical DOS drive number (of destination disk)
  3787 0000B855 E965FFFFFF          <1>         jmp     csftdf_check_disk_free_size_3
  3788                              <1>  
  3789                              <1> csftdf_check_disk_free_size_ok:
  3790                              <1> 	; 18/03/2016
  3791                              <1> csftdf_df_check_copy_cmd_phase:
  3792 0000B85A A0[58830100]        <1> 	mov	al, [copy_cmd_phase]
  3793 0000B85F 3C01                <1> 	cmp	al, 1
  3794 0000B861 7514                <1> 	jne	short csftdf2_check_cdrv
  3795                              <1> 	
  3796 0000B863 31C0                <1> 	xor	eax, eax
  3797 0000B865 A2[58830100]        <1> 	mov	[copy_cmd_phase], al ; 0
  3798                              <1> 
  3799 0000B86A 8A15[5A830100]      <1> 	mov	dl, [DestinationFileFound]            
  3800 0000B870 8A35[8D820100]      <1> 	mov	dh, [SourceFile_DirEntry+11] ; Attributes
  3801                              <1>  
  3802                              <1> csftdf_return:	
  3803 0000B876 C3                  <1> 	retn
  3804                              <1> 
  3805                              <1> ; Phase 2
  3806                              <1> csftdf_ph2:
  3807                              <1> 	; 29/07/2022
  3808                              <1> csftdf2_check_cdrv:
  3809                              <1> 	; 18/03/2016
  3810                              <1> 	; Here, destination drive and directory are ready !
  3811                              <1> 	; (checking/restoring is not needed)
  3812                              <1> 	; (Since at the end of the phase 1)
  3813                              <1> 
  3814                              <1> ;	mov	dl, [DestinationFile_Drv]
  3815                              <1> ;	cmp	dl, [Current_Drv]
  3816                              <1> ;	je	short csftdf2_df_check_directory
  3817                              <1> ;
  3818                              <1> ;	call	change_current_drive
  3819                              <1> ;	jc	short csftdf2_read_error
  3820                              <1> ;
  3821                              <1> ;csftdf2_df_check_directory:
  3822                              <1> ;	mov	esi, DestinationFile_Directory  
  3823                              <1> ;	cmp	byte [esi], 20h
  3824                              <1> ;	jna	short csftdf2_df_check_found_or_not
  3825                              <1> ;
  3826                              <1> ;csftdf2_df_change_directory:
  3827                              <1> ;	inc	byte [Restore_CDIR]
  3828                              <1> ;	xor	ah, ah ; CD_COMMAND sign -> 0 
  3829                              <1> ;	call	change_current_directory
  3830                              <1> ;	jc	short csftdf2_stc_return
  3831                              <1> ;
  3832                              <1> ;;csftdf2_df_change_prompt_dir_string:
  3833                              <1> ;;	call	change_prompt_dir_string
  3834                              <1> 
  3835                              <1> csftdf2_df_check_found_or_not:
  3836                              <1> 	; 21/03/2016
  3837 0000B877 803D[5A830100]00    <1> 	cmp	byte [DestinationFileFound], 0 
  3838 0000B87E 773A                <1> 	ja	short csftdf2_set_sf_percentage
  3839                              <1> 
  3840                              <1> csftdf2_create_file:
  3841 0000B880 BE[F2820100]        <1> 	mov	esi, DestinationFile_Name
  3842 0000B885 A1[5C830100]        <1> 	mov	eax, [csftdf_filesize]
  3843 0000B88A 30C9                <1> 	xor	cl, cl ; 0
  3844                              <1> 
  3845 0000B88C 31DB                <1> 	xor	ebx, ebx ; 0
  3846 0000B88E 4B                  <1> 	dec	ebx ; 0FFFFFFFFh 
  3847                              <1> 
  3848                              <1> 	; INPUT ->
  3849                              <1> 	; 	EAX -> File Size
  3850                              <1> 	; 	ESI = ASCIIZ File name
  3851                              <1> 	;	 CL = File attributes
  3852                              <1> 	;	EBX = FFFFFFFFh -> empty file sign for FAT fs
  3853                              <1> 	;	EBX <> FFFFFFFFh -> use file size for FAT fs 
  3854                              <1> 	;
  3855                              <1> 	; OUTPUT ->
  3856                              <1> 	;	EAX = New file's first cluster
  3857                              <1> 	;	ESI = Logical Dos Drv Descr. Table Addr.
  3858                              <1> 	;	EBX = CreateFile_Size address
  3859                              <1> 	;	ECX = Sectors per cluster (<256)
  3860                              <1> 	;	EDX = Directory Entry Index/Number (<65536)
  3861                              <1> 	;		
  3862                              <1> 	;	cf = 1 -> error code in AL (EAX)
  3863                              <1> 
  3864 0000B88F E8EC050000          <1> 	call	create_file
  3865                              <1> 	;pop	esi
  3866                              <1> 	;jc	csftdf2_rw_error
  3867                              <1> 	; 29/07/2022
  3868 0000B894 7305                <1> 	jnc	short csftdf2_create_file_OK
  3869 0000B896 E9A3050000          <1> 	jmp	csftdf2_rw_error
  3870                              <1> 
  3871                              <1> csftdf2_create_file_OK:
  3872 0000B89B A3[6C830100]        <1> 	mov	[csftdf_df_cluster], eax
  3873                              <1> 	
  3874                              <1> 	; 24/03/2016
  3875 0000B8A0 668915[2A830100]    <1> 	mov	[DestinationFile_DirEntryNumber], dx 
  3876                              <1> 
  3877                              <1> 	; 21/03/2016
  3878 0000B8A7 BE00000800          <1> 	mov	esi, Directory_Buffer
  3879 0000B8AC C1E205              <1> 	shl	edx, 5 ; 32 * index number
  3880 0000B8AF 01D6                <1> 	add	esi, edx
  3881 0000B8B1 BF[02830100]        <1> 	mov	edi, DestinationFile_DirEntry	
  3882 0000B8B6 B108                <1> 	mov	cl, 8 ; 32 bytes
  3883 0000B8B8 F3A5                <1> 	rep	movsd
  3884                              <1> 
  3885                              <1> csftdf2_set_sf_percentage:
  3886                              <1> 	; 17/03/2016
  3887 0000B8BA 31C0                <1> 	xor	eax, eax	
  3888 0000B8BC A2[80830100]        <1> 	mov 	[csftdf_percentage], al ; 0, reset
  3889                              <1> 
  3890 0000B8C1 A3[78830100]        <1> 	mov	[csftdf_sf_rbytes], eax ; 0, reset
  3891 0000B8C6 A3[7C830100]        <1> 	mov	[csftdf_df_wbytes], eax ; 0, reset
  3892                              <1> 
  3893 0000B8CB 8A25[30820100]      <1> 	mov	ah, [SourceFile_Drv]	
  3894 0000B8D1 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3895 0000B8D6 01C6                <1> 	add	esi, eax
  3896                              <1> 	
  3897 0000B8D8 8935[84830100]      <1> 	mov	[csftdf_sf_drv_dt], esi ; 23/03/2016
  3898                              <1> 
  3899 0000B8DE 668B15[96820100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusHI]
  3900 0000B8E5 C1E210              <1> 	shl	edx, 16
  3901 0000B8E8 668B15[9C820100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusLO]
  3902 0000B8EF 8915[68830100]      <1> 	mov	[csftdf_sf_cluster], edx
  3903                              <1> 
  3904                              <1> 	; 16/03/2016
  3905                              <1> 	; Note: Singlix FS boot sector parameters (for cluster
  3906                              <1> 	;	related calculations) has same offset
  3907                              <1> 	;	values from LD_BPB as in FAT file system.
  3908                              <1> 	;	[esi+LD_BPB+SecPerClust] is 1 for Singlix FS.
  3909                              <1> 	;	
  3910 0000B8F5 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  3911 0000B8F9 880D[AE820100]      <1> 	mov	[SourceFile_SecPerClust], cl
  3912                              <1> 
  3913                              <1> 	; 17/03/2016
  3914 0000B8FF 386E03              <1> 	cmp	[esi+LD_FATType], ch ; 0
  3915 0000B902 7707                <1> 	ja	short csftdf2_set_sf_percent_rsize1
  3916                              <1> 
  3917 0000B904 B800000100          <1> 	mov	eax, 65536 ; read/write buffer size for Singlix FS
  3918 0000B909 EB06                <1> 	jmp	short csftdf2_set_sf_percent_rsize2	
  3919                              <1>  
  3920                              <1> csftdf2_set_sf_percent_rsize1:
  3921 0000B90B 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec]
  3922 0000B90F F7E1                <1> 	mul	ecx
  3923                              <1> 	;sub	edx, edx
  3924                              <1> csftdf2_set_sf_percent_rsize2:
  3925 0000B911 A3[70830100]        <1> 	mov	[csftdf_r_size], eax
  3926                              <1> 
  3927                              <1> csftdf2_set_df_percentage:
  3928                              <1> 	;sub	eax, eax
  3929                              <1> 	;mov	ah, [DestinationFile_Drv]	
  3930                              <1> 	;mov	edi, Logical_DOSDisks
  3931                              <1> 	;add	edi, eax
  3932                              <1> 	;mov	[csftdf_df_drv_dt], edi ; 17/03/2016
  3933                              <1> 
  3934 0000B916 8B3D[88830100]      <1> 	mov	edi, [csftdf_df_drv_dt] ; 23/03/2016
  3935                              <1> 
  3936                              <1> 	; 16/03/2016
  3937                              <1> 	; Note: Singlix FS boot sector parameters (for cluster
  3938                              <1> 	;	related calculations) has same offset
  3939                              <1> 	;	values from LD_BPB as in FAT file system.
  3940                              <1> 	;	[edi+LD_BPB+SecPerClust] is 1 for Singlix FS.
  3941                              <1> 	;	
  3942                              <1> 	;movzx	ecx, byte [edi+LD_BPB+SecPerClust]
  3943 0000B91C 8A4F13              <1> 	mov	cl, [edi+LD_BPB+SecPerClust]
  3944 0000B91F 880D[2E830100]      <1> 	mov	[DestinationFile_SecPerClust], cl
  3945                              <1> 
  3946                              <1> 	; 17/03/2016
  3947 0000B925 386F03              <1> 	cmp	[edi+LD_FATType], ch ; 0
  3948 0000B928 7707                <1> 	ja	short csftdf2_set_df_percent_wsize1
  3949                              <1> 	
  3950 0000B92A B800000100          <1> 	mov	eax, 65536 ; read/write buffer size for Singlix FS
  3951 0000B92F EB06                <1> 	jmp	short csftdf2_set_df_percent_wsize2	
  3952                              <1> 
  3953                              <1> csftdf2_set_df_percent_wsize1:
  3954 0000B931 0FB74711            <1> 	movzx	eax, word [edi+LD_BPB+BytesPerSec]
  3955 0000B935 F7E1                <1> 	mul	ecx
  3956                              <1> 	;sub	edx, edx
  3957                              <1> csftdf2_set_df_percent_wsize2:
  3958 0000B937 A3[74830100]        <1> 	mov	[csftdf_w_size], eax
  3959                              <1> 
  3960 0000B93C A1[5C830100]        <1> 	mov	eax, [csftdf_filesize]
  3961                              <1> 
  3962 0000B941 3D00000100          <1> 	cmp	eax, 65536 ; 64KB	; small file
  3963 0000B946 721F                <1> 	jb	short csftdf2_load_file ; do not display percentage
  3964                              <1> 	
  3965                              <1> csftdf2_reset_wf_percent_ptr_chk_64k:
  3966 0000B948 B201                <1> 	mov	dl, 1 ; 25/03/2016
  3967                              <1> 
  3968 0000B94A 3D00000400          <1> 	cmp	eax, 65536*4 ; 256KB
  3969 0000B94F 7310                <1> 	jnb	short csftdf2_enable_percentage_display ; big file
  3970                              <1> 
  3971                              <1> 	; 64-128KB file size for floppy disks
  3972 0000B951 3815[30820100]      <1> 	cmp	byte [SourceFile_Drv], dl ; 1 ; read from floppy disk ?
  3973 0000B957 7608                <1> 	jna	short csftdf2_enable_percentage_display
  3974                              <1> 
  3975 0000B959 3815[B0820100]      <1> 	cmp	byte [DestinationFile_Drv], dl ; 1 ; write to floppy disk ?
  3976 0000B95F 7706                <1> 	ja	short csftdf2_load_file
  3977                              <1> 
  3978                              <1> csftdf2_enable_percentage_display:	
  3979 0000B961 8815[80830100]      <1> 	mov	[csftdf_percentage], dl ; 1	
  3980                              <1> 	
  3981                              <1> csftdf2_load_file:
  3982                              <1> 	; 13/05/2016
  3983                              <1> 	; 19/03/2016
  3984                              <1> 	; 18/03/2016
  3985                              <1> 	; 17/03/2016
  3986 0000B967 B40F                <1> 	mov	ah, 0Fh
  3987 0000B969 E8A25DFFFF          <1> 	call	_int10h
  3988                              <1> 	; 13/05/2016
  3989 0000B96E 883D[81830100]      <1> 	mov	[csftdf_videopage], bh ; active video page
  3990 0000B974 B403                <1> 	mov	ah, 03h
  3991 0000B976 E8955DFFFF          <1> 	call	_int10h
  3992 0000B97B 668915[82830100]    <1> 	mov	[csftdf_cursorpos], dx
  3993                              <1> 
  3994 0000B982 29C0                <1> 	sub	eax, eax
  3995 0000B984 A2[59830100]        <1> 	mov	[csftdf_rw_err], al ; 0 
  3996                              <1> 
  3997                              <1> ; ///
  3998                              <1> csftdf_sf_amb: ; 15/03/2016
  3999 0000B989 8B0D[5C830100]      <1> 	mov	ecx, [csftdf_filesize]	; 23/03/2016
  4000                              <1> 
  4001                              <1> 	; TRDOS 386 (TRDOS v2.0)
  4002                              <1> 	; Allocate contiguous memory block for loading the file
  4003                              <1> 	
  4004                              <1> 	;mov	ecx, [SourceFile_DirEntry+DirEntry_FileSize]
  4005                              <1> 	
  4006                              <1> 	;sub	eax, eax ; First free memory aperture
  4007                              <1> 	
  4008                              <1> 	; eax = 0 (Allocate memory from the beginning)
  4009                              <1> 	; ecx = File (Allocation) size in bytes
  4010                              <1> 	
  4011 0000B98F E858A2FFFF          <1> 	call	allocate_memory_block
  4012 0000B994 7304                <1> 	jnc	short loc_check_sf_save_loading_parms
  4013                              <1> 
  4014 0000B996 29C0                <1> 	sub	eax, eax
  4015 0000B998 29C9                <1> 	sub	ecx, ecx
  4016                              <1> 	
  4017                              <1> loc_check_sf_save_loading_parms:
  4018 0000B99A A3[60830100]        <1> 	mov	[csftdf_sf_mem_addr], eax ; loading address
  4019 0000B99F 890D[64830100]      <1> 	mov	[csftdf_sf_mem_bsize], ecx ; block size
  4020                              <1> ; ///   
  4021                              <1> 	; 19/03/2016
  4022 0000B9A5 8B35[84830100]      <1> 	mov	esi, [csftdf_sf_drv_dt] ; logical dos drv desc. tbl.
  4023                              <1> 
  4024                              <1> 	; 17/03/2016
  4025 0000B9AB 09C0                <1> 	or	eax, eax ; contiguous free memory block address 
  4026                              <1> 	;jz	csftdf2_read_sf_cluster
  4027                              <1> 	; 29/07/2022
  4028 0000B9AD 7505                <1> 	jnz	short csftdf2_1
  4029 0000B9AF E95E010000          <1> 	jmp	csftdf2_read_sf_cluster
  4030                              <1> 
  4031                              <1> csftdf2_1:
  4032                              <1> 	; 18/03/2016
  4033 0000B9B4 8B1D[60830100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  4034                              <1> 
  4035 0000B9BA 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  4036                              <1>         ;jna	csftdf2_load_fs_file
  4037                              <1> 	; 29/07/2022
  4038 0000B9BE 7705                <1> 	ja	short csftdf2_load_fat_file
  4039 0000B9C0 E900020000          <1> 	jmp	csftdf2_load_fs_file
  4040                              <1> 
  4041                              <1> csftdf2_load_fat_file:
  4042 0000B9C5 53                  <1> 	push	ebx ; *
  4043                              <1> 
  4044                              <1> csftdf2_load_fat_file_next:
  4045 0000B9C6 BE[E9360100]        <1> 	mov	esi, msg_reading
  4046 0000B9CB E88AB2FFFF          <1> 	call	print_msg
  4047                              <1> 
  4048 0000B9D0 803D[80830100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4049 0000B9D7 7605                <1> 	jna	short csftdf2_load_fat_file_1
  4050                              <1> 	
  4051 0000B9D9 E87E000000          <1> 	call	csftdf2_print_percentage ; 19/03/2016
  4052                              <1> 
  4053                              <1> csftdf2_load_fat_file_1:
  4054 0000B9DE 8B35[84830100]      <1> 	mov	esi, [csftdf_sf_drv_dt]	
  4055 0000B9E4 5B                  <1> 	pop	ebx ; *
  4056                              <1> 
  4057                              <1> csftdf2_load_fat_file_2:
  4058 0000B9E5 E8BA000000          <1> 	call	csftdf2_read_fat_file_sectors ; 19/03/2016
  4059                              <1> 	;jc	csftdf2_rw_error ; eocc! or disk error! 
  4060                              <1> 	; 29/07/2022
  4061 0000B9EA 7305                <1> 	jnc	short csftdf2_load_fat_file_3 
  4062 0000B9EC E94D040000          <1> 	jmp	csftdf2_rw_error
  4063                              <1> csftdf2_load_fat_file_3:
  4064 0000B9F1 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  4065 0000B9F3 7520                <1> 	jnz	short csftdf2_load_fat_file_ok
  4066                              <1> 
  4067 0000B9F5 803D[80830100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4068 0000B9FC 76E7                <1> 	jna	short csftdf2_load_fat_file_2
  4069                              <1> 
  4070 0000B9FE 53                  <1> 	push	ebx ; *	
  4071                              <1> 
  4072                              <1> 	; Set cursor position
  4073                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  4074 0000B9FF 8A3D[81830100]      <1> 	mov	bh, [csftdf_videopage]
  4075 0000BA05 668B15[82830100]    <1> 	mov	dx, [csftdf_cursorpos]
  4076 0000BA0C B402                <1> 	mov	ah, 2
  4077 0000BA0E E8FD5CFFFF          <1> 	call	_int10h
  4078 0000BA13 EBB1                <1> 	jmp	short csftdf2_load_fat_file_next
  4079                              <1> 	
  4080                              <1> csftdf2_load_fat_file_ok:
  4081 0000BA15 803D[80830100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4082                              <1> 	;jna	csftdf2_save_file ; 25/03/2016
  4083                              <1> 	; 29/07/2022
  4084 0000BA1C 7705                <1> 	ja	short csftdf2_2
  4085 0000BA1E E94B020000          <1> 	jmp	csftdf2_save_file
  4086                              <1> csftdf2_2:	
  4087                              <1> 	; "Reading... 100%"
  4088 0000BA23 BF[01370100]        <1> 	mov	edi, percentagestr
  4089 0000BA28 B031                <1> 	mov	al, '1'
  4090 0000BA2A AA                  <1> 	stosb
  4091 0000BA2B B030                <1> 	mov	al, '0'
  4092 0000BA2D AA                  <1> 	stosb
  4093 0000BA2E AA                  <1> 	stosb
  4094                              <1> 
  4095 0000BA2F 8A3D[81830100]      <1> 	mov	bh, [csftdf_videopage]
  4096 0000BA35 668B15[82830100]    <1> 	mov	dx, [csftdf_cursorpos]
  4097 0000BA3C B402                <1> 	mov	ah, 2
  4098 0000BA3E E8CD5CFFFF          <1> 	call	_int10h
  4099                              <1> 
  4100 0000BA43 BE[E9360100]        <1> 	mov	esi, msg_reading
  4101 0000BA48 E80DB2FFFF          <1> 	call	print_msg
  4102                              <1> 	
  4103 0000BA4D BE[01370100]        <1> 	mov	esi, percentagestr
  4104 0000BA52 E803B2FFFF          <1> 	call	print_msg
  4105                              <1> 
  4106 0000BA57 E912020000          <1>         jmp     csftdf2_save_file ; 25/03/2016
  4107                              <1> 
  4108                              <1> csftdf2_print_percentage:
  4109                              <1> 	; 09/12/2017
  4110                              <1> 	; 19/03/2016
  4111                              <1> 	; 18/03/2016
  4112 0000BA5C B020                <1> 	mov	al, 20h
  4113 0000BA5E BF[01370100]        <1> 	mov	edi, percentagestr
  4114 0000BA63 AA                  <1> 	stosb
  4115 0000BA64 AA                  <1> 	stosb
  4116 0000BA65 A1[78830100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  4117                              <1> 	;mov	edx, 100
  4118                              <1> 	; 29/07/2022
  4119 0000BA6A 29D2                <1> 	sub	edx, edx
  4120 0000BA6C B264                <1> 	mov	dl, 100
  4121 0000BA6E F7E2                <1> 	mul	edx
  4122 0000BA70 8B0D[5C830100]      <1> 	mov	ecx, [csftdf_filesize]	
  4123 0000BA76 F7F1                <1> 	div	ecx
  4124 0000BA78 B10A                <1> 	mov	cl, 10
  4125 0000BA7A F6F1                <1> 	div	cl
  4126 0000BA7C 80C430              <1> 	add	ah, '0'
  4127 0000BA7F 8827                <1> 	mov	[edi], ah
  4128 0000BA81 20C0                <1> 	and	al, al
  4129 0000BA83 740A                <1> 	jz	short csftdf2_print_percent_1
  4130 0000BA85 4F                  <1> 	dec	edi
  4131                              <1> 	;cbw
  4132 0000BA86 28E4                <1> 	sub	ah, ah ; 09/12/2017
  4133 0000BA88 F6F1                <1> 	div	cl
  4134 0000BA8A 80C430              <1> 	add	ah, '0'
  4135 0000BA8D 8827                <1> 	mov	[edi], ah
  4136                              <1> 	;and	al, al
  4137                              <1> 	;jz	short csftdf2_print_percent_1
  4138                              <1> 	;dec	edi
  4139                              <1> 	;mov	[edi], '1' ; 100%		
  4140                              <1> 
  4141                              <1> csftdf2_print_percent_1:
  4142 0000BA8F BE[01370100]        <1> 	mov	esi, percentagestr
  4143                              <1> 	;call	print_msg
  4144                              <1> 	;retn
  4145 0000BA94 E9C1B1FFFF          <1> 	jmp	print_msg
  4146                              <1> 
  4147                              <1> csftdf2_read_file_sectors:
  4148                              <1> 	; 19/03/2016
  4149 0000BA99 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  4150                              <1> 	;jna	csftdf2_read_fs_file_sectors
  4151                              <1> 	; 29/07/2022
  4152 0000BA9D 7705                <1> 	ja	short csftdf2_read_fat_file_sectors
  4153 0000BA9F E912070000          <1> 	jmp	csftdf2_read_fs_file_sectors
  4154                              <1> 
  4155                              <1> csftdf2_read_fat_file_sectors:
  4156                              <1> 	; 19/03/2016
  4157                              <1> 	; 18/03/2016
  4158                              <1> 	; return:
  4159                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  4160                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  4161                              <1> 	;   CF = 1 -> read error (error code in AL)	
  4162                              <1> 
  4163                              <1> csftdf2_read_fat_file_secs_0:
  4164 0000BAA4 8B15[5C830100]      <1> 	mov	edx, [csftdf_filesize]
  4165 0000BAAA 2B15[78830100]      <1> 	sub	edx, [csftdf_sf_rbytes]
  4166 0000BAB0 3B15[70830100]      <1> 	cmp	edx, [csftdf_r_size]	
  4167 0000BAB6 7306                <1> 	jnb	short csftdf2_read_fat_file_secs_1
  4168 0000BAB8 8915[70830100]      <1> 	mov	[csftdf_r_size], edx
  4169                              <1> 		
  4170                              <1> csftdf2_read_fat_file_secs_1:
  4171 0000BABE A1[70830100]        <1> 	mov	eax, [csftdf_r_size]
  4172 0000BAC3 29D2                <1> 	sub	edx, edx
  4173 0000BAC5 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  4174 0000BAC9 01C8                <1> 	add	eax, ecx
  4175 0000BACB 48                  <1> 	dec	eax
  4176 0000BACC F7F1                <1> 	div	ecx
  4177 0000BACE 89C1                <1> 	mov	ecx, eax ; sector count
  4178 0000BAD0 A1[68830100]        <1> 	mov	eax, [csftdf_sf_cluster]
  4179                              <1> 
  4180                              <1> 	; EBX = memory block address (current)
  4181                              <1> 	
  4182 0000BAD5 E8DD080000          <1> 	call	read_fat_file_sectors
  4183 0000BADA 7235                <1> 	jc	short csftdf2_read_fat_file_secs_3
  4184                              <1> 
  4185                              <1> 	; EBX = next memory address
  4186                              <1> 
  4187 0000BADC A1[78830100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  4188 0000BAE1 0305[70830100]      <1> 	add	eax, [csftdf_r_size]
  4189 0000BAE7 8B15[5C830100]      <1> 	mov	edx, [csftdf_filesize]
  4190 0000BAED 39D0                <1> 	cmp	eax, edx
  4191 0000BAEF 7320                <1> 	jnb	short csftdf2_read_fat_file_secs_3 ; edx > 0
  4192 0000BAF1 A3[78830100]        <1> 	mov	[csftdf_sf_rbytes], eax
  4193                              <1> 
  4194 0000BAF6 53                  <1> 	push	ebx ; *
  4195                              <1> 	; get next cluster (csftdf_r_size! bytes)
  4196 0000BAF7 A1[68830100]        <1> 	mov	eax, [csftdf_sf_cluster]
  4197 0000BAFC E8B6060000          <1> 	call	get_next_cluster
  4198 0000BB01 5B                  <1> 	pop	ebx ; *
  4199 0000BB02 7306                <1> 	jnc	short csftdf2_read_fat_file_secs_2
  4200                              <1> 
  4201                              <1> 	; 15/10/2016
  4202                              <1> 	;Disk read error instad of drv not ready err
  4203 0000BB04 B811000000          <1> 	mov	eax, 17 ; Read error !
  4204 0000BB09 C3                  <1> 	retn
  4205                              <1> 
  4206                              <1> csftdf2_read_fat_file_secs_2:
  4207 0000BB0A 29D2                <1> 	sub	edx, edx ; 0
  4208 0000BB0C A3[68830100]        <1> 	mov	[csftdf_sf_cluster], eax ; next cluster
  4209                              <1> 
  4210                              <1> csftdf2_read_fat_file_secs_3:
  4211 0000BB11 C3                  <1> 	retn
  4212                              <1> 
  4213                              <1> csftdf2_read_sf_cluster:
  4214                              <1> 	; 19/03/2016
  4215 0000BB12 BB00000700          <1> 	mov	ebx, Cluster_Buffer ; buffer address (64KB)
  4216                              <1> 
  4217 0000BB17 803D[80830100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4218 0000BB1E 760D                <1> 	jna	short csftdf2_read_sf_clust_2
  4219                              <1> 
  4220 0000BB20 53                  <1> 	push	ebx ; *	
  4221                              <1> 
  4222                              <1> csftdf2_read_sf_clust_next:
  4223 0000BB21 E836FFFFFF          <1> 	call	csftdf2_print_percentage
  4224                              <1> 
  4225                              <1> csftdf2_read_sf_clust_0:
  4226 0000BB26 8B35[84830100]      <1> 	mov	esi, [csftdf_sf_drv_dt]	
  4227                              <1> csftdf2_read_sf_clust_1:
  4228 0000BB2C 5B                  <1> 	pop	ebx ; *
  4229                              <1> 
  4230                              <1> csftdf2_read_sf_clust_2:
  4231 0000BB2D 89DA                <1> 	mov	edx, ebx
  4232 0000BB2F 0315[70830100]      <1> 	add	edx, [csftdf_r_size]
  4233 0000BB35 81FA00000800        <1> 	cmp	edx, Cluster_Buffer + 65536
  4234 0000BB3B 772B                <1> 	ja	short csftdf2_write_df_cluster
  4235                              <1> 
  4236 0000BB3D E857FFFFFF          <1> 	call	csftdf2_read_file_sectors ; 19/03/2016
  4237                              <1> 	;jc	csftdf2_save_fat_file_err2 ; eocc! or disk error! 
  4238                              <1> 	; 29/07/2022
  4239 0000BB42 7236                <1> 	jc	short csftdf2_3
  4240                              <1> 
  4241 0000BB44 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  4242 0000BB46 7520                <1> 	jnz	short csftdf2_write_df_cluster
  4243                              <1> 
  4244 0000BB48 803D[80830100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4245 0000BB4F 76DC                <1> 	jna	short csftdf2_read_sf_clust_2
  4246                              <1> 
  4247 0000BB51 53                  <1> 	push	ebx ; *	
  4248                              <1> 
  4249                              <1> 	; Set cursor position
  4250                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  4251 0000BB52 8A3D[81830100]      <1> 	mov	bh, [csftdf_videopage]
  4252 0000BB58 668B15[82830100]    <1> 	mov	dx, [csftdf_cursorpos]
  4253 0000BB5F B402                <1> 	mov	ah, 2
  4254 0000BB61 E8AA5BFFFF          <1> 	call	_int10h
  4255 0000BB66 EBB9                <1> 	jmp	short csftdf2_read_sf_clust_next
  4256                              <1> 
  4257                              <1> csftdf2_write_df_cluster:
  4258                              <1> 	; 19/03/2016
  4259 0000BB68 8B35[88830100]      <1> 	mov	esi, [csftdf_df_drv_dt]	
  4260 0000BB6E BB00000700          <1> 	mov	ebx, Cluster_Buffer ; buffer address (64KB)
  4261                              <1> 
  4262                              <1> csftdf2_write_df_clust_next:
  4263 0000BB73 E852000000          <1> 	call	csftdf2_write_file_sectors ; 19/03/2016
  4264                              <1> 	;jc	csftdf2_save_fat_file_err2 ; eocc! or disk error! 
  4265                              <1> 	; 29/07/2022
  4266 0000BB78 7305                <1> 	jnc	short csftdf2_4
  4267                              <1> csftdf2_3:
  4268 0000BB7A E946020000          <1> 	jmp	csftdf2_save_fat_file_err2
  4269                              <1> csftdf2_4:
  4270 0000BB7F 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  4271 0000BB81 750A                <1> 	jnz	short csftdf2_rw_f_clust_ok
  4272                              <1> 
  4273 0000BB83 81FB00000800        <1> 	cmp	ebx, Cluster_Buffer + 65536
  4274 0000BB89 72E8                <1> 	jb	short csftdf2_write_df_clust_next
  4275                              <1> 	
  4276 0000BB8B EB85                <1> 	jmp	short csftdf2_read_sf_cluster
  4277                              <1>  
  4278                              <1> csftdf2_rw_f_clust_ok:
  4279 0000BB8D 803D[80830100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4280                              <1> 	;jna	csftdf2_save_fat_file_4 ; 25/03/2016
  4281                              <1> 	; 29/07/2022
  4282 0000BB94 762A                <1> 	jna	short csftdf2_5
  4283                              <1> 
  4284                              <1> 	; "100%"
  4285 0000BB96 BF[01370100]        <1> 	mov	edi, percentagestr
  4286 0000BB9B B031                <1> 	mov	al, '1'
  4287 0000BB9D AA                  <1> 	stosb
  4288 0000BB9E B030                <1> 	mov	al, '0'
  4289 0000BBA0 AA                  <1> 	stosb
  4290 0000BBA1 AA                  <1> 	stosb
  4291                              <1> 
  4292 0000BBA2 8A3D[81830100]      <1> 	mov	bh, [csftdf_videopage]
  4293 0000BBA8 668B15[82830100]    <1> 	mov	dx, [csftdf_cursorpos]
  4294 0000BBAF B402                <1> 	mov	ah, 2
  4295 0000BBB1 E85A5BFFFF          <1> 	call	_int10h
  4296                              <1> 
  4297 0000BBB6 BE[01370100]        <1> 	mov	esi, percentagestr
  4298 0000BBBB E89AB0FFFF          <1> 	call	print_msg
  4299                              <1> csftdf2_5:
  4300 0000BBC0 E987010000          <1>         jmp     csftdf2_save_fat_file_4
  4301                              <1> 
  4302                              <1> csftdf2_load_fs_file:
  4303                              <1> 	; temporary - 18/03/2016
  4304 0000BBC5 E972020000          <1>         jmp     csftdf2_read_error
  4305                              <1> 
  4306                              <1> csftdf2_write_file_sectors:
  4307                              <1> 	; 19/03/2016
  4308 0000BBCA 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  4309                              <1> 	;jna	csftdf2_write_fs_file_sectors
  4310                              <1> 	; 29/07/2022
  4311 0000BBCE 7705                <1> 	ja	short csftdf2_write_fat_file_sectors
  4312 0000BBD0 E9E1050000          <1> 	jmp	csftdf2_write_fs_file_sectors
  4313                              <1> 
  4314                              <1> csftdf2_write_fat_file_sectors:
  4315                              <1> 	; 19/03/2016
  4316                              <1> 	; 18/03/2016
  4317                              <1> 	; return:
  4318                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  4319                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  4320                              <1> 	;   CF = 1 -> write error (error code in AL)	
  4321                              <1> 
  4322                              <1> csftdf2_write_fat_file_secs_0:
  4323 0000BBD5 8B15[5C830100]      <1> 	mov	edx, [csftdf_filesize]
  4324 0000BBDB 2B15[7C830100]      <1> 	sub	edx, [csftdf_df_wbytes]
  4325 0000BBE1 3B15[74830100]      <1> 	cmp	edx, [csftdf_w_size]	
  4326 0000BBE7 7306                <1> 	jnb	short csftdf2_write_fat_file_secs_1
  4327 0000BBE9 8915[74830100]      <1> 	mov	[csftdf_w_size], edx		
  4328                              <1> 
  4329                              <1> csftdf2_write_fat_file_secs_1:
  4330 0000BBEF A1[74830100]        <1> 	mov	eax, [csftdf_w_size]
  4331 0000BBF4 29D2                <1> 	sub	edx, edx
  4332 0000BBF6 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  4333 0000BBFA 01C8                <1> 	add	eax, ecx
  4334 0000BBFC 48                  <1> 	dec	eax
  4335 0000BBFD F7F1                <1> 	div	ecx
  4336 0000BBFF 89C1                <1> 	mov	ecx, eax ; sector count
  4337 0000BC01 A1[6C830100]        <1> 	mov	eax, [csftdf_df_cluster]
  4338                              <1> 
  4339                              <1> 	; EBX = memory block address (current)	
  4340                              <1> 
  4341 0000BC06 E80A0F0000          <1> 	call	write_fat_file_sectors
  4342 0000BC0B 7259                <1> 	jc	short csftdf2_write_fat_file_secs_4
  4343                              <1> 
  4344                              <1> 	; EBX = next memory address
  4345                              <1> 
  4346 0000BC0D A1[7C830100]        <1> 	mov	eax, [csftdf_df_wbytes]
  4347 0000BC12 0305[74830100]      <1> 	add	eax, [csftdf_w_size]
  4348 0000BC18 8B15[5C830100]      <1> 	mov	edx, [csftdf_filesize]
  4349 0000BC1E 39D0                <1> 	cmp	eax, edx
  4350 0000BC20 7344                <1> 	jnb	short csftdf2_write_fat_file_secs_4
  4351 0000BC22 A3[7C830100]        <1> 	mov	[csftdf_df_wbytes], eax
  4352                              <1> 	;
  4353 0000BC27 A3[1E830100]        <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], eax
  4354                              <1> 
  4355 0000BC2C 53                  <1> 	push	ebx ; *
  4356                              <1> 
  4357 0000BC2D 803D[5A830100]01    <1> 	cmp	byte [DestinationFileFound], 1
  4358 0000BC34 7210                <1> 	jb	short csftdf2_write_fat_file_secs_2
  4359                              <1> 
  4360                              <1> 	; get next cluster (csftdf_w_size! bytes)
  4361 0000BC36 A1[6C830100]        <1> 	mov	eax, [csftdf_df_cluster]
  4362 0000BC3B E877050000          <1> 	call	get_next_cluster
  4363 0000BC40 731C                <1> 	jnc	short csftdf2_write_fat_file_secs_3
  4364                              <1> 
  4365 0000BC42 21C0                <1> 	and	eax, eax ; end of cluster chain!?
  4366 0000BC44 7521                <1> 	jnz	short csftdf2_write_fat_file_secs_5 ; disk error !
  4367                              <1> 
  4368                              <1> csftdf2_write_fat_file_secs_2:
  4369 0000BC46 A1[6C830100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  4370 0000BC4B E8F30D0000          <1> 	call	add_new_cluster		
  4371 0000BC50 7215                <1> 	jc	short csftdf2_write_fat_file_secs_5
  4372                              <1> 
  4373                              <1> 	; NOTE: Destination file size may be bigger than
  4374                              <1> 	; source file size when the last reading fails after here.
  4375                              <1> 	; (The last -empty- cluster of destination file must be 
  4376                              <1> 	; truncated and LMDT must be current date&time for partial
  4377                              <1> 	; copy result!) 
  4378 0000BC52 8B15[74830100]      <1> 	mov	edx, [csftdf_w_size] ; bytes per cluster
  4379 0000BC58 0115[1E830100]      <1> 	add	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  4380                              <1> 
  4381                              <1> csftdf2_write_fat_file_secs_3:
  4382 0000BC5E 5B                  <1> 	pop	ebx ; *
  4383 0000BC5F 29D2                <1> 	sub	edx, edx ; 0
  4384 0000BC61 A3[6C830100]        <1> 	mov	[csftdf_df_cluster], eax ; next cluster
  4385                              <1> 
  4386                              <1> csftdf2_write_fat_file_secs_4:
  4387 0000BC66 C3                  <1> 	retn
  4388                              <1> 
  4389                              <1> csftdf2_write_fat_file_secs_5:
  4390 0000BC67 5B                  <1> 	pop	ebx ; *
  4391                              <1> 	; 16/10/2016 (1Dh -> 18)
  4392 0000BC68 B812000000          <1> 	mov	eax, 18 ; Write error !
  4393 0000BC6D C3                  <1> 	retn
  4394                              <1> 
  4395                              <1> csftdf2_save_file:
  4396                              <1> 	; 09/12/2017
  4397                              <1> 	; 25/03/2016
  4398                              <1> 	; 19/03/2016
  4399                              <1> 	; 18/03/2016
  4400 0000BC6E 8B35[88830100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; logical dos drv desc. tbl.
  4401                              <1> 
  4402 0000BC74 8B1D[60830100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  4403                              <1> 
  4404 0000BC7A 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  4405                              <1> 	;jna	csftdf2_save_fs_file
  4406                              <1> 	; 29/07/2022	
  4407 0000BC7E 7705                <1> 	ja	short csftdf2_save_fat_file
  4408 0000BC80 E9F5010000          <1> 	jmp	csftdf2_save_fs_file
  4409                              <1> 
  4410                              <1> csftdf2_save_fat_file:
  4411 0000BC85 53                  <1> 	push	ebx; *
  4412                              <1> 
  4413 0000BC86 803D[80830100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4414 0000BC8D 7724                <1> 	ja	short csftdf2_save_fat_file_0
  4415                              <1> 
  4416                              <1> 	; Set cursor position
  4417                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  4418 0000BC8F 8A3D[81830100]      <1> 	mov	bh, [csftdf_videopage]
  4419 0000BC95 668B15[82830100]    <1> 	mov	dx, [csftdf_cursorpos]
  4420 0000BC9C B402                <1> 	mov	ah, 2
  4421 0000BC9E E86D5AFFFF          <1> 	call	_int10h
  4422                              <1> 	
  4423 0000BCA3 BE[F5360100]        <1> 	mov	esi, msg_writing
  4424 0000BCA8 E8ADAFFFFF          <1> 	call	print_msg
  4425                              <1> 
  4426                              <1> csftdf2_save_fat_file_next:
  4427 0000BCAD 8B35[88830100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 25/03/2016
  4428                              <1> 
  4429                              <1> csftdf2_save_fat_file_0:
  4430 0000BCB3 5B                  <1> 	pop	ebx ; *
  4431                              <1> 
  4432                              <1> csftdf2_save_fat_file_1:
  4433 0000BCB4 E811FFFFFF          <1> 	call	csftdf2_write_file_sectors ; 19/03/2016	
  4434                              <1> 	;jc	csftdf2_rw_error ; eocc! or disk error! 
  4435                              <1> 	; 29/07/2022
  4436 0000BCB9 7305                <1> 	jnc	short csftdf2_6
  4437 0000BCBB E97E010000          <1> 	jmp	csftdf2_rw_error
  4438                              <1> 
  4439                              <1> csftdf2_6:
  4440 0000BCC0 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  4441 0000BCC2 756C                <1>         jnz     short csftdf2_save_fat_file_3 ; 25/03/2016
  4442                              <1> 
  4443 0000BCC4 803D[80830100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4444 0000BCCB 76E7                <1> 	jna	short csftdf2_save_fat_file_1
  4445                              <1> 
  4446 0000BCCD B020                <1> 	mov	al, 20h
  4447 0000BCCF BF[01370100]        <1> 	mov	edi, percentagestr
  4448 0000BCD4 AA                  <1> 	stosb
  4449 0000BCD5 AA                  <1> 	stosb
  4450 0000BCD6 A1[7C830100]        <1> 	mov	eax, [csftdf_df_wbytes]
  4451                              <1> 	;mov	edx, 100
  4452                              <1> 	; 29/07/2022
  4453 0000BCDB 31D2                <1> 	xor	edx, edx
  4454 0000BCDD B264                <1> 	mov	dl, 100
  4455 0000BCDF F7E2                <1> 	mul	edx
  4456 0000BCE1 8B0D[5C830100]      <1> 	mov	ecx, [csftdf_filesize]	
  4457 0000BCE7 F7F1                <1> 	div	ecx
  4458 0000BCE9 B10A                <1> 	mov	cl, 10
  4459 0000BCEB F6F1                <1> 	div	cl
  4460 0000BCED 80C430              <1> 	add	ah, '0'
  4461 0000BCF0 8827                <1> 	mov	[edi], ah
  4462 0000BCF2 20C0                <1> 	and	al, al
  4463 0000BCF4 740A                <1> 	jz	short csftdf2_save_fat_file_2
  4464 0000BCF6 4F                  <1> 	dec	edi
  4465                              <1> 	;cbw
  4466 0000BCF7 30E4                <1> 	xor	ah, ah ; 09/12/2017
  4467 0000BCF9 F6F1                <1> 	div	cl
  4468 0000BCFB 80C430              <1> 	add	ah, '0'
  4469 0000BCFE 8827                <1> 	mov	[edi], ah
  4470                              <1> 	;and	al, al
  4471                              <1> 	;jz	short csftdf2_save_fat_file_2
  4472                              <1> 	;dec	edi
  4473                              <1> 	;mov	[edi], '1' ; 100%		
  4474                              <1> 
  4475                              <1> csftdf2_save_fat_file_2:
  4476 0000BD00 53                  <1> 	push	ebx ; *
  4477                              <1> 
  4478 0000BD01 E802000000          <1> 	call	csftdf2_print_wr_percentage ; 25/03/2016
  4479                              <1> 
  4480 0000BD06 EBA5                <1>         jmp     csftdf2_save_fat_file_next
  4481                              <1> 
  4482                              <1> csftdf2_print_wr_percentage:
  4483                              <1> 	; Set cursor position
  4484                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  4485 0000BD08 8A3D[81830100]      <1> 	mov	bh, [csftdf_videopage]
  4486 0000BD0E 668B15[82830100]    <1> 	mov	dx, [csftdf_cursorpos]
  4487 0000BD15 B402                <1> 	mov	ah, 2
  4488 0000BD17 E8F459FFFF          <1> 	call	_int10h
  4489                              <1> 
  4490 0000BD1C BE[F5360100]        <1> 	mov	esi, msg_writing
  4491 0000BD21 E834AFFFFF          <1> 	call	print_msg
  4492                              <1> 
  4493 0000BD26 BE[01370100]        <1> 	mov	esi, percentagestr
  4494                              <1> 	;call	print_msg
  4495                              <1> 	;retn
  4496 0000BD2B E92AAFFFFF          <1> 	jmp	print_msg
  4497                              <1> 
  4498                              <1> csftdf2_save_fat_file_3:
  4499 0000BD30 803D[80830100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4500                              <1>         ;jna	csftdf2_save_fat_file_4 ; 25/03/2016
  4501                              <1> 	; 29/07/2022
  4502 0000BD37 7702                <1> 	ja	short csftdf2_7
  4503 0000BD39 EB11                <1> 	jmp	csftdf2_save_fat_file_4
  4504                              <1> 
  4505                              <1> csftdf2_7:
  4506                              <1> 	; "100%"
  4507 0000BD3B BF[01370100]        <1> 	mov	edi, percentagestr
  4508 0000BD40 B031                <1> 	mov	al, '1'
  4509 0000BD42 AA                  <1> 	stosb
  4510 0000BD43 B030                <1> 	mov	al, '0'
  4511 0000BD45 AA                  <1> 	stosb
  4512 0000BD46 AA                  <1> 	stosb
  4513                              <1> 
  4514 0000BD47 E8BCFFFFFF          <1> 	call	csftdf2_print_wr_percentage
  4515                              <1> 
  4516                              <1> csftdf2_save_fat_file_4:
  4517 0000BD4C 803D[5A830100]00    <1> 	cmp	byte [DestinationFileFound], 0
  4518 0000BD53 7647                <1> 	jna	short csftdf2_save_fat_file_6
  4519                              <1> 
  4520 0000BD55 8B35[88830100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 31/03/2016	
  4521                              <1> 
  4522 0000BD5B A1[6C830100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  4523 0000BD60 E852040000          <1> 	call	get_next_cluster
  4524 0000BD65 7235                <1> 	jc	short csftdf2_save_fat_file_6 ; eocc! or disk error!
  4525                              <1> 
  4526 0000BD67 A1[6C830100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  4527                              <1> 	;xor	ecx, ecx
  4528                              <1> 	;mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  4529                              <1> 	;dec	ecx ; 0FFFFFFFFh
  4530                              <1> 	;shr	ecx, 4 ; 28 bit ; 0FFFFFFFh
  4531 0000BD6C B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh
  4532 0000BD71 E830070000          <1> 	call	update_cluster
  4533 0000BD76 7224                <1> 	jc	short csftdf2_save_fat_file_6 ; really last cluster!?
  4534                              <1> 
  4535 0000BD78 A3[6C830100]        <1> 	mov	[csftdf_df_cluster], eax ; next cluster
  4536                              <1> 	
  4537                              <1> 	; byte [FAT_BuffValidData] = 2 
  4538 0000BD7D E8A7090000          <1> 	call	save_fat_buffer
  4539 0000BD82 730E                <1> 	jnc	short csftdf2_save_fat_file_5
  4540                              <1> 	
  4541 0000BD84 8B15[5C830100]      <1> 	mov	edx, [csftdf_filesize]
  4542 0000BD8A 8915[1E830100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  4543 0000BD90 EB58                <1> 	jmp	short csftdf2_save_fat_file_err3
  4544                              <1> 
  4545                              <1> csftdf2_save_fat_file_5:
  4546 0000BD92 A1[6C830100]        <1> 	mov	eax, [csftdf_df_cluster]
  4547                              <1> 
  4548                              <1> 	; EAX = First cluster to be truncated/unlinked
  4549                              <1> 	; ESI = Logical dos drive description table address
  4550 0000BD97 E8CB0B0000          <1> 	call	truncate_cluster_chain
  4551                              <1> 
  4552                              <1> csftdf2_save_fat_file_6:
  4553                              <1> 	; 28/03/2016
  4554 0000BD9C BE[8D820100]        <1> 	mov	esi, SourceFile_DirEntry+DirEntry_Attr ; +11 to + 18
  4555 0000BDA1 BF[0D830100]        <1> 	mov	edi, DestinationFile_DirEntry+DirEntry_Attr ; +11 to + 18
  4556 0000BDA6 A4                  <1> 	movsb ; +11
  4557 0000BDA7 A5                  <1> 	movsd ; +12 .. +15
  4558 0000BDA8 66A5                <1> 	movsw ; +16 .. +17
  4559                              <1> 		; + 18
  4560 0000BDAA 83C604              <1> 	add	esi, 4
  4561 0000BDAD 83C704              <1> 	add	edi, 4
  4562 0000BDB0 A5                  <1> 	movsd	; DirEntry_WrtTime ; +22 .. +25
  4563                              <1> 
  4564 0000BDB1 8B15[5C830100]      <1> 	mov	edx, [csftdf_filesize]
  4565 0000BDB7 8915[1E830100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  4566                              <1> 
  4567 0000BDBD E8E9F0FFFF          <1> 	call	convert_current_date_time
  4568                              <1> 	; DX = Date in dos dir entry format
  4569                              <1> 	; AX = Time in dos dir entry format
  4570 0000BDC2 EB4D                <1> 	jmp	short csftdf2_save_fat_file_7
  4571                              <1> 
  4572                              <1> csftdf2_save_fat_file_err1:
  4573 0000BDC4 5B                  <1> 	pop	ebx ; *	
  4574                              <1> csftdf2_save_fat_file_err2:
  4575 0000BDC5 A1[7C830100]        <1> 	mov	eax, [csftdf_df_wbytes]
  4576 0000BDCA 8B15[1E830100]      <1> 	mov	edx, [DestinationFile_DirEntry+DirEntry_FileSize]
  4577 0000BDD0 39C2                <1> 	cmp	edx, eax
  4578 0000BDD2 7616                <1> 	jna	short csftdf2_save_fat_file_err3
  4579 0000BDD4 A1[6C830100]        <1> 	mov	eax, [csftdf_df_cluster] ; last (empty) cluster
  4580                              <1> 	; ESI = Logical dos drive description table address
  4581 0000BDD9 E8890B0000          <1> 	call	truncate_cluster_chain
  4582 0000BDDE 720A                <1> 	jc	short csftdf2_save_fat_file_err3
  4583 0000BDE0 A1[7C830100]        <1> 	mov	eax, [csftdf_df_wbytes]	
  4584 0000BDE5 A3[1E830100]        <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], eax
  4585                              <1> csftdf2_save_fat_file_err3:
  4586 0000BDEA E8BCF0FFFF          <1> 	call	convert_current_date_time
  4587                              <1> 	; DX = Date in dos dir entry format
  4588                              <1> 	; AX = Time in dos dir entry format
  4589 0000BDEF C605[0F830100]00    <1> 	mov	byte [DestinationFile_DirEntry+DirEntry_CrtTimeTenth], 0
  4590 0000BDF6 66A3[10830100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_CrtTime], ax
  4591 0000BDFC 668915[12830100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_CrtDate], dx		
  4592 0000BE03 66A3[18830100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_WrtTime], ax
  4593 0000BE09 668915[1A830100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_WrtDate], dx
  4594 0000BE10 F9                  <1> 	stc
  4595                              <1> csftdf2_save_fat_file_7:
  4596 0000BE11 9C                  <1> 	pushf
  4597 0000BE12 668915[14830100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_LastAccDate], dx
  4598 0000BE19 BE[02830100]        <1> 	mov	esi, DestinationFile_DirEntry
  4599 0000BE1E BF00000800          <1> 	mov	edi, Directory_Buffer
  4600 0000BE23 0FB70D[2A830100]    <1> 	movzx	ecx, word [DestinationFile_DirEntryNumber] ; (<2048)
  4601                              <1> 	;shl	cx, 5 ; 32 * directory entry number
  4602                              <1> 	; 29/07/2022
  4603 0000BE2A C1E105              <1> 	shl	ecx, 5
  4604 0000BE2D 01CF                <1> 	add	edi, ecx
  4605                              <1> 	;mov	ecx, 8
  4606                              <1> 	;mov	cx, 8
  4607                              <1> 	; 29/07/2022
  4608                              <1> 	;sub	ecx, ecx
  4609 0000BE2F 28ED                <1> 	sub	ch, ch
  4610 0000BE31 B108                <1> 	mov	cl, 8
  4611 0000BE33 F3A5                <1> 	rep	movsd
  4612 0000BE35 9D                  <1> 	popf
  4613 0000BE36 730B                <1> 	jnc	short csftdf2_write_file_OK
  4614                              <1> 	 		
  4615                              <1> csftdf2_write_error:
  4616                              <1> 	; 18/03/2016
  4617 0000BE38 B01D                <1> 	mov	al, 1Dh ; write error
  4618 0000BE3A EB02                <1> 	jmp	short csftdf2_rw_error
  4619                              <1> 
  4620                              <1> 	; 16/03/2016
  4621                              <1> csftdf2_read_error:
  4622 0000BE3C B011                <1> 	mov	al, 17 ; ; Drive not ready or read error!
  4623                              <1> csftdf2_rw_error:
  4624 0000BE3E A2[59830100]        <1> 	mov	[csftdf_rw_err], al 
  4625                              <1> 
  4626                              <1> csftdf2_write_file_OK:
  4627                              <1> 	; 18/03/2016
  4628 0000BE43 C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  4629 0000BE4A E8F1F0FFFF          <1> 	call	save_directory_buffer
  4630                              <1> 
  4631                              <1>  	; Update last modification date&time of destination
  4632                              <1> 	; file's (parent) directory
  4633 0000BE4F E884F1FFFF          <1> 	call	update_parent_dir_lmdt
  4634                              <1> 	;
  4635 0000BE54 A1[60830100]        <1> 	mov	eax, [csftdf_sf_mem_addr] ; start address
  4636                              <1> 
  4637 0000BE59 21C0                <1> 	and	eax, eax
  4638 0000BE5B 750E                <1> 	jnz	short csftdf2_dealloc_mblock
  4639                              <1> 
  4640 0000BE5D 88C5                <1> 	mov	ch, al ; 0 (Cluster r/w, not full loading)
  4641                              <1> csftdf2_dealloc_retn:
  4642 0000BE5F 8A0D[59830100]      <1> 	mov	cl, [csftdf_rw_err]
  4643 0000BE65 A1[6C830100]        <1> 	mov	eax, [csftdf_df_cluster]
  4644 0000BE6A C3                  <1> 	retn
  4645                              <1> 
  4646                              <1> csftdf2_dealloc_mblock:
  4647 0000BE6B 8B0D[64830100]      <1> 	mov	ecx, [csftdf_sf_mem_bsize] ; block size	
  4648 0000BE71 E8929FFFFF          <1> 	call	deallocate_memory_block
  4649 0000BE76 B5FF                <1>         mov     ch, 0FFh ; (File was full loaded at memory)
  4650 0000BE78 EBE5                <1> 	jmp	short csftdf2_dealloc_retn
  4651                              <1> 
  4652                              <1> csftdf2_save_fs_file:
  4653                              <1> 	; 16/10/2016 (1Dh -> 18)
  4654                              <1> 	; temporary - (21/03/2016)
  4655                              <1> 	;mov	eax, 18 ; write error
  4656                              <1> 	; 29/07/2022
  4657 0000BE7A 31C0                <1> 	xor	eax, eax
  4658 0000BE7C B012                <1> 	mov	al, 18
  4659 0000BE7E F9                  <1> 	stc
  4660 0000BE7F C3                  <1> 	retn
  4661                              <1> 
  4662                              <1> create_file:
  4663                              <1> 	; 30/07/2022
  4664                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  4665                              <1> 	; 16/10/2016
  4666                              <1> 	; 24/03/2016, 31/03/2016
  4667                              <1> 	; 20/03/2016, 21/03/2016, 23/03/2016
  4668                              <1> 	; 19/03/2016 (TRDOS 396 = TRDOS v2.0)
  4669                              <1> 	; 03/09/2011 (FILE.ASM, 'proc_create_file')
  4670                              <1> 	; 09/08/2010
  4671                              <1> 	;
  4672                              <1> 	; INPUT ->
  4673                              <1> 	; 	EAX = File Size
  4674                              <1> 	; 	ESI = ASCIIZ File Name
  4675                              <1> 	; 	CL = File Attributes 
  4676                              <1> 	;	EBX = FFFFFFFFh -> create empty file 
  4677                              <1> 	;			 (only for FAT fs) 
  4678                              <1> 	; OUTPUT ->
  4679                              <1> 	;     CF = 0 ->
  4680                              <1> 	;	EAX = New file's first cluster
  4681                              <1> 	; 	ESI = Logical Dos Drv Descr. Table Addr.
  4682                              <1> 	; 	EBX = offset CreateFile_Size
  4683                              <1> 	; 	ECX = Sectors per cluster (<256) 
  4684                              <1> 	; 	EDX = Directory entry index/number (<65536)
  4685                              <1> 	;     CF = 1 -> error code in AL
  4686                              <1> 
  4687                              <1> ;	test	cl, 18h (directory or volume name)
  4688                              <1> ;	jnz	short loc_createfile_access_denied
  4689 0000BE80 80E107              <1> 	and	cl, 07h ; S, H, R
  4690 0000BE83 880D[A8830100]      <1>         mov     [createfile_attrib], cl 
  4691                              <1> 
  4692 0000BE89 89D9                <1> 	mov	ecx, ebx
  4693 0000BE8B 89F3                <1> 	mov	ebx, esi ; ASCIIZ File Name address
  4694 0000BE8D 29D2                <1> 	sub	edx, edx
  4695 0000BE8F 8A35[4A780100]      <1>         mov     dh, [Current_Drv]
  4696 0000BE95 BE00010900          <1>         mov     esi, Logical_DOSDisks
  4697 0000BE9A 01D6                <1> 	add	esi, edx
  4698                              <1> 
  4699 0000BE9C 8815[B3830100]      <1> 	mov	[createfile_UpdatePDir], dl ; 0 ; 31/03/2016 
  4700                              <1> 
  4701                              <1> 	; LD_DiskType = 0 for write protection (read only) 
  4702 0000BEA2 807E0101            <1> 	cmp	byte [esi+LD_DiskType], 1 ; 0 = Invalid
  4703 0000BEA6 7308                <1> 	jnb	short loc_createfile_check_file_sytem
  4704                              <1> 	; 16/10/2016 (TRDOS Error code: 30, disk write protected) 
  4705                              <1> 	;mov	eax, 30 ; 13h, MSDOS err : Disk write-protected 
  4706                              <1> 	;mov	dx, 0
  4707                              <1> 	; 29/07/2022
  4708 0000BEA8 31D2                <1> 	xor	edx, edx ; 0
  4709 0000BEAA 31C0                <1> 	xor	eax, eax ; 0
  4710 0000BEAC B01E                <1> 	mov	al, 30	
  4711 0000BEAE F9                  <1> 	stc
  4712                              <1> 	; err retn: EDX = 0, EBX = File name offset
  4713                              <1> 	; ESI -> Dos drive description table address	
  4714 0000BEAF C3                  <1> 	retn
  4715                              <1> 
  4716                              <1> ;loc_createfile_access_denied:
  4717                              <1> ;	mov	eax, 05h ; access denied (invalid attributes input)
  4718                              <1> ;	stc
  4719                              <1> ;	retn
  4720                              <1> 
  4721                              <1> loc_createfile_check_file_sytem:
  4722 0000BEB0 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  4723 0000BEB4 730A                <1> 	jnb	short loc_createfile_chk_empty_FAT_file_sign1
  4724                              <1> 
  4725 0000BEB6 A3[94830100]        <1> 	mov	[createfile_size], eax
  4726                              <1> 	; ESI = Logical Dos Drive Description Table address
  4727                              <1> 	; EBX = ASCIIZ File Name address
  4728 0000BEBB E9F6020000          <1> 	jmp	create_fs_file
  4729                              <1> 
  4730                              <1> loc_createfile_chk_empty_FAT_file_sign1:
  4731                              <1> 	; ECX = FFFFFFFFh -> create empty file if drive has FAT fs
  4732 0000BEC0 41                  <1> 	inc	ecx
  4733 0000BEC1 7506                <1> 	jnz	short loc_createfile_chk_empty_FAT_file_sign2
  4734 0000BEC3 890D[94830100]      <1> 	mov	[createfile_size], ecx ; 0 ; empty file
  4735                              <1> 
  4736                              <1> loc_createfile_chk_empty_FAT_file_sign2:
  4737                              <1> 	; 23/03/2016
  4738 0000BEC9 668B4E11            <1> 	mov	cx, [esi+LD_BPB+BytesPerSec]
  4739 0000BECD 66890D[B0830100]    <1> 	mov	[createfile_BytesPerSec], cx
  4740                              <1> 	
  4741                              <1> 	; EBX = ASCIIZ File Name address
  4742 0000BED4 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
  4743 0000BED8 8815[A9830100]      <1> 	mov	[createfile_SecPerClust], dl
  4744 0000BEDE 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  4745 0000BEE1 39D1                <1> 	cmp	ecx, edx ; byte [createfile_SecPerClust]
  4746 0000BEE3 7306                <1> 	jnb	short loc_create_fat_file
  4747                              <1> 	  
  4748                              <1> loc_createfile_insufficient_disk_space:
  4749 0000BEE5 B827000000          <1> 	mov	eax, 27h
  4750                              <1> loc_createfile_gffc_retn:
  4751 0000BEEA C3                  <1> 	retn
  4752                              <1> 
  4753                              <1> loc_create_fat_file:
  4754 0000BEEB 891D[8C830100]      <1> 	mov	[createfile_Name_Offset], ebx
  4755 0000BEF1 890D[90830100]      <1> 	mov	[createfile_FreeSectors], ecx
  4756                              <1> 
  4757                              <1> loc_createfile_gffc_1:
  4758 0000BEF7 E8DD040000          <1> 	call	get_first_free_cluster
  4759 0000BEFC 72EC                <1> 	jc	short loc_createfile_gffc_retn
  4760                              <1> 
  4761 0000BEFE A3[98830100]        <1> 	mov	[createfile_FFCluster], eax
  4762                              <1> 
  4763                              <1> loc_createfile_locate_ffe_on_directory:
  4764                              <1> 	; Current directory fcluster <> Directory buffer cluster
  4765                              <1> 	; Current directory will be reloaded by
  4766                              <1> 	; 'locate_current_dir_file' procedure
  4767                              <1> 	;
  4768                              <1> 	; ESI = Logical Dos Drv Desc. Table Adress
  4769 0000BF03 56                  <1> 	push	esi ; *
  4770 0000BF04 31C0                <1> 	xor	eax, eax
  4771                              <1> 
  4772 0000BF06 A3[667F0100]        <1> 	mov	dword [FAT_ClusterCounter], eax ; 0
  4773                              <1> 	; 21/03/2016
  4774 0000BF0B A2[B2830100]        <1> 	mov	byte [createfile_wfc], al ; 0 
  4775                              <1> 
  4776 0000BF10 89C1                <1>  	mov	ecx, eax
  4777 0000BF12 6649                <1> 	dec	cx ; FFFFh  
  4778                              <1> 	; CX = FFFFh -> find first deleted or free entry
  4779                              <1> 	; ESI would be ASCIIZ filename address if the call
  4780                              <1> 	; would not be for first free or deleted dir entry  
  4781 0000BF14 E852E8FFFF          <1> 	call	locate_current_dir_file
  4782                              <1> 	;jnc	loc_createfile_set_ff_dir_entry
  4783                              <1> 	; 29/07/2022
  4784 0000BF19 7205                <1> 	jc	short loc_createfile_locate_file_err
  4785 0000BF1B E9EC000000          <1> 	jmp	loc_createfile_set_ff_dir_entry	
  4786                              <1> 
  4787                              <1> loc_createfile_locate_file_err: ; 29/07/2022
  4788 0000BF20 5E                  <1> 	pop	esi ; *
  4789                              <1> 	 ; ESI = Logical DOS Drv. Description Table Address 
  4790 0000BF21 83F802              <1> 	cmp	eax, 2
  4791 0000BF24 7402                <1> 	je	short loc_createfile_add_new_cluster
  4792                              <1> loc_createfile_locate_file_stc_retn:
  4793 0000BF26 F9                  <1> 	stc
  4794 0000BF27 C3                  <1> 	retn
  4795                              <1> 
  4796                              <1> loc_createfile_add_new_cluster:
  4797 0000BF28 803D[49780100]02    <1> 	cmp	byte [Current_FATType], 2
  4798                              <1> 	;cmp	byte [esi+LD_FATType], 2
  4799 0000BF2F 770C                <1> 	ja	short loc_createfile_add_new_cluster_check_fsc
  4800 0000BF31 803D[48780100]01    <1> 	cmp	byte [Current_Dir_Level], 1
  4801                              <1> 	;cmp	byte [esi+LD_CDirLevel], 1
  4802 0000BF38 7303                <1> 	jnb	short loc_createfile_add_new_cluster_check_fsc
  4803                              <1> 	
  4804                              <1> 	;mov	eax, 12
  4805 0000BF3A B00C                <1> 	mov	al, 12 ; No more files 
  4806                              <1> 
  4807                              <1> loc_createfile_anc_retn:
  4808 0000BF3C C3                  <1> 	retn
  4809                              <1> 
  4810                              <1> loc_createfile_add_new_cluster_check_fsc:
  4811 0000BF3D 8B0D[90830100]      <1> 	mov	ecx, [createfile_FreeSectors]
  4812 0000BF43 0FB605[A9830100]    <1> 	movzx	eax, byte [createfile_SecPerClust]
  4813                              <1> 	;shl	ax, 1 ; AX = 2 * AX
  4814                              <1> 	; 29/07/2022
  4815 0000BF4A D1E0                <1> 	shl	eax, 1
  4816 0000BF4C 39C1                <1> 	cmp	ecx, eax
  4817 0000BF4E 7295                <1>         jb	short loc_createfile_insufficient_disk_space
  4818                              <1> 
  4819                              <1> loc_createfile_add_new_subdir_cluster:
  4820 0000BF50 8B15[767F0100]      <1> 	mov	edx, [DirBuff_Cluster]
  4821 0000BF56 8915[9C830100]      <1> 	mov	[createfile_LastDirCluster], edx	
  4822                              <1> 
  4823 0000BF5C A1[98830100]        <1> 	mov	eax, [createfile_FFCluster]
  4824 0000BF61 E80D040000          <1> 	call	load_FAT_sub_directory 
  4825 0000BF66 72D4                <1> 	jc	short loc_createfile_anc_retn
  4826                              <1> 
  4827                              <1> pass_createfile_add_new_subdir_cluster:
  4828                              <1> 	;movzx	eax, word [esi+LD_BPB+BytesPerSec]
  4829 0000BF68 0FB705[B0830100]    <1> 	movzx	eax, word [createfile_BytesPerSec] ; 23/03/2016
  4830 0000BF6F F7E1                <1> 	mul	ecx ; ecx = directory buffer sector count
  4831 0000BF71 89C1                <1> 	mov	ecx, eax
  4832 0000BF73 C1E902              <1> 	shr	ecx, 2 ; dword count
  4833 0000BF76 29C0                <1> 	sub	eax, eax ; 0
  4834 0000BF78 F3AB                <1> 	rep	stosd 
  4835                              <1> 	;
  4836 0000BF7A C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  4837 0000BF81 E8BAEFFFFF          <1> 	call	save_directory_buffer
  4838 0000BF86 72B4                <1> 	jc	short loc_createfile_anc_retn
  4839                              <1> 
  4840                              <1> loc_createfile_save_added_subdir_cluster:
  4841 0000BF88 A1[9C830100]        <1> 	mov	eax, [createfile_LastDirCluster]
  4842 0000BF8D 8B0D[98830100]      <1> 	mov	ecx, [createfile_FFCluster]
  4843 0000BF93 E80E050000          <1> 	call	update_cluster
  4844 0000BF98 7304                <1> 	jnc	short loc_createfile_save_fat_buffer_0
  4845 0000BF9A 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4846 0000BF9C 751A                <1> 	jnz	short loc_createfile_save_fat_buffer_stc_retn
  4847                              <1> 
  4848                              <1> loc_createfile_save_fat_buffer_0:
  4849 0000BF9E A1[98830100]        <1> 	mov	eax, [createfile_FFCluster]
  4850 0000BFA3 A3[9C830100]        <1> 	mov	[createfile_LastDirCluster], eax
  4851 0000BFA8 B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh ; 28 bit
  4852 0000BFAD E8F4040000          <1> 	call	update_cluster
  4853 0000BFB2 7306                <1> 	jnc	short loc_createfile_save_fat_buffer_1
  4854 0000BFB4 09C0                <1> 	or	eax, eax ; Was it free cluster
  4855 0000BFB6 7402                <1> 	jz	short loc_createfile_save_fat_buffer_1
  4856                              <1> 
  4857                              <1> loc_createfile_save_fat_buffer_stc_retn:
  4858 0000BFB8 F9                  <1> 	stc
  4859                              <1> loc_createfile_save_fat_buffer_retn:
  4860                              <1> loc_createfile_gffc_2_stc_retn:
  4861 0000BFB9 C3                  <1> 	retn
  4862                              <1> 
  4863                              <1> loc_createfile_save_fat_buffer_1:
  4864                              <1> 	; byte [FAT_BuffValidData] = 2 
  4865 0000BFBA E86A070000          <1> 	call	save_fat_buffer
  4866 0000BFBF 72F8                <1> 	jc	short loc_createfile_save_fat_buffer_retn
  4867                              <1> 
  4868 0000BFC1 803D[667F0100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  4869 0000BFC8 7222                <1> 	jb	short loc_createfile_save_fat_buffer_2
  4870                              <1> 
  4871                              <1> 	; ESI = Logical DOS Drive Description Table address 
  4872 0000BFCA A1[667F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
  4873                              <1> 
  4874 0000BFCF C605[667F0100]00    <1> 	mov	byte [FAT_ClusterCounter], 0 ; 21/03/2016
  4875                              <1> 
  4876 0000BFD6 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  4877 0000BFDA E8DB070000          <1> 	call	calculate_fat_freespace
  4878                              <1> 
  4879                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  4880                              <1> 	;jnz	short loc_createfile_save_fat_buffer_2
  4881                              <1> 
  4882                              <1> 	; ecx > 0 -> Recalculation is needed
  4883 0000BFDF 09C9                <1> 	or	ecx, ecx 
  4884 0000BFE1 7409                <1> 	jz	short loc_createfile_save_fat_buffer_2
  4885                              <1> 
  4886 0000BFE3 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  4887 0000BFE7 E8CE070000          <1> 	call	calculate_fat_freespace
  4888                              <1> 
  4889                              <1> loc_createfile_save_fat_buffer_2:
  4890                              <1> 	;call	update_parent_dir_lmdt
  4891                              <1> 
  4892                              <1> loc_createfile_gffc_2:
  4893 0000BFEC E8E8030000          <1> 	call	get_first_free_cluster
  4894 0000BFF1 72C6                <1> 	jc	short loc_createfile_gffc_2_stc_retn
  4895                              <1> 
  4896 0000BFF3 A3[98830100]        <1> 	mov	[createfile_FFCluster], eax
  4897                              <1> 
  4898 0000BFF8 A1[9C830100]        <1> 	mov	eax, [createfile_LastDirCluster]
  4899                              <1> 	
  4900 0000BFFD E871030000          <1> 	call	load_FAT_sub_directory 
  4901 0000C002 72B5                <1> 	jc	short loc_createfile_gffc_2_stc_retn
  4902                              <1> 
  4903 0000C004 BF00000800          <1> 	mov	edi, Directory_Buffer
  4904                              <1> 
  4905                              <1> 	;sub	bx, bx ; directory entry index/number = 0
  4906                              <1> 	; 29/07/2022
  4907 0000C009 29C9                <1> 	sub	ecx, ecx
  4908                              <1> 
  4909 0000C00B 56                  <1> 	push	esi ; * ; 23/03/2016
  4910                              <1> 
  4911                              <1> loc_createfile_set_ff_dir_entry:
  4912                              <1> 	;mov	[createfile_DirIndex], bx
  4913                              <1> 	; 29/07/2022
  4914 0000C00C 66890D[AA830100]    <1> 	mov	[createfile_DirIndex], cx ; 0
  4915                              <1> 
  4916                              <1>         ; EDI = Directory entry address
  4917 0000C013 8B35[8C830100]      <1> 	mov	esi, [createfile_Name_Offset]
  4918 0000C019 A1[98830100]        <1> 	mov	eax, [createfile_FFCluster]
  4919 0000C01E A3[A0830100]        <1> 	mov	[createfile_Cluster], eax ; 24/03/2016
  4920                              <1> 	;mov	ch, 0FFh
  4921                              <1>         ; 29/07/2022
  4922                              <1> 	; ecx = 0
  4923 0000C023 FECD                <1> 	dec	ch ; 0 -> 0FFh
  4924 0000C025 8A0D[A8830100]      <1> 	mov	cl, [createfile_attrib] ; file attributes
  4925                              <1> 	; CH > 0 -> File size is in [EBX]
  4926 0000C02B BB[94830100]        <1> 	mov	ebx, createfile_size
  4927                              <1>   
  4928 0000C030 E838EEFFFF          <1> 	call	make_directory_entry
  4929                              <1> 	
  4930 0000C035 5E                  <1> 	pop	esi ; * ; ESI = Logical Dos Drv Desc. Table address
  4931                              <1> 
  4932 0000C036 C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  4933 0000C03D E8FEEEFFFF          <1> 	call	save_directory_buffer
  4934 0000C042 7221                <1> 	jc	short loc_createfile_set_ff_dir_entry_retn
  4935                              <1> 
  4936 0000C044 C605[B3830100]01    <1> 	mov	byte [createfile_UpdatePDir], 1 ; 31/03/2016 
  4937                              <1> 
  4938                              <1> loc_createfile_get_set_write_file_cluster:
  4939 0000C04B A1[94830100]        <1> 	mov	eax, [createfile_size]
  4940 0000C050 09C0                <1> 	or	eax, eax
  4941 0000C052 756B                <1> 	jnz	short loc_createfile_get_set_wfc_cont
  4942 0000C054 40                  <1> 	inc	eax
  4943                              <1> 	; 23/03/2016
  4944 0000C055 0FB61D[A9830100]    <1> 	movzx	ebx, byte [createfile_SecPerClust]
  4945                              <1> 	;movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 512
  4946 0000C05C 0FB70D[B0830100]    <1>         movzx   ecx, word [createfile_BytesPerSec] ; 512
  4947 0000C063 EB77                <1> 	jmp	loc_createfile_set_cluster_count 
  4948                              <1> 
  4949                              <1> loc_createfile_set_ff_dir_entry_retn:
  4950 0000C065 C3                  <1> 	retn
  4951                              <1> 
  4952                              <1> loc_createfile_write_fcluster_to_disk:
  4953 0000C066 034668              <1> 	add	eax, [esi+LD_DATABegin] ; convert to physical address
  4954 0000C069 BB00000700          <1> 	mov	ebx, Cluster_Buffer
  4955                              <1> 	; ESI = Logical DOS Drv. Desc. Tbl. address
  4956                              <1> 	; EAX = Disk address
  4957                              <1> 	; EBX = Sector Buffer
  4958                              <1> 	; ECX = sectors per cluster
  4959 0000C06E E8D35C0000          <1> 	call	disk_write
  4960 0000C073 7211                <1> 	jc	short loc_createfile_dsk_wr_err
  4961                              <1> 
  4962                              <1> loc_createfile_update_fat_cluster:
  4963                              <1> 	; 21/03/2016	
  4964 0000C075 803D[B2830100]00    <1> 	cmp	byte [createfile_wfc], 0 
  4965 0000C07C 7711                <1> 	ja	short loc_createfile_update_fat_cluster_n1
  4966                              <1> 
  4967 0000C07E FE05[B2830100]      <1> 	inc	byte [createfile_wfc] ; 1
  4968 0000C084 EB1F                <1> 	jmp	short loc_createfile_update_fat_cluster_n2
  4969                              <1> 
  4970                              <1> loc_createfile_dsk_wr_err:
  4971                              <1> 	; 16/10/2016 (1Dh -> 18)
  4972                              <1> 	; 23/03/2016
  4973                              <1> 	;mov	eax, 18 ; Drive not ready or write error !
  4974                              <1> 	; 29/07/2022
  4975 0000C086 29C0                <1> 	sub	eax, eax
  4976 0000C088 B012                <1> 	mov	al, 18
  4977                              <1> loc_cf_stc_retn:
  4978 0000C08A E9B7000000          <1> 	jmp	loc_createfile_stc_retn
  4979                              <1> 
  4980                              <1> loc_createfile_update_fat_cluster_n1:
  4981 0000C08F A1[A4830100]        <1> 	mov	eax, [createfile_PCluster]
  4982 0000C094 8B0D[A0830100]      <1> 	mov	ecx, [createfile_Cluster]
  4983 0000C09A E807040000          <1> 	call	update_cluster
  4984 0000C09F 7304                <1> 	jnc	short loc_createfile_update_fat_cluster_n2
  4985 0000C0A1 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4986                              <1> 	;jnz	loc_createfile_stc_retn
  4987                              <1> 	; 29/07/2022
  4988 0000C0A3 75E5                <1> 	jnz	short loc_cf_stc_retn
  4989                              <1> 
  4990                              <1> loc_createfile_update_fat_cluster_n2:
  4991 0000C0A5 A1[A0830100]        <1>         mov	eax, [createfile_Cluster]
  4992 0000C0AA B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh
  4993 0000C0AF E8F2030000          <1> 	call	update_cluster
  4994 0000C0B4 734D                <1> 	jnc	short loc_createfile_save_fat_buffer_3
  4995 0000C0B6 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4996 0000C0B8 7449                <1> 	jz	short loc_createfile_save_fat_buffer_3
  4997                              <1> 
  4998                              <1> loc_cf_upd_fat_fcluster_stc_retn:
  4999 0000C0BA E987000000          <1> 	jmp	loc_createfile_stc_retn
  5000                              <1> 
  5001                              <1> loc_createfile_get_set_wfc_cont:
  5002                              <1> 	;movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 512	
  5003 0000C0BF 0FB70D[B0830100]    <1> 	movzx	ecx, word [createfile_BytesPerSec] ; 512
  5004 0000C0C6 01C8                <1> 	add	eax, ecx
  5005 0000C0C8 48                  <1> 	dec	eax  ; add eax, 511
  5006 0000C0C9 29D2                <1> 	sub	edx, edx
  5007 0000C0CB F7F1                <1> 	div	ecx
  5008 0000C0CD 0FB61D[A9830100]    <1> 	movzx	ebx, byte [createfile_SecPerClust]
  5009 0000C0D4 01D8                <1> 	add	eax, ebx
  5010 0000C0D6 48                  <1> 	dec	eax  ; add eax, SecPerClust - 1
  5011 0000C0D7 6631D2              <1> 	xor	dx, dx
  5012 0000C0DA F7F3                <1> 	div	ebx
  5013                              <1> 
  5014                              <1> loc_createfile_set_cluster_count:
  5015 0000C0DC A3[AC830100]        <1> 	mov 	[createfile_CCount], eax
  5016                              <1> 	
  5017 0000C0E1 BF00000700          <1> 	mov	edi, Cluster_Buffer
  5018 0000C0E6 89C8                <1> 	mov	eax, ecx ; Bytes per Sector
  5019 0000C0E8 F7E3                <1> 	mul	ebx ; Sectors per Cluster 
  5020                              <1> 	; EAX = Bytes per Cluster
  5021 0000C0EA 89C1                <1> 	mov	ecx, eax
  5022 0000C0EC C1E902              <1> 	shr	ecx, 2 ; dword count
  5023 0000C0EF 31C0                <1> 	xor	eax, eax
  5024 0000C0F1 F3AB                <1> 	rep	stosd ; clear cluster buffer
  5025                              <1> 
  5026 0000C0F3 A1[A0830100]        <1> 	mov	eax, [createfile_Cluster] ; 24/03/2016
  5027                              <1> 
  5028 0000C0F8 89D9                <1> 	mov	ecx, ebx
  5029                              <1> 
  5030                              <1> loc_createfile_get_set_wf_fclust_cont:
  5031                              <1> 	;sub	eax, 2
  5032                              <1> 	; 30/07/2022
  5033 0000C0FA 48                  <1> 	dec	eax
  5034 0000C0FB 48                  <1> 	dec	eax
  5035 0000C0FC F7E1                <1> 	mul	ecx
  5036                              <1> 	; EAX = Logical DOS disk address (offset)
  5037 0000C0FE E963FFFFFF          <1>         jmp     loc_createfile_write_fcluster_to_disk
  5038                              <1> 
  5039                              <1> loc_createfile_save_fat_buffer_3:
  5040                              <1> 	; byte [FAT_BuffValidData] = 2
  5041 0000C103 E821060000          <1> 	call	save_fat_buffer
  5042                              <1> 	;jc	loc_createfile_stc_retn
  5043                              <1> 	; 29/07/2022
  5044 0000C108 72B0                <1> 	jc	short loc_cf_upd_fat_fcluster_stc_retn
  5045                              <1> 
  5046                              <1> 	; 21/03/2016
  5047 0000C10A 803D[667F0100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  5048 0000C111 721B                <1> 	jb	short loc_createfile_save_fat_buffer_4
  5049                              <1> 
  5050                              <1> 	; ESI = Logical DOS Drive Description Table address 
  5051 0000C113 A1[667F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
  5052 0000C118 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  5053 0000C11C E899060000          <1> 	call	calculate_fat_freespace
  5054                              <1> 
  5055                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  5056                              <1> 	;jnz	short loc_createfile_save_fat_buffer_4
  5057                              <1> 
  5058                              <1> 	; ecx > 0 -> Recalculation is needed
  5059 0000C121 09C9                <1> 	or	ecx, ecx 
  5060 0000C123 7409                <1> 	jz	short loc_createfile_save_fat_buffer_4
  5061                              <1> 
  5062 0000C125 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  5063 0000C129 E88C060000          <1> 	call	calculate_fat_freespace
  5064                              <1> 
  5065                              <1> loc_createfile_save_fat_buffer_4:
  5066 0000C12E FF0D[AC830100]      <1> 	dec	dword [createfile_CCount]
  5067                              <1> 	;jz	short loc_createfile_upd_dir_modif_date_time
  5068 0000C134 743E                <1> 	jz	short loc_createfile_stc_retn_cc ; 31/03/2016
  5069                              <1> 
  5070                              <1> loc_createfile_get_set_write_next_cluster:
  5071 0000C136 E89E020000          <1> 	call	get_first_free_cluster
  5072 0000C13B 7209                <1> 	jc	short loc_createfile_stc_retn
  5073                              <1> 
  5074                              <1> loc_createfile_get_set_write_next_cluster_1:
  5075 0000C13D 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh
  5076 0000C140 7212                <1> 	jb	short loc_createfile_get_set_write_next_cluster_2
  5077                              <1> 
  5078                              <1> loc_createfile_wnc_insufficient_disk_space:	
  5079                              <1> 	;mov	eax, 27h ; Insufficient disk space
  5080                              <1> 	; 29/07/2022
  5081 0000C142 31C0                <1> 	xor	eax, eax
  5082 0000C144 B027                <1> 	mov	al, 27h
  5083                              <1> 
  5084                              <1> loc_createfile_stc_retn:
  5085 0000C146 803D[B2830100]01    <1> 	cmp	byte [createfile_wfc], 1
  5086 0000C14D 7324                <1> 	jnb	short loc_createfile_err_retn
  5087 0000C14F C3                  <1> 	retn
  5088                              <1> 
  5089                              <1> loc_createfile_wnc_inv_format_retn:
  5090                              <1> 	;mov	eax, 28
  5091 0000C150 B01C                <1> 	mov	al, 28 ; Invalid format
  5092 0000C152 EBF2                <1> 	jmp	short loc_createfile_stc_retn
  5093                              <1> 	         
  5094                              <1> loc_createfile_get_set_write_next_cluster_2:
  5095 0000C154 83F802              <1> 	cmp	eax, 2
  5096 0000C157 72F7                <1> 	jb	short loc_createfile_wnc_inv_format_retn
  5097                              <1> 
  5098                              <1> loc_createfile_get_set_write_next_cluster_3:
  5099 0000C159 8B0D[A0830100]      <1> 	mov	ecx, [createfile_Cluster]
  5100 0000C15F A3[A0830100]        <1> 	mov	[createfile_Cluster], eax
  5101 0000C164 890D[A4830100]      <1> 	mov	[createfile_PCluster], ecx
  5102 0000C16A 0FB60D[A9830100]    <1> 	movzx	ecx, byte [createfile_SecPerClust]
  5103 0000C171 EB87                <1> 	jmp	short loc_createfile_get_set_wf_fclust_cont
  5104                              <1> 
  5105                              <1> loc_createfile_err_retn:
  5106 0000C173 F9                  <1> 	stc
  5107                              <1> 
  5108                              <1> ;loc_createfile_upd_dir_modif_date_time:
  5109                              <1> loc_createfile_stc_retn_cc: ; 31/03/2016
  5110 0000C174 9C                  <1> 	pushf	; cpu is here for an error return or completion 
  5111 0000C175 50                  <1> 	push	eax ; error code if cf = 1
  5112                              <1> 
  5113                              <1> 	;call	update_parent_dir_lmdt
  5114                              <1> 
  5115                              <1> ;loc_createfile_stc_retn_cc:
  5116 0000C176 A1[667F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
  5117 0000C17B 09C0                <1> 	or	eax, eax
  5118 0000C17D 741A                <1> 	jz	short loc_createfile_stc_retn_pop_eax
  5119 0000C17F 8A3D[4A780100]      <1> 	mov	bh, [Current_Drv]
  5120 0000C185 B301                <1> 	mov	bl, 01h ; BL = 1 -> add clusters
  5121                              <1> 	; NOTE: EAX value will be added to Free Cluster Count
  5122                              <1> 	; (If EAX value is negative, Free Cluster Count will be decreased)
  5123 0000C187 E82E060000          <1>   	call	calculate_fat_freespace
  5124                              <1>         ; ESI = Logical DOS Drive Description Table Address 
  5125                              <1>         ;jc	short loc_createfile_stc_retn_pop_eax_cf
  5126 0000C18C 21C9                <1> 	and	ecx, ecx ; cx = 0 -> valid free sector count
  5127 0000C18E 7409                <1> 	jz	short loc_createfile_stc_retn_pop_eax
  5128                              <1> 
  5129                              <1> loc_createfile_stc_retn_recalc_FAT_freespace:
  5130 0000C190 66BB00FF            <1> 	mov	bx, 0FF00h ; bh = 0FFh -> 
  5131                              <1> 	; ESI = Logical DOS Drv DT Addr
  5132                              <1> 	; BL = 0 -> Recalculate 
  5133 0000C194 E821060000          <1> 	call	calculate_fat_freespace
  5134                              <1> 
  5135                              <1> loc_createfile_stc_retn_pop_eax:
  5136 0000C199 58                  <1> 	pop	eax
  5137 0000C19A 9D                  <1> 	popf
  5138 0000C19B 7218                <1> 	jc	short loc_createfile_retn
  5139                              <1> 
  5140                              <1> loc_createfile_retn_fcluster:
  5141 0000C19D A1[98830100]        <1> 	mov	eax, [createfile_FFCluster]
  5142 0000C1A2 BB[94830100]        <1> 	mov	ebx, createfile_size
  5143                              <1> 	;movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  5144 0000C1A7 0FB60D[A9830100]    <1> 	movzx	ecx, byte [createfile_SecPerClust] ; 23/03/2016
  5145 0000C1AE 0FB715[AA830100]    <1> 	movzx	edx, word [createfile_DirIndex]
  5146                              <1> 
  5147                              <1> loc_createfile_retn:
  5148 0000C1B5 C3                  <1> 	retn
  5149                              <1> 
  5150                              <1> ; 28/07/2022 (TRDOS 386 Kernel v2.0.5)
  5151                              <1> 
  5152                              <1> create_fs_file:
  5153                              <1> 	; temporary (21/03/2016)
  5154                              <1> 	;retn
  5155                              <1> 
  5156                              <1> delete_fs_file:
  5157                              <1> 	; temporary (28/02/2016)
  5158                              <1> 	;retn
  5159                              <1> 
  5160                              <1> rename_fs_file_or_directory:
  5161                              <1> 	;retn
  5162                              <1> 
  5163                              <1> make_fs_directory:
  5164                              <1> 	; temporary (21/02/2016)
  5165                              <1> 	;retn
  5166                              <1> 
  5167                              <1> add_new_fs_section:
  5168                              <1> 	; temporary (11/03/2016)
  5169                              <1> 	;retn
  5170                              <1> 
  5171                              <1> delete_fs_directory_entry:
  5172                              <1> 	; temporary (11/03/2016)
  5173                              <1> 	;retn
  5174                              <1> 
  5175                              <1> csftdf2_read_fs_file_sectors:
  5176                              <1> 	; temporary (19/03/2016)
  5177                              <1> 	;retn
  5178                              <1> 
  5179                              <1> csftdf2_write_fs_file_sectors:
  5180                              <1> 	; temporary (19/03/2016)
  5181 0000C1B6 C3                  <1> 	retn
  3241                                  %include 'trdosk5.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - File System Procedures : trdosk5s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 07/08/2022 (Previous: 23/10/2016)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; DRV_FAT.ASM (21/08/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; DRV_FAT.ASM (c) 2005-2011 Erdogan TAN [ 07/07/2009 ] Last Update: 21/08/2011
    14                              <1> 
    15                              <1> get_next_cluster:
    16                              <1> 	; 07/08/2022
    17                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
    18                              <1> 	; 15/10/2016
    19                              <1> 	; 23/03/2016
    20                              <1> 	; 01/02/2016 (TRDOS 386 = TRDOS v2.0)
    21                              <1> 	; 05/07/2011
    22                              <1> 	; 07/07/2009
    23                              <1> 	; 2005
    24                              <1> 	; INPUT ->
    25                              <1> 	;	EAX = Cluster Number (32 bit)
    26                              <1> 	;	ESI = Logical DOS Drive Parameters Table
    27                              <1> 	; OUTPUT ->
    28                              <1> 	;	cf = 0 -> No Error, EAX valid
    29                              <1> 	;	cf = 1 & EAX = 0 -> End Of Cluster Chain
    30                              <1> 	;	cf = 1 & EAX > 0 -> Error
    31                              <1> 	;	ECX = Current/Previous cluster (if CF = 0)
    32                              <1> 	;	EAX = Next Cluster Number (32 bit)
    33                              <1> 	;
    34                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
    35                              <1> 
    36 0000C1B7 A3[5A7F0100]        <1> 	mov	[FAT_CurrentCluster], eax
    37                              <1> check_next_cluster_fat_type:
    38 0000C1BC 29D2                <1> 	sub	edx, edx ; 0
    39 0000C1BE 807E0302            <1> 	cmp     byte [esi+LD_FATType], 2
    40 0000C1C2 7243                <1> 	jb	short get_FAT12_next_cluster
    41                              <1> 	;ja	get_FAT32_next_cluster
    42                              <1> 	; 25/07/2022
    43 0000C1C4 7605                <1> 	jna	short get_FAT16_next_cluster
    44 0000C1C6 E9B2000000          <1> 	jmp	get_FAT32_next_cluster
    45                              <1> 
    46                              <1> get_FAT16_next_cluster:
    47 0000C1CB BB00030000          <1> 	mov	ebx, 300h ;768
    48 0000C1D0 F7F3                <1> 	div	ebx
    49                              <1> 	; EAX = Count of 3 FAT sectors
    50                              <1> 	; EDX = Cluster Offset (< 768)
    51                              <1> 	;shl	dx, 1 ; Multiply by 2
    52                              <1> 	; 25/07/2022
    53 0000C1D2 D1E2                <1> 	shl	edx, 1
    54 0000C1D4 89D3                <1> 	mov	ebx, edx ; Byte Offset
    55 0000C1D6 81C3001C0900        <1> 	add	ebx, FAT_Buffer
    56 0000C1DC 66BA0300            <1> 	mov	dx, 3
    57 0000C1E0 F7E2                <1> 	mul	edx  
    58                              <1> 	; EAX = FAT Sector (<= 256)
    59                              <1> 	; EDX = 0
    60 0000C1E2 8A0E                <1> 	mov	cl, [esi+LD_Name]
    61                              <1> 	;cmp	byte [FAT_BuffValidData], 0
    62 0000C1E4 3815[5E7F0100]      <1>         cmp	[FAT_BuffValidData], dl ; 0
    63 0000C1EA 7674                <1> 	jna     short load_FAT_sectors0
    64 0000C1EC 3A0D[5F7F0100]      <1> 	cmp	cl, [FAT_BuffDrvName]
    65 0000C1F2 756C                <1>         jne     short load_FAT_sectors0
    66 0000C1F4 3B05[627F0100]      <1> 	cmp	eax, [FAT_BuffSector]
    67 0000C1FA 756A                <1>         jne     short load_FAT_sectors1
    68                              <1> 	;movzx	eax, word [ebx]
    69 0000C1FC 668B03              <1> 	mov	ax, [ebx]
    70                              <1> 	; 01/02/2016
    71                              <1> 	; DRV_FAT.ASM (21/08/2011) had a FATal bug here !
    72                              <1> 	; (cmp ah, 0Fh) ! (ax >= FF7h)
    73                              <1> 	; (how can i do a such mistake!?)
    74                              <1> 	;cmp	al, 0F7h
    75                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
    76                              <1> 	;cmp	ah, 0FFh
    77                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
    78 0000C1FF 6683F8F7            <1> 	cmp	ax, 0FFF7h
    79 0000C203 724E                <1> 	jb	short loc_pass_gnc_FAT16_eoc_check
    80                              <1> 	; ax >= FFF7h (cluster 0002h to FFF6h is valid, in use)
    81 0000C205 EB4A                <1> 	jmp	short loc_pass_gnc_FAT16_eoc_check_xor_eax
    82                              <1> 
    83                              <1> get_FAT12_next_cluster:
    84 0000C207 BB00040000          <1> 	mov	ebx, 400h ;1024
    85 0000C20C F7F3                <1> 	div	ebx
    86                              <1> 	; EAX = Count of 3 FAT sectors
    87                              <1> 	; EDX = Cluster Offset (< 1024)
    88                              <1> 	; 25/07/2022
    89                              <1> 	;push	ax
    90 0000C20E 50                  <1> 	push	eax
    91                              <1> 	;mov	ax, 3	
    92 0000C20F B003                <1> 	mov	al, 3
    93                              <1> 	;mul	dx    	; Multiply by 3
    94 0000C211 F7E2                <1> 	mul	edx
    95                              <1> 	;shr	ax, 1	; Divide by 2
    96 0000C213 D1E8                <1>         shr	eax, 1
    97                              <1> 	;mov	bx, ax 	; Byte Offset
    98 0000C215 89C3                <1> 	mov	ebx, eax
    99 0000C217 81C3001C0900        <1> 	add	ebx, FAT_Buffer
   100 0000C21D 58                  <1> 	pop	eax
   101                              <1> 	;pop	ax
   102                              <1> 	;mov	dx, 3
   103 0000C21E B203                <1> 	mov	dl, 3
   104 0000C220 F7E2                <1> 	mul	edx 
   105                              <1> 	; EAX = FAT Sector (<= 12)
   106                              <1> 	; EDX = 0
   107 0000C222 8A0E                <1> 	mov	cl, [esi+LD_Name]
   108                              <1> 	;cmp	byte [FAT_BuffValidData], 0
   109 0000C224 3815[5E7F0100]      <1> 	cmp	[FAT_BuffValidData], dl ; 0
   110 0000C22A 7634                <1> 	jna	short load_FAT_sectors0
   111 0000C22C 3A0D[5F7F0100]      <1> 	cmp	cl, [FAT_BuffDrvName]
   112 0000C232 752C                <1> 	jne	short load_FAT_sectors0
   113 0000C234 3B05[627F0100]      <1> 	cmp	eax, [FAT_BuffSector]
   114 0000C23A 752A                <1> 	jne	short load_FAT_sectors1
   115 0000C23C A1[5A7F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
   116                              <1> 	;shr	ax, 1
   117                              <1> 	; 25/07/2022
   118 0000C241 D1E8                <1> 	shr	eax, 1
   119                              <1> 	;movzx	eax, word [ebx]
   120 0000C243 668B03              <1> 	mov	ax, [ebx]
   121 0000C246 7313                <1> 	jnc	short get_FAT12_nc_even
   122                              <1> 	;shr	ax, 4
   123 0000C248 C1E804              <1> 	shr	eax, 4
   124                              <1> loc_gnc_fat12_eoc_check:
   125                              <1> 	;cmp	al, 0F7h
   126                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
   127                              <1> 	;cmp	ah, 0Fh
   128                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
   129 0000C24B 663DF70F            <1> 	cmp	ax, 0FF7h
   130 0000C24F 7202                <1> 	jb	short loc_pass_gnc_FAT16_eoc_check
   131                              <1> 	; ax >= FF7h (cluster 0002h to FF6h is valid, in use)
   132                              <1> 
   133                              <1> loc_pass_gnc_FAT16_eoc_check_xor_eax:
   134 0000C251 31C0                <1> 	xor	eax, eax ; 0
   135                              <1> loc_pass_gnc_FAT16_eoc_check:
   136                              <1> loc_pass_gnc_FAT32_eoc_check:
   137 0000C253 8B0D[5A7F0100]      <1> 	mov	ecx, [FAT_CurrentCluster]
   138 0000C259 F5                  <1> 	cmc
   139 0000C25A C3                  <1> 	retn
   140                              <1> 
   141                              <1> get_FAT12_nc_even:
   142 0000C25B 80E40F              <1> 	and	ah, 0Fh
   143 0000C25E EBEB                <1> 	jmp	short loc_gnc_fat12_eoc_check
   144                              <1> 
   145                              <1> load_FAT_sectors0:
   146 0000C260 880D[5F7F0100]      <1> 	mov	[FAT_BuffDrvName], cl
   147                              <1> load_FAT_sectors1:
   148                              <1> 	; 25/07/2022
   149                              <1> 	;sub	edx, edx
   150                              <1> 	; edx = 0
   151 0000C266 A3[627F0100]        <1> 	mov	[FAT_BuffSector], eax
   152 0000C26B 89C3                <1> 	mov	ebx, eax
   153 0000C26D 034660              <1>         add     eax, [esi+LD_FATBegin]
   154 0000C270 B202                <1> 	mov	dl, 2
   155                              <1> 	;cmp	byte [esi+LD_FATType], 2
   156 0000C272 385603              <1>         cmp	[esi+LD_FATType], dl ; 2
   157 0000C275 7748                <1> 	ja      short load_FAT_sectors3
   158 0000C277 0FB74E1C            <1> 	movzx	ecx, word [esi+LD_BPB+BPB_FATSz16]
   159 0000C27B EB45                <1> 	jmp	short load_FAT_sectors4
   160                              <1> 
   161                              <1> 	; 07/08/2022
   162                              <1> get_FAT32_next_cluster:
   163 0000C27D BB80010000          <1> 	mov	ebx, 180h ;384
   164 0000C282 F7F3                <1> 	div	ebx
   165                              <1> 	; EAX = Count of 3 FAT sectors
   166                              <1> 	; EDX = Cluster Offset (< 384)
   167                              <1> 	;shl	dx, 2	; Multiply by 4
   168                              <1> 	; 25/07/2022
   169 0000C284 C1E202              <1> 	shl	edx, 2
   170 0000C287 89D3                <1> 	mov	ebx, edx ; Byte Offset
   171 0000C289 81C3001C0900        <1> 	add	ebx, FAT_Buffer
   172 0000C28F 66BA0300            <1> 	mov	dx, 3
   173 0000C293 F7E2                <1> 	mul	edx	
   174                              <1>         ; EAX = FAT Sector (<= 2097152) ; (FFFFFF7h * 4) / 512
   175                              <1> 	; 	for 32KB cluster size:
   176                              <1> 	;	EAX <= 1024 = (4GB / 32KB) * 4) / 512 	
   177                              <1> 	; EDX = 0
   178 0000C295 8A0E                <1> 	mov	cl, [esi+LD_Name]
   179                              <1> 	;cmp	byte [FAT_BuffValidData], 0
   180 0000C297 3815[5E7F0100]      <1> 	cmp	[FAT_BuffValidData], dl ; 0
   181 0000C29D 76C1                <1> 	jna	short load_FAT_sectors0
   182 0000C29F 3A0D[5F7F0100]      <1> 	cmp	cl, [FAT_BuffDrvName]
   183 0000C2A5 75B9                <1> 	jne	short load_FAT_sectors0
   184 0000C2A7 3B05[627F0100]      <1> 	cmp	eax, [FAT_BuffSector] ; 0, 3, 6, 9 ...
   185 0000C2AD 75B7                <1> 	jne	short load_FAT_sectors1
   186 0000C2AF 8B03                <1> 	mov	eax, [ebx]
   187 0000C2B1 25FFFFFF0F          <1>  	and	eax, 0FFFFFFFh ; 28 bit Cluster
   188 0000C2B6 3DF7FFFF0F          <1> 	cmp	eax, 0FFFFFF7h
   189 0000C2BB 7296                <1> 	jb	short loc_pass_gnc_FAT32_eoc_check
   190                              <1> 	; eax >= FFFFFF7h (cluster 0002h to FFFFFF6h is valid)
   191 0000C2BD EB92                <1> 	jmp	short loc_pass_gnc_FAT16_eoc_check_xor_eax
   192                              <1> 
   193                              <1> load_FAT_sectors3:
   194 0000C2BF 8B4E2A              <1> 	mov	ecx, [esi+LD_BPB+BPB_FATSz32]
   195                              <1> load_FAT_sectors4:
   196 0000C2C2 29D9                <1> 	sub	ecx, ebx ; [FAT_BuffSector]
   197                              <1> 	; 25/07/2022
   198 0000C2C4 FEC2                <1> 	inc	dl
   199                              <1> 	; edx = 3
   200                              <1>         ;cmp	ecx, 3
   201 0000C2C6 39D1                <1>         cmp	ecx, edx ; 3
   202 0000C2C8 7602                <1> 	jna     short load_FAT_sectors5
   203                              <1> 	;mov	ecx, 3
   204                              <1> 	; 25/07/2022
   205 0000C2CA 89D1                <1> 	mov	ecx, edx ; 3
   206                              <1> load_FAT_sectors5:
   207 0000C2CC BB001C0900          <1> 	mov	ebx, FAT_Buffer
   208 0000C2D1 E87F5A0000          <1> 	call	disk_read
   209 0000C2D6 730C                <1> 	jnc	short load_FAT_sectors_ok
   210                              <1> 	; 15/10/2016 (15h -> 17)
   211                              <1> 	; 23/03/2016 (15h)
   212 0000C2D8 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error
   213                              <1> 	;mov	byte [FAT_BuffValidData], 0
   214                              <1> 	; 25/07/2022
   215 0000C2DD 8825[5E7F0100]      <1> 	mov	byte [FAT_BuffValidData], ah ; 0
   216 0000C2E3 C3                  <1> 	retn
   217                              <1> load_FAT_sectors_ok:
   218 0000C2E4 C605[5E7F0100]01    <1> 	mov	byte [FAT_BuffValidData], 1
   219 0000C2EB A1[5A7F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
   220 0000C2F0 E9C7FEFFFF          <1>         jmp     check_next_cluster_fat_type
   221                              <1> 
   222                              <1> load_FAT_root_directory:
   223                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   224                              <1> 	; 23/10/2016
   225                              <1> 	; 15/10/2016
   226                              <1> 	; 07/02/2016
   227                              <1> 	; 02/02/2016
   228                              <1> 	; 01/02/2016 (TRDOS 386 = TRDOS v2.0)
   229                              <1> 	; 21/05/2011
   230                              <1> 	; 22/08/2009
   231                              <1> 	;
   232                              <1> 	; INPUT ->
   233                              <1> 	;	ESI = Logical DOS Drive Description Table
   234                              <1> 	; OUTPUT ->
   235                              <1> 	;	cf = 1 -> Root directory could not be loaded
   236                              <1> 	;	    EAX > 0 -> Error number
   237                              <1> 	;	cf = 0 -> EAX = 0
   238                              <1> 	;	ECX = Directory buffer size in sectors (CL)
   239                              <1> 	;	EBX = Directory buffer address
   240                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
   241                              <1> 	;
   242                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   243                              <1> 
   244                              <1> 	; NOTE: Only for FAT12 and FAT16 file systems !
   245                              <1> 	; (FAT32 fs root dir must be loaded as sub directory)
   246                              <1> 
   247 0000C2F5 8A1E                <1> 	mov	bl, [esi+LD_Name]
   248 0000C2F7 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
   249                              <1> 
   250                              <1> 	;mov	[DirBuff_DRV], bl
   251                              <1> 	;mov	[DirBuff_FATType], bh
   252 0000C2FA 66891D[6F7F0100]    <1> 	mov	[DirBuff_DRV], bx
   253                              <1> 	
   254                              <1> 	;cmp	bh, 2
   255                              <1> 	;ja	short load_FAT32_root_dir0 ; FAT32 root dir
   256                              <1> 
   257                              <1> load_FAT_root_dir0: ; 23/10/2016
   258 0000C301 0FB75617            <1> 	movzx	edx, word [esi+LD_BPB+RootDirEnts]
   259                              <1> 
   260                              <1> 	;or	dx, dx ; 0 for FAT32 file systems
   261                              <1> 	;jz	short load_FAT32_root_dir0 ; FAT32 root dir
   262                              <1> 	
   263                              <1> 	; 25/07/2022
   264 0000C305 89D0                <1> 	mov	eax, edx
   265 0000C307 6681FA0002          <1> 	cmp	dx, 512 ; Number of Root Dir Entries
   266 0000C30C 740B                <1> 	je	short lrd_mov_ecx_32
   267                              <1> 	;mov	eax, edx ; 25/07/2022
   268                              <1> 	; 23/10/2016
   269 0000C30E 89C1                <1> 	mov	ecx, eax
   270 0000C310 6683C10F            <1> 	add	cx, 15 ; round up 
   271                              <1> 	;shr	cx, 4  ; 16 entries per sector (512/32)
   272                              <1> 	; 25/07/2022
   273 0000C314 C1E904              <1> 	shr	ecx, 4
   274                              <1> 	; ecx = Root directory size in sectors
   275                              <1> 	;;shl	ax, 5 ; Root directory size in bytes
   276                              <1> 	; 25/07/2022
   277                              <1> 	;shl	eax, 5
   278                              <1> 	;;dec	dx    ; Last entry number of root dir
   279                              <1> 	;dec	edx
   280                              <1> 	; cx = Dir Buffer sector count             
   281 0000C317 EB04                <1> 	jmp	short lrd_check_dir_buffer
   282                              <1> 
   283                              <1> lrd_mov_ecx_32:
   284                              <1> 	;mov	ecx, 32
   285                              <1> 	; 25/07/2022
   286 0000C319 29C9                <1> 	sub	ecx, ecx
   287 0000C31B B120                <1> 	mov	cl, 32
   288                              <1> 	;dec	dx ; 511
   289                              <1> 	;mov	ax, 32*512 
   290                              <1> 
   291                              <1> lrd_check_dir_buffer:
   292                              <1> 	; 25/07/2022
   293 0000C31D 4A                  <1> 	dec	edx ; root dir entries - 1
   294 0000C31E C1E005              <1> 	shl	eax, 5 ; * 32
   295                              <1> 	;
   296 0000C321 29DB                <1> 	sub	ebx, ebx ; 0
   297 0000C323 881D[717F0100]      <1> 	mov	[DirBuff_ValidData], bl ; 0
   298 0000C329 668915[747F0100]    <1> 	mov	[DirBuff_LastEntry], dx
   299 0000C330 891D[767F0100]      <1> 	mov	[DirBuff_Cluster], ebx ; 0
   300 0000C336 66A3[7A7F0100]      <1> 	mov	[DirBuffer_Size], ax
   301                              <1> 
   302 0000C33C 8B4664              <1> 	mov	eax, [esi+LD_ROOTBegin]
   303                              <1> read_directory:
   304 0000C33F BB00000800          <1> 	mov	ebx, Directory_Buffer
   305 0000C344 51                  <1> 	push	ecx ; Directory buffer sector count
   306 0000C345 53                  <1> 	push	ebx
   307 0000C346 E80A5A0000          <1> 	call	disk_read
   308 0000C34B 5B                  <1> 	pop	ebx
   309 0000C34C 720B                <1> 	jc	short load_DirBuff_error
   310                              <1> 
   311                              <1> validate_DirBuff_and_return:
   312 0000C34E 59                  <1> 	pop	ecx ; Number of loaded sectors
   313 0000C34F C605[717F0100]01    <1> 	mov	byte [DirBuff_ValidData], 1
   314 0000C356 31C0                <1> 	xor	eax, eax ; 0 = no error
   315 0000C358 C3                  <1> 	retn
   316                              <1> 
   317                              <1> load_DirBuff_error:
   318 0000C359 89C8                <1> 	mov	eax, ecx ; remaining sectors
   319 0000C35B 59                  <1> 	pop	ecx ; sector count
   320 0000C35C 29C1                <1> 	sub	ecx, eax ; Number of loaded sectors
   321                              <1> 	; 15/10/2016 (15h -> 17)
   322                              <1> 	;mov	eax, 17 ; DRV NOT READY OR READ ERROR !
   323                              <1> 	; 25/07/2022
   324                              <1> 	;sub	eax, eax
   325 0000C35E B011                <1> 	mov	al, 17
   326 0000C360 F9                  <1> 	stc
   327 0000C361 C3                  <1>         retn
   328                              <1> 
   329                              <1> load_FAT32_root_directory:
   330                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   331                              <1> 	; 02/02/2016 (TRDOS 386 = TRDOS v2.0)
   332                              <1> 	;
   333                              <1> 	; INPUT ->
   334                              <1> 	;	ESI = Logical DOS Drive Description Table
   335                              <1> 	; OUTPUT ->
   336                              <1> 	;	cf = 1 -> Root directory could not be loaded
   337                              <1> 	;	    EAX > 0 -> Error number
   338                              <1> 	;	cf = 0 -> EAX = 0
   339                              <1> 	;	ECX = Directory buffer size in sectors (CL)
   340                              <1> 	;	EBX = Directory buffer address
   341                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
   342                              <1> 	;
   343                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   344                              <1> 
   345 0000C362 8A1E                <1> 	mov	bl, [esi+LD_Name]
   346 0000C364 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
   347                              <1> 
   348                              <1> 	;mov	[DirBuff_DRV], bl
   349                              <1> 	;mov	[DirBuff_FATType], bh
   350 0000C367 66891D[6F7F0100]    <1> 	mov	[DirBuff_DRV], bx
   351                              <1> 
   352                              <1> load_FAT32_root_dir0:
   353 0000C36E 8B4632              <1> 	mov	eax, [esi+LD_BPB+FAT32_RootFClust]
   354 0000C371 EB0C                <1> 	jmp	short load_FAT_sub_dir0
   355                              <1> 	
   356                              <1> load_FAT_sub_directory:
   357                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   358                              <1> 	; 01/02/2016 (TRDOS 386 = TRDOS v2.0)
   359                              <1> 	; 05/07/2011
   360                              <1> 	; 23/08/2009
   361                              <1> 	;
   362                              <1> 	; INPUT ->
   363                              <1> 	;	ESI = Logical DOS Drive Description Table
   364                              <1> 	;	EAX = Cluster Number
   365                              <1> 	; OUTPUT ->
   366                              <1> 	;	cf = 1 -> Sub directory could not be loaded
   367                              <1> 	;	    EAX > 0 -> Error number
   368                              <1> 	;	cf = 0 -> EAX = 0
   369                              <1> 	;	ECX = Directory buffer size in sectors (CL)
   370                              <1> 	;	EBX = Directory buffer address
   371                              <1> 	;
   372                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
   373                              <1> 	;
   374                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   375                              <1> 
   376 0000C373 8A1E                <1> 	mov	bl, [esi+LD_Name]
   377 0000C375 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
   378                              <1> 
   379                              <1> 	;mov	[DirBuff_DRV], bl
   380                              <1> 	;mov	[DirBuff_FATType], bh
   381 0000C378 66891D[6F7F0100]    <1> 	mov	[DirBuff_DRV], bx
   382                              <1> 
   383                              <1> load_FAT_sub_dir0:
   384 0000C37F 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
   385                              <1> 
   386 0000C383 882D[717F0100]      <1> 	mov	[DirBuff_ValidData], ch ; 0
   387 0000C389 A3[767F0100]        <1> 	mov	[DirBuff_Cluster], eax
   388                              <1> 
   389 0000C38E 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
   390 0000C392 F7E1                <1> 	mul	ecx
   391 0000C394 C1E805              <1> 	shr	eax, 5 ; directory entry count (dir size / 32)
   392                              <1> 	;dec	ax ; last entry
   393                              <1> 	; 25/07/2022
   394 0000C397 48                  <1> 	dec	eax
   395 0000C398 66A3[747F0100]      <1> 	mov	[DirBuff_LastEntry], ax
   396                              <1> 
   397 0000C39E A1[767F0100]        <1> 	mov	eax, [DirBuff_Cluster]
   398 0000C3A3 83E802              <1> 	sub	eax, 2
   399 0000C3A6 F7E1                <1> 	mul	ecx
   400 0000C3A8 034668              <1> 	add	eax, [esi+LD_DATABegin]
   401                              <1> 	; ecx = sectors per cluster (dir buffer size <= 128 sectors)
   402 0000C3AB EB92                <1> 	jmp	short read_directory
   403                              <1> 
   404                              <1> ; DRV_FS.ASM
   405                              <1> 
   406                              <1> ; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   407                              <1> 
   408                              <1> load_current_FS_directory:
   409                              <1> 	;retn
   410                              <1> load_FS_root_directory:
   411                              <1> 	;retn
   412                              <1> load_FS_sub_directory:
   413 0000C3AD C3                  <1> 	retn
   414                              <1> 
   415                              <1> read_cluster:
   416                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   417                              <1> 	; 15/10/2016
   418                              <1> 	; 18/03/2016
   419                              <1> 	; 16/03/2016
   420                              <1> 	; 17/02/2016
   421                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
   422                              <1> 	;
   423                              <1> 	; INPUT ->
   424                              <1> 	;	EAX = Cluster Number (Sector index for SINGLIX FS)
   425                              <1> 	;	ESI = Logical DOS Drive Description Table address
   426                              <1> 	;	EBX = Cluster (File R/W) Buffer address (max. 64KB)
   427                              <1> 	;	Only for SINGLIX FS:
   428                              <1> 	;	EDX = File Number (The 1st FDT address) 
   429                              <1> 	; OUTPUT ->
   430                              <1> 	;	cf = 1 -> Cluster can not be loaded at the buffer
   431                              <1> 	;	    EAX > 0 -> Error number
   432                              <1> 	;	cf = 0 -> Cluster has been loaded at the buffer
   433                              <1> 	;
   434                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   435                              <1> 	
   436 0000C3AE 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust] 
   437                              <1> 	; CL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
   438                              <1> 
   439                              <1> read_file_sectors: ; 16/03/2016
   440                              <1> 	;cmp	byte [esi+LD_FATType], 0
   441                              <1> 	; 25/07/2022
   442 0000C3B2 386E03              <1> 	cmp	[esi+LD_FATType], ch ; 0
   443 0000C3B5 761C                <1> 	jna	short read_fs_cluster
   444                              <1> 
   445                              <1> read_fat_file_sectors: ; 18/03/2016
   446 0000C3B7 83E802              <1> 	sub	eax, 2 ; Beginning cluster number is always 2
   447 0000C3BA 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+BPB_SecPerClust] ; 18/03/2016 
   448 0000C3BE F7E2                <1> 	mul	edx
   449 0000C3C0 034668              <1> 	add	eax, [esi+LD_DATABegin] ; absolute address of the cluster
   450                              <1> 
   451                              <1> 	; EAX = Disk sector address
   452                              <1> 	; ECX = Sector count
   453                              <1> 	; EBX = Buffer address
   454                              <1> 	; (EDX = 0)
   455                              <1> 	; ESI = Logical DOS drive description table address	
   456                              <1> 
   457 0000C3C3 E88D590000          <1> 	call	disk_read
   458 0000C3C8 7306                <1> 	jnc	short rclust_retn
   459                              <1> 	
   460                              <1> 	; 15/10/2016 (15h -> 17)
   461 0000C3CA B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
   462 0000C3CF C3                  <1> 	retn
   463                              <1> 
   464                              <1> rclust_retn:
   465 0000C3D0 29C0                <1> 	sub	eax, eax ; 0
   466 0000C3D2 C3                  <1> 	retn
   467                              <1> 
   468                              <1> read_fs_cluster:
   469                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   470                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
   471                              <1> 	; Singlix FS
   472                              <1> 	
   473                              <1> 	; EAX = Cluster number is sector index number of the file (eax)
   474                              <1> 	
   475                              <1> 	; EDX = File number is the first File Descriptor Table address 
   476                              <1> 	;	of the file. (Absolute address of the FDT).
   477                              <1> 	
   478                              <1> 	; eax = sector index (0 for the first sector)
   479                              <1> 	; edx = FDT0 address
   480                              <1> 		; 64 KB buffer = 128 sectors (limit) 
   481                              <1> 	;mov	ecx, 128 ; maximum count of sectors (before eof) 
   482                              <1> 	; 25/07/2022
   483 0000C3D3 29C9                <1> 	sub	ecx, ecx
   484 0000C3D5 B180                <1> 	mov	cl, 128
   485                              <1> 	;call	read_fs_sectors
   486                              <1> 	;retn
   487                              <1> 	;jmp	short read_fs_sectors
   488                              <1> 
   489                              <1> read_fs_sectors:
   490                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
   491 0000C3D7 F9                  <1> 	stc
   492 0000C3D8 C3                  <1> 	retn
   493                              <1> 
   494                              <1> get_first_free_cluster:
   495                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   496                              <1> 	; 02/03/2016
   497                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
   498                              <1> 	; 26/10/2010 (DRV_FAT.ASM, 'proc_get_first_free_cluster')
   499                              <1> 	; 10/07/2010
   500                              <1> 	; INPUT ->
   501                              <1> 	;	ESI = Logical DOS Drive Description Table address
   502                              <1> 	; OUTPUT ->
   503                              <1> 	;	cf = 1 -> Error code in AL (EAX)
   504                              <1> 	;	cf = 0 -> 
   505                              <1> 	;	  EAX = Cluster number 
   506                              <1> 	;	  If EAX = FFFFFFFFh -> no free space
   507                              <1> 	;	If the drive has FAT32 fs:
   508                              <1> 	;	  EBX = FAT32 FSI sector buffer address (if > 0)
   509                              <1> 
   510 0000C3D9 8B4678              <1> 	mov	eax, [esi+LD_Clusters]
   511 0000C3DC 40                  <1> 	inc	eax ; add eax, 1
   512 0000C3DD A3[F8810100]        <1> 	mov	[gffc_last_free_cluster], eax
   513                              <1> 
   514 0000C3E2 31DB                <1> 	xor	ebx, ebx ; 0 ; 02/03/2016
   515                              <1> 
   516 0000C3E4 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
   517 0000C3E8 760E                <1> 	jna	short loc_gffc_get_first_fat_free_cluster0
   518                              <1> 
   519                              <1> loc_gffc_get_first_fat32_free_cluster:
   520                              <1> 	; 02/03/2016
   521 0000C3EA E8FF050000          <1> 	call	get_fat32_fsinfo_sector_parms
   522 0000C3EF 7207                <1> 	jc	short loc_gffc_get_first_fat_free_cluster0 
   523                              <1> 
   524                              <1> loc_gffc_check_fsinfo_parms:
   525                              <1> 	;;mov	ebx, DOSBootSectorBuff
   526                              <1> 	;cmp	dword [ebx], 41615252h
   527                              <1> 	;jne	short loc_gffc_fat32_fsinfo_err
   528                              <1> 	;cmp	dword [ebx+484], 61417272h
   529                              <1> 	;jne	short loc_gffc_fat32_fsinfo_err
   530                              <1> 	;mov	eax, [ebx+492] ; FSI_Next_Free
   531                              <1> 	;EAX = First free cluster 
   532                              <1> 	;(from FAT32 FSInfo sector)
   533 0000C3F1 89D0                <1> 	mov	eax, edx ; FSI_Next_Free (First Free Cluster)
   534 0000C3F3 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; invalid (unknown) !
   535 0000C3F6 7204                <1> 	jb	short loc_gffc_get_first_fat_free_cluster1
   536                              <1> 
   537                              <1> 	; Start from the 1st cluster of the FAT(32) file system
   538                              <1> loc_gffc_get_first_fat_free_cluster0:
   539                              <1> 	;mov	eax, 2
   540                              <1> 	; 25/07/2022
   541 0000C3F8 29C0                <1> 	sub	eax, eax
   542 0000C3FA B002                <1> 	mov	al, 2
   543                              <1> 	;xor	edx, edx
   544                              <1> 
   545                              <1> loc_gffc_get_first_fat_free_cluster1:
   546 0000C3FC 53                  <1> 	push	ebx ; 02/03/2016 
   547                              <1> 
   548                              <1> loc_gffc_get_first_fat_free_cluster2:   
   549 0000C3FD A3[F4810100]        <1> 	mov	[gffc_first_free_cluster], eax
   550 0000C402 A3[F0810100]        <1> 	mov	[gffc_next_free_cluster], eax
   551                              <1> 
   552                              <1> 	; EBX = FAT32 FSINFO sector buffer address
   553                              <1> 	; (EBX = 0, if the drive has not got FAT32 fs or
   554                              <1> 	; FAT32 FSINFO sector buffer is invalid.)
   555                              <1> 
   556                              <1> loc_gffc_get_first_fat_free_cluster3:
   557 0000C407 E8ABFDFFFF          <1> 	call	get_next_cluster
   558 0000C40C 7307                <1> 	jnc	short loc_gffc_get_first_fat_free_cluster4
   559 0000C40E 09C0                <1> 	or	eax, eax
   560 0000C410 740B                <1> 	jz	short loc_gffc_first_free_fat_cluster_next
   561 0000C412 5B                  <1> 	pop	ebx ; 02/03/2016
   562 0000C413 F5                  <1> 	cmc 	; stc
   563 0000C414 C3                  <1> 	retn
   564                              <1> 
   565                              <1> loc_gffc_get_first_fat_free_cluster4:
   566 0000C415 21C0                <1> 	and	eax, eax ; next cluster value
   567 0000C417 7504                <1> 	jnz	short loc_gffc_first_free_fat_cluster_next
   568 0000C419 89C8                <1> 	mov	eax, ecx ; current (previous cluster) value
   569 0000C41B EB22                <1> 	jmp	short loc_gffc_check_for_set
   570                              <1>  
   571                              <1> loc_gffc_first_free_fat_cluster_next:
   572 0000C41D A1[F0810100]        <1> 	mov	eax, [gffc_next_free_cluster]
   573 0000C422 3B05[F8810100]      <1> 	cmp	eax, [gffc_last_free_cluster]
   574 0000C428 7308                <1> 	jnb	short retn_stc_from_get_first_free_cluster
   575                              <1> pass_gffc_last_cluster_eax_check:
   576 0000C42A 40                  <1> 	inc	eax ; add eax, 1
   577 0000C42B A3[F0810100]        <1> 	mov	[gffc_next_free_cluster], eax
   578 0000C430 EBD5                <1> 	jmp	short loc_gffc_get_first_fat_free_cluster3
   579                              <1> 
   580                              <1> retn_stc_from_get_first_free_cluster:
   581 0000C432 A1[F4810100]        <1> 	mov	eax, [gffc_first_free_cluster]
   582 0000C437 83F802              <1> 	cmp	eax, 2
   583 0000C43A 7709                <1> 	ja	short loc_gffc_check_previous_clusters
   584 0000C43C 29C0                <1> 	sub	eax, eax
   585 0000C43E 48                  <1> 	dec	eax ; FFFFFFFFh
   586                              <1> 
   587                              <1> loc_gffc_check_for_set:
   588                              <1> 	; 02/03/2016
   589 0000C43F 5B                  <1> 	pop	ebx
   590                              <1> 
   591                              <1> 	; EBX = FAT32 FSINFO sector buffer address
   592                              <1> 	; (EBX = 0, if the drive has not got FAT32 fs or
   593                              <1> 	; FAT32 FSINFO sector buffer is invalid.)
   594                              <1> 
   595 0000C440 09DB                <1> 	or	ebx, ebx
   596 0000C442 750D                <1> 	jnz	short loc_gffc_set_ffree_fat32_cluster
   597                              <1> 
   598                              <1> 	;cmp	byte [esi+LD_FATType], 3
   599                              <1> 	;jnb	short loc_gffc_set_ffree_fat32_cluster
   600                              <1> 
   601                              <1> 	;xor	ebx, ebx ; 0
   602                              <1> 
   603                              <1> loc_gffc_retn:
   604 0000C444 C3                  <1> 	retn
   605                              <1> 
   606                              <1> loc_gffc_check_previous_clusters:
   607 0000C445 48                  <1> 	dec	eax ; sub eax, 1
   608 0000C446 A3[F8810100]        <1> 	mov	[gffc_last_free_cluster], eax 
   609                              <1> 	;mov	eax, 2
   610                              <1> 	; 25/07/2022
   611 0000C44B 31C0                <1> 	xor	eax, eax
   612 0000C44D B002                <1> 	mov	al, 2
   613                              <1> 	; eax = 2
   614                              <1> 	;xor	edx, edx
   615 0000C44F EBAC                <1> 	jmp	short loc_gffc_get_first_fat_free_cluster2
   616                              <1> 
   617                              <1> loc_gffc_set_ffree_fat32_cluster:
   618                              <1> 	;call	set_first_free_cluster
   619                              <1> 	;retn
   620                              <1> 	;jmp	short set_first_free_cluster	
   621                              <1> 
   622                              <1> set_first_free_cluster:
   623                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   624                              <1> 	; 15/10/2016
   625                              <1> 	; 23/03/2016
   626                              <1> 	; 02/03/2016
   627                              <1> 	; 29/02/2016
   628                              <1> 	; 26/02/2016
   629                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
   630                              <1> 	; 21/08/2011 (DRV_FAT.ASM, 'proc_set_first_free_cluster')
   631                              <1> 	; 11/07/2010
   632                              <1> 	; INPUT -> 
   633                              <1> 	;	ESI = Logical DOS Drive Description Table address
   634                              <1> 	;	EAX = First free cluster
   635                              <1> 	;	EBX = FSINFO sector buffer address
   636                              <1> 	;  	;;If EBX > 0, it is FSINFO sector buffer address
   637                              <1> 	;	;;EBX = 0, if FSINFO sector is not loaded
   638                              <1> 	; OUTPUT->
   639                              <1> 	;	ESI = Logical DOS Drive Description Table address
   640                              <1> 	;  	If EBX > 0, it is FSINFO sector buffer address
   641                              <1> 	;	EBX = 0, if FSINFO sector could not be loaded
   642                              <1> 	; 	CF = 1 -> Error code in AL (EAX)
   643                              <1> 	;	CF = 0 -> first free cluster is successfully updated 
   644                              <1> 
   645                              <1> 	;cmp	byte [esi+LD_FATType], 3
   646                              <1> 	;jb	short loc_sffc_invalid_drive
   647                              <1> 
   648                              <1> 	; Save First Free Cluster value for 'update_cluster'
   649 0000C451 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First free Cluster	
   650                              <1> 
   651                              <1> 	;or	ebx, ebx
   652                              <1> 	;jnz	short loc_sffc_read_fsinfo_sector
   653                              <1> 
   654 0000C454 813B52526141        <1> 	cmp     dword [ebx], 41615252h
   655 0000C45A 753C                <1> 	jne	short loc_sffc_read_fsinfo_sector
   656 0000C45C 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
   656 0000C465 61                  <1>
   657 0000C466 7530                <1> 	jne	short loc_sffc_read_fsinfo_sector
   658                              <1> 
   659 0000C468 3B83EC010000        <1> 	cmp	eax, [ebx+492]  ; FSI_Next_Free
   660 0000C46E 741E                <1> 	je	short loc_sffc_retn
   661                              <1> 
   662                              <1> loc_sffc_write_fsinfo_sector:
   663                              <1> 	; EBX = FSINFO sector buffer
   664                              <1> 	; [CFS_FAT32FSINFOSEC] is set in 'get_fat32_fsinfo_sector_parms'
   665 0000C470 8983EC010000        <1> 	mov	[ebx+492], eax
   666 0000C476 A1[08820100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC] 
   667                              <1> 	;mov	ecx, 1
   668                              <1> 	; 25/07/2022
   669 0000C47B 31C9                <1> 	xor	ecx, ecx
   670 0000C47D FEC1                <1> 	inc	cl
   671                              <1> 	; ecx = 1
   672 0000C47F 53                  <1> 	push	ebx
   673 0000C480 E8C1580000          <1> 	call	disk_write
   674 0000C485 7208                <1> 	jc      short loc_sffc_read_fsinfo_sector_err1
   675 0000C487 5B                  <1> 	pop	ebx
   676                              <1> 
   677 0000C488 8B83EC010000        <1> 	mov	eax, [ebx+492] ; First (Next) Free Cluster
   678                              <1> 
   679                              <1> loc_sffc_retn:
   680 0000C48E C3                  <1> 	retn
   681                              <1> 
   682                              <1> ;loc_sffc_invalid_drive:
   683                              <1> ;	mov	eax, 0Fh ; MSDOS Error : Invalid drive
   684                              <1> ;	push	edx
   685                              <1> 
   686                              <1> loc_sffc_read_fsinfo_sector_err1:
   687                              <1> 	; 25/07/2022
   688                              <1> 	;mov	ebx, 0
   689                              <1> 	; 15/10/2016 (1Dh -> 18)
   690                              <1> 	; 23/03/2016 (1Dh)
   691                              <1> 	;mov	eax, 18 ; Drive not ready or write error
   692 0000C48F 31C0                <1> 	xor	eax, eax
   693 0000C491 89C3                <1> 	mov	ebx, eax ; 0
   694 0000C493 B012                <1> 	mov	al, 18	
   695 0000C495 F9                  <1> 	stc
   696                              <1> loc_sffc_read_fsinfo_sector_err2:
   697 0000C496 5A                  <1> 	pop	edx
   698 0000C497 C3                  <1> 	retn
   699                              <1> 	
   700                              <1> loc_sffc_read_fsinfo_sector:
   701 0000C498 50                  <1> 	push	eax
   702                              <1> 
   703 0000C499 E850050000          <1> 	call	get_fat32_fsinfo_sector_parms
   704 0000C49E 72F6                <1> 	jc	short loc_sffc_read_fsinfo_sector_err2
   705                              <1> 
   706 0000C4A0 58                  <1> 	pop	eax
   707                              <1> 	; EDX = First (Next) Free Cluster value from FSINFO sector
   708                              <1> 	; EAX = First Free Cluster value from 'get_next_cluster'
   709                              <1> 	; (edx = old value)
   710 0000C4A1 39D0                <1> 	cmp	eax, edx ; First free Cluster (eax = new value) 
   711 0000C4A3 75CB                <1> 	jne	short loc_sffc_write_fsinfo_sector
   712                              <1> 
   713 0000C4A5 C3                  <1> 	retn	
   714                              <1> 
   715                              <1> update_cluster:
   716                              <1> 	; 07/08/2022
   717                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
   718                              <1> 	; 23/10/2016
   719                              <1> 	; 23/03/2016
   720                              <1> 	; 02/03/2016
   721                              <1> 	; 01/03/2016
   722                              <1> 	; 29/02/2016
   723                              <1> 	; 27/02/2016
   724                              <1> 	; 26/02/2016
   725                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
   726                              <1> 	; 11/08/2011  
   727                              <1> 	; 09/02/2005
   728                              <1> 	; INPUT ->
   729                              <1> 	;	EAX = Cluster Number
   730                              <1> 	;	ECX = New Cluster Value
   731                              <1> 	;	ESI = Logical Dos Drive Parameters Table
   732                              <1> 	;
   733                              <1> 	;	/// dword [FAT_ClusterCounter] ///
   734                              <1> 	;
   735                              <1> 	; OUTPUT ->
   736                              <1> 	;	cf = 0 -> No Error, EAX is valid
   737                              <1> 	;	cf = 1 & EAX = 0 -> End Of Cluster Chain
   738                              <1> 	; 	cf = 1 & EAX > 0 -> Error
   739                              <1> 	;		(ECX -> any value)
   740                              <1> 	; 	EAX = Next Cluster
   741                              <1> 	;	ECX = New Cluster Value
   742                              <1> 	;
   743                              <1> 	;	/// [FAT_ClusterCounter] is updated,
   744                              <1> 	;	/// decreased when a free cluster is assigned,
   745                              <1> 	;	/// increased if an assigned cluster is freed.	
   746                              <1> 	;		
   747                              <1> 	;
   748                              <1> 	; (Modified registers: EAX, EBX, -ECX-, EDX)
   749                              <1> 	
   750 0000C4A6 A3[5A7F0100]        <1> 	mov	[FAT_CurrentCluster], eax
   751 0000C4AB 890D[FC810100]      <1> 	mov	[ClusterValue], ecx
   752                              <1> 
   753                              <1> loc_update_cluster_check_fat_buffer:
   754 0000C4B1 8A1E                <1> 	mov	bl, [esi+LD_Name]
   755 0000C4B3 381D[5F7F0100]      <1> 	cmp	[FAT_BuffDrvName], bl
   756 0000C4B9 7418                <1> 	je	short loc_update_cluster_check_fat_type
   757 0000C4BB 803D[5E7F0100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
   758                              <1> 	;je	loc_uc_save_fat_buffer
   759                              <1> 	; 25/07/2022
   760 0000C4C2 7502                <1> 	jne	short loc_uc_reset_fat_buffer_validation
   761 0000C4C4 EB65                <1> 	jmp	loc_uc_save_fat_buffer
   762                              <1> 
   763                              <1> loc_uc_reset_fat_buffer_validation:
   764 0000C4C6 C605[5E7F0100]00    <1> 	mov	byte [FAT_BuffValidData], 0
   765                              <1> 
   766                              <1> loc_uc_check_fat_type_reset_drvname:
   767 0000C4CD 881D[5F7F0100]      <1> 	mov	[FAT_BuffDrvName], bl
   768                              <1> 
   769                              <1> loc_update_cluster_check_fat_type:
   770 0000C4D3 29D2                <1> 	sub	edx, edx ; 26/02/2016
   771 0000C4D5 8A5E03              <1> 	mov	bl, [esi+LD_FATType]
   772 0000C4D8 83F802              <1> 	cmp	eax, 2
   773 0000C4DB 721D                <1>         jb	short update_cluster_inv_data
   774 0000C4DD 80FB02              <1> 	cmp	bl, 2 
   775                              <1>         ;ja	update_fat32_cluster
   776                              <1> 	; 25/07/2022
   777 0000C4E0 7605                <1> 	jna	short loc_uc_check_fat_type_1
   778 0000C4E2 E98D010000          <1> 	jmp	update_fat32_cluster
   779                              <1> 
   780                              <1> loc_uc_check_fat_type_1:
   781                              <1> 	;cmp	bl, 1
   782                              <1> 	;jb	short update_cluster_inv_data
   783 0000C4E7 8B4E78              <1> 	mov	ecx, [esi+LD_Clusters]
   784 0000C4EA 41                  <1> 	inc	ecx  
   785 0000C4EB 890D[6A7F0100]      <1> 	mov	[LastCluster], ecx
   786 0000C4F1 39C8                <1> 	cmp	eax, ecx ; dword [LastCluster]
   787                              <1> 	;ja	return_uc_fat_stc
   788                              <1> 	; 25/07/2022
   789 0000C4F3 7608                <1> 	jna	short loc_uc_check_fat_type_2
   790 0000C4F5 E9D6000000          <1> 	jmp	return_uc_fat_stc
   791                              <1> 
   792                              <1> 	; 25/07/2022
   793                              <1> update_cluster_inv_data:
   794                              <1> 	;mov	eax, 0Dh
   795 0000C4FA B00D                <1> 	mov	al, 0Dh  ; Invalid Data
   796 0000C4FC C3                  <1> 	retn 
   797                              <1> 
   798                              <1> loc_uc_check_fat_type_2:
   799                              <1> 	; TRDOS v1 has a FATal bug here ! 
   800                              <1> 		; or bl, bl ; cmp bl, 0
   801                              <1> 		; jz short update_fat12_cluster
   802                              <1> 	; !! It would destroy FAT12 floppy disk fs here !!
   803                              <1> 	; ('A:' disks of TRDOS v1 operating system project
   804                              <1> 	; had 'singlix fs', so, I could not differ this mistake
   805                              <1> 	; on a drive 'A:')
   806 0000C4FD 80FB01              <1> 	cmp	bl, 1 ; correct comparison is this !
   807                              <1> 	;jna	update_fat12_cluster
   808                              <1> 	; 25/07/2022
   809 0000C500 7705                <1> 	ja	short update_fat16_cluster
   810 0000C502 E9CE000000          <1> 	jmp	update_fat12_cluster	 
   811                              <1> 
   812                              <1> update_fat16_cluster:
   813                              <1> pass_uc_fat16_errc:
   814                              <1> 	;sub	edx, edx
   815 0000C507 BB00030000          <1> 	mov	ebx, 300h ;768
   816 0000C50C F7F3                <1> 	div	ebx
   817                              <1> 	; EAX = Count of 3 FAT sectors
   818                              <1> 	; DX = Cluster offset in FAT buffer
   819                              <1> 	;mov	bx, dx  
   820                              <1> 	; 25/07/2022
   821 0000C50E 89D3                <1> 	mov	ebx, edx
   822                              <1> 	;shl	bx, 1 ; Multiply by 2
   823                              <1> 	; 25/07/2022
   824 0000C510 D1E3                <1> 	shl	ebx, 1
   825 0000C512 66BA0300            <1> 	mov	dx, 3
   826 0000C516 F7E2                <1> 	mul	edx  
   827                              <1> 	; EAX = FAT Sector
   828                              <1> 	; EDX = 0
   829                              <1> 	; EBX = Byte offset in FAT buffer
   830 0000C518 8A0D[5E7F0100]      <1> 	mov	cl, [FAT_BuffValidData]
   831 0000C51E 80F902              <1> 	cmp	cl, 2
   832 0000C521 7518                <1> 	jne	short loc_uc_check_fat16_buff_sector_load
   833                              <1> 
   834                              <1> loc_uc_check_fat16_buff_sector_save:
   835 0000C523 3B05[627F0100]      <1> 	cmp	eax, [FAT_BuffSector]
   836                              <1> 	;jne	short loc_uc_save_fat_buffer
   837                              <1> 	;jmp	short loc_update_fat16_cell
   838                              <1> 	; 07/08/2022
   839 0000C529 741D                <1> 	je	short loc_update_fat16_cell
   840                              <1> 	;jmp	loc_uc_save_fat_buffer
   841                              <1> 	
   842                              <1> 	; 07/08/2022
   843                              <1> loc_uc_save_fat_buffer:
   844                              <1> 	; byte [FAT_BuffValidData] = 2 
   845 0000C52B E8F9010000          <1> 	call	save_fat_buffer
   846 0000C530 7267                <1>         jc      short loc_fat_sectors_rw_error2
   847                              <1> 	;mov	byte [FAT_BuffValidData], 1
   848 0000C532 A1[5A7F0100]        <1> 	mov	eax, [FAT_CurrentCluster]
   849                              <1> 	;mov	ecx, [ClusterValue]
   850                              <1> 	;jmp	short loc_update_cluster_check_fat_buffer
   851 0000C537 8A1E                <1> 	mov	bl, [esi+LD_Name] ; 01/03/2016
   852 0000C539 EB8B                <1>         jmp     loc_uc_reset_fat_buffer_validation
   853                              <1> 
   854                              <1> loc_uc_check_fat16_buff_sector_load:
   855 0000C53B 80F901              <1> 	cmp	cl, 1 ; byte [FAT_BuffValidData]
   856 0000C53E 7560                <1>         jne     short loc_uc_load_fat_sectors
   857 0000C540 3B05[627F0100]      <1> 	cmp	eax, [FAT_BuffSector]
   858 0000C546 7558                <1>         jne     short loc_uc_load_fat_sectors
   859                              <1> 
   860                              <1> loc_update_fat16_cell:
   861                              <1> loc_update_fat16_buffer:
   862 0000C548 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
   863                              <1> 	;movzx	eax, word [ebx]
   864 0000C54E 668B03              <1> 	mov	ax, [ebx]
   865                              <1> 	; 01/03/2016
   866 0000C551 89C2                <1> 	mov	edx, eax ; old value of the cluster
   867 0000C553 A3[5A7F0100]        <1> 	mov	[FAT_CurrentCluster], eax
   868 0000C558 8B0D[FC810100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
   869 0000C55E 66890B              <1> 	mov	[ebx], cx ; 16 bits !
   870                              <1> 
   871 0000C561 C605[5E7F0100]02    <1> 	mov	byte [FAT_BuffValidData], 2
   872                              <1> 	
   873 0000C568 6683F802            <1> 	cmp	ax, 2
   874 0000C56C 7262                <1> 	jb	short return_uc_fat16_stc
   875 0000C56E 3B05[6A7F0100]      <1> 	cmp	eax, [LastCluster]
   876 0000C574 775A                <1> 	ja	short return_uc_fat16_stc
   877                              <1> 
   878                              <1> loc_fat_buffer_updated:
   879                              <1> 	; 01/03/2016
   880 0000C576 F8                  <1> 	clc
   881                              <1> loc_fat_buffer_stc_1:
   882 0000C577 9C                  <1> 	pushf
   883 0000C578 21C9                <1> 	and	ecx, ecx
   884 0000C57A 7506                <1> 	jnz	short loc_fat_buffer_updated_1
   885                              <1> 
   886                              <1> 	; 01/03/2016 
   887                              <1> 	; new value of the cluster = 0 (free)
   888                              <1> 	; increase free(d) cluster count
   889 0000C57C FF05[667F0100]      <1> 	inc	dword [FAT_ClusterCounter]
   890                              <1> 
   891                              <1> loc_fat_buffer_updated_1: ; new value of the cluster > 0
   892 0000C582 09D2                <1> 	or	edx, edx ; 02/03/2016
   893 0000C584 7506                <1> 	jnz	short loc_fat_buffer_updated_2
   894                              <1> 	; old value of the cluster = 0 (it was free cluster)
   895                              <1> 	; decrease free(d) cluster count
   896 0000C586 FF0D[667F0100]      <1> 	dec	dword [FAT_ClusterCounter] ; it may be negative number
   897                              <1> 
   898                              <1> loc_fat_buffer_updated_2:
   899 0000C58C 9D                  <1> 	popf
   900 0000C58D C3                  <1> 	retn
   901                              <1> 
   902                              <1> 	; 25/07/2022
   903                              <1> loc_fat_sectors_rw_error1:
   904                              <1> 	;mov	byte [FAT_BuffValidData], 0
   905                              <1> 	; 23/10/2016 (15h -> 17)
   906                              <1> 	; 23/03/2016
   907 0000C58E B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error
   908 0000C593 8825[5E7F0100]      <1> 	mov	[FAT_BuffValidData], ah ; 0
   909                              <1> 
   910                              <1> loc_fat_sectors_rw_error2:
   911                              <1> 	;mov	eax, error code
   912                              <1> 	;mov	edx, 0
   913 0000C599 8B0D[FC810100]      <1> 	mov	ecx, [ClusterValue]
   914 0000C59F C3                  <1> 	retn
   915                              <1> 
   916                              <1> 	; 25/07/2022
   917                              <1> loc_uc_load_fat_sectors:
   918 0000C5A0 A3[627F0100]        <1> 	mov	[FAT_BuffSector], eax
   919                              <1> 
   920                              <1> load_uc_fat_sectors_zero:
   921 0000C5A5 034660              <1> 	add	eax, [esi+LD_FATBegin]
   922 0000C5A8 BB001C0900          <1> 	mov	ebx, FAT_Buffer
   923 0000C5AD B903000000          <1> 	mov	ecx, 3
   924 0000C5B2 E89E570000          <1> 	call	disk_read
   925 0000C5B7 72D5                <1> 	jc	short loc_fat_sectors_rw_error1
   926                              <1> 
   927 0000C5B9 C605[5E7F0100]01    <1>         mov     byte [FAT_BuffValidData], 1
   928 0000C5C0 A1[5A7F0100]        <1> 	mov 	eax, [FAT_CurrentCluster]
   929 0000C5C5 8B0D[FC810100]      <1> 	mov	ecx, [ClusterValue]
   930 0000C5CB E903FFFFFF          <1>         jmp     loc_update_cluster_check_fat_type
   931                              <1> 
   932                              <1> return_uc_fat16_stc:
   933                              <1> 	; 25/07/2022
   934                              <1> return_uc_fat_stc:
   935                              <1> 	; 01/03/2016
   936 0000C5D0 31C0                <1> 	xor	eax, eax
   937 0000C5D2 F9                  <1> 	stc
   938 0000C5D3 EBA2                <1> 	jmp	short loc_fat_buffer_stc_1
   939                              <1> 
   940                              <1> update_fat12_cluster:
   941                              <1> pass_uc_fat12_errc:
   942                              <1> 	;sub	edx, edx
   943 0000C5D5 BB00040000          <1> 	mov	ebx, 400h ;1024
   944 0000C5DA F7F3                <1> 	div	ebx
   945                              <1> 	; EAX = Count of 3 FAT sectors
   946                              <1> 	; DX = Cluster offset in FAT buffer
   947                              <1> 	;mov	cx, 3
   948                              <1> 	; 25/07/2022
   949 0000C5DC 29C9                <1> 	sub	ecx, ecx
   950 0000C5DE B103                <1> 	mov	cl, 3
   951                              <1> 	; ecx = 3
   952                              <1> 	;mov	bx, ax
   953 0000C5E0 89C3                <1> 	mov	ebx, eax
   954                              <1> 	;mov	ax, cx ; 3
   955 0000C5E2 89C8                <1> 	mov	eax, ecx
   956                              <1> 	;mul	dx     ; Multiply by 3
   957 0000C5E4 F7E2                <1> 	mul	edx
   958                              <1> 	;shr	ax, 1  ; Divide by 2
   959 0000C5E6 D1E8                <1> 	shr	eax, 1
   960                              <1> 	;xchg	bx, ax
   961 0000C5E8 93                  <1> 	xchg	ebx, eax
   962                              <1> 	; EAX = Count of 3 FAT sectors
   963                              <1> 	; EBX = Byte Offset in FAT buffer   
   964                              <1> 	;mul	cx  ; 3 * AX
   965 0000C5E9 F7E1                <1> 	mul	ecx ; 3 * EAX
   966                              <1> 	; EAX = FAT Beginning Sector
   967                              <1> 	; EDX = 0
   968 0000C5EB 8A0D[5E7F0100]      <1> 	mov	cl, [FAT_BuffValidData]
   969                              <1> 	; TRDOS v1 has a FATal bug here ! 
   970                              <1> 	; (it does not have 'cmp cl, 2' instruction here !
   971                              <1> 	;  while 'jne' is existing !)
   972 0000C5F1 80F902              <1> 	cmp	cl, 2 ; 2 = dirty buffer (must be written to disk)
   973 0000C5F4 750D                <1> 	jne	short loc_uc_check_fat12_buff_sector_load
   974                              <1> 
   975                              <1> loc_uc_check_fat12_buff_sector_save:
   976 0000C5F6 3B05[627F0100]      <1> 	cmp	eax, [FAT_BuffSector]
   977                              <1>         ;jne	short loc_uc_save_fat_buffer
   978                              <1> 	;jmp	short loc_update_fat12_cell
   979                              <1> 	; 07/08/2022
   980 0000C5FC 7412                <1> 	je	short loc_update_fat12_cell
   981 0000C5FE E928FFFFFF          <1> 	jmp	loc_uc_save_fat_buffer
   982                              <1> 
   983                              <1> loc_uc_check_fat12_buff_sector_load:
   984 0000C603 80F901              <1> 	cmp	cl, 1 ; byte ptr [FAT_BuffValidData]
   985 0000C606 7598                <1>         jne     short loc_uc_load_fat_sectors
   986 0000C608 3B05[627F0100]      <1> 	cmp	eax, [FAT_BuffSector]
   987 0000C60E 7590                <1> 	jne	short loc_uc_load_fat_sectors
   988                              <1> 	; 07/08/2022
   989                              <1> 	;je	short loc_update_fat12_cell
   990                              <1> 	;jmp	loc_uc_load_fat_sectors
   991                              <1> 
   992                              <1> loc_update_fat12_cell:
   993 0000C610 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
   994                              <1> 	;mov	cx, [FAT_CurrentCluster]
   995                              <1> 	; 25/07/2022
   996 0000C616 8B0D[5A7F0100]      <1> 	mov	ecx, [FAT_CurrentCluster] 
   997                              <1> 	;shr	cx, 1
   998                              <1> 	; 25/07/2022
   999 0000C61C D1E9                <1> 	shr	ecx, 1
  1000 0000C61E 668B03              <1> 	mov	ax, [ebx]
  1001                              <1> 	;mov	dx, ax
  1002 0000C621 89C2                <1> 	mov	edx, eax ; 25/07/2022
  1003 0000C623 7336                <1> 	jnc	short uc_fat12_nc_even
  1004                              <1> 
  1005                              <1> 	;and	ax, 0Fh
  1006                              <1> 	; 25/07/2022
  1007 0000C625 240F                <1> 	and	al, 0Fh
  1008 0000C627 8B0D[FC810100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
  1009                              <1> 	;shl	cx, 4
  1010 0000C62D C1E104              <1> 	shl	ecx, 4
  1011                              <1> 	;or	cx, ax
  1012 0000C630 08C1                <1> 	or	cl, al ; 25/07/2022
  1013                              <1> 	;mov	ax, dx
  1014 0000C632 89D0                <1> 	mov	eax, edx
  1015 0000C634 66890B              <1> 	mov	[ebx], cx  ; 16 bits !
  1016                              <1> 	;shr	ax, 4 ; al(bit4..7)+ah(bit0..7)
  1017                              <1> 	; 25/07/2022
  1018 0000C637 C1E804              <1> 	shr	eax, 4
  1019                              <1> 
  1020                              <1> update_fat12_buffer:
  1021 0000C63A A3[5A7F0100]        <1> 	mov	[FAT_CurrentCluster], eax
  1022 0000C63F 89C2                <1> 	mov	edx, eax ; 01/03/2016
  1023 0000C641 C605[5E7F0100]02    <1> 	mov	byte [FAT_BuffValidData], 2
  1024 0000C648 6683F802            <1> 	cmp	ax, 2
  1025 0000C64C 725E                <1>         jb      short return_uc_fat12_stc
  1026 0000C64E 3B05[6A7F0100]      <1> 	cmp	eax, [LastCluster]
  1027 0000C654 7756                <1>         ja      short return_uc_fat12_stc
  1028 0000C656 E91BFFFFFF          <1>         jmp     loc_fat_buffer_updated
  1029                              <1> 
  1030                              <1> uc_fat12_nc_even:
  1031 0000C65B 662500F0            <1> 	and	ax, 0F000h
  1032 0000C65F 8B0D[FC810100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
  1033 0000C665 80E50F              <1> 	and	ch, 0Fh
  1034                              <1> 	;or	cx, ax
  1035                              <1> 	; 25/07/2022
  1036 0000C668 09C1                <1> 	or	ecx, eax
  1037                              <1> 	;mov	ax, dx
  1038 0000C66A 89D0                <1> 	mov	eax, edx
  1039 0000C66C 66890B              <1> 	mov	[ebx], cx ; 16 bits !
  1040 0000C66F 80E40F              <1> 	and	ah, 0Fh ; al(bit0..7)+ah(bit0..3)
  1041 0000C672 EBC6                <1> 	jmp	short update_fat12_buffer
  1042                              <1> 
  1043                              <1> update_fat32_cluster:
  1044 0000C674 8B4E78              <1> 	mov	ecx, [esi+LD_Clusters]
  1045 0000C677 41                  <1> 	inc	ecx
  1046 0000C678 890D[6A7F0100]      <1> 	mov	[LastCluster], ecx
  1047                              <1> 
  1048 0000C67E 39C8                <1> 	cmp	eax, ecx
  1049 0000C680 772A                <1>         ja      short return_uc_fat32_stc ; 25/07/2022
  1050                              <1> 
  1051                              <1> pass_uc_fat32_errc:
  1052                              <1> 	;sub	edx, edx
  1053 0000C682 BB80010000          <1> 	mov	ebx, 180h ;384
  1054 0000C687 F7F3                <1> 	div	ebx
  1055                              <1> 	; EAX = Count of 3 FAT sectors
  1056                              <1> 	; DX = Cluster offset in FAT buffer
  1057 0000C689 89D3                <1> 	mov	ebx, edx
  1058 0000C68B C1E302              <1> 	shl	ebx, 2 ; Multiply by 4
  1059                              <1> 	;mov	edx, 3	
  1060                              <1> 	; 25/07/2022
  1061                              <1> 	;xor	dh, dh
  1062                              <1> 	;mov	dl, 3
  1063 0000C68E 66BA0300            <1> 	mov	dx, 3
  1064 0000C692 F7E2                <1> 	mul	edx
  1065                              <1> 	; EBX = Cluster Offset in FAT buffer
  1066                              <1> 	; EAX = FAT Sector
  1067                              <1> 	; EDX = 0
  1068 0000C694 8A0D[5E7F0100]      <1> 	mov	cl, [FAT_BuffValidData]
  1069 0000C69A 80F902              <1> 	cmp	cl, 2
  1070 0000C69D 7515                <1> 	jne	short loc_uc_check_fat32_buff_sector_load
  1071                              <1> 
  1072                              <1> loc_uc_check_fat32_buff_sector_save:
  1073 0000C69F 3B05[627F0100]      <1> 	cmp	eax, [FAT_BuffSector]
  1074                              <1> 	;jne	loc_uc_save_fat_buffer
  1075                              <1> 	;jmp	short loc_update_fat32_cell
  1076                              <1> 	; 25/07/2022
  1077 0000C6A5 741F                <1> 	je	short loc_update_fat32_cell
  1078 0000C6A7 E97FFEFFFF          <1> 	jmp	loc_uc_save_fat_buffer
  1079                              <1> 
  1080                              <1> return_uc_fat12_stc:
  1081                              <1> return_uc_fat32_stc:
  1082                              <1> 	; 25/07/2022
  1083 0000C6AC 29C0                <1> 	sub	eax, eax
  1084 0000C6AE F9                  <1> 	stc
  1085 0000C6AF E9C3FEFFFF          <1> 	jmp	loc_fat_buffer_stc_1
  1086                              <1> 
  1087                              <1> loc_uc_check_fat32_buff_sector_load:
  1088 0000C6B4 80F901              <1> 	cmp	cl, 1 ; byte [FAT_BuffValidData]
  1089                              <1> 	;jne	loc_uc_load_fat_sectors
  1090                              <1> 	; 25/07/2022
  1091 0000C6B7 7508                <1> 	jne	short loc_uc_load_fat_sects
  1092 0000C6B9 3B05[627F0100]      <1> 	cmp	eax, [FAT_BuffSector]
  1093                              <1> 	;jne	loc_uc_load_fat_sectors
  1094                              <1> 	; 25/07/2022
  1095 0000C6BF 7405                <1> 	je	short loc_update_fat32_cell
  1096                              <1> loc_uc_load_fat_sects:
  1097 0000C6C1 E9DAFEFFFF          <1> 	jmp	loc_uc_load_fat_sectors	
  1098                              <1> 
  1099                              <1> loc_update_fat32_cell:
  1100                              <1> loc_update_fat32_buffer:
  1101 0000C6C6 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
  1102 0000C6CC 8B03                <1> 	mov	eax, [ebx]
  1103 0000C6CE 25FFFFFF0F          <1> 	and	eax, 0FFFFFFFh ; 28 bit cluster value
  1104                              <1> 	
  1105 0000C6D3 8B15[5A7F0100]      <1> 	mov	edx, [FAT_CurrentCluster] ; 01/03/2016
  1106                              <1> 
  1107 0000C6D9 A3[5A7F0100]        <1> 	mov 	[FAT_CurrentCluster], eax
  1108 0000C6DE 8B0D[FC810100]      <1> 	mov	ecx, [ClusterValue]
  1109 0000C6E4 890B                <1> 	mov	[ebx], ecx ; 29/02/2016 
  1110                              <1> 
  1111 0000C6E6 C605[5E7F0100]02    <1> 	mov	byte [FAT_BuffValidData], 2
  1112                              <1> 
  1113                              <1> 	; 01/03/2016
  1114 0000C6ED 21C0                <1> 	and	eax, eax ; was it free cluster ?
  1115 0000C6EF 7513                <1> 	jnz	short loc_upd_fat32_c0
  1116                              <1> 
  1117                              <1> 	;or	ecx, ecx ; it will be left free ?!
  1118                              <1> 	;jz	short loc_upd_fat32_c3
  1119                              <1> 
  1120 0000C6F1 3B563E              <1> 	cmp	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free cluster
  1121 0000C6F4 751F                <1> 	jne	short loc_upd_fat32_c3
  1122                              <1> 
  1123 0000C6F6 3B15[6A7F0100]      <1> 	cmp	edx, [LastCluster]
  1124 0000C6FC 7206                <1> 	jb	short loc_upd_fat32_c0
  1125                              <1> 
  1126                              <1> 	;mov	edx, 2 ; rewind !
  1127                              <1> 	; 25/07/2022
  1128 0000C6FE 29D2                <1> 	sub	edx, edx
  1129 0000C700 B202                <1> 	mov	dl, 2
  1130 0000C702 EB0E                <1> 	jmp	short loc_upd_fat32_c2
  1131                              <1> 
  1132                              <1> loc_upd_fat32_c0:
  1133 0000C704 FF463E              <1> 	inc	dword [esi+LD_BPB+BPB_Reserved+4] ; set it to next cluster		
  1134 0000C707 EB0C                <1> 	jmp	short loc_upd_fat32_c3
  1135                              <1> 
  1136                              <1> loc_upd_fat32_c1:
  1137 0000C709 09C9                <1> 	or	ecx, ecx ; will it be free cluster ?
  1138 0000C70B 7508                <1> 	jnz	short loc_upd_fat32_c3
  1139                              <1> 
  1140 0000C70D 3B563E              <1> 	cmp	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free cluster
  1141 0000C710 7303                <1> 	jnb	short loc_upd_fat32_c3
  1142                              <1> 
  1143                              <1> loc_upd_fat32_c2:	
  1144 0000C712 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx			
  1145                              <1> 
  1146                              <1> loc_upd_fat32_c3:
  1147 0000C715 89C2                <1> 	mov	edx, eax
  1148                              <1> 
  1149                              <1> loc_upd_fat32_c4:
  1150 0000C717 83F802              <1> 	cmp	eax, 2
  1151 0000C71A 7290                <1> 	jb	short return_uc_fat32_stc ; 25/07/2022 
  1152                              <1> 
  1153                              <1> pass_uc_fat32_c_zero_check_2:
  1154 0000C71C 3B05[6A7F0100]      <1> 	cmp	eax, [LastCluster]
  1155 0000C722 7788                <1> 	ja	short return_uc_fat32_stc ; 25/07/2022
  1156                              <1> 	
  1157 0000C724 E94DFEFFFF          <1> 	jmp     loc_fat_buffer_updated
  1158                              <1> 
  1159                              <1> 
  1160                              <1> save_fat_buffer:
  1161                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  1162                              <1> 	; 15/10/2016
  1163                              <1> 	; 01/03/2016
  1164                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
  1165                              <1> 	; 11/08/2011
  1166                              <1> 	; 09/02/2005 
  1167                              <1> 	; INPUT ->
  1168                              <1> 	;	None
  1169                              <1> 	; OUTPUT ->
  1170                              <1> 	;	cf = 0 -> OK.
  1171                              <1> 	;	cf = 1 -> error code in AL (EAX)
  1172                              <1> 	;
  1173                              <1> 	;	EBX = FAT_Buffer address
  1174                              <1> 	;
  1175                              <1> 	; (EAX, EDX, ECX will be modified)
  1176                              <1> 
  1177                              <1> 	;cmp	byte [FAT_BuffValidData], 2 
  1178                              <1> 	;je	short loc_save_fat_buff
  1179                              <1> 
  1180                              <1> ;loc_save_fat_buffer_retn:
  1181                              <1> ;	xor	eax, eax
  1182                              <1> ;	retn
  1183                              <1> 
  1184                              <1> loc_save_fat_buff:
  1185 0000C729 31D2                <1> 	xor	edx, edx
  1186 0000C72B 8A35[5F7F0100]      <1> 	mov	dh, [FAT_BuffDrvName]
  1187 0000C731 80FE41              <1> 	cmp	dh, 'A'
  1188 0000C734 7252                <1> 	jb	short loc_save_fat_buffer_inv_data_retn
  1189 0000C736 80EE41              <1> 	sub	dh, 'A'
  1190 0000C739 56                  <1> 	push	esi ; *
  1191 0000C73A BE00010900          <1>         mov     esi, Logical_DOSDisks
  1192 0000C73F 01D6                <1> 	add	esi, edx
  1193                              <1> 	
  1194 0000C741 8A5603              <1> 	mov	dl, [esi+LD_FATType]
  1195 0000C744 20D2                <1> 	and	dl, dl
  1196 0000C746 743F                <1> 	jz	short loc_save_fat_buffer_inv_data_pop_retn 
  1197                              <1> 
  1198 0000C748 A1[627F0100]        <1> 	mov	eax, [FAT_BuffSector]
  1199 0000C74D 80FA02              <1> 	cmp	dl, 2
  1200 0000C750 772E                <1> 	ja	short loc_save_fat32_buff
  1201                              <1> 
  1202                              <1> loc_save_fat_12_16_buff:
  1203                              <1> 	; 01/03/2016
  1204                              <1> 	; TRDOS v1 has a FATal bug here!
  1205                              <1> 	; Correct code: mov dx, word ptr [FAT_BuffSector]+2
  1206                              <1> 	; (DX:AX in TRDOS v1 -> EAX in TRDOS v2)
  1207                              <1> 	;
  1208 0000C752 0FB74E1C            <1> 	movzx	ecx, word [esi+LD_BPB+FATSecs] 
  1209 0000C756 29C1                <1> 	sub	ecx, eax
  1210                              <1> 	; TRDOS v1 has a bug here... ('pop esi' was forgotten!)
  1211                              <1> 	;jna	short loc_save_fat_buffer_inv_data_retn ; wrong addr!
  1212 0000C758 762D                <1> 	jna	short loc_save_fat_buffer_inv_data_pop_retn ; correct addr.
  1213                              <1> 	; 25/07/2022
  1214                              <1> 	;jmp	short loc_save_fat_buffer_check_rs3
  1215                              <1> 
  1216                              <1> loc_save_fat_buffer_check_rs3:
  1217                              <1> 	; 25/07/2022
  1218 0000C75A 29DB                <1> 	sub	ebx, ebx
  1219 0000C75C B303                <1> 	mov	bl, 3
  1220                              <1> 	;cmp	ecx, 3
  1221 0000C75E 39D9                <1> 	cmp	ecx, ebx ; 3
  1222 0000C760 7602                <1> 	jna	short loc_save_fat_buff_continue
  1223 0000C762 89D9                <1> 	mov	ecx, ebx ; mov ecx, 3
  1224                              <1> loc_save_fat_buff_continue:
  1225 0000C764 BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1226 0000C769 034660              <1> 	add	eax, [esi+LD_FATBegin]
  1227 0000C76C 51                  <1> 	push	ecx
  1228 0000C76D E8D4550000          <1> 	call	disk_write
  1229 0000C772 59                  <1> 	pop	ecx
  1230 0000C773 7239                <1> 	jc	short loc_save_FAT_buff_write_err
  1231                              <1> 	
  1232 0000C775 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1233 0000C779 7613                <1> 	jna	short loc_calc_2nd_fat12_16_addr
  1234                              <1> 
  1235                              <1> loc_calc_2nd_fat32_addr:
  1236 0000C77B 8B462A              <1> 	mov	eax, [esi+LD_BPB+FAT32_FAT_Size]
  1237 0000C77E EB12                <1> 	jmp	short loc_calc_2nd_fat_addr
  1238                              <1> 
  1239                              <1> 	; 25/07/2022
  1240                              <1> loc_save_fat32_buff:
  1241 0000C780 8B4E2A              <1> 	mov	ecx, [esi+LD_BPB+FAT32_FAT_Size]
  1242 0000C783 29C1                <1> 	sub	ecx, eax
  1243 0000C785 77D3                <1> 	ja	short loc_save_fat_buffer_check_rs3
  1244                              <1> 
  1245                              <1> loc_save_fat_buffer_inv_data_pop_retn:
  1246 0000C787 5E                  <1> 	pop	esi ; *
  1247                              <1> loc_save_fat_buffer_inv_data_retn:
  1248                              <1> 	;mov	eax, 0Dh ; Invalid DATA
  1249                              <1> 	; 25/07/2022
  1250 0000C788 29C0                <1> 	sub	eax, eax
  1251 0000C78A B00D                <1> 	mov	al, 0Dh  ; Invalid DATA
  1252 0000C78C F9                  <1> 	stc	; cf = 1
  1253 0000C78D C3                  <1> 	retn
  1254                              <1> 
  1255                              <1> loc_calc_2nd_fat12_16_addr:
  1256 0000C78E 0FB7461C            <1> 	movzx	eax, word [esi+LD_BPB+FATSecs]
  1257                              <1> 
  1258                              <1> loc_calc_2nd_fat_addr:
  1259 0000C792 034660              <1> 	add	eax, [esi+LD_FATBegin]
  1260 0000C795 0305[627F0100]      <1> 	add	eax, [FAT_BuffSector]
  1261 0000C79B BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1262                              <1> 	; ecx = 1 to 3
  1263 0000C7A0 E8A1550000          <1> 	call	disk_write
  1264 0000C7A5 7207                <1> 	jc	short loc_save_FAT_buff_write_err
  1265                              <1>  	; Valid  buffer (1 = valid but do not save)
  1266 0000C7A7 C605[5E7F0100]01    <1> 	mov	byte [FAT_BuffValidData], 1
  1267                              <1> 
  1268                              <1> loc_save_FAT_buff_write_err:
  1269 0000C7AE 5E                  <1> 	pop	esi ; *
  1270 0000C7AF BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1271                              <1> 	; 15/10/2016 (1Dh -> 18)
  1272                              <1> 	; 23/03/2016 (1Dh)
  1273 0000C7B4 B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error
  1274 0000C7B9 C3                  <1> 	retn
  1275                              <1> 
  1276                              <1> calculate_fat_freespace:
  1277                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  1278                              <1> 	; 23/03/2016
  1279                              <1> 	; 02/03/2016
  1280                              <1> 	; 01/03/2016
  1281                              <1> 	; 29/02/2016
  1282                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
  1283                              <1> 	; 30/04/2011
  1284                              <1> 	; 03/04/2010
  1285                              <1> 	; 2005
  1286                              <1> 	; INPUT ->
  1287                              <1> 	;	EAX = Cluster count to be added or subtracted
  1288                              <1> 	; 	If BH = FFh, ESI = TR-DOS Logical Drive Description Table
  1289                              <1> 	; 	If BH < FFh, BH = TR-DOS Logical Drive Number
  1290                              <1> 	; 	BL: 
  1291                              <1> 	;	0 = Calculate, 1 = Add, 2 = Subtract, 3 = Get (Not Set/Calc)
  1292                              <1> 	; OUTPUT ->
  1293                              <1> 	;	EAX = Free Space in sectors
  1294                              <1> 	;	ESI = Logical Dos Drive Description Table address
  1295                              <1> 	;	BH = Logical Dos Drive Number (same with input value of BH)
  1296                              <1> 	;	BL = Type of operation (same with input value of BL)
  1297                              <1> 	;	ECX = 0 -> valid
  1298                              <1> 	;	ECX > 0 -> error or invalid
  1299                              <1> 	;	If EAX = FFFFFFFFh, it is 're-calculation needed'
  1300                              <1> 	;			          sign due to r/w error   
  1301                              <1> 
  1302 0000C7BA 66891D[02820100]    <1> 	mov	[CFS_OPType], bx
  1303 0000C7C1 A3[04820100]        <1> 	mov	[CFS_CC], eax
  1304                              <1> 	
  1305 0000C7C6 80FFFF              <1> 	cmp	bh, 0FFh
  1306 0000C7C9 740B                <1> 	je	short pass_calculate_freespace_get_drive_dt_offset
  1307                              <1> 
  1308                              <1> loc_calculate_freespace_get_drive_dt_offset:     
  1309 0000C7CB 31C0                <1> 	xor	eax, eax
  1310 0000C7CD 88FC                <1>         mov     ah, bh
  1311 0000C7CF BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1312 0000C7D4 01C6                <1>         add     esi, eax
  1313                              <1> 
  1314                              <1> pass_calculate_freespace_get_drive_dt_offset:
  1315 0000C7D6 08DB                <1> 	or	bl, bl
  1316 0000C7D8 7436                <1> 	jz	short loc_reset_fcc
  1317                              <1> 	
  1318                              <1> loc_get_free_sectors:
  1319 0000C7DA 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors]
  1320                              <1> 
  1321                              <1> 	;xor	ecx, ecx
  1322                              <1> 	;dec	ecx ; 0FFFFFFFFh
  1323                              <1> 	;cmp	eax, ecx ; 29/02/2016
  1324                              <1> 	;je	short loc_get_free_sectors_retn ; recalculation is needed!
  1325                              <1> 	
  1326                              <1> 	; 23/03/2016
  1327 0000C7DD 8B4E70              <1> 	mov	ecx, [esi+LD_TotalSectors]
  1328 0000C7E0 39C1                <1> 	cmp	ecx, eax ; Total sectors must be greater than Free sectors !
  1329 0000C7E2 7707                <1> 	ja	short loc_get_free_sectors_check_optype
  1330                              <1> 	
  1331 0000C7E4 31C0                <1> 	xor	eax, eax
  1332 0000C7E6 48                  <1> 	dec	eax ; 0FFFFFFFFh  ; recalculation is needed!
  1333 0000C7E7 894674              <1> 	mov	[esi+LD_FreeSectors], eax ; reset (for recalculation)
  1334                              <1> 		
  1335                              <1> loc_get_free_sectors_retn:
  1336 0000C7EA C3                  <1> 	retn
  1337                              <1> 	
  1338                              <1> loc_get_free_sectors_check_optype:
  1339 0000C7EB 80FB03              <1> 	cmp	bl, 3
  1340 0000C7EE 7203                <1> 	jb	short loc_set_fcc_1 ; 25/07/2022
  1341                              <1> 
  1342 0000C7F0 29C9                <1> 	sub	ecx, ecx ; 0
  1343                              <1> 
  1344 0000C7F2 C3                  <1> 	retn	
  1345                              <1> 
  1346                              <1> loc_set_fcc_1:
  1347 0000C7F3 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1348                              <1> 	;ja	loc_update_FAT32_fs_info_fcc
  1349                              <1> 	; 25/07/2022
  1350 0000C7F7 7605                <1> 	jna	short loc_set_fcc_2
  1351 0000C7F9 E9DD000000          <1> 	jmp	loc_update_FAT32_fs_info_fcc
  1352                              <1> 
  1353                              <1> loc_set_fcc_2:
  1354                              <1> 	;mov	eax, [esi+LD_FreeSectors]
  1355 0000C7FE 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  1356 0000C802 29D2                <1> 	sub	edx, edx
  1357 0000C804 F7F1                <1> 	div	ecx
  1358                              <1> 	;or	dx, dx 
  1359                              <1> 	;	; DX -> Remain sectors < SecPerClust
  1360                              <1> 	;	; DX > 0 -> invalid free sector count
  1361                              <1> 	;jnz	short loc_reset_fcc 
  1362                              <1> 
  1363                              <1> ;pass_set_fcc_div32:
  1364 0000C806 A3[7C7F0100]        <1> 	mov	[FreeClusterCount], eax
  1365 0000C80B E986000000          <1>         jmp     loc_set_free_sectors_FAT12_FAT16
  1366                              <1> 
  1367                              <1> loc_reset_fcc:
  1368 0000C810 31C0                <1> 	xor	eax, eax
  1369 0000C812 A3[7C7F0100]        <1> 	mov	[FreeClusterCount], eax ; 0
  1370 0000C817 8B5678              <1> 	mov	edx, [esi+LD_Clusters]
  1371 0000C81A 42                  <1> 	inc	edx
  1372 0000C81B 8915[6A7F0100]      <1> 	mov	[LastCluster], edx
  1373                              <1> 
  1374 0000C821 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1375 0000C825 7645                <1> 	jna	short loc_count_free_fat_clusters_0  
  1376                              <1> 
  1377 0000C827 48                  <1> 	dec	eax ; FFFFFFFFh
  1378 0000C828 A3[0C820100]        <1> 	mov	[CFS_FAT32FC], eax
  1379                              <1> 
  1380                              <1> 	; 29/02/2016
  1381 0000C82D 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; reset
  1382 0000C830 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; reset
  1383                              <1> 	
  1384                              <1> 	;mov 	eax, 2
  1385                              <1> 	; 25/07/2022
  1386 0000C833 40                  <1> 	inc	eax ; eax = 0
  1387 0000C834 B002                <1> 	mov	al, 2
  1388                              <1> 
  1389                              <1> loc_count_fc_next_cluster_0:
  1390 0000C836 50                  <1> 	push	eax
  1391 0000C837 E87BF9FFFF          <1> 	call	get_next_cluster
  1392 0000C83C 7310                <1> 	jnc	short loc_check_fat32_ff_cluster
  1393 0000C83E 09C0                <1> 	or	eax, eax
  1394 0000C840 741E                <1> 	jz	short pass_inc_cfs_fcc_0
  1395                              <1> 
  1396                              <1> loc_put_fcc_unknown_sign:
  1397 0000C842 58                  <1> 	pop	eax
  1398                              <1> 	; "Free count is Unknown" sign
  1399                              <1> 	;mov	dword [FreeClusterCount], 0FFFFFFFFh
  1400                              <1> 
  1401                              <1> 	; 29/02/2016
  1402                              <1> 	; Save Free Cluster Count value in FAT32 'BPB_Reserved' area
  1403                              <1> 	;mov	[esi+LD_BPB+BPB_Reserved], 0FFFFFFFFh ; unknown!
  1404 0000C843 8B15[0C820100]      <1> 	mov	edx, [CFS_FAT32FC] ; First Free Cluster
  1405                              <1> 	; Save First Free Cluster value in FAT32 'BPB_Reserved+4' area
  1406 0000C849 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx
  1407                              <1> 	
  1408 0000C84C EB7D                <1>         jmp     loc_put_fcc_invalid_sign
  1409                              <1> 
  1410                              <1> loc_check_fat32_ff_cluster:
  1411 0000C84E 09C0                <1> 	or	eax, eax
  1412 0000C850 750E                <1> 	jnz	short pass_inc_cfs_fcc_0
  1413 0000C852 58                  <1> 	pop	eax
  1414 0000C853 A3[0C820100]        <1> 	mov	[CFS_FAT32FC], eax
  1415                              <1> 	;mov	dword [FreeClusterCount], 1
  1416 0000C858 FF05[7C7F0100]      <1> 	inc	dword [FreeClusterCount]
  1417 0000C85E EB27                <1> 	jmp	short pass_inc_cfs_fcc_1
  1418                              <1> 
  1419                              <1> pass_inc_cfs_fcc_0:
  1420 0000C860 58                  <1> 	pop	eax
  1421                              <1> 
  1422                              <1> pass_inc_cfs_fcc_0c:
  1423 0000C861 40                  <1> 	inc	eax ; add eax, 1
  1424 0000C862 3B05[6A7F0100]      <1> 	cmp	eax, [LastCluster]
  1425 0000C868 76CC                <1> 	jna 	short loc_count_fc_next_cluster_0
  1426 0000C86A EB6F                <1> 	jmp	short loc_update_FAT32_fs_info_fcc
  1427                              <1> 
  1428                              <1> loc_count_free_fat_clusters_0:
  1429                              <1> 	;mov	eax, 2
  1430 0000C86C B002                <1> 	mov	al, 2
  1431                              <1> 
  1432                              <1> loc_count_fc_next_cluster:
  1433 0000C86E 50                  <1> 	push	eax
  1434 0000C86F E843F9FFFF          <1> 	call	get_next_cluster
  1435 0000C874 720C                <1> 	jc	short loc_count_fcc_stc
  1436                              <1> 
  1437                              <1> loc_count_free_clusters_1:
  1438 0000C876 21C0                <1> 	and	eax, eax
  1439 0000C878 750C                <1> 	jnz	short pass_inc_cfs_fcc
  1440                              <1> 
  1441 0000C87A FF05[7C7F0100]      <1> 	inc	dword [FreeClusterCount]
  1442 0000C880 EB04                <1> 	jmp	short pass_inc_cfs_fcc
  1443                              <1> 
  1444                              <1> loc_count_fcc_stc:
  1445 0000C882 09C0                <1> 	or	eax, eax
  1446 0000C884 75BC                <1> 	jnz	short loc_put_fcc_unknown_sign ; 29/02/2016
  1447                              <1> 
  1448                              <1> pass_inc_cfs_fcc:
  1449 0000C886 58                  <1> 	pop	eax
  1450                              <1> 
  1451                              <1> pass_inc_cfs_fcc_1:
  1452 0000C887 40                  <1> 	inc	eax ; add eax, 1
  1453 0000C888 3B05[6A7F0100]      <1> 	cmp	eax, [LastCluster]
  1454 0000C88E 76DE                <1> 	jna	short loc_count_fc_next_cluster
  1455                              <1> 
  1456                              <1> loc_set_free_sectors:
  1457 0000C890 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1458 0000C894 7745                <1> 	ja	short loc_update_FAT32_fs_info_fcc
  1459                              <1> 
  1460                              <1> loc_set_free_sectors_FAT12_FAT16:
  1461 0000C896 803D[02820100]00    <1> 	cmp	byte [CFS_OPType], 0
  1462 0000C89D 761C                <1> 	jna	short pass_FAT_add_sub_fcc
  1463 0000C89F A1[04820100]        <1> 	mov	eax, [CFS_CC]
  1464 0000C8A4 803D[02820100]01    <1> 	cmp	byte [CFS_OPType], 1
  1465 0000C8AB 7708                <1> 	ja	short pass_FAT_add_fcc
  1466 0000C8AD 0105[7C7F0100]      <1> 	add 	[FreeClusterCount], eax
  1467 0000C8B3 EB06                <1> 	jmp	short pass_FAT_add_sub_fcc
  1468                              <1> 
  1469                              <1> pass_FAT_add_fcc:
  1470 0000C8B5 2905[7C7F0100]      <1> 	sub	[FreeClusterCount], eax
  1471                              <1> 
  1472                              <1> pass_FAT_add_sub_fcc:
  1473 0000C8BB 0FB64613            <1> 	movzx	eax, byte [esi+LD_BPB+SecPerClust]
  1474 0000C8BF 8B15[7C7F0100]      <1> 	mov	edx, [FreeClusterCount]
  1475 0000C8C5 F7E2                <1> 	mul	edx
  1476                              <1> 
  1477 0000C8C7 31C9                <1> 	xor	ecx, ecx 
  1478 0000C8C9 EB05                <1> 	jmp	short loc_cfs_retn_params
  1479                              <1> 
  1480                              <1> loc_put_fcc_invalid_sign:
  1481 0000C8CB 29C0                <1>        	sub	eax, eax ; 0
  1482 0000C8CD 48                  <1> 	dec	eax ; FFFFFFFFh
  1483                              <1> loc_fat32_ffc_recalc_needed:
  1484 0000C8CE 89C1                <1> 	mov	ecx, eax
  1485                              <1> 
  1486                              <1> loc_cfs_retn_params:
  1487 0000C8D0 894674              <1> 	mov 	[esi+LD_FreeSectors], eax
  1488 0000C8D3 0FB71D[02820100]    <1> 	movzx	ebx, word [CFS_OPType]
  1489 0000C8DA C3                  <1> 	retn
  1490                              <1> 
  1491                              <1> loc_update_FAT32_fs_info_fcc:
  1492                              <1> loc_check_fcc_FSINFO_op:
  1493                              <1> 	; 29/02/2016
  1494                              <1> 	; EAX = Free cluster count (before this update) ; value from disk
  1495                              <1> 	; EDX = First Free Cluster (before this update) ; value from disk
  1496 0000C8DB 803D[02820100]01    <1> 	cmp	byte [CFS_OPType], 1
  1497 0000C8E2 7221                <1> 	jb	short loc_cfs_FAT32_get_rcalc_parms ; 0 = recalculated
  1498 0000C8E4 7406                <1> 	je	short loc_check_fcc_FSINFO_op1 ; 1 = add
  1499                              <1> loc_check_fcc_FSINFO_op2: ; subtract
  1500 0000C8E6 F71D[04820100]      <1> 	neg	dword [CFS_CC] ; prepare to subtract ; 2 = sub (add negative)
  1501                              <1> loc_check_fcc_FSINFO_op1:
  1502                              <1> 	; 01/03/2016
  1503 0000C8EC 31D2                <1> 	xor	edx, edx ; 0
  1504 0000C8EE 4A                  <1> 	dec	edx ; 0FFFFFFFFh
  1505 0000C8EF 8B463A              <1> 	mov	eax, [esi+LD_BPB+BPB_Reserved]
  1506 0000C8F2 39D0                <1> 	cmp	eax, edx
  1507 0000C8F4 73D5                <1> 	jnb	short loc_put_fcc_invalid_sign
  1508 0000C8F6 0305[04820100]      <1>         add     eax, [CFS_CC] ; free cluster count on disk + current count
  1509 0000C8FC 72CD                <1> 	jc	short loc_put_fcc_invalid_sign
  1510                              <1> 	
  1511 0000C8FE A3[7C7F0100]        <1> 	mov	[FreeClusterCount], eax
  1512 0000C903 EB0E                <1> 	jmp	short loc_cfs_write_FSINFO_sector
  1513                              <1> 
  1514                              <1> loc_cfs_FAT32_get_rcalc_parms:
  1515 0000C905 8B15[0C820100]      <1> 	mov	edx, [CFS_FAT32FC]
  1516 0000C90B A1[7C7F0100]        <1> 	mov	eax, [FreeClusterCount]
  1517 0000C910 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx ; First Free Cluster
  1518                              <1> loc_cfs_write_FSINFO_sector:
  1519 0000C913 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count
  1520                              <1> 	; 01/03/2016
  1521 0000C916 E8AA000000          <1> 	call	set_fat32_fsinfo_sector_parms
  1522 0000C91B 72AE                <1>         jc      short loc_put_fcc_invalid_sign
  1523                              <1> 
  1524                              <1> loc_set_FAT32_free_sectors:
  1525                              <1> 	; 29/02/2016
  1526                              <1> 	;mov	eax, [FreeClusterCount]
  1527                              <1> 	;mov	ecx, eax
  1528                              <1> 	;cmp	eax, 0FFFFFFFFh ; Invalid !
  1529                              <1> 	;je	short loc_cfs_retn_params
  1530                              <1> 	;
  1531 0000C91D 8B0D[7C7F0100]      <1> 	mov	ecx, [FreeClusterCount]
  1532 0000C923 0FB64613            <1> 	movzx	eax, byte [esi+LD_BPB+SecPerClust]
  1533 0000C927 F7E1                <1> 	mul	ecx
  1534                              <1> 	; 29/02/2016
  1535 0000C929 31C9                <1> 	xor	ecx, ecx ; 0
  1536 0000C92B 09D2                <1> 	or	edx, edx ; 0 ?
  1537 0000C92D 759C                <1>         jnz	short loc_put_fcc_invalid_sign ; 25/07/2022
  1538 0000C92F 394670              <1> 	cmp	[esi+LD_TotalSectors], eax ; Volume size in sectors
  1539 0000C932 7697                <1>         jna     short loc_put_fcc_invalid_sign
  1540                              <1> 	;
  1541                              <1> loc_set_FAT32_free_sectors_ok:
  1542 0000C934 31D2                <1> 	xor	edx, edx ; 0
  1543 0000C936 EB98                <1>         jmp     short loc_cfs_retn_params 
  1544                              <1> 	;
  1545                              <1> 
  1546                              <1> get_last_cluster:
  1547                              <1> 	; 22/10/2016
  1548                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
  1549                              <1> 	; 12/06/2010 (DRV_FAT.ASM, 'proc_get_last_custer')
  1550                              <1> 	; 06/06/2010
  1551                              <1> 	; INPUT ->
  1552                              <1> 	;	EAX = First Cluster Number
  1553                              <1> 	; 	ESI = Logical Dos Drive Parameters Table
  1554                              <1> 	; OUTPUT ->
  1555                              <1> 	;	cf = 0 -> No Error, EAX is valid
  1556                              <1> 	;	cf = 1 -> EAX > 0 -> Error
  1557                              <1> 	;	EAX = Last Cluster Number
  1558                              <1> 	;       ECX = Previous Cluster -just before the last cluster-
  1559                              <1> 	;       ; 22/10/2016
  1560                              <1> 	;	[glc_index] = cluster index number of the last cluster	
  1561                              <1> 	;
  1562                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  1563                              <1> 
  1564 0000C938 89C1                <1> 	mov	ecx, eax
  1565                              <1> 
  1566 0000C93A C705[14820100]FFFF- <1> 	mov	dword [glc_index], 0FFFFFFFFh ; 22/10/2016	
  1566 0000C942 FFFF                <1>
  1567                              <1> 
  1568                              <1> loc_glc_get_next_cluster_1:
  1569 0000C944 890D[10820100]      <1> 	mov	[glc_prevcluster], ecx
  1570                              <1>  	; 22/10/2016
  1571 0000C94A FF05[14820100]      <1> 	inc	dword [glc_index]
  1572                              <1> 
  1573                              <1> loc_glc_get_next_cluster_2:
  1574 0000C950 E862F8FFFF          <1> 	call	get_next_cluster
  1575                              <1> 	; ecx = current/previous cluster 
  1576                              <1> 	; eax = next/last cluster
  1577 0000C955 73ED                <1> 	jnc	short loc_glc_get_next_cluster_1
  1578                              <1> 
  1579 0000C957 09C0                <1> 	or	eax, eax
  1580 0000C959 7509                <1> 	jnz	short loc_glc_stc_retn
  1581                              <1> 
  1582                              <1> 	; ecx = previous cluster
  1583 0000C95B 89C8                <1>         mov	eax, ecx
  1584                              <1> 
  1585                              <1> 	; previous cluster becomes last cluster (ecx -> eax)
  1586                              <1> 	; previous of previous cluster becomes previous cluster (ecx)
  1587                              <1> 
  1588                              <1> loc_glc_prev_cluster_retn:
  1589 0000C95D 8B0D[10820100]      <1> 	mov	ecx, [glc_prevcluster] 
  1590 0000C963 C3                  <1> 	retn
  1591                              <1> 
  1592                              <1> loc_glc_stc_retn:
  1593 0000C964 F5                  <1> 	cmc	;stc
  1594 0000C965 EBF6                <1>         jmp	short loc_glc_prev_cluster_retn
  1595                              <1> 
  1596                              <1> truncate_cluster_chain:
  1597                              <1> 	; 01/03/2016
  1598                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  1599                              <1> 	; 22/01/2011 (DRV_FAT.ASM, 'proc_truncate_cluster_chain')
  1600                              <1> 	; 11/09/2010
  1601                              <1> 	; INPUT ->
  1602                              <1> 	;	ESI = Logical dos drive description table address
  1603                              <1> 	;	EAX = First cluster to be truncated/unlinked 
  1604                              <1> 	; OUTPUT ->
  1605                              <1> 	;	ESI = Logical dos drive description table address
  1606                              <1> 	; 	ECX = Count of truncated/removed clusters
  1607                              <1> 	; 	CF = 0 -> EAX = Free sectors
  1608                              <1> 	; 	CF = 1 -> Error code in EAX (AL)
  1609                              <1> 
  1610                              <1> 	; NOTE: This procedure does not update lm date&time ! 
  1611                              <1> 
  1612                              <1> loc_truncate_cc:	
  1613 0000C967 31C9                <1> 	xor	ecx, ecx ; mov ecx, 0
  1614                              <1> 	;mov	byte [FAT_BuffValidData], 0
  1615 0000C969 890D[667F0100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  1616                              <1> 
  1617                              <1> loc_tcc_unlink_clusters:
  1618 0000C96F E832FBFFFF          <1> 	call	update_cluster
  1619                              <1> 	; EAX = Next Cluster
  1620                              <1> 	; ECX = Cluster Value
  1621                              <1> 	; Note:
  1622                              <1> 	; Returns count of unlinked clusters in
  1623                              <1> 	; dword ptr FAT_ClusterCounter
  1624 0000C974 73F9                <1> 	jnc	short loc_tcc_unlink_clusters
  1625                              <1> 
  1626                              <1> pass_tcc_unlink_clusters:
  1627 0000C976 A2[1B820100]        <1> 	mov	byte [TCC_FATErr], al
  1628 0000C97B 803D[5E7F0100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
  1629 0000C982 750E                <1> 	jne	short loc_tcc_calculate_FAT_freespace
  1630 0000C984 E8A0FDFFFF          <1> 	call	save_fat_buffer
  1631 0000C989 7307                <1> 	jnc	short loc_tcc_calculate_FAT_freespace
  1632 0000C98B A2[1B820100]        <1> 	mov	byte [TCC_FATErr], al ; Error
  1633                              <1> 	;mov	byte [FAT_BuffValidData], 0
  1634                              <1> 
  1635                              <1> 	; 01/03/2016
  1636 0000C990 EB12                <1> 	jmp	short loc_tcc_recalculate_FAT_freespace
  1637                              <1> 
  1638                              <1> loc_tcc_calculate_FAT_freespace:
  1639 0000C992 A1[667F0100]        <1> 	mov	eax, [FAT_ClusterCounter] ; signed (+-) number
  1640 0000C997 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> ESI = Dos drv desc. table
  1641                              <1> 			   ; BL = 1 -> add cluster(s)
  1642 0000C99B E81AFEFFFF          <1> 	call	calculate_fat_freespace
  1643 0000C9A0 21C9                <1> 	and	ecx, ecx ; cx = 0 -> valid free sector count
  1644 0000C9A2 7409                <1> 	jz	short pass_truncate_cc_recalc_FAT_freespace
  1645                              <1> 
  1646                              <1> loc_tcc_recalculate_FAT_freespace:
  1647 0000C9A4 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate !
  1648 0000C9A8 E80DFEFFFF          <1> 	call	calculate_fat_freespace
  1649                              <1>               
  1650                              <1> loc_tcc_calculate_FAT_freespace_err:
  1651                              <1> pass_truncate_cc_recalc_FAT_freespace:
  1652 0000C9AD 8B0D[667F0100]      <1> 	mov	ecx, [FAT_ClusterCounter]
  1653                              <1> 
  1654 0000C9B3 803D[1B820100]00    <1> 	cmp	byte [TCC_FATErr], 0
  1655 0000C9BA 7608                <1> 	jna	short loc_tcc_unlink_clusters_retn
  1656                              <1> 
  1657                              <1> loc_tcc_unlink_clusters_error:
  1658 0000C9BC 0FB605[1B820100]    <1> 	movzx	eax, byte [TCC_FATErr]
  1659 0000C9C3 F9                  <1> 	stc
  1660                              <1> loc_tcc_unlink_clusters_retn:
  1661 0000C9C4 C3                  <1> 	retn
  1662                              <1> 
  1663                              <1> set_fat32_fsinfo_sector_parms:
  1664                              <1> 	; 15/10/2016
  1665                              <1> 	; 23/03/2016
  1666                              <1> 	; 29/02/2016 (TRDOS 386 = TRDOS v2.0)
  1667                              <1> 	; INPUT ->
  1668                              <1> 	;	ESI = Logical dos drive description table address
  1669                              <1> 	;	[esi+LD_BPB+BPB_Reserved] = Free Cluster Count
  1670                              <1> 	;	[esi+LD_BPB+BPB_Reserved+4] = First Free Cluster 
  1671                              <1> 	; OUTPUT ->
  1672                              <1> 	;	ESI = Logical dos drive description table address
  1673                              <1> 	; 	CF = 0 -> OK..
  1674                              <1> 	; 	CF = 1 -> Error code in EAX (AL)
  1675                              <1> 	;
  1676                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
  1677                              <1> 
  1678 0000C9C5 E824000000          <1> 	call	get_fat32_fsinfo_sector_parms
  1679 0000C9CA 7221                <1> 	jc	short update_fat32_fsinfo_sector_retn
  1680                              <1> 
  1681 0000C9CC 8B463A              <1> 	mov	eax, [esi+LD_BPB+BPB_Reserved] ; Free Cluster Count
  1682 0000C9CF 8B563E              <1> 	mov	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free Cluster	
  1683                              <1> 
  1684                              <1>         ;mov	ebx, DOSBootSectorBuff
  1685 0000C9D2 8983E8010000        <1> 	mov	[ebx+488], eax
  1686 0000C9D8 8993EC010000        <1> 	mov	[ebx+492], edx	
  1687                              <1> 
  1688 0000C9DE A1[08820100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC]
  1689 0000C9E3 B901000000          <1> 	mov	ecx, 1
  1690 0000C9E8 E859530000          <1> 	call	disk_write
  1691                              <1> 	;jnc	short update_fat32_fsinfo_sector_retn
  1692                              <1> 
  1693                              <1> 	; 15/10/2016 (1Dh -> 18)
  1694                              <1> 	; 23/03/2016 (1Dh)
  1695                              <1> 	;mov	eax, 18 ; Drive not ready or write error
  1696                              <1> 
  1697                              <1> update_fat32_fsinfo_sector_retn:
  1698 0000C9ED C3                  <1> 	retn
  1699                              <1> 
  1700                              <1> get_fat32_fsinfo_sector_parms:
  1701                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  1702                              <1> 	; 15/10/2016
  1703                              <1> 	; 23/03/2016
  1704                              <1> 	; 01/03/2016
  1705                              <1> 	; 29/02/2016 (TRDOS 386 = TRDOS v2.0)
  1706                              <1> 	; INPUT ->
  1707                              <1> 	;	ESI = Logical dos drive description table address
  1708                              <1> 	; OUTPUT ->
  1709                              <1> 	;	ESI = Logical dos drive description table address
  1710                              <1> 	;	EBX = FSINFO sector buffer address (DOSBootSectorBuff)	
  1711                              <1> 	;	CF = 0 -> OK..
  1712                              <1> 	;	   EAX = FsInfo sector address
  1713                              <1> 	;	   ECX = Free cluster count
  1714                              <1> 	;	   EDX = First free cluster 	
  1715                              <1> 	;	CF = 1 -> Error code in AL (EAX)
  1716                              <1> 	;	   EBX = 0
  1717                              <1> 	;	
  1718                              <1> 	;	[CFS_FAT32FSINFOSEC] = FAT32 FSINFO sector address
  1719                              <1>         ;
  1720                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
  1721                              <1> 
  1722 0000C9EE 0FB74636            <1> 	movzx	eax, word [esi+LD_BPB+FAT32_FSInfoSec]
  1723 0000C9F2 03466C              <1> 	add	eax, [esi+LD_StartSector]
  1724 0000C9F5 A3[08820100]        <1> 	mov	[CFS_FAT32FSINFOSEC], eax
  1725                              <1> 	
  1726 0000C9FA BB[5A7D0100]        <1>         mov     ebx, DOSBootSectorBuff
  1727                              <1> 	;mov	ecx, 1
  1728                              <1> 	; 25/07/2022
  1729 0000C9FF 29C9                <1> 	sub	ecx, ecx
  1730 0000CA01 FEC1                <1> 	inc	cl
  1731                              <1> 	; ecx = 1
  1732 0000CA03 E84D530000          <1> 	call	disk_read
  1733 0000CA08 722F                <1> 	jc	short loc_read_FAT32_fsinfo_sec_err
  1734                              <1> 
  1735 0000CA0A BB[5A7D0100]        <1> 	mov	ebx, DOSBootSectorBuff
  1736                              <1> 
  1737 0000CA0F 813B52526141        <1> 	cmp	dword [ebx], 41615252h
  1738 0000CA15 751E                <1> 	jne	short loc_read_FAT32_fsinfo_sec_stc
  1739                              <1> 
  1740 0000CA17 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
  1740 0000CA20 61                  <1>
  1741 0000CA21 7512                <1> 	jne	short loc_read_FAT32_fsinfo_sec_stc
  1742                              <1> 
  1743 0000CA23 A1[08820100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC]
  1744 0000CA28 8B8BE8010000        <1> 	mov	ecx, [ebx+488] ; free cluster count
  1745 0000CA2E 8B93EC010000        <1> 	mov	edx, [ebx+492] ; first (next) free cluster	
  1746                              <1> 
  1747 0000CA34 C3                  <1> 	retn
  1748                              <1> 
  1749                              <1> loc_read_FAT32_fsinfo_sec_stc: 
  1750                              <1> 	; 15/10/2016 (0Bh -> 28)
  1751                              <1> 	;mov	eax, 28 ; Invalid format!
  1752                              <1> 	; 25/07/2022
  1753 0000CA35 B31C                <1> 	mov	bl, 28
  1754 0000CA37 EB02                <1> 	jmp	short loc_read_FAT32_fsinfo_sec_stc_retn
  1755                              <1> 
  1756                              <1> loc_read_FAT32_fsinfo_sec_err:
  1757                              <1> 	; 15/10/2016 (15h -> 17)
  1758                              <1> 	; 23/03/2016 (15h)
  1759                              <1> 	;mov	eax, 17 ; Drive not ready or read error
  1760                              <1> 	; 25/07/2022
  1761 0000CA39 B311                <1> 	mov	bl, 17
  1762                              <1> loc_read_FAT32_fsinfo_sec_stc_retn:
  1763                              <1> 	; 25/07/2022
  1764 0000CA3B 29C0                <1> 	sub	eax, eax
  1765 0000CA3D 88D8                <1> 	mov	al, bl ; error code
  1766                              <1> 	; eax = error code
  1767 0000CA3F 29DB                <1> 	sub	ebx, ebx ; 0
  1768 0000CA41 F9                  <1> 	stc
  1769 0000CA42 C3                  <1> 	retn
  1770                              <1> 
  1771                              <1> add_new_cluster:
  1772                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  1773                              <1> 	; 15/10/2016
  1774                              <1> 	; 16/05/2016
  1775                              <1> 	; 18/03/2016, 24/03/2016
  1776                              <1> 	; 11/03/2016 (TRDOS 386 = TRDOS v2.0)
  1777                              <1> 	; 30/07/2011 (DRV_FAT.ASM)
  1778                              <1> 	; 11/09/2010
  1779                              <1> 	; INPUT ->
  1780                              <1> 	;	ESI = Logical dos drv desc. table address
  1781                              <1> 	;	EAX = Last cluster
  1782                              <1> 	; OUTPUT ->
  1783                              <1> 	;	ESI = Logical dos drv desc. table address
  1784                              <1> 	;	EAX = New Last cluster (next cluster)
  1785                              <1> 	;	cf = 1 -> error code in EAX (AL)
  1786                              <1> 	;	cf = 1 -> EBX = sectors per cluster
  1787                              <1> 	;	ECX = Free sectors
  1788                              <1> 	;;;	25/07/2022
  1789                              <1> 	;	(EBX = sectors per cluster -not used-)
  1790                              <1> 	;	EDX = 0 (if cf = 0)
  1791                              <1> 	; NOTE:
  1792                              <1> 	; This procedure does not update lm date&time !
  1793                              <1> 	;
  1794                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, EDI)
  1795                              <1> 
  1796 0000CA43 A3[38830100]        <1> 	mov	[FAT_anc_LCluster], eax
  1797                              <1> 	
  1798 0000CA48 E88CF9FFFF          <1> 	call	get_first_free_cluster
  1799 0000CA4D 720A                <1> 	jc	short loc_add_new_cluster_retn
  1800                              <1> 	; EAX >= 2 and EAX < FFFFFFFFh is valid
  1801                              <1> 
  1802 0000CA4F 89C2                <1> 	mov	edx, eax
  1803                              <1> 
  1804 0000CA51 42                  <1> 	inc	edx
  1805                              <1> 	;jnz	short loc_add_new_cluster_check_ffc_eax
  1806 0000CA52 7510                <1> 	jnz	short loc_add_new_cluster_save_fcc
  1807                              <1> 
  1808                              <1> loc_add_new_cluster_no_disk_space_retn:
  1809                              <1> 	;mov	eax, 27h ; MSDOS err => insufficient disk space
  1810                              <1> 	; 25/07/2022
  1811 0000CA54 31C0                <1> 	xor	eax, eax
  1812 0000CA56 B027                <1> 	mov	al, 27h
  1813                              <1> loc_add_new_cluster_stc_retn:
  1814 0000CA58 F9                  <1> 	stc
  1815                              <1> loc_add_new_cluster_retn:
  1816                              <1> 	; 25/07/2022
  1817                              <1> 	;movzx	ebx, byte [esi+LD_BPB+SecPerClust]
  1818 0000CA59 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  1819                              <1> 	;xor	edx, edx
  1820                              <1> 	;stc
  1821 0000CA5C C3                  <1> 	retn
  1822                              <1> 
  1823                              <1> loc_anc_invalid_format_stc_retn:
  1824 0000CA5D F9                  <1> 	stc
  1825                              <1> loc_add_new_cluster_invalid_format_retn:
  1826                              <1> 	; 15/10/2016 (0Bh -> 28)
  1827                              <1> 	;mov	eax, 28 ; Invalid format
  1828                              <1> 	;jmp	short loc_add_new_cluster_retn 
  1829                              <1> 	; 25/07/2022
  1830 0000CA5E 29C0                <1> 	sub	eax, eax
  1831 0000CA60 B01C                <1> 	mov	al, 28
  1832 0000CA62 EBF4                <1> 	jmp	short loc_add_new_cluster_stc_retn
  1833                              <1> 
  1834                              <1> ;loc_add_new_cluster_check_ffc_eax:
  1835                              <1> ;	cmp	eax, 2
  1836                              <1> ;	jb	short loc_add_new_cluster_invalid_format_retn
  1837                              <1> 
  1838                              <1> loc_add_new_cluster_save_fcc:  
  1839 0000CA64 A3[3C830100]        <1> 	mov	[FAT_anc_FFCluster], eax
  1840                              <1> 
  1841 0000CA69 83E802              <1> 	sub	eax, 2
  1842 0000CA6C 0FB65E13            <1> 	movzx   ebx, byte [esi+LD_BPB+SecPerClust]
  1843 0000CA70 F7E3                <1> 	mul	ebx
  1844 0000CA72 09D2                <1> 	or	edx, edx
  1845 0000CA74 75E7                <1> 	jnz	short loc_anc_invalid_format_stc_retn
  1846                              <1> 
  1847                              <1> loc_add_new_cluster_allocate_cluster:
  1848                              <1> 	; 18/03/2016
  1849 0000CA76 92                  <1> 	xchg	edx, eax ; eax = 0
  1850                              <1> 	; 16/05/2016
  1851                              <1> 	;cmp	[ClusterBuffer_Valid], al ; 0
  1852                              <1> 	;jna	short loc_anc_clear_cluster_buffer
  1853                              <1> 	;; 'copy' command, 
  1854                              <1> 	;; writing destination file clust after reading source file clust
  1855                              <1> 	;mov	[ClusterBuffer_Valid], al ; 0 ; reset
  1856                              <1> 	;jmp	short loc_add_new_cluster_write_nc_to_disk
  1857                              <1> 
  1858                              <1> loc_anc_clear_cluster_buffer:
  1859                              <1> 	; 11/03/2016
  1860                              <1> 	; Clear buffer
  1861 0000CA77 BF00000700          <1> 	mov	edi, Cluster_Buffer ; 70000h (for current TRDOS 386 version)
  1862 0000CA7C 89D9                <1> 	mov	ecx, ebx ; sector count
  1863 0000CA7E C1E107              <1> 	shl	ecx, 7 ; 1 sector = 512 bytes -> 128 double words
  1864                              <1> 	;xor	eax, eax ; 0
  1865 0000CA81 F3AB                <1> 	rep	stosd
  1866                              <1> 
  1867                              <1> loc_add_new_cluster_write_nc_to_disk:
  1868                              <1> 	; 11/03/2016
  1869                              <1> 	;xchg	eax, edx ; edx = 0, eax = sector offset
  1870 0000CA83 89D0                <1> 	mov	eax, edx
  1871 0000CA85 034668              <1>         add     eax, [esi+LD_DATABegin]
  1872 0000CA88 72D4                <1> 	jc	short loc_add_new_cluster_invalid_format_retn 
  1873                              <1> 		
  1874 0000CA8A 89D9                <1> 	mov	ecx, ebx ; ECX = sectors per cluster (<256)
  1875 0000CA8C BB00000700          <1> 	mov	ebx, Cluster_Buffer
  1876 0000CA91 E8B0520000          <1> 	call	disk_write
  1877 0000CA96 7306                <1> 	jnc	short loc_add_new_cluster_update_fat_nlc
  1878                              <1> 	
  1879                              <1> 	; 15/10/2016 (1Dh -> 18)
  1880                              <1> 	;mov	eax, 18 ; Write Error
  1881                              <1> 	; 25/07/2022
  1882 0000CA98 31C0                <1> 	xor	eax, eax
  1883 0000CA9A B012                <1> 	mov	al, 18
  1884 0000CA9C EBBA                <1> 	jmp	short loc_add_new_cluster_stc_retn
  1885                              <1> 
  1886                              <1> loc_add_new_cluster_update_fat_nlc:
  1887 0000CA9E A1[3C830100]        <1> 	mov	eax, [FAT_anc_FFCluster]
  1888 0000CAA3 31C9                <1> 	xor	ecx, ecx
  1889 0000CAA5 890D[667F0100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  1890 0000CAAB 49                  <1> 	dec	ecx ; 0FFFFFFFFh
  1891 0000CAAC E8F5F9FFFF          <1> 	call	update_cluster
  1892 0000CAB1 7304                <1> 	jnc	short loc_add_new_cluster_update_fat_plc
  1893 0000CAB3 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  1894 0000CAB5 75A1                <1> 	jnz	short loc_add_new_cluster_stc_retn
  1895                              <1> 
  1896                              <1> loc_add_new_cluster_update_fat_plc:
  1897 0000CAB7 A1[38830100]        <1> 	mov	eax, [FAT_anc_LCluster]
  1898 0000CABC 8B0D[3C830100]      <1> 	mov	ecx, [FAT_anc_FFCluster]
  1899 0000CAC2 E8DFF9FFFF          <1> 	call	update_cluster
  1900 0000CAC7 7314                <1> 	jnc	short loc_add_new_cluster_save_fat_buffer
  1901 0000CAC9 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  1902 0000CACB 7410                <1> 	jz	short loc_add_new_cluster_save_fat_buffer
  1903                              <1> 
  1904                              <1> loc_anc_save_fat_buffer_err_retn:
  1905                              <1> 	;cmp	byte [FAT_ClusterCounter], 1
  1906                              <1> 	;jb	short loc_add_new_cluster_retn
  1907                              <1> 
  1908 0000CACD 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space (BL = 0)
  1909                              <1> 			   ; (BH = FFh -> Use ESI as Drv Param. Tbl.)
  1910 0000CAD1 50                  <1> 	push	eax
  1911 0000CAD2 E8E3FCFFFF          <1> 	call	calculate_fat_freespace
  1912 0000CAD7 58                  <1> 	pop	eax
  1913 0000CAD8 E97BFFFFFF          <1>         jmp     loc_add_new_cluster_stc_retn
  1914                              <1> 
  1915                              <1> loc_add_new_cluster_save_fat_buffer:
  1916                              <1> 	;cmp	byte [FAT_BuffValidData], 2
  1917                              <1> 	;jne	short loc_add_new_cluster_calc_FAT_freespace 
  1918                              <1> 	;Byte [FAT_BuffValidData] = 2 
  1919 0000CADD E847FCFFFF          <1> 	call	save_fat_buffer
  1920 0000CAE2 72E9                <1> 	jc	short loc_anc_save_fat_buffer_err_retn
  1921                              <1> 
  1922                              <1> loc_add_new_cluster_calc_FAT_freespace:
  1923                              <1> 	;mov	eax, 1 ; Only one Cluster
  1924 0000CAE4 A1[667F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
  1925 0000CAE9 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> ESI -> Dos drv desc. table
  1926                              <1> 		; BL = 1 -> add cluster(s)
  1927 0000CAED B301                <1> 	mov	bl, 01h
  1928                              <1> 	; NOTE: EAX value will be added to Free Cluster Count
  1929                              <1> 	; (Free Cluster Count is decreased when EAX value is negative)
  1930 0000CAEF E8C6FCFFFF          <1>         call    calculate_fat_freespace
  1931                              <1> 	; ECX = 0 -> no error, ECX > 0 -> error or invalid return
  1932 0000CAF4 21C9                <1> 	and	ecx, ecx ; ECX = 0 -> valid free sector count
  1933 0000CAF6 7409                <1> 	jz	short loc_add_new_cluster_return_cluster_number
  1934                              <1> 
  1935                              <1> loc_add_new_cluster_recalc_FAT_freespace:
  1936 0000CAF8 66BB00FF            <1> 	mov	bx, 0FF00h  ; recalculate free space
  1937 0000CAFC E8B9FCFFFF          <1>         call    calculate_fat_freespace
  1938                              <1> 	; cf = 0
  1939                              <1> loc_add_new_cluster_return_cluster_number:
  1940 0000CB01 89C1                <1> 	mov	ecx, eax ; Free sector count
  1941 0000CB03 A1[3C830100]        <1> 	mov	eax, [FAT_anc_FFCluster]
  1942                              <1> 	;mov	edi, Cluster_Buffer
  1943                              <1> 	; 25/07/2022 (EBX is not used by callers of this sprocedure)
  1944                              <1> 	;movzx	ebx, byte [esi+LD_BPB+SecPerClust]
  1945 0000CB08 31D2                <1> 	xor	edx, edx ; 0
  1946 0000CB0A C3                  <1>         retn
  1947                              <1> 
  1948                              <1> write_cluster:
  1949                              <1> 	; 15/10/2016
  1950                              <1> 	; 21/03/2016 (TRDOS 386 = TRDOS v2.0)
  1951                              <1> 	;
  1952                              <1> 	; INPUT ->
  1953                              <1> 	;	EAX = Cluster Number (Sector index for SINGLIX FS)
  1954                              <1> 	;	ESI = Logical DOS Drive Description Table address
  1955                              <1> 	;	EBX = Cluster (File R/W) Buffer address (max. 64KB)
  1956                              <1> 	;	Only for SINGLIX FS:
  1957                              <1> 	;	EDX = File Number (The 1st FDT address) 
  1958                              <1> 	; OUTPUT ->
  1959                              <1> 	;	cf = 1 -> Cluster can not be written onto disk
  1960                              <1> 	;	    EAX > 0 -> Error number
  1961                              <1> 	;	cf = 0 -> Cluster has been written successfully
  1962                              <1> 	;
  1963                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  1964                              <1> 	
  1965 0000CB0B 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust] 
  1966                              <1> 	; CL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
  1967                              <1> 
  1968                              <1> write_file_sectors: ; 16/03/2016
  1969 0000CB0F 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  1970 0000CB13 761C                <1> 	jna	short write_fs_cluster
  1971                              <1> 
  1972                              <1> write_fat_file_sectors: 
  1973 0000CB15 83E802              <1> 	sub	eax, 2 ; Beginning cluster number is always 2
  1974 0000CB18 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+BPB_SecPerClust] ; 18/03/2016 
  1975 0000CB1C F7E2                <1> 	mul	edx
  1976 0000CB1E 034668              <1> 	add	eax, [esi+LD_DATABegin] ; absolute address of the cluster
  1977                              <1> 
  1978                              <1> 	; EAX = Disk sector address
  1979                              <1> 	; ECX = Sector count
  1980                              <1> 	; EBX = Buffer address
  1981                              <1> 	; (EDX = 0)
  1982                              <1> 	; ESI = Logical DOS drive description table address	
  1983                              <1> 
  1984 0000CB21 E820520000          <1> 	call	disk_write
  1985 0000CB26 7306                <1> 	jnc	short wclust_retn
  1986                              <1> 	
  1987                              <1> 	; 15/10/2016 (1Dh -> 18)
  1988 0000CB28 B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error !
  1989 0000CB2D C3                  <1> 	retn
  1990                              <1> 
  1991                              <1> wclust_retn:
  1992 0000CB2E 29C0                <1> 	sub	eax, eax ; 0
  1993 0000CB30 C3                  <1> 	retn
  1994                              <1> 
  1995                              <1> write_fs_cluster:
  1996                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  1997                              <1> 	; 21/03/2016 (TRDOS 386 = TRDOS v2.0)
  1998                              <1> 	; Singlix FS
  1999                              <1> 	
  2000                              <1> 	; EAX = Cluster number is sector index number of the file (eax)
  2001                              <1> 	
  2002                              <1> 	; EDX = File number is the first File Descriptor Table address 
  2003                              <1> 	;	of the file. (Absolute address of the FDT).
  2004                              <1> 	
  2005                              <1> 	; eax = sector index (0 for the first sector)
  2006                              <1> 	; edx = FDT0 address
  2007                              <1> 		; 64 KB buffer = 128 sectors (limit) 
  2008                              <1> 	;mov	ecx, 128 ; maximum count of sectors (before eof) 
  2009                              <1> 	; 25/07/2022
  2010 0000CB31 29C9                <1> 	sub	ecx, ecx
  2011 0000CB33 B180                <1> 	mov	cl, 128
  2012                              <1> 	;call	write_fs_sectors
  2013                              <1> 	;retn
  2014                              <1> 	;jmp	short write_fs_sectors
  2015                              <1> 
  2016                              <1> write_fs_sectors:
  2017                              <1> 	; 21/03/2016 (TRDOS 386 = TRDOS v2.0)
  2018 0000CB35 F9                  <1> 	stc
  2019 0000CB36 C3                  <1> 	retn
  2020                              <1> 
  2021                              <1> get_cluster_by_index:
  2022                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
  2023                              <1> 	; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
  2024                              <1> 	; INPUT ->
  2025                              <1> 	; 	EAX = Beginning cluster
  2026                              <1> 	; 	EDX = Sector index in disk/file section
  2027                              <1> 	;	      (Only for SINGLIX file system!)
  2028                              <1> 	; 	ECX = Cluster sequence number after the beginning cluster
  2029                              <1> 	; 	ESI = Logical DOS Drive Description Table address
  2030                              <1> 	; OUTPUT ->
  2031                              <1> 	;	EAX = Cluster number 
  2032                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  2033                              <1> 	;
  2034                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
  2035                              <1> 	;	
  2036 0000CB37 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  2037 0000CB3B 721D                <1>         jb      short get_fs_section_by_index 
  2038                              <1> 
  2039 0000CB3D 3B4E78              <1> 	cmp	ecx, [esi+LD_Clusters]
  2040 0000CB40 7206                <1> 	jb	short gcbi_1
  2041                              <1> gcbi_0:
  2042                              <1> 	;stc
  2043                              <1> 	;mov	eax, 23h ; Cluster not available ! 
  2044                              <1> 			 ; MSDOS error code: FCB unavailable
  2045                              <1> 	; 25/07/2022
  2046 0000CB42 29C0                <1> 	sub	eax, eax
  2047                              <1> gcbi_4:
  2048 0000CB44 B023                <1> 	mov	al, 23h
  2049 0000CB46 F9                  <1> 	stc
  2050 0000CB47 C3                  <1> 	retn
  2051                              <1> gcbi_1:
  2052 0000CB48 51                  <1> 	push	ecx
  2053 0000CB49 E869F6FFFF          <1> 	call	get_next_cluster
  2054 0000CB4E 59                  <1> 	pop	ecx
  2055 0000CB4F 7203                <1> 	jc	short gcbi_3
  2056 0000CB51 E2F5                <1> 	loop	gcbi_1
  2057                              <1> gcbi_2:
  2058 0000CB53 C3                  <1> 	retn
  2059                              <1> gcbi_3:
  2060 0000CB54 09C0                <1> 	or	eax, eax
  2061                              <1> 	;jz	short gcbi_0
  2062                              <1> 	; 25/07/2022
  2063 0000CB56 74EC                <1> 	jz	short gcbi_4
  2064 0000CB58 F5                  <1> 	cmc 	; stc
  2065 0000CB59 C3                  <1> 	retn
  2066                              <1> 
  2067                              <1> get_fs_section_by_index:
  2068                              <1> 	; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
  2069                              <1> 	; INPUT ->
  2070                              <1> 	; 	EAX = Beginning FDT number/address
  2071                              <1> 	; 	EDX = Sector index in disk/file section
  2072                              <1> 	; 	ECX = Sector sequence number after the beginning FDT
  2073                              <1> 	; 	ESI = Logical DOS Drive Description Table address
  2074                              <1> 	; OUTPUT ->
  2075                              <1> 	; 	EAX = FDT number/address
  2076                              <1> 	; 	EDX = Sector index of the section (0,1,2,3,4...)
  2077                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  2078                              <1> 	;
  2079                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
  2080                              <1> 	;
  2081 0000CB5A B8FFFFFFFF          <1> 	mov	eax, 0FFFFFFFFh
  2082 0000CB5F C3                  <1> 	retn
  2083                              <1> 
  2084                              <1> get_last_section:
  2085                              <1> 	; 22/10/2016 (TRDOS 386 = TRDOS v2.0)	
  2086                              <1> 	; INPUT ->
  2087                              <1> 	; 	EAX = (The 1st) FDT number/address
  2088                              <1> 	; 	ESI = Logical DOS Drive Description Table address
  2089                              <1> 	; OUTPUT ->
  2090                              <1> 	; 	EAX = FDT number/address of the last section
  2091                              <1> 	; 	EDX = Last sector of the section (0,1,2,3,4...)
  2092                              <1> 	;	[glc_index] = sector index number of the last sector
  2093                              <1> 	;		      (for file, not for the last section)  	
  2094                              <1> 	;		   	
  2095                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  2096                              <1> 	;
  2097                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
  2098                              <1> 	;
  2099 0000CB60 B800000000          <1> 	mov	eax, 0
  2100 0000CB65 BA00000000          <1> 	mov	edx, 0
  2101 0000CB6A C3                  <1> 	retn
  3242                                  %include 'trdosk6.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.6) - MAIN PROGRAM : trdosk6.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 29/08/2023  (Previous: 11/08/2022)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    11                              <1> ; u1.s (27/17/2015), u2.s (03/01/2016)
    12                              <1> ; ****************************************************************************
    13                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    14                              <1> ; TRDOS2.ASM (09/11/2011)
    15                              <1> ; ----------------------------------------------------------------------------
    16                              <1> ; INT_21H.ASM (c) 2009-2011 Erdogan TAN  [14/11/2009] Last Update: 08/11/2011
    17                              <1> 
    18                              <1> ; Ref: Retro UNIX 386 v1.2 Kernel (v0.2.2.3) - ux.s - 15/07/2022
    19                              <1> 
    20                              <1> sysent: ; < enter to system call >
    21                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
    22                              <1> 	; 17/03/2017
    23                              <1> 	; 03/03/2017
    24                              <1> 	; 19/02/2017
    25                              <1> 	; 13/01/2017
    26                              <1> 	; 06/06/2016
    27                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
    28                              <1> 	; 16/04/2015 - 19/10/2015 (Retro UNIX 386 v1)
    29                              <1> 	; 10/04/2013 - 18/01/2014 (Retro UNIX 8086 v1)
    30                              <1> 	;
    31                              <1> 	; 'unkni' or 'sysent' is sytem entry from various traps. 
    32                              <1> 	; The trap type is determined and an indirect jump is made to 
    33                              <1> 	; the appropriate system call handler. If there is a trap inside
    34                              <1> 	; the system a jump to panic is made. All user registers are saved 
    35                              <1> 	; and u.sp points to the end of the users stack. The sys (trap)
    36                              <1> 	; instructor is decoded to get the the system code part (see
    37                              <1> 	; trap instruction in the PDP-11 handbook) and from this 
    38                              <1> 	; the indirect jump address is calculated. If a bad system call is
    39                              <1> 	; made, i.e., the limits of the jump table are exceeded, 'badsys'
    40                              <1> 	; is called. If the call is legitimate control passes to the
    41                              <1> 	; appropriate system routine.
    42                              <1> 	;
    43                              <1> 	; Calling sequence:
    44                              <1> 	;	Through a trap caused by any sys call outside the system.
    45                              <1> 	; Arguments:
    46                              <1> 	;	Arguments of particular system call.	
    47                              <1> 	; ...............................................................
    48                              <1> 	;	
    49                              <1> 	; Retro UNIX 8086 v1 modification: 
    50                              <1> 	;       System call number is in EAX register.
    51                              <1> 	;
    52                              <1> 	;       Other parameters are in EDX, EBX, ECX, ESI, EDI, EBP
    53                              <1> 	;	registers depending of function details.
    54                              <1>   	;
    55                              <1> 	; 16/04/2015
    56 0000CB6B 368925[14010300]    <1>         mov     [ss:u.sp], esp ; Kernel stack points to return address
    57                              <1> 
    58                              <1> 	; save user registers
    59 0000CB72 1E                  <1> 	push	ds
    60 0000CB73 06                  <1> 	push	es
    61 0000CB74 0FA0                <1> 	push	fs
    62 0000CB76 0FA8                <1> 	push	gs
    63 0000CB78 60                  <1> 	pushad  ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
    64                              <1> 	;
    65                              <1> 	; ESPACE = [ss:u.sp] - esp ; 4*12 = 48 ; 17/09/2015 ; 06/06/2016
    66                              <1> 	; 	(ESPACE is size of space in kernel stack 
    67                              <1> 	;	for saving/restoring user registers.)
    68                              <1> 	;
    69 0000CB79 50                  <1> 	push	eax ; 01/07/2015
    70 0000CB7A 66B81000            <1> 	mov     ax, KDATA
    71 0000CB7E 8ED8                <1>         mov     ds, ax
    72 0000CB80 8EC0                <1>         mov     es, ax
    73 0000CB82 8EE0                <1>         mov     fs, ax
    74 0000CB84 8EE8                <1>         mov     gs, ax
    75 0000CB86 A1[88770100]        <1> 	mov	eax, [k_page_dir]
    76 0000CB8B 0F22D8              <1> 	mov	cr3, eax
    77 0000CB8E 58                  <1> 	pop	eax ; 01/07/2015
    78                              <1> 	; 19/10/2015
    79 0000CB8F FC                  <1> 	cld
    80                              <1> 	;
    81 0000CB90 FE05[10010300]      <1> 	inc	byte [sysflg]
    82                              <1> 		; incb sysflg / indicate a system routine is in progress
    83 0000CB96 FB                  <1>         sti 	; 18/01/2014
    84                              <1> 	;jnz	panic ; 24/05/2013
    85                              <1> 		; beq 1f
    86                              <1> 		; jmp panic ; / called if trap inside system
    87                              <1> 	; 23/07/2022
    88 0000CB97 7405                <1> 	jz	short sysent0
    89 0000CB99 E91BA1FFFF          <1> 	jmp	panic
    90                              <1> ;1:
    91                              <1> sysent0:
    92                              <1> 	; 17/03/2017
    93 0000CB9E 80642438FE          <1> 	and	byte [esp+ESPACE+8], ~1 ; clear carry flag
    94                              <1> 
    95                              <1> 	; 16/04/2015
    96 0000CBA3 A3[1C010300]        <1> 	mov	[u.r0], eax
    97 0000CBA8 8925[18010300]      <1> 	mov	[u.usp], esp ; kernel stack points to user's registers
    98                              <1> 
    99                              <1> 	; 13/01/2017 (TRDOS 386 Feaure only !)
   100 0000CBAE 803D[90010300]00    <1> 	cmp	byte [u.t_lock], 0 ; timer interrupt lock ?
   101                              <1> 	;ja	sysrele		   ; yes, sys release only !!!
   102                              <1> 	; 23/07/2022
   103 0000CBB5 7605                <1> 	jna	short sysent1
   104 0000CBB7 E9FE010000          <1> 	jmp	sysrele
   105                              <1> 		; mov $s.syst+2,clockp
   106                              <1> 		; mov r0,-(sp) / save user registers 
   107                              <1> 		; mov sp,u.r0 / pointer to bottom of users stack 
   108                              <1> 			   ; / in u.r0
   109                              <1> 		; mov r1,-(sp)
   110                              <1> 		; mov r2,-(sp)
   111                              <1> 		; mov r3,-(sp)
   112                              <1> 		; mov r4,-(sp)
   113                              <1> 		; mov r5,-(sp)
   114                              <1> 		; mov ac,-(sp) / "accumulator" register for extended
   115                              <1> 		             ; / arithmetic unit
   116                              <1> 		; mov mq,-(sp) / "multiplier quotient" register for the
   117                              <1> 		             ; / extended arithmetic unit
   118                              <1> 		; mov sc,-(sp) / "step count" register for the extended
   119                              <1> 		             ; / arithmetic unit
   120                              <1> 		; mov sp,u.sp / u.sp points to top of users stack
   121                              <1> 		; mov 18.(sp),r0 / store pc in r0
   122                              <1> 		; mov -(r0),r0 / sys inst in r0      10400xxx
   123                              <1> 		; sub $sys,r0 / get xxx code
   124                              <1> sysent1:
   125 0000CBBC C1E002              <1> 	shl	eax, 2
   126                              <1> 		; asl r0 / multiply by 2 to jump indirect in bytes
   127 0000CBBF 3DB8000000          <1> 	cmp	eax, end_of_syscalls - syscalls
   128                              <1> 		; cmp r0,$2f-1f / limit of table (35) exceeded
   129                              <1> 	;jnb	short badsys
   130                              <1> 		; bhis badsys / yes, bad system call
   131 0000CBC4 F5                  <1> 	cmc
   132 0000CBC5 9C                  <1> 	pushf	
   133 0000CBC6 50                  <1> 	push	eax
   134 0000CBC7 8B2D[14010300]      <1>  	mov 	ebp, [u.sp] ; Kernel stack at the beginning of sys call
   135 0000CBCD B0FE                <1> 	mov	al, 0FEh ; 11111110b
   136 0000CBCF 1400                <1> 	adc	al, 0 ; al = al + cf
   137 0000CBD1 204508              <1> 	and	[ebp+8], al ; flags (reset carry flag)
   138                              <1> 		; bic $341,20.(sp) / set users processor priority to 0 
   139                              <1> 				 ; / and clear carry bit
   140 0000CBD4 5D                  <1> 	pop	ebp ; eax
   141 0000CBD5 9D                  <1> 	popf
   142 0000CBD6 720B                <1>         jc      short badsys ; 23/07/2022
   143 0000CBD8 A1[1C010300]        <1> 	mov	eax, [u.r0]
   144                              <1> 	; system call registers: EAX, EDX, ECX, EBX, ESI, EDI
   145 0000CBDD FFA5[30CC0000]      <1> 	jmp	dword [ebp+syscalls]
   146                              <1> 		; jmp *1f(r0) / jump indirect thru table of addresses
   147                              <1> 		            ; / to proper system routine.
   148                              <1> 	; 30/07/2022
   149                              <1> 	; 23/07/2022
   150                              <1> badsys:
   151                              <1> 	; 25/12/2016
   152                              <1> 	; 18/04/2016 (TRDOS 386 = TRDOS v2.0)
   153                              <1> 	; 17/04/2011 (TRDOS v1.0, 'IFC.ASM')
   154                              <1> 	; 03/02/2011 ('trdos_ifc_routine')
   155                              <1> 	;
   156                              <1> 	; 16/04/2015 (Retro UNIX 386 v1, 'badsys')
   157                              <1> 	; (EIP, EAX values will be shown on screen with error message)
   158                              <1> 	; (EIP = 'CD 40h' instruction address -INT 40h-)
   159                              <1> 	; (EAX = Function number)  
   160                              <1> 	;
   161 0000CBE3 FE05[6C010300]      <1> 	inc	byte [u.bsys]
   162                              <1> 	;
   163 0000CBE9 8B1D[14010300]      <1> 	mov	ebx, [u.sp] ; esp at the beginning of 'sysent'
   164 0000CBEF 8B03                <1> 	mov	eax, [ebx] ; EIP (return address, not 'INT 30h' address)
   165                              <1> 	;sub	eax, 2 ; CDh, ##h
   166                              <1> 	; 30/07/2022
   167 0000CBF1 48                  <1> 	dec	eax
   168 0000CBF2 48                  <1> 	dec	eax
   169 0000CBF3 E87B75FFFF          <1> 	call	dwordtohex
   170 0000CBF8 8915[A7370100]      <1> 	mov	[eip_str], edx
   171 0000CBFE A3[AB370100]        <1> 	mov	[eip_str+4], eax
   172 0000CC03 A1[1C010300]        <1> 	mov	eax, [u.r0]
   173 0000CC08 E86675FFFF          <1> 	call	dwordtohex
   174 0000CC0D 8915[96370100]      <1> 	mov	[eax_str], edx
   175 0000CC13 A3[9A370100]        <1> 	mov	[eax_str+4], eax
   176                              <1> 
   177 0000CC18 66C705[8B370100]34- <1> 	mov	word [int_num_str], SYSCALL_INT_NUM ; 25/12/2016
   177 0000CC20 30                  <1>
   178                              <1> 
   179 0000CC21 BE[5D370100]        <1> 	mov	esi, ifc_msg ; "invalid funtion call !" msg (trdosk9.s)
   180 0000CC26 E82FA0FFFF          <1> 	call	print_msg
   181                              <1> 
   182 0000CC2B E92C020000          <1> 	jmp	sysexit
   183                              <1> 
   184                              <1> syscalls: ; 1:
   185                              <1> 	; 31/12/2017
   186                              <1> 	; 28/02/2017
   187                              <1> 	; 20/02/2017
   188                              <1> 	; 19/02/2017
   189                              <1> 	; 15/10/2016
   190                              <1> 	; 20/05/2016
   191                              <1> 	; 19/05/2016
   192                              <1> 	; 16/05/2016
   193                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   194                              <1> 	; 21/09/2015
   195                              <1> 	; 01/07/2015
   196                              <1> 	; 16/04/2015 (32 bit address modification) 
   197 0000CC30 [A50C0100]          <1> 	dd sysver	; 0 ; Get TRDOS 386 version number (v2.0)	
   198 0000CC34 [5CCE0000]          <1> 	dd sysexit 	; 1
   199 0000CC38 [29D00000]          <1> 	dd sysfork 	; 2
   200 0000CC3C [B6D30000]          <1> 	dd sysread 	; 3
   201 0000CC40 [D5D30000]          <1> 	dd syswrite 	; 4
   202 0000CC44 [04D20000]          <1> 	dd sysopen 	; 5
   203 0000CC48 [8CD30000]          <1> 	dd sysclose 	; 6
   204 0000CC4C [B1CF0000]          <1> 	dd syswait 	; 7
   205 0000CC50 [31D10000]          <1> 	dd syscreat 	; 8
   206 0000CC54 [B11A0100]          <1> 	dd sysrename	; 9  ; TRDOS 386, Rename File (31/12/2017)
   207 0000CC58 [44160100]          <1> 	dd sysdelete	; 10 ; TRDOS 386, Delete File (29/12/2017)
   208 0000CC5C [F3000100]          <1> 	dd sysexec 	; 11
   209 0000CC60 [60170100]          <1> 	dd syschdir 	; 12
   210 0000CC64 [1B190100]          <1> 	dd systime 	; 13 ; TRDOS 386, Get Sys Date&Time (30/12/2017)
   211 0000CC68 [4FD30000]          <1> 	dd sysmkdir 	; 14
   212 0000CC6C [94170100]          <1> 	dd syschmod 	; 15 ; TRDOS 386, Change Attributes (30/12/2017) 
   213 0000CC70 [AB160100]          <1> 	dd sysrmdir 	; 16 ; TRDOS 386, Remove Directory (29/12/2017)
   214 0000CC74 [8F050100]          <1> 	dd sysbreak 	; 17
   215 0000CC78 [70180100]          <1> 	dd sysdrive 	; 18 ; TRDOS 386, Get/Set Current Drv (30/12/2017) 
   216 0000CC7C [D0050100]          <1> 	dd sysseek 	; 19
   217 0000CC80 [E2050100]          <1> 	dd systell 	; 20
   218 0000CC84 [C71B0100]          <1> 	dd sysmem 	; 21 ; TRDOS 386, Get Total&Free Mem (31/12/2017)
   219 0000CC88 [FD1B0100]          <1> 	dd sysprompt 	; 22 ; TRDOS 386, Change Cmd Prompt (31/12/2017)
   220 0000CC8C [3E1C0100]          <1> 	dd syspath 	; 23 ; TRDOS 386, Get/Set Run Path (31/12/2017)
   221 0000CC90 [A31C0100]          <1> 	dd sysenv 	; 24 ; TRDOS 386, Get/Set Env Vars (31/12/2017)
   222 0000CC94 [9C190100]          <1> 	dd sysstime 	; 25 ; TRDOS 386, Set Sys Date&Time (30/12/2017)
   223 0000CC98 [48060100]          <1> 	dd sysquit 	; 26
   224 0000CC9C [3C060100]          <1> 	dd sysintr 	; 27
   225 0000CCA0 [BF180100]          <1> 	dd sysdir 	; 28 ; TRDOS 386, Get Curr Drive&Dir (30/12/2017) 
   226 0000CCA4 [E8CC0000]          <1> 	dd sysemt 	; 29
   227 0000CCA8 [FA180100]          <1> 	dd sysldrvt	; 30 ; TRDOS 386, Get Logical DOS DDT (30/12/2017)
   228 0000CCAC [C7D50000]          <1> 	dd sysvideo 	; 31 ; TRDOS 386 Video Functions (16/05/2016)
   229 0000CCB0 [F7240100]          <1> 	dd sysaudio 	; 32 ; TRDOS 386 Audio Functions (16/05/2016)
   230 0000CCB4 [32D40000]          <1> 	dd systimer 	; 33 ; TRDOS 386 Timer Functions (18/05/2016)
   231 0000CCB8 [54060100]          <1> 	dd syssleep 	; 34 ; Retro UNIX 8086 v1 feature only !
   232                              <1> 			     ; 11/06/2014
   233 0000CCBC [8E060100]          <1> 	dd sysmsg	; 35 ; Retro UNIX 386 v1 feature only !
   234                              <1> 			     ; 01/07/2015
   235 0000CCC0 [A8070100]          <1> 	dd sysgeterr	; 36 ; Retro UNIX 386 v1 feature only !
   236                              <1> 			     ; 21/09/2015 - get last error number
   237 0000CCC4 [1B160100]          <1> 	dd sysfpstat	; 37 ; TRDOS 386 FPU state option (28/02/2017)
   238 0000CCC8 [B40C0100]          <1> 	dd syspri 	; 38 ; change priority - TRDOS 386 (20/05/2016)
   239 0000CCCC [BACD0000]          <1> 	dd sysrele	; 39 ; TRDOS 386 (19/05/2016) (0 -> 39)
   240 0000CCD0 [DF0D0100]          <1> 	dd sysfff	; 40 ; Find First File - TRDOS 386 (15/10/2016)
   241 0000CCD4 [B30E0100]          <1> 	dd sysfnf	; 41 ; Find Next File - TRDOS 386 (15/10/2016)
   242 0000CCD8 [09150100]          <1> 	dd sysalloc	; 42 ; Allocate contiguous memory block/pages
   243                              <1> 			     ; TRDOS 386 (19/02/2017) DMA buff fuctions		
   244 0000CCDC [C3150100]          <1> 	dd sysdalloc	; 43 ; Deallocate contiguous memory block/pages
   245                              <1> 			     ; TRDOS 386 (19/02/2017) DMA buff fuctions
   246 0000CCE0 [FE150100]          <1> 	dd syscalbac	; 44 ; IRQ Callback and Signal Response Byte
   247                              <1> 			     ; service setup - TRDOS 386 (20/02/2017)
   248                              <1> 			     ; 28/08/2017 (20/08/2017)	
   249 0000CCE4 [542D0100]          <1> 	dd sysdma	; 45 ; TRDOS 386 - (ISA) DMA service
   250                              <1> 	
   251                              <1> end_of_syscalls:
   252                              <1> 
   253                              <1> sysemt: ; enable (or disable) multi tasking -time sharing-
   254                              <1> 	;
   255                              <1> 	; 08/08/2022
   256                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
   257                              <1> 	; 23/05/2016 - TRDOS 386 (TRDOS v2.0)
   258                              <1> 	; 14/05/2015 (Retro UNIX 386 v1)
   259                              <1> 	; 10/12/2013 - 20/04/2014 (Retro UNIX 8086 v1)
   260                              <1> 	;
   261                              <1> 	; Retro UNIX 8086 v1 modification: 
   262                              <1> 	;	'Enable Multi Tasking'  system call instead 
   263                              <1> 	;	of 'Emulator Trap' in original UNIX v1 for PDP-11.
   264                              <1> 	;
   265                              <1> 	; Retro UNIX 8086 v1 feature only!
   266                              <1> 	;	Using purpose: Kernel will start without time-out
   267                              <1> 	;	(internal clock/timer) functionality.
   268                              <1> 	;	Then etc/init will enable clock/timer for
   269                              <1> 	;	multi tasking. 
   270                              <1> 	;
   271                              <1> 	; INPUT ->
   272                              <1> 	;	BL = 0 -> disable multi tasking
   273                              <1> 	;	BL > 1 -> enable multi tasking (time sharing) 
   274                              <1> 	; OUTPUT ->
   275                              <1> 	;	none	
   276                              <1> 	;
   277                              <1> 	;  Note: Multi tasking is disabled during system
   278                              <1> 	;	 initialization, it must be enabled by using
   279                              <1> 	;	 this system call. (Otherwise, running proces 
   280                              <1> 	;	 will not be changed by another process within
   281                              <1> 	;	 run time sequence/schedule, if running process
   282                              <1> 	;	 will not 'release' itself. Only 'wakeup' procedure
   283                              <1> 	;	 for waiting processes and programmed timer events
   284                              <1> 	;	 for other processes can change running process 
   285                              <1> 	;	 while multi tasking is disabled.) ** 23/05/2016 **
   286                              <1> 
   287 0000CCE8 803D[6E010300]00    <1> 	cmp	byte [u.uid], 0 ; root ?
   288                              <1> 	;ja	short error
   289                              <1> 	; 23/07/2022
   290                              <1> 	;ja	short badsys ; 14/05/2015
   291                              <1> 	; 08/08/2022
   292 0000CCEF 7605                <1> 	jna	short sysemt_root
   293 0000CCF1 E9EDFEFFFF          <1> 	jmp	badsys
   294                              <1> sysemt_root:	; 08/08/2022
   295 0000CCF6 FA                  <1> 	cli
   296 0000CCF7 881D[16840100]      <1> 	mov	[multi_tasking], bl ; 0 to disable, >0 to enable
   297 0000CCFD EB20                <1> 	jmp	sysret
   298                              <1> 
   299                              <1> error:
   300                              <1> 	; 18/05/2016
   301                              <1> 	; 13/05/2016
   302                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   303                              <1> 	; 16/04/2015 - 17/09/2015 (Retro UNIX 386 v1)
   304                              <1> 	; 10/04/2013 - 07/08/2013 (Retro UNIX 8086 v1)
   305                              <1> 	;
   306                              <1> 	; 'error' merely sets the error bit off the processor status (c-bit)
   307                              <1> 	; then falls right into the 'sysret', 'sysrele' return sequence.
   308                              <1> 	;
   309                              <1> 	; INPUTS -> none
   310                              <1> 	; OUTPUTS ->
   311                              <1> 	;	processor status - carry (c) bit is set (means error)
   312                              <1> 	;
   313                              <1> 	; 26/05/2013 (Stack pointer must be reset here! 
   314                              <1> 	; 	      Because, jumps to error procedure
   315                              <1> 	;	      disrupts push-pop nesting balance)
   316                              <1> 	;
   317 0000CCFF 8B2D[14010300]      <1> 	mov	ebp, [u.sp] ; interrupt (system call) return (iretd) address
   318 0000CD05 804D0801            <1> 	or	byte [ebp+8], 1  ; set carry bit of flags register
   319                              <1> 				 ; (system call will return with cf = 1)
   320                              <1> 		; bis $1,20.(r1) / set c bit in processor status word below
   321                              <1> 		               ; / users stack
   322                              <1> 	; 17/09/2015
   323 0000CD09 83ED30              <1> 	sub	ebp, ESPACE ; 48 ; total size of stack frame ('sysdefs.inc')
   324                              <1> 				 ; for saving/restoring user registers	
   325                              <1> 	;cmp	ebp, [u.usp]
   326                              <1> 	;je	short err0	
   327 0000CD0C 892D[18010300]      <1> 	mov	[u.usp], ebp
   328                              <1> ;err0:
   329                              <1> 	; 01/09/2015
   330 0000CD12 8B25[18010300]      <1> 	mov	esp, [u.usp] 	    ; Retro Unix 8086 v1 modification!
   331                              <1> 				    ; 10/04/2013
   332                              <1> 				    ; (If an I/O error occurs during disk I/O,
   333                              <1> 				    ; related procedures will jump to 'error'
   334                              <1> 				    ; procedure directly without returning to 
   335                              <1> 				    ; the caller procedure. So, stack pointer
   336                              <1>                                     ; must be restored here.)
   337                              <1> 	; 13/05/2016
   338                              <1> 	; NOTE: (The last) error code is in 'u.error', it can be retrieved by
   339                              <1> 	;	'get last error' system call later. 	
   340                              <1> 
   341                              <1> 	; 03/09/2015 - 09/06/2015 - 07/08/2013
   342 0000CD18 C605[82010300]00    <1> 	mov 	byte [u.kcall], 0 ; namei_r, mkdir_w reset
   343                              <1> 
   344                              <1> sysret: ; < return from system call>
   345                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
   346                              <1> 	; 01/03/2017
   347                              <1> 	; 28/02/2017
   348                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   349                              <1> 	; 16/04/2015 - 10/09/2015 (Retro UNIX 386 v1)
   350                              <1> 	; 10/04/2013 - 23/02/2014 (Retro UNIX 8086 v1)
   351                              <1> 	;
   352                              <1> 	; 'sysret' first checks to see if process is about to be 
   353                              <1> 	; terminated (u.bsys). If it is, 'sysexit' is called.
   354                              <1> 	; If not, following happens:	 
   355                              <1> 	; 	1) The user's stack pointer is restored.
   356                              <1> 	;	2) r1=0 and 'iget' is called to see if last mentioned
   357                              <1> 	;	   i-node has been modified. If it has, it is written out
   358                              <1> 	;	   via 'ppoke'.
   359                              <1> 	;	3) If the super block has been modified, it is written out
   360                              <1> 	;	   via 'ppoke'.				
   361                              <1> 	;	4) If the dismountable file system's super block has been
   362                              <1> 	;	   modified, it is written out to the specified device
   363                              <1> 	;	   via 'ppoke'.
   364                              <1> 	;	5) A check is made if user's time quantum (uquant) ran out
   365                              <1> 	;	   during his execution. If so, 'tswap' is called to give
   366                              <1> 	;	   another user a chance to run.
   367                              <1> 	;	6) 'sysret' now goes into 'sysrele'. 
   368                              <1> 	;	    (See 'sysrele' for conclusion.)		
   369                              <1> 	;
   370                              <1> 	; Calling sequence:
   371                              <1> 	;	jump table or 'br sysret'
   372                              <1> 	; Arguments: 
   373                              <1> 	;	-	
   374                              <1> 	; ...............................................................
   375                              <1> 	;	
   376                              <1> 	; ((AX=r1 for 'iget' input))
   377                              <1> 	;	
   378 0000CD1F 31C0                <1> 	xor	eax, eax ; 28/02/2017
   379                              <1> sysret0: ; 29/07/2015 (eax = 0, jump from sysexec)
   380 0000CD21 FEC0                <1> 	inc	al ; 04/05/2013
   381 0000CD23 3805[6C010300]      <1> 	cmp	[u.bsys], al ; 1
   382                              <1> 		; tstb u.bsys / is a process about to be terminated because
   383                              <1>         ;jnb	sysexit ; 04/05/2013
   384                              <1> 		; bne sysexit / of an error? yes, go to sysexit
   385                              <1> 	; 23/07/2022
   386 0000CD29 7205                <1> 	jb	short sysret1
   387 0000CD2B E92C010000          <1> 	jmp	sysexit
   388                              <1> sysret1:	; 23/07/2022
   389                              <1> 	;mov	esp, [u.usp] ; 24/05/2013 (that is not needed here)
   390                              <1> 		; mov u.sp,sp / no point stack to users stack
   391 0000CD30 FEC8                <1> 	dec 	al ; mov ax, 0
   392                              <1> 		; clr r1 / zero r1 to check last mentioned i-node
   393 0000CD32 E80E500000          <1> 	call	iget
   394                              <1> 		; jsr r0,iget / if last mentioned i-node has been modified
   395                              <1> 		            ; / it is written out
   396                              <1> 	; 10/01/2017
   397                              <1> 	; 09/01/2017
   398                              <1> ;sysrele: ; < release >
   399                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   400                              <1> 	; 16/04/2015 - 14/10/2015 (Retro UNIX 386 v1)
   401                              <1> 	; 10/04/2013 - 07/03/2014 (Retro UNIX 8086 v1)
   402                              <1> 	;
   403                              <1> 	; 'sysrele' first calls 'tswap' if the time quantum for a user is
   404                              <1> 	;  zero (see 'sysret'). It then restores the user's registers and
   405                              <1> 	; turns off the system flag. It then checked to see if there is
   406                              <1> 	; an interrupt from the user by calling 'isintr'. If there is, 
   407                              <1> 	; the output gets flashed (see isintr) and interrupt action is
   408                              <1> 	; taken by a branch to 'intract'. If there is no interrupt from
   409                              <1> 	; the user, a rti is made.
   410                              <1> 	;
   411                              <1> 	; Calling sequence:
   412                              <1> 	;	Fall through a 'bne' in 'sysret' & ?
   413                              <1> 	; Arguments:
   414                              <1> 	;	-	
   415                              <1> 	; ...............................................................
   416                              <1> 	;	
   417                              <1> 	; 23/02/2014 (swapret)
   418                              <1> 	; 22/09/2013
   419                              <1> sysrel0: ;1:
   420 0000CD37 803D[64010300]00    <1> 	cmp	byte [u.quant], 0 ; 16/05/2013
   421                              <1> 		; tstb uquant / is the time quantum 0?
   422 0000CD3E 7705                <1>         ja      short swapret
   423                              <1> 		; bne 1f / no, don't swap it out
   424                              <1> sysrelease: ; 07/12/2013 (jump from 'clock')
   425 0000CD40 E8283E0000          <1> 	call	tswap
   426                              <1> 		; jsr r0,tswap / yes, swap it out
   427                              <1> 	
   428                              <1> ; Retro Unix 8086 v1 feature: return from 'swap' to 'swapret' address.
   429                              <1> swapret: ;1:
   430                              <1> 	; 10/09/2015
   431                              <1> 	; 01/09/2015
   432                              <1> 	; 14/05/2015
   433                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - 32 bit, pm modifications)
   434                              <1> 	; 26/05/2013 (Retro UNIX 8086 v1)
   435                              <1> 	; cli
   436                              <1> 	; 24/07/2015
   437                              <1> 	;
   438                              <1> 	;; 'esp' must be already equal to '[u.usp]' here ! 
   439                              <1> 	;; mov	esp, [u.usp]
   440                              <1> 
   441                              <1> 	; 22/09/2013
   442 0000CD45 E8FB4F0000          <1> 	call	isintr
   443                              <1> 	; 20/10/2013
   444 0000CD4A 7405                <1> 	jz	short sysrel1
   445 0000CD4C E8F4000000          <1> 	call	intract
   446                              <1> 		; jsr r0,isintr / is there an interrupt from the user
   447                              <1> 		;     br intract / yes, output gets flushed, take interrupt
   448                              <1> 		               ; / action
   449                              <1> sysrel1:
   450 0000CD51 FA                  <1> 	cli	; 14/10/2015
   451                              <1> sysrel2:
   452                              <1> 	; 28/02/2017
   453                              <1> 	; Check if there is a (delayed) callback for current user/process
   454 0000CD52 A0[93010300]        <1> 	mov	al, [u.irqwait]
   455 0000CD57 240F                <1> 	and	al, 0Fh ; is there a waiting IRQ callback service ?
   456 0000CD59 7444                <1> 	jz	short sysrel8 ; no
   457                              <1> 
   458                              <1> 	; Set return to IRQ callback service and return from the service
   459 0000CD5B 0FB6D8              <1> 	movzx	ebx, al
   460 0000CD5E 883D[93010300]      <1> 	mov 	[u.irqwait], bh ; 0 ; reset
   461 0000CD64 8A9B[B4370100]      <1> 	mov	bl, [ebx+IRQenum] ; (available) IRQ index +1 (1 to 9)
   462                              <1> 	; 01/03/2017
   463 0000CD6A FECB                <1> 	dec	bl ; IRQ index number, 0 to 8
   464 0000CD6C 7831                <1> 	js	short sysrel8 ; 0 -> FFh (not in use!?) 
   465                              <1> 	;
   466 0000CD6E A0[6D010300]        <1> 	mov 	al, [u.uno] ; current process (user) number 
   467 0000CD73 3883[60890100]      <1> 	cmp	[ebx+IRQ.owner], al
   468 0000CD79 7524                <1> 	jne	short sysrel8 ; it is not the current user/process !?
   469 0000CD7B F683[72890100]01    <1> 	test	byte [ebx+IRQ.method], 1 ; callback ?
   470 0000CD82 741B                <1> 	jz	short sysrel8 ; not a callback method !?
   471                              <1> 
   472 0000CD84 8B93[84890100]      <1> 	mov	edx, [ebx+IRQ.addr] ; IRQ callback service address (virtual)
   473 0000CD8A C605[94010300]01    <1> 	mov	byte [u.r_lock], 1 ; IRQ callback service in progress flag
   474                              <1> 
   475 0000CD91 E87F3E0000          <1> 	call	wswap ; save user's registers & status 
   476                              <1> 		      ;	(for return from IRQ callback service)
   477                              <1> 
   478 0000CD96 8B2D[14010300]      <1> 	mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
   479 0000CD9C 895500              <1> 	mov	[ebp], edx ; IRQ call back service address
   480                              <1> sysrel8:
   481 0000CD9F FE0D[10010300]      <1> 	dec	byte [sysflg]
   482                              <1> 		; decb sysflg / turn system flag off
   483                              <1> 	
   484 0000CDA5 A1[74010300]        <1> 	mov	eax, [u.pgdir]	
   485 0000CDAA 0F22D8              <1> 	mov	cr3, eax  ; 1st PDE points to Kernel Page Table 0 (1st 4 MB)
   486                              <1> 			  ; (others are different than kernel page tables) 
   487                              <1> 	; 10/09/2015
   488 0000CDAD 61                  <1> 	popad ; edi, esi, ebp, temp (icrement esp by 4), ebx, edx, ecx, eax
   489                              <1> 		; mov (sp)+,sc / restore user registers
   490                              <1> 		; mov (sp)+,mq
   491                              <1> 		; mov (sp)+,ac
   492                              <1> 		; mov (sp)+,r5
   493                              <1> 		; mov (sp)+,r4
   494                              <1> 		; mov (sp)+,r3
   495                              <1> 		; mov (sp)+,r2
   496                              <1> 	;
   497 0000CDAE A1[1C010300]        <1> 	mov	eax, [u.r0]  ; ((return value in EAX))
   498 0000CDB3 0FA9                <1> 	pop	gs
   499 0000CDB5 0FA1                <1> 	pop	fs
   500 0000CDB7 07                  <1> 	pop	es
   501 0000CDB8 1F                  <1> 	pop	ds
   502                              <1> 	;or	word [esp+8], 200h ; 22/01/2017 ; force enabling interrupts
   503 0000CDB9 CF                  <1> 	iretd	
   504                              <1> 		; rti / no, return from interrupt
   505                              <1> 
   506                              <1> sysrele:
   507                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
   508                              <1> 	; 24/03/2017
   509                              <1> 	; 28/02/2017
   510                              <1> 	; 27/02/2017
   511                              <1> 	; 29/01/2017
   512                              <1> 	; 14/01/2017
   513                              <1> 	; 13/01/2017
   514                              <1> 	; 09/01/2017 - 10/01/2017 - 12/01/2017
   515                              <1> 	; Major modification for TRDOS 386 (CallBack return)
   516                              <1> 	;
   517                              <1> 	; 'sysrele' system call restores previously saved
   518                              <1> 	; registers and addresses of the process
   519                              <1> 	; (Main purpose -in TRDOS 386- is to return from
   520                              <1> 	; timer callback service routine in ring 3 -user mode-.)
   521                              <1> 	;
   522                              <1> 	; check if the process is in timer callback phase
   523 0000CDBA 803D[90010300]00    <1> 	cmp	byte [u.t_lock], 0 ; TIMER INT LOCK
   524                              <1> 	;je	short sysrel0 ; classic (Retro UNIX 386 type) sysrele
   525 0000CDC1 7735                <1> 	ja	short sysrel3
   526                              <1> 	; 27/02/2017
   527 0000CDC3 803D[94010300]00    <1> 	cmp	byte [u.r_lock], 0 ; IRQ callback lock	
   528                              <1> 	;jna	sysrel0 ; classic sysrele ; 24/03/2017
   529                              <1> 	; 23/07/2022
   530 0000CDCA 7705                <1> 	ja	short sysrel9
   531 0000CDCC E966FFFFFF          <1> 	jmp	sysrel0
   532                              <1> sysrel9:	; 23/07/2022
   533 0000CDD1 E859000000          <1> 	call	sysrel7
   534 0000CDD6 803D[94010300]00    <1> 	cmp	byte [u.r_lock], 0 ; IRQ callback service lock
   535 0000CDDD 7628                <1> 	jna	short sysrel4
   536 0000CDDF C605[94010300]00    <1> 	mov	byte [u.r_lock], 0 ; reset
   537                              <1> 	;mov	byte [u.irqwait], 0 ; reset ; 28/02/2017
   538 0000CDE6 A0[95010300]        <1> 	mov	al, [u.r_mode]
   539 0000CDEB 08C0                <1> 	or	al, al
   540 0000CDED 7518                <1> 	jnz	short sysrel4
   541 0000CDEF FEC8                <1> 	dec	al
   542 0000CDF1 A2[95010300]        <1> 	mov	[u.r_mode], al ; 0FFh ; not necessary !?
   543 0000CDF6 EB32                <1> 	jmp	short sysrel6		
   544                              <1> sysrel3:
   545                              <1> 	; 27/02/2017
   546 0000CDF8 E832000000          <1> 	call	sysrel7
   547                              <1> 	; 14/01/2017
   548 0000CDFD 28C0                <1> 	sub	al, al
   549 0000CDFF 3805[90010300]      <1> 	cmp	[u.t_lock], al ; 0 ; TIMER INT LOCK
   550 0000CE05 770E                <1> 	ja	short sysrel5 ; yes
   551                              <1> sysrel4:
   552                              <1> 	; 29/01/2017
   553 0000CE07 8B44241C            <1> 	mov	eax, [esp+28] ; eax
   554 0000CE0B A3[1C010300]        <1> 	mov	[u.r0], eax
   555 0000CE10 E93DFFFFFF          <1> 	jmp	sysrel2
   556                              <1> sysrel5:
   557 0000CE15 A2[90010300]        <1> 	mov	[u.t_lock], al ; 0 ; reset
   558 0000CE1A A0[91010300]        <1> 	mov	al, [u.t_mode]
   559 0000CE1F 20C0                <1> 	and	al, al
   560                              <1> 	;jnz	short sysrel2 ; 0FFh ; user mode
   561 0000CE21 75E4                <1> 	jnz	short sysrel4 ; 29/01/2017
   562 0000CE23 FEC8                <1> 	dec	al
   563 0000CE25 A2[91010300]        <1> 	mov	[u.t_mode], al ; 0FFh ; not necessary !?
   564                              <1> sysrel6:
   565                              <1> 	; cpu will continue from the interrupted sytem call addr
   566 0000CE2A 61                  <1> 	popad		; edi, esi, ebp, esp, ebx, edx, ecx, eax
   567 0000CE2B 83C410              <1> 	add	esp, 16	; pass segment segisters: ds, es, fs, gs		
   568 0000CE2E CF                  <1> 	iretd		; eip, cs, eflags
   569                              <1> 
   570                              <1> sysrel7:
   571 0000CE2F 0FB61D[6D010300]    <1> 	movzx	ebx, byte [u.uno] ; current process number
   572                              <1> 	;shl	bx, 2
   573                              <1> 	; 23/07/2022
   574 0000CE36 C1E302              <1> 	shl	ebx, 2
   575                              <1> 	;cmp	[ebx+p.tcb-4], eax ; 0 ; is there callback address ?
   576                              <1> 	;jna	short sysrel0 
   577                              <1> 	; yes, reset callback address then restore process registers 
   578                              <1> 	;mov	[ebx+p.tcb-4], eax ; 0 ; reset
   579 0000CE39 8B83[6C000300]      <1> 	mov     eax, [ebx+p.upage-4] ; UPAGE address
   580 0000CE3F FA                  <1> 	cli	; disable interrupts till 'iretd'
   581 0000CE40 E9083E0000          <1> 	jmp	rswap ; restore process 'u' structure
   582                              <1>  
   583                              <1> intract: ; / interrupt action
   584                              <1> 	; 14/10/2015
   585                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - Beginning)
   586                              <1> 	; 09/05/2013 - 07/12/2013 (Retro UNIX 8086 v1)
   587                              <1> 	;
   588                              <1> 	; Retro UNIX 8086 v1 modification !
   589                              <1> 	; (Process/task switching and quit routine by using
   590                              <1> 	; Retro UNIX 8086 v1 keyboard interrupt output.))
   591                              <1> 	;
   592                              <1> 	; input -> 'u.quit'  (also value of 'u.intr' > 0)
   593                              <1> 	; output -> If value of 'u.quit' = FFFFh ('ctrl+brk' sign)
   594                              <1> 	;		'intract' will jump to 'sysexit'.
   595                              <1> 	;	    Intract will return to the caller 
   596                              <1> 	;		if value of 'u.quit' <> FFFFh. 	 
   597                              <1> 	; 14/10/2015
   598 0000CE45 FB                  <1> 	sti
   599                              <1> 	; 07/12/2013	
   600 0000CE46 66FF05[6A010300]    <1> 	inc 	word [u.quit]
   601 0000CE4D 7408                <1> 	jz	short intrct0 ; FFFFh -> 0
   602 0000CE4F 66FF0D[6A010300]    <1> 	dec	word [u.quit]
   603                              <1> 	; 16/04/2015
   604 0000CE56 C3                  <1> 	retn
   605                              <1> intrct0:	
   606 0000CE57 58                  <1> 	pop	eax ; call intract -> retn
   607                              <1> 	;
   608 0000CE58 31C0                <1> 	xor 	eax, eax
   609 0000CE5A FEC0                <1> 	inc	al  ; mov ax, 1
   610                              <1> ;;;
   611                              <1> 	; UNIX v1 original 'intract' routine... 
   612                              <1> 	; / interrupt action
   613                              <1> 		;cmp *(sp),$rti / are you in a clock interrupt?
   614                              <1> 		; bne 1f / no, 1f
   615                              <1> 		; cmp (sp)+,(sp)+ / pop clock pointer
   616                              <1> 	; 1: / now in user area
   617                              <1> 		; mov r1,-(sp) / save r1
   618                              <1> 		; mov u.ttyp,r1 
   619                              <1> 			; / pointer to tty buffer in control-to r1
   620                              <1> 		; cmpb 6(r1),$177
   621                              <1> 			; / is the interrupt char equal to "del"
   622                              <1> 		; beq 1f / yes, 1f
   623                              <1> 		; clrb 6(r1) 
   624                              <1> 		        ; / no, clear the byte 
   625                              <1> 			; / (must be a quit character)
   626                              <1> 		; mov (sp)+,r1 / restore r1
   627                              <1> 		; clr u.quit / clear quit flag
   628                              <1> 		; bis $20,2(sp) 
   629                              <1> 		    	; / set trace for quit (sets t bit of 
   630                              <1> 			; / ps-trace trap)
   631                              <1> 		; rti   ;  / return from interrupt
   632                              <1> 	; 1: / interrupt char = del
   633                              <1> 		; clrb 6(r1) / clear the interrupt byte 
   634                              <1> 			   ; / in the buffer
   635                              <1> 		; mov (sp)+,r1 / restore r1
   636                              <1> 		; cmp u.intr,$core / should control be 
   637                              <1> 				; / transferred to loc core?
   638                              <1> 		; blo 1f
   639                              <1> 		; jmp *u.intr / user to do rti yes, 
   640                              <1> 				; / transfer to loc core
   641                              <1> 	; 1:
   642                              <1> 		; sys 1 / exit
   643                              <1> 
   644                              <1> sysexit: ; <terminate process>
   645                              <1> 	; 30/07/2022
   646                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
   647                              <1> 	; 14/11/2017
   648                              <1> 	; 27/05/2017
   649                              <1> 	; 10/04/2017
   650                              <1> 	; 26/02/2017 - 28/02/2017
   651                              <1> 	; 02/01/2017 - 23/01/2017
   652                              <1> 	; 06/06/2016 - 10/06/2016
   653                              <1> 	; 19/05/2016 - 23/05/2016
   654                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   655                              <1> 	; 16/04/2015 - 01/09/2015 (Retro UNIX 386 v1)
   656                              <1> 	; 19/04/2013 - 14/02/2014 (Retro UNIX 8086 v1)
   657                              <1> 	;
   658                              <1> 	; 'sysexit' terminates a process. First each file that
   659                              <1> 	; the process has opened is closed by 'flose'. The process
   660                              <1> 	; status is then set to unused. The 'p.pid' table is then
   661                              <1> 	; searched to find children of the dying process. If any of
   662                              <1> 	; children are zombies (died by not waited for), they are
   663                              <1> 	; set free. The 'p.pid' table is then searched to find the
   664                              <1> 	; dying process's parent. When the parent is found, it is
   665                              <1> 	; checked to see if it is free or it is a zombie. If it is
   666                              <1> 	; one of these, the dying process just dies. If it is waiting
   667                              <1> 	; for a child process to die, it notified that it doesn't 
   668                              <1> 	; have to wait anymore by setting it's status from 2 to 1
   669                              <1> 	; (waiting to active). It is awakened and put on runq by
   670                              <1> 	; 'putlu'. The dying process enters a zombie state in which
   671                              <1> 	; it will never be run again but stays around until a 'wait'
   672                              <1> 	; is completed by it's parent process. If the parent is not
   673                              <1> 	; found, process just dies. This means 'swap' is called with
   674                              <1> 	; 'u.uno=0'. What this does is the 'wswap' is not called
   675                              <1> 	; to write out the process and 'rswap' reads the new process
   676                              <1> 	; over the one that dies..i.e., the dying process is 
   677                              <1> 	; overwritten and destroyed.	
   678                              <1>  	;
   679                              <1> 	; Calling sequence:
   680                              <1> 	;	sysexit or conditional branch.
   681                              <1> 	; Arguments:
   682                              <1> 	;	-	
   683                              <1> 	; ...............................................................
   684                              <1> 	;	
   685                              <1> 	; Retro UNIX 8086 v1 modification: 
   686                              <1> 	;       System call number (=1) is in EAX register.
   687                              <1> 	;
   688                              <1> 	;       Other parameters are in EDX, EBX, ECX, ESI, EDI, EBP
   689                              <1> 	;       registers depending of function details.
   690                              <1> 	;
   691                              <1> 	; ('swap' procedure is mostly different than original UNIX v1.)
   692                              <1> 	;
   693                              <1> ; / terminate process
   694                              <1> 	; AX = 1
   695 0000CE5C 6648                <1> 	dec 	ax ; 0
   696 0000CE5E 66A3[68010300]      <1> 	mov	[u.intr], ax ; 0
   697                              <1> 		; clr u.intr / clear interrupt control word
   698                              <1> 		; clr r1 / clear r1
   699                              <1> sysexit_0:
   700                              <1> 	; 30/07/2022
   701                              <1> 	; 23/01/2017
   702                              <1> 	; 02/01/2017
   703                              <1> 	; 10/06/2016
   704                              <1> 	; 06/06/2016
   705                              <1> 	; 23/05/2016
   706                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
   707                              <1> 	; Check and stop/clear timer event(s) of this (dying) process
   708                              <1> 	; if there is.
   709                              <1> 
   710                              <1> 	; 02/01/2017 
   711 0000CE64 FA                  <1> 	cli	; disable interrupts
   712                              <1> 	; 23/01/2017 - reset timer frequency (to 18.2Hz)
   713 0000CE65 B036                <1> 	mov	al, 00110110b ; 36h
   714 0000CE67 E643                <1>  	out	43h, al
   715 0000CE69 28C0                <1> 	sub	al, al ; 0
   716 0000CE6B E640                <1> 	out	40h, al ; LB
   717 0000CE6D E640                <1> 	out	40h, al ; HB
   718                              <1>  	; 
   719 0000CE6F 0FB61D[6D010300]    <1> 	movzx	ebx, byte [u.uno]
   720                              <1> 	;mov	bl, [u.uno] ; process number of dying process
   721 0000CE76 3883[AF000300]      <1> 	cmp	byte [ebx+p.timer-1], al ; 0
   722 0000CE7C 7639                <1> 	jna	short sysexit_12 ; no timer events for this process
   723 0000CE7E 8883[AF000300]      <1> 	mov	byte [ebx+p.timer-1], al ; 0 ; reset
   724                              <1> 	;mov	al, [timer_events]
   725                              <1> 	;or	al, al
   726                              <1>  	;jz	short sysexit_12 ; no timer events
   727                              <1> 	;mov	cl, al
   728 0000CE84 8A0D[17840100]      <1> 	mov	cl, [timer_events] ; 14/11/2017
   729                              <1> 	;cli	; disable interrupts 
   730 0000CE8A B410                <1> 	mov	ah, 16 ; number of available timer events
   731 0000CE8C BE[2C020300]        <1> 	mov	esi, timer_set ; beginning address of timer events
   732                              <1> sysexit_7:
   733 0000CE91 8A06                <1> 	mov	al, [esi] ; process number (of timer event)
   734 0000CE93 38D8                <1> 	cmp	al, bl ; process number comparison
   735 0000CE95 7411                <1> 	je	short sysexit_10
   736 0000CE97 20C0                <1> 	and	al, al
   737 0000CE99 7404                <1> 	jz	short sysexit_9
   738                              <1> sysexit_8:
   739 0000CE9B FEC9                <1> 	dec	cl
   740 0000CE9D 7416                <1> 	jz	short sysexit_11
   741                              <1> sysexit_9:
   742 0000CE9F FECC                <1> 	dec	ah
   743 0000CEA1 7414                <1> 	jz	short sysexit_12
   744 0000CEA3 83C610              <1> 	add	esi, 16
   745 0000CEA6 EBE9                <1> 	jmp	short sysexit_7
   746                              <1> 
   747                              <1> sysexit_10:
   748                              <1> 	;mov	byte [esi], 0
   749 0000CEA8 66C7060000          <1> 	mov	word [esi], 0
   750                              <1> 	;mov	dword [esi+12], 0
   751                              <1> 	;
   752 0000CEAD FE0D[17840100]      <1> 	dec	byte [timer_events] ; 02/01/2017
   753                              <1> 	;
   754 0000CEB3 EBE6                <1> 	jmp	short sysexit_8
   755                              <1> 
   756                              <1> sysexit_11:
   757                              <1> 	;sub	ax, ax ; 0 ; 26/02/2017
   758                              <1> 	; 30/07/2022
   759 0000CEB5 29C0                <1> 	sub	eax, eax ; 0
   760                              <1> sysexit_12:
   761                              <1> 	; 26/02/2017 (Unlink IRQ callbacks belong to the user)
   762 0000CEB7 803D[92010300]00    <1> 	cmp	byte [u.irqc], 0 ; Count of IRQ callbacks
   763 0000CEBE 7E2E                <1> 	jng	short sysexit_16 ; zero or invalid
   764                              <1> 	; 28/02/2017
   765                              <1> 	; clear IRQ callback flags (for 'sysrele' and 'sysret')
   766 0000CEC0 A2[93010300]        <1> 	mov	[u.irqwait], al ; 0 ; force to clear waiting flag
   767 0000CEC5 A2[94010300]        <1> 	mov	[u.r_lock], al ; 0 ; force to clear busy flag
   768 0000CECA BE[60890100]        <1> 	mov	esi, IRQ.owner
   769                              <1> sysexit_13:	
   770 0000CECF AC                  <1> 	lodsb
   771 0000CED0 3A05[6D010300]      <1> 	cmp	al, [u.uno] ; owner = current user ?
   772 0000CED6 750C                <1> 	jne	short sysexit_14
   773 0000CED8 C646FF00            <1> 	mov	byte [esi-1], 0 ; owner = 0 : Free
   774 0000CEDC FE0D[92010300]      <1> 	dec	byte [u.irqc]
   775 0000CEE2 7408                <1> 	jz	short sysexit_15
   776                              <1> sysexit_14:
   777 0000CEE4 81FE[68890100]      <1> 	cmp	esi, IRQ.owner + 8 ; the last IRQ index number ?
   778 0000CEEA 76E3                <1> 	jna	short sysexit_13 ; no
   779                              <1> sysexit_15:
   780 0000CEEC 30C0                <1> 	xor	al, al ; 0
   781                              <1> sysexit_16: ; 2:
   782 0000CEEE FB                  <1> 	sti	; enable interrupts 
   783                              <1> 	;
   784                              <1> 	; AX = 0
   785                              <1> sysexit_1: ; 1:
   786                              <1> 	; AX = File descriptor
   787                              <1> 		; / r1 has file descriptor (index to u.fp list)
   788                              <1> 		; / Search the whole list
   789 0000CEEF E8D8350000          <1> 	call	fclose
   790                              <1> 		; jsr r0,fclose / close all files the process opened
   791                              <1> 	;; ignore error return
   792                              <1> 		; br .+2 / ignore error return
   793                              <1> 	;inc	ax
   794 0000CEF4 FEC0                <1> 	inc	al
   795                              <1> 		; inc r1 / increment file descriptor
   796                              <1> 	;cmp	ax, 10
   797 0000CEF6 3C0A                <1> 	cmp	al, 10
   798                              <1> 		; cmp r1,$10. / end of u.fp list?
   799 0000CEF8 72F5                <1> 	jb	short sysexit_1
   800                              <1> 		; blt 1b / no, go back
   801                              <1> 	;movzx	ebx, byte [u.uno]
   802 0000CEFA 8A1D[6D010300]      <1> 	mov	bl, [u.uno] ; 02/01/2017
   803                              <1> 		; movb	u.uno,r1 / yes, move dying process's number to r1
   804 0000CF00 88A3[5F000300]      <1> 	mov	[ebx+p.stat-1], ah ; 0, SFREE
   805                              <1> 		; clrb p.stat-1(r1) / free the process
   806                              <1> 	; 10/04/2017
   807 0000CF06 381D[D9890100]      <1> 	cmp	[audio_user], bl
   808 0000CF0C 7518                <1> 	jne	short sysexit_17
   809                              <1> 	; reset audio device (current) owner and 'initializated' flag
   810 0000CF0E 883D[D9890100]      <1> 	mov	[audio_user], bh ; 0
   811                              <1> 	; 27/05/2017
   812 0000CF14 8B0D[C4890100]      <1> 	mov	ecx,  [audio_buffer]
   813 0000CF1A 09C9                <1> 	or	ecx, ecx
   814 0000CF1C 7408                <1> 	jz	short sysexit_17
   815                              <1> 	; 'deallocate_user_pages' is not necessary in sysexit !!!
   816                              <1> 	;push	ebx
   817                              <1> 	;mov	ebx, ecx
   818                              <1> 	;mov	ecx, [audio_buff_size]
   819                              <1> 	;call	deallocate_user_pages
   820                              <1> 	;; (Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP)
   821 0000CF1E 29C9                <1> 	sub	ecx, ecx
   822 0000CF20 890D[C4890100]      <1> 	mov	[audio_buffer], ecx ; 0
   823                              <1> 	;pop	ebx
   824                              <1> sysexit_17:
   825                              <1> 	;shl	bx, 1
   826 0000CF26 D0E3                <1> 	shl	bl, 1
   827                              <1> 		; asl r1 / use r1 for index into the below tables
   828 0000CF28 668B8B[FEFF0200]    <1> 	mov	cx, [ebx+p.pid-2]
   829                              <1> 		; mov p.pid-2(r1),r3 / move dying process's name to r3
   830 0000CF2F 668B93[1E000300]    <1> 	mov	dx, [ebx+p.ppid-2]
   831                              <1> 		; mov p.ppid-2(r1),r4 / move its parents name to r4
   832                              <1> 	; xor 	bx, bx ; 0
   833 0000CF36 30DB                <1> 	xor	bl, bl ; 0
   834                              <1> 		; clr r2
   835 0000CF38 31F6                <1> 	xor	esi, esi ; 0
   836                              <1> 		; clr r5 / initialize reg
   837                              <1> sysexit_2: ; 1:
   838                              <1> 	        ; / find children of this dying process, 
   839                              <1> 		; / if they are zombies, free them
   840                              <1> 	;add	bx, 2
   841 0000CF3A 80C302              <1> 	add	bl, 2
   842                              <1> 		; add $2,r2 / search parent process table 
   843                              <1> 		          ; / for dying process's name
   844 0000CF3D 66398B[1E000300]    <1> 	cmp	[ebx+p.ppid-2], cx
   845                              <1> 		; cmp p.ppid-2(r2),r3 / found it?
   846 0000CF44 7513                <1> 	jne	short sysexit_4
   847                              <1> 		; bne 3f / no
   848                              <1> 	;shr	bx, 1
   849 0000CF46 D0EB                <1> 	shr	bl, 1
   850                              <1> 		; asr r2 / yes, it is a parent
   851 0000CF48 80BB[5F000300]03    <1> 	cmp	byte [ebx+p.stat-1], 3 ; SZOMB
   852                              <1> 		; cmpb p.stat-1(r2),$3 / is the child of this 
   853                              <1> 				     ; / dying process a zombie
   854 0000CF4F 7506                <1> 	jne	short sysexit_3 
   855                              <1> 		; bne 2f / no
   856 0000CF51 88A3[5F000300]      <1> 	mov	[ebx+p.stat-1], ah ; 0, SFREE
   857                              <1> 		; clrb p.stat-1(r2) / yes, free the child process
   858                              <1> sysexit_3: ; 2:
   859                              <1> 	;shr	bx, 1
   860 0000CF57 D0E3                <1> 	shl	bl, 1
   861                              <1> 		; asl r2
   862                              <1> sysexit_4: ; 3:
   863                              <1> 		; / search the process name table 
   864                              <1> 		; / for the dying process's parent
   865 0000CF59 663993[FEFF0200]    <1> 	cmp	[ebx+p.pid-2], dx
   866                              <1> 		; cmp p.pid-2(r2),r4 / found it?
   867 0000CF60 7502                <1> 	jne	short sysexit_5
   868                              <1> 		; bne 3f / no
   869 0000CF62 89DE                <1> 	mov	esi, ebx
   870                              <1> 		; mov r2,r5 / yes, put index to p.pid table (parents
   871                              <1> 		          ; / process # x2) in r5
   872                              <1> sysexit_5: ; 3:
   873                              <1> 	;cmp	bx, nproc + nproc
   874 0000CF64 80FB20              <1> 	cmp	bl, nproc + nproc
   875                              <1> 		; cmp r2,$nproc+nproc / has whole table been searched?
   876 0000CF67 72D1                <1> 	jb	short sysexit_2
   877                              <1> 		; blt 1b / no, go back
   878                              <1> 		; mov r5,r1 / yes, r1 now has parents process # x2
   879 0000CF69 21F6                <1> 	and	esi, esi ; r5=r1
   880 0000CF6B 7435                <1> 	jz	short sysexit_6
   881                              <1> 		; beq 2f / no parent has been found. 
   882                              <1> 		       ; / The process just dies
   883                              <1> 	;shr	si, 1
   884                              <1> 	; 23/07/2022
   885 0000CF6D D1EE                <1> 	shr	esi, 1
   886                              <1> 		; asr r1 / set up index to p.stat
   887 0000CF6F 8A86[5F000300]      <1> 	mov	al, [esi+p.stat-1]
   888                              <1> 		; movb p.stat-1(r1),r2 / move status of parent to r2
   889 0000CF75 20C0                <1> 	and	al, al
   890 0000CF77 7429                <1> 	jz	short sysexit_6
   891                              <1> 		; beq 2f / if its been freed, 2f
   892 0000CF79 3C03                <1> 	cmp	al, 3
   893                              <1> 		; cmp r2,$3 / is parent a zombie?
   894 0000CF7B 7425                <1> 	je	short sysexit_6
   895                              <1> 		; beq 2f / yes, 2f
   896                              <1> 	; BH = 0
   897 0000CF7D 8A1D[6D010300]      <1> 	mov	bl, [u.uno]
   898                              <1> 		; movb u.uno,r3 / move dying process's number to r3
   899 0000CF83 C683[5F000300]03    <1> 	mov	byte [ebx+p.stat-1], 3  ; SZOMB
   900                              <1> 		; movb $3,p.stat-1(r3) / make the process a zombie
   901 0000CF8A 3C01                <1> 	cmp	al, 1 ; SRUN
   902 0000CF8C 7414                <1> 	je	short sysexit_6
   903                              <1> 	;cmp	al, 2
   904                              <1> 		; cmp r2,$2 / is the parent waiting for 
   905                              <1> 			  ; / this child to die
   906                              <1> 	;jne	short sysexit_6	
   907                              <1> 		; bne 2f / yes, notify parent not to wait any more
   908                              <1> 	; p.stat = 2 --> waiting
   909                              <1> 	; p.stat = 4 --> sleeping
   910 0000CF8E C686[5F000300]01    <1> 	mov	byte [esi+p.stat-1], 1 ; SRUN
   911                              <1> 	;dec	byte [esi+p.stat-1]
   912                              <1> 		; decb	p.stat-1(r1) / awaken it by putting it (parent)
   913 0000CF95 6689F0              <1> 	mov	ax, si ; r1  (process number in AL)
   914                              <1> 	; 
   915                              <1> 	;mov	ebx, runq + 4
   916                              <1> 		; mov $runq+4,r2 / on the runq
   917 0000CF98 BB[0C010300]        <1> 	mov	ebx, runq+2 ; normal run queue ; 02/01/2017
   918 0000CF9D E8E33C0000          <1> 	call	putlu
   919                              <1> 		; jsr r0, putlu
   920                              <1> sysexit_6: 
   921                              <1> 		; / the process dies
   922 0000CFA2 C605[6D010300]00    <1> 	mov	byte [u.uno], 0
   923                              <1> 		; clrb u.uno / put zero as the process number, 
   924                              <1> 	           ; / so "swap" will
   925 0000CFA9 E8D93B0000          <1> 	call	swap
   926                              <1> 		; jsr r0,swap / overwrite process with another process
   927                              <1> hlt_sys:
   928                              <1> 	;sti
   929                              <1> hlts0:
   930 0000CFAE F4                  <1> 	hlt
   931 0000CFAF EBFD                <1> 	jmp	short hlts0
   932                              <1> 		; 0 / and thereby kill it; halt?
   933                              <1> 
   934                              <1> syswait: ; < wait for a processs to die >
   935                              <1> 	; 30/07/2022
   936                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
   937                              <1> 	; 17/09/2015
   938                              <1> 	; 02/09/2015
   939                              <1> 	; 01/09/2015
   940                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - Beginning)
   941                              <1> 	; 24/05/2013 - 05/02/2014 (Retro UNIX 8086 v1)
   942                              <1> 	;
   943                              <1> 	; 'syswait' waits for a process die. 
   944                              <1> 	; It works in following way:
   945                              <1> 	;    1) From the parent process number, the parent's 
   946                              <1> 	; 	process name is found. The p.ppid table of parent
   947                              <1> 	;	names is then searched for this process name.
   948                              <1> 	;	If a match occurs, r2 contains child's process
   949                              <1> 	;	number. The child status is checked to see if it is
   950                              <1> 	;	a zombie, i.e; dead but not waited for (p.stat=3)
   951                              <1> 	;	If it is, the child process is freed and it's name
   952                              <1> 	;	is put in (u.r0). A return is then made via 'sysret'.
   953                              <1> 	;	If the child is not a zombie, nothing happens and
   954                              <1> 	;	the search goes on through the p.ppid table until
   955                              <1> 	;	all processes are checked or a zombie is found.
   956                              <1> 	;    2) If no zombies are found, a check is made to see if
   957                              <1> 	;	there are any children at all. If there are none,
   958                              <1> 	;	an error return is made. If there are, the parent's
   959                              <1> 	;	status is set to 2 (waiting for child to die),
   960                              <1> 	;	the parent is swapped out, and a branch to 'syswait'
   961                              <1> 	;	is made to wait on the next process.
   962                              <1> 	;
   963                              <1> 	; Calling sequence:
   964                              <1> 	;	?
   965                              <1> 	; Arguments:
   966                              <1> 	;	-
   967                              <1> 	; Inputs: - 
   968                              <1> 	; Outputs: if zombie found, it's name put in u.r0.	
   969                              <1> 	; ...............................................................
   970                              <1> 	;				
   971                              <1> 	
   972                              <1> ; / wait for a process to die
   973                              <1> 
   974                              <1> syswait_0:
   975 0000CFB1 0FB61D[6D010300]    <1> 	movzx	ebx, byte [u.uno] ; 01/09/2015
   976                              <1> 		; movb u.uno,r1 / put parents process number in r1
   977 0000CFB8 D0E3                <1> 	shl	bl, 1
   978                              <1> 	;shl	bx, 1
   979                              <1> 		; asl r1 / x2 to get index into p.pid table
   980 0000CFBA 668B83[FEFF0200]    <1> 	mov	ax, [ebx+p.pid-2]
   981                              <1> 		; mov p.pid-2(r1),r1 / get the name of this process
   982 0000CFC1 31F6                <1> 	xor	esi, esi
   983                              <1> 		; clr r2
   984 0000CFC3 31C9                <1> 	xor	ecx, ecx ; 30/10/2013
   985                              <1> 	;xor 	cl, cl
   986                              <1> 		; clr r3 / initialize reg 3
   987                              <1> syswait_1: ; 1:
   988                              <1> 	;add	si, 2
   989                              <1> 	; 23/07/2022
   990 0000CFC5 46                  <1> 	inc	esi
   991 0000CFC6 46                  <1> 	inc	esi
   992                              <1> 		; add $2,r2 / use r2 for index into p.ppid table
   993                              <1> 			  ; / search table of parent processes 
   994                              <1> 			  ; / for this process name
   995 0000CFC7 663B86[1E000300]    <1> 	cmp	ax, [esi+p.ppid-2]
   996                              <1> 		; cmp p.ppid-2(r2),r1 / r2 will contain the childs 
   997                              <1> 			            ; / process number
   998 0000CFCE 7531                <1> 	jne	short syswait_3
   999                              <1> 		;bne 3f / branch if no match of parent process name
  1000                              <1> 	;inc	cx
  1001 0000CFD0 FEC1                <1> 	inc	cl
  1002                              <1> 		;inc r3 / yes, a match, r3 indicates number of children
  1003                              <1> 	;shr	si, 1
  1004                              <1> 	; 23/07/2022
  1005 0000CFD2 D1EE                <1> 	shr	esi, 1 
  1006                              <1> 		; asr r2 / r2/2 to get index to p.stat table
  1007                              <1> 	; The possible states ('p.stat' values) of a process are:
  1008                              <1> 	;	0 = free or unused
  1009                              <1> 	;	1 = active
  1010                              <1> 	;	2 = waiting for a child process to die
  1011                              <1> 	;	3 = terminated, but not yet waited for (zombie).	
  1012 0000CFD4 80BE[5F000300]03    <1> 	cmp	byte [esi+p.stat-1], 3 ; SZOMB, 05/02/2014
  1013                              <1> 		; cmpb p.stat-1(r2),$3 / is the child process a zombie?
  1014 0000CFDB 7522                <1> 	jne	short syswait_2
  1015                              <1> 		; bne 2f / no, skip it
  1016 0000CFDD 88BE[5F000300]      <1> 	mov	[esi+p.stat-1], bh ; 0
  1017                              <1> 		; clrb p.stat-1(r2) / yes, free it
  1018                              <1> 	;shl	si, 1
  1019                              <1> 	; 23/07/2022
  1020 0000CFE3 D1E6                <1> 	shl	esi, 1
  1021                              <1> 		; asl r2 / r2x2 to get index into p.pid table
  1022 0000CFE5 0FB786[FEFF0200]    <1> 	movzx	eax, word [esi+p.pid-2]
  1023 0000CFEC A3[1C010300]        <1> 	mov	[u.r0], eax
  1024                              <1> 		; mov p.pid-2(r2),*u.r0 
  1025                              <1> 			      ; / put childs process name in (u.r0)
  1026                              <1> 	;
  1027                              <1> 	; Retro UNIX 386 v1 modification ! (17/09/2015)
  1028                              <1> 	;
  1029                              <1> 	; Parent process ID -p.ppid- field (of the child process)
  1030                              <1> 	; must be cleared in order to prevent infinitive 'syswait'
  1031                              <1> 	; system call loop from the application/program if it calls
  1032                              <1> 	; 'syswait' again (mistakenly) while there is not a zombie
  1033                              <1> 	; or running child process to wait. ('forktest.s', 17/09/2015)
  1034                              <1> 	;
  1035                              <1> 	; Note: syswait will return with error if there is not a
  1036                              <1> 	;       zombie or running process to wait.	
  1037                              <1> 	
  1038                              <1> 	;sub	ax, ax
  1039                              <1> 	; 30/07/2022
  1040 0000CFF1 29C0                <1> 	sub	eax, eax ; 0
  1041 0000CFF3 668986[1E000300]    <1> 	mov 	[esi+p.ppid-2], ax ; 0 ; 17/09/2015
  1042 0000CFFA E922FDFFFF          <1> 	jmp	sysret0 ; ax = 0
  1043                              <1> 	;
  1044                              <1> 	;jmp	sysret
  1045                              <1> 		; br sysret1 / return cause child is dead
  1046                              <1> syswait_2: ; 2:
  1047                              <1> 	;shl	si, 1
  1048                              <1> 	; 23/07/2022
  1049 0000CFFF D1E6                <1> 	shl	esi, 1
  1050                              <1> 		; asl r2 / r2x2 to get index into p.ppid table
  1051                              <1> syswait_3: ; 3:
  1052 0000D001 6683FE20            <1> 	cmp	si, nproc+nproc
  1053                              <1> 		; cmp r2,$nproc+nproc / have all processes been checked?
  1054 0000D005 72BE                <1> 	jb	short syswait_1
  1055                              <1> 		; blt 1b / no, continue search
  1056                              <1> 	;and	cx, cx
  1057 0000D007 20C9                <1> 	and	cl, cl
  1058                              <1> 		; tst r3 / one gets here if there are no children 
  1059                              <1> 		       ; / or children that are still active
  1060                              <1> 	; 30/10/2013
  1061 0000D009 750B                <1> 	jnz	short syswait_4
  1062                              <1> 	;jz	error
  1063                              <1> 		; beq error1 / there are no children, error
  1064 0000D00B 890D[1C010300]      <1> 	mov	[u.r0], ecx ; 0
  1065 0000D011 E9E9FCFFFF          <1> 	jmp	error
  1066                              <1> syswait_4:
  1067 0000D016 8A1D[6D010300]      <1> 	mov	bl, [u.uno]
  1068                              <1> 		; movb u.uno,r1 / there are children so put 
  1069                              <1> 			      ; / parent process number in r1
  1070 0000D01C FE83[5F000300]      <1> 	inc	byte [ebx+p.stat-1] ; 2, SWAIT, 05/02/2014
  1071                              <1> 		; incb p.stat-1(r1) / it is waiting for 
  1072                              <1> 				  ; / other children to die
  1073                              <1> 	; 04/11/2013
  1074 0000D022 E8603B0000          <1> 	call	swap
  1075                              <1> 		; jsr r0,swap / swap it out, because it's waiting
  1076 0000D027 EB88                <1> 	jmp	syswait_0
  1077                              <1> 		; br syswait / wait on next process
  1078                              <1> 
  1079                              <1> sysfork: ; < create a new process >
  1080                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
  1081                              <1> 	; 02/01/2017 (TRDOS 386 modification)
  1082                              <1> 	; 04/09/2015 - 18/05/2015
  1083                              <1> 	; 28/08/2015 - 01/09/2015 - 02/09/2015
  1084                              <1> 	; 09/05/2015 - 10/05/2015 - 14/05/2015
  1085                              <1> 	; 06/05/2015 (Retro UNIX 386 v1 - Beginning)
  1086                              <1> 	; 24/05/2013 - 14/02/2014 (Retro UNIX 8086 v1)
  1087                              <1> 	;
  1088                              <1> 	; 'sysfork' creates a new process. This process is referred
  1089                              <1> 	; to as the child process. This new process core image is
  1090                              <1> 	; a copy of that of the caller of 'sysfork'. The only
  1091                              <1> 	; distinction is the return location and the fact that (u.r0)
  1092                              <1> 	; in the old process (parent) contains the process id (p.pid)
  1093                              <1> 	; of the new process (child). This id is used by 'syswait'.
  1094                              <1> 	; 'sysfork' works in the following manner: 	
  1095                              <1> 	;    1) The process status table (p.stat) is searched to find
  1096                              <1> 	;	a process number that is unused. If none are found
  1097                              <1> 	;	an error occurs.
  1098                              <1> 	;    2) when one is found, it becomes the child process number
  1099                              <1> 	;	and it's status (p.stat) is set to active.
  1100                              <1> 	;    3) If the parent had a control tty, the interrupt 
  1101                              <1> 	;	character in that tty buffer is cleared.
  1102                              <1> 	;    4) The child process is put on the lowest priority run 
  1103                              <1> 	;	queue via 'putlu'.
  1104                              <1> 	;    5) A new process name is gotten from 'mpid' (actually 
  1105                              <1> 	;	it is a unique number) and is put in the child's unique
  1106                              <1> 	;	identifier; process id (p.pid).
  1107                              <1> 	;    6) The process name of the parent is then obtained and
  1108                              <1> 	;	placed in the unique identifier of the parent process
  1109                              <1> 	;	name is then put in 'u.r0'.	
  1110                              <1> 	;    7) The child process is then written out on disk by
  1111                              <1> 	;	'wswap',i.e., the parent process is copied onto disk
  1112                              <1> 	;	and the child is born. (The child process is written 
  1113                              <1> 	;	out on disk/drum with 'u.uno' being the child process
  1114                              <1> 	;	number.)
  1115                              <1> 	;    8) The parent process number is then restored to 'u.uno'.
  1116                              <1> 	;    9) The child process name is put in 'u.r0'.
  1117                              <1> 	;   10) The pc on the stack sp + 18 is incremented by 2 to
  1118                              <1> 	;	create the return address for the parent process.
  1119                              <1> 	;   11) The 'u.fp' list as then searched to see what files
  1120                              <1> 	;	the parent has opened. For each file the parent has
  1121                              <1> 	;	opened, the corresponding 'fsp' entry must be updated
  1122                              <1> 	;	to indicate that the child process also has opened
  1123                              <1> 	;	the file. A branch to 'sysret' is then made.	 			 				
  1124                              <1> 	;
  1125                              <1> 	; Calling sequence:
  1126                              <1> 	;	from shell ?
  1127                              <1> 	; Arguments:
  1128                              <1> 	;	-
  1129                              <1> 	; Inputs: -
  1130                              <1> 	; Outputs: *u.r0 - child process name
  1131                              <1> 	; ...............................................................
  1132                              <1> 	;	
  1133                              <1> 	; Retro UNIX 8086 v1 modification: 
  1134                              <1> 	;	AX = r0 = PID (>0) (at the return of 'sysfork')
  1135                              <1> 	;	= process id of child a parent process returns
  1136                              <1> 	;	= process id of parent when a child process returns
  1137                              <1> 	;
  1138                              <1> 	;       In original UNIX v1, sysfork is called and returns as
  1139                              <1> 	;	in following manner: (with an example: c library, fork)
  1140                              <1> 	;	
  1141                              <1> 	;	1:
  1142                              <1> 	;		sys	fork
  1143                              <1> 	;			br 1f  / child process returns here
  1144                              <1> 	;		bes	2f     / parent process returns here
  1145                              <1> 	;		/ pid of new process in r0
  1146                              <1> 	;		rts	pc
  1147                              <1> 	;	2: / parent process condionally branches here
  1148                              <1> 	;		mov	$-1,r0 / pid = -1 means error return
  1149                              <1> 	;		rts	pc
  1150                              <1> 	;
  1151                              <1> 	;	1: / child process brances here
  1152                              <1> 	;		clr	r0   / pid = 0 in child process
  1153                              <1> 	;		rts	pc
  1154                              <1> 	;
  1155                              <1> 	;	In UNIX v7x86 (386) by Robert Nordier (1999)
  1156                              <1> 	;		// pid = fork();
  1157                              <1> 	;		//
  1158                              <1> 	;		// pid == 0 in child process; 
  1159                              <1> 	;		// pid == -1 means error return
  1160                              <1> 	;		// in child, 
  1161                              <1> 	;		//	parents id is in par_uid if needed
  1162                              <1> 	;		
  1163                              <1> 	;		_fork:
  1164                              <1> 	;			mov	$.fork,eax
  1165                              <1> 	;			int	$0x30
  1166                              <1> 	;			jmp	1f
  1167                              <1> 	;			jnc	2f
  1168                              <1> 	;			jmp	cerror
  1169                              <1> 	;		1:
  1170                              <1> 	;			mov	eax,_par_uid
  1171                              <1> 	;			xor	eax,eax
  1172                              <1> 	;		2:
  1173                              <1> 	;			ret
  1174                              <1> 	;
  1175                              <1> 	;	In Retro UNIX 8086 v1,
  1176                              <1> 	;	'sysfork' returns in following manner:
  1177                              <1> 	;	
  1178                              <1> 	;		mov	ax, sys_fork
  1179                              <1> 	;		mov	bx, offset @f ; routine for child
  1180                              <1> 	;		int	20h
  1181                              <1> 	;		jc	error
  1182                              <1> 	;		
  1183                              <1> 	;	; Routine for parent process here (just after 'jc')
  1184                              <1> 	;		mov	word ptr [pid_of_child], ax
  1185                              <1> 	;		jmp	next_routine_for_parent	
  1186                              <1> 	;
  1187                              <1> 	;	@@: ; routine for child process here				
  1188                              <1> 	;		....	
  1189                              <1> 	;	NOTE: 'sysfork' returns to specified offset
  1190                              <1> 	;	       for child process by using BX input.
  1191                              <1> 	;	      (at first, parent process will return then 
  1192                              <1> 	;	      child process will return -after swapped in-
  1193                              <1> 	;	      'syswait' is needed in parent process
  1194                              <1> 	;	      if return from child process will be waited for.)
  1195                              <1> 	;	  				
  1196                              <1> 	
  1197                              <1> ; / create a new process
  1198                              <1> 	; EBX = return address for child process 
  1199                              <1> 	     ; (Retro UNIX 8086 v1 modification !)
  1200 0000D029 31F6                <1> 	xor 	esi, esi
  1201                              <1> 		; clr r1
  1202                              <1> sysfork_1: ; 1: / search p.stat table for unused process number
  1203 0000D02B 46                  <1> 	inc	esi
  1204                              <1> 		; inc r1
  1205 0000D02C 80BE[5F000300]00    <1> 	cmp	byte [esi+p.stat-1], 0 ; SFREE, 05/02/2014
  1206                              <1> 		; tstb p.stat-1(r1) / is process active, unused, dead
  1207 0000D033 760B                <1> 	jna	short sysfork_2	
  1208                              <1> 		; beq 1f / it's unused so branch
  1209 0000D035 6683FE10            <1> 	cmp	si, nproc
  1210                              <1> 		; cmp r1,$nproc / all processes checked
  1211 0000D039 72F0                <1> 	jb	short sysfork_1
  1212                              <1> 		; blt 1b / no, branch back
  1213                              <1> 	;
  1214                              <1> 	; Retro UNIX 8086 v1. modification:
  1215                              <1> 	;	Parent process returns from 'sysfork' to address 
  1216                              <1> 	;	which is just after 'sysfork' system call in parent
  1217                              <1> 	;	process. Child process returns to address which is put
  1218                              <1> 	;	in BX register by parent process for 'sysfork'. 
  1219                              <1> 	;
  1220                              <1> 		; add $2,18.(sp) / add 2 to pc when trap occured, points
  1221                              <1> 		             ; / to old process return
  1222                              <1> 		; br error1 / no room for a new process
  1223                              <1> sysfork_err:
  1224 0000D03B E9BFFCFFFF          <1> 	jmp	error
  1225                              <1> sysfork_2: ; 1:
  1226 0000D040 E89086FFFF          <1> 	call	allocate_page
  1227                              <1> 	;jc	error
  1228                              <1> 	; 23/07/2022
  1229 0000D045 72F4                <1> 	jc	short sysfork_err
  1230 0000D047 50                  <1> 	push	eax   ; UPAGE (user structure page) address
  1231                              <1> 	; Retro UNIX 386 v1 modification!
  1232 0000D048 E87888FFFF          <1> 	call	duplicate_page_dir
  1233                              <1> 		; EAX = New page directory 
  1234 0000D04D 730B                <1> 	jnc	short sysfork_3
  1235 0000D04F 58                  <1> 	pop	eax   ; UPAGE (user structure page) address
  1236 0000D050 E83F88FFFF          <1> 	call 	deallocate_page
  1237 0000D055 E9A5FCFFFF          <1> 	jmp	error
  1238                              <1> sysfork_3:
  1239                              <1> 	; Retro UNIX 386 v1 modification !
  1240 0000D05A 56                  <1> 	push	esi
  1241 0000D05B E8B53B0000          <1> 	call	wswap ; save current user (u) structure, user registers
  1242                              <1> 		      ; and interrupt return components (for IRET)
  1243 0000D060 8705[74010300]      <1> 	xchg	eax, [u.pgdir] ; page directory of the child process
  1244 0000D066 A3[78010300]        <1> 	mov	[u.ppgdir], eax ; page directory of the parent process
  1245 0000D06B 5E                  <1> 	pop	esi
  1246 0000D06C 58                  <1> 	pop	eax   ; UPAGE (user structure page) address
  1247                              <1> 		; [u.usp] = esp
  1248 0000D06D 89F7                <1> 	mov	edi, esi
  1249                              <1> 	;shl	di, 2
  1250                              <1> 	; 23/07/2022
  1251 0000D06F C1E702              <1> 	shl	edi, 2
  1252 0000D072 8987[6C000300]      <1> 	mov	[edi+p.upage-4], eax ; memory page for 'user' struct
  1253 0000D078 A3[70010300]        <1> 	mov	[u.upage], eax ; memory page for 'user' struct (child)
  1254                              <1> 	; 28/08/2015
  1255 0000D07D 0FB605[6D010300]    <1> 	movzx	eax, byte [u.uno] ; parent process number
  1256                              <1> 		; movb u.uno,-(sp) / save parent process number
  1257 0000D084 89C7                <1> 	mov	edi, eax
  1258 0000D086 50                  <1>         push	eax ; ** 
  1259 0000D087 8A87[3F000300]      <1> 	mov     al, [edi+p.ttyc-1] ; console tty (parent)
  1260                              <1> 	; 18/09/2015
  1261                              <1> 	;;mov	[esi+p.ttyc-1], al ; set child's console tty
  1262                              <1> 	;;mov	[esi+p.waitc-1], ah ; 0 ; reset child's wait channel
  1263                              <1> 	;mov    [esi+p.ttyc-1], ax ; al - set child's console tty
  1264                              <1> 				   ; ah - reset child's wait channel	
  1265                              <1> 	; 23/07/2022
  1266 0000D08D 8886[3F000300]      <1> 	mov	[esi+p.ttyc-1], al ; set child's console tty
  1267 0000D093 89F0                <1> 	mov	eax, esi
  1268 0000D095 A2[6D010300]        <1> 	mov	[u.uno], al ; child process number
  1269                              <1> 		;movb r1,u.uno / set child process number to r1
  1270 0000D09A FE86[5F000300]      <1>         inc     byte [esi+p.stat-1] ; 1, SRUN, 05/02/2014
  1271                              <1> 		; incb p.stat-1(r1) / set p.stat entry for child 
  1272                              <1> 				; / process to active status
  1273                              <1> 		; mov u.ttyp,r2 / put pointer to parent process' 
  1274                              <1> 			      ; / control tty buffer in r2
  1275                              <1>                 ; beq 2f / branch, if no such tty assigned
  1276                              <1> 		; clrb 6(r2) / clear interrupt character in tty buffer
  1277                              <1> 	; 2:
  1278 0000D0A0 53                  <1> 	push	ebx  ; * return address for the child process
  1279                              <1> 		     ; * Retro UNIX 8086 v1 feature only !	
  1280                              <1> 	; (Retro UNIX 8086 v1 modification!)
  1281                              <1> 		; mov $runq+4,r2
  1282 0000D0A1 BB[0C010300]        <1> 	mov	ebx, runq+2 ; normal run queue ; 02/01/2017  
  1283 0000D0A6 E8DA3B0000          <1> 	call	putlu
  1284                              <1>  		; jsr r0,putlu / put child process on lowest priority 
  1285                              <1> 			   ; / run queue
  1286                              <1> 	; 23/07/2022
  1287 0000D0AB D1E6                <1> 	shl	esi, 1
  1288                              <1> 	;shl	si, 1
  1289                              <1> 		; asl r1 / multiply r1 by 2 to get index 
  1290                              <1> 		       ; / into p.pid table
  1291 0000D0AD 66FF05[04010300]    <1> 	inc	word [mpid]
  1292                              <1> 		; inc mpid / increment m.pid; get a new process name
  1293 0000D0B4 66A1[04010300]      <1> 	mov	ax, [mpid]
  1294 0000D0BA 668986[FEFF0200]    <1> 	mov	[esi+p.pid-2], ax
  1295                              <1> 		;mov mpid,p.pid-2(r1) / put new process name 
  1296                              <1> 				    ; / in child process' name slot
  1297 0000D0C1 5A                  <1> 	pop	edx  ; * return address for the child process
  1298                              <1> 		     ; * Retro UNIX 8086 v1 feature only !	
  1299 0000D0C2 5B                  <1>   	pop	ebx  ; **
  1300                              <1> 	;mov	ebx, [esp] ; ** parent process number
  1301                              <1> 		; movb (sp),r2 / put parent process number in r2
  1302                              <1> 	; 23/07/2022
  1303 0000D0C3 D1E3                <1> 	shl	ebx, 1
  1304                              <1> 	;shl 	bx, 1
  1305                              <1> 		;asl r2 / multiply by 2 to get index into below tables
  1306                              <1> 	;movzx eax, word [ebx+p.pid-2]
  1307 0000D0C5 668B83[FEFF0200]    <1> 	mov	ax, [ebx+p.pid-2]
  1308                              <1> 		; mov p.pid-2(r2),r2 / get process name of parent
  1309                              <1> 				   ; / process
  1310 0000D0CC 668986[1E000300]    <1> 	mov	[esi+p.ppid-2], ax
  1311                              <1> 		; mov r2,p.ppid-2(r1) / put parent process name 
  1312                              <1> 			  ; / in parent process slot for child
  1313 0000D0D3 A3[1C010300]        <1> 	mov	[u.r0], eax	
  1314                              <1> 		; mov r2,*u.r0 / put parent process name on stack 
  1315                              <1> 			     ; / at location where r0 was saved
  1316 0000D0D8 8B2D[14010300]      <1> 	mov 	ebp, [u.sp] ; points to return address (EIP for IRET)
  1317 0000D0DE 895500              <1> 	mov	[ebp], edx ; *, CS:EIP -> EIP
  1318                              <1> 			   ; * return address for the child process
  1319                              <1> 		; mov $sysret1,-(sp) /
  1320                              <1> 		; mov sp,u.usp / contents of sp at the time when 
  1321                              <1> 			      ; / user is swapped out
  1322                              <1> 		; mov $sstack,sp / point sp to swapping stack space
  1323                              <1> 	; 04/09/2015 - 01/09/2015
  1324                              <1> 	; [u.usp] = esp
  1325 0000D0E1 68[1FCD0000]        <1> 	push	sysret ; ***
  1326 0000D0E6 8925[18010300]      <1> 	mov	[u.usp], esp ; points to 'sysret' address (***)
  1327                              <1> 			     ; (for child process)	
  1328 0000D0EC 31C0                <1> 	xor 	eax, eax
  1329 0000D0EE 66A3[50010300]      <1> 	mov 	[u.ttyp], ax ; 0
  1330                              <1> 	;
  1331 0000D0F4 E81C3B0000          <1> 	call	wswap ; Retro UNIX 8086 v1 modification !
  1332                              <1> 		; jsr r0,wswap / put child process out on drum
  1333                              <1> 		; jsr r0,unpack / unpack user stack
  1334                              <1> 		; mov u.usp,sp / restore user stack pointer
  1335                              <1> 		; tst (sp)+ / bump stack pointer
  1336                              <1> 	; Retro UNIX 386 v1 modification !
  1337 0000D0F9 58                  <1> 	pop	eax ; ***
  1338                              <1> 	;shl	bx, 1
  1339                              <1> 	; 23/07/2022
  1340 0000D0FA D1E3                <1> 	shl	ebx, 1
  1341 0000D0FC 8B83[6C000300]      <1> 	mov     eax, [ebx+p.upage-4] ; UPAGE address ; 14/05/2015
  1342 0000D102 E8463B0000          <1> 	call	rswap ; restore parent process 'u' structure, 
  1343                              <1> 		      ; registers and return address (for IRET)
  1344                              <1> 		;movb (sp)+,u.uno / put parent process number in u.uno
  1345 0000D107 0FB705[04010300]    <1>         movzx   eax, word [mpid]
  1346 0000D10E A3[1C010300]        <1> 	mov	[u.r0], eax
  1347                              <1> 		; mov mpid,*u.r0 / put child process name on stack 
  1348                              <1> 			       ; / where r0 was saved
  1349                              <1> 		; add $2,18.(sp) / add 2 to pc on stack; gives parent
  1350                              <1> 			          ; / process return
  1351                              <1> 	;xor	ebx, ebx
  1352 0000D113 31F6                <1> 	xor     esi, esi
  1353                              <1> 		;clr r1
  1354                              <1> sysfork_4: ; 1: / search u.fp list to find the files 
  1355                              <1> 	      ; / opened by the parent process
  1356                              <1> 	; 01/09/2015
  1357                              <1> 	;xor	bh, bh
  1358                              <1> 	;mov 	bl, [esi+u.fp]
  1359 0000D115 8A86[26010300]      <1> 	mov 	al, [esi+u.fp]
  1360                              <1> 		; movb u.fp(r1),r2 / get an open file for this process
  1361                              <1>         ;or	bl, bl
  1362 0000D11B 08C0                <1> 	or	al, al
  1363 0000D11D 7406                <1> 	jz	short sysfork_5	
  1364                              <1> 		; beq 2f / file has not been opened by parent, 
  1365                              <1> 		       ; / so branch
  1366                              <1> 	;mov	ah, 10 ; Retro UNIX 386 v1 fsp structure size = 10 bytes
  1367                              <1> 	;mul	ah
  1368                              <1> 	; 23/07/2022
  1369                              <1> 	; Retro UNIX 386 v2 & TRDOS 386 v2.0.5 fsp struc size = 16 bytes
  1370                              <1> 	;mov	ebx, eax 	
  1371                              <1> 	;shl	ebx, 4 ; * 16
  1372                              <1> 	;inc	byte [ebx+fsp-10]
  1373                              <1> 
  1374                              <1> 	; 23/07/2022 (BugFix)
  1375 0000D11F FE80[24850100]      <1> 	inc	byte [OF_OPENCOUNT+eax] 
  1376                              <1> 
  1377                              <1> 	;;movzx	ebx, ax
  1378                              <1> 	;mov	bx, ax
  1379                              <1> 	;shl	bx, 3
  1380                              <1> 		; asl r2 / multiply by 8
  1381                              <1>        		; asl r2 / to get index into fsp table
  1382                              <1>        		; asl r2
  1383                              <1>   	;inc	byte [ebx+fsp-2]
  1384                              <1> 		; incb fsp-2(r2) / increment number of processes
  1385                              <1> 			     ; / using file, because child will now be
  1386                              <1> 			     ; / using this file
  1387                              <1> sysfork_5: ; 2:
  1388 0000D125 46                  <1>         inc     esi
  1389                              <1> 		; inc r1 / get next open file
  1390                              <1> 	; 23/07/2022
  1391 0000D126 6683FE20            <1> 	cmp	si, OPENFILES ; = 10
  1392                              <1> 	;cmp	si, 10
  1393                              <1> 		; cmp r1,$10. / 10. files is the maximum number which
  1394                              <1> 			    ; / can be opened
  1395 0000D12A 72E9                <1> 	jb	short sysfork_4	
  1396                              <1> 		; blt 1b / check next entry
  1397 0000D12C E9EEFBFFFF          <1> 	jmp	sysret
  1398                              <1> 		; br sysret1
  1399                              <1> 
  1400                              <1> syscreat: ; < create file >
  1401                              <1> 	; 08/08/2022
  1402                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
  1403                              <1> 	; 13/11/2017
  1404                              <1> 	; 27/10/2016
  1405                              <1> 	; 25/10/2016 - 26/10/2016
  1406                              <1> 	; 15/10/2016 - 16/10/2016 - 17/10/2016
  1407                              <1> 	; 10/10/2016 (TRDOS 386 = TRDOS v2.0) 
  1408                              <1> 	;	     -derived from INT_21H.ASM-
  1409                              <1> 	;            ("loc_INT21h_create_file")
  1410                              <1>         ; 	10/07/2011 (12/03/2011)
  1411                              <1>         ;	INT 21h Function AH = 3Ch
  1412                              <1>         ;	Create File
  1413                              <1>         ;	INPUT
  1414                              <1>         ;	   CX = Attributes
  1415                              <1>         ;          DS:DX= Address of zero terminaned path name
  1416                              <1>         ;
  1417                              <1> 	; 27/12/2015 (Retro UNIX 386 v1.1)
  1418                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  1419                              <1> 	; 27/05/2013 (Retro UNIX 8086 v1)
  1420                              <1> 	;
  1421                              <1> 	; 'syscreat' called with two arguments; name and mode.
  1422                              <1> 	; u.namep points to name of the file and mode is put
  1423                              <1> 	; on the stack. 'namei' is called to get i-number of the file.		
  1424                              <1> 	; If the file aready exists, it's mode and owner remain 
  1425                              <1> 	; unchanged, but it is truncated to zero length. If the file
  1426                              <1> 	; did not exist, an i-node is created with the new mode via
  1427                              <1> 	; 'maknod' whether or not the file already existed, it is
  1428                              <1> 	; open for writing. The fsp table is then searched for a free
  1429                              <1> 	; entry. When a free entry is found, proper data is placed
  1430                              <1> 	; in it and the number of this entry is put in the u.fp list.
  1431                              <1> 	; The index to the u.fp (also know as the file descriptor)
  1432                              <1> 	; is put in the user's r0. 			
  1433                              <1> 	;
  1434                              <1> 	; Calling sequence:
  1435                              <1> 	;	syscreate; name; mode
  1436                              <1> 	; Arguments:
  1437                              <1> 	;	name - name of the file to be created
  1438                              <1> 	;	mode - mode of the file to be created
  1439                              <1> 	; Inputs: (arguments)
  1440                              <1> 	; Outputs: *u.r0 - index to u.fp list 
  1441                              <1> 	;		   (the file descriptor of new file)
  1442                              <1> 	; ...............................................................
  1443                              <1> 	;				
  1444                              <1> 	; Retro UNIX 8086 v1 modification: 
  1445                              <1> 	;       'syscreate' system call has two arguments; so,
  1446                              <1> 	;	* 1st argument, name is pointed to by BX register
  1447                              <1> 	;	* 2nd argument, mode is in CX register
  1448                              <1> 	;
  1449                              <1> 	;	AX register (will be restored via 'u.r0') will return
  1450                              <1> 	;	to the user with the file descriptor/number 
  1451                              <1> 	;	(index to u.fp list).
  1452                              <1> 	;
  1453                              <1> 	;call	arg2
  1454                              <1> 	; * name - 'u.namep' points to address of file/path name
  1455                              <1> 	;          in the user's program segment ('u.segmnt')
  1456                              <1> 	;          with offset in BX register (as sysopen argument 1).
  1457                              <1> 	; * mode - sysopen argument 2 is in CX register 
  1458                              <1> 	;          which is on top of stack.
  1459                              <1> 	;
  1460                              <1> 	; TRDOS 386 (10/10/2016)
  1461                              <1> 	;	
  1462                              <1>         ; INPUT ->
  1463                              <1>         ;	   CL = File Attributes
  1464                              <1> 	;     	      bit 0 (1) - Read only file (R)
  1465                              <1> 	;             bit 1 (1) - Hidden file (H)
  1466                              <1>         ;             bit 2 (1) - System file (R)
  1467                              <1> 	;             bit 3 (1) - Volume label/name (V)
  1468                              <1>         ;             bit 4 (1) - Subdirectory (D)
  1469                              <1> 	;	      bit 5 (1) - File has been archived (A)	 	
  1470                              <1>         ;          EBX = Pointer to filename (ASCIIZ) -path-
  1471                              <1> 	;	
  1472                              <1> 	; OUTPUT ->
  1473                              <1> 	;          eax = File/Device Handle/Number (index) (AL)
  1474                              <1> 	;          cf = 1 -> Error code in AL
  1475                              <1> 	;
  1476                              <1> 	; Modified Registers: EAX (at the return of system call)
  1477                              <1> 	;  
  1478                              <1> 	; Note: If the file is existing and it has not any one
  1479                              <1> 	;	of S,H,R,V,D attributes, it will be truncated 
  1480                              <1> 	;	to zero length; otherwise, access error will be 
  1481                              <1> 	;	returned. 
  1482                              <1> 
  1483                              <1> sysmkdir_0:
  1484 0000D131 F6C108              <1> 	test	cl, 08h ; Volume name 
  1485 0000D134 740A                <1> 	jz	short syscreat_0
  1486                              <1> 
  1487                              <1> 	; Volume name or long name creation
  1488                              <1> 	; is not permitted (in TRDOS 386)!
  1489 0000D136 B80B000000          <1> 	mov	eax, ERR_FILE_ACCESS  ; 11 ; 'permission denied !'
  1490 0000D13B E9CE000000          <1>         jmp	sysopen_dev_err ; 08/08/2022
  1491                              <1> syscreat_0:
  1492                              <1>         ;mov	[u.namep], ebx
  1493 0000D140 51                  <1> 	push	ecx
  1494 0000D141 89DE                <1> 	mov	esi, ebx
  1495                              <1> 	; file name is forced, change directory as temporary
  1496                              <1> 	;mov	ax, 1
  1497                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
  1498                              <1> 	;call	set_working_path 
  1499 0000D143 E821500000          <1> 	call	set_working_path_x ; 17/10/2016	
  1500                              <1> 	;jc	short syscreat_err
  1501                              <1> 	; 23/07/2022
  1502 0000D148 7305                <1> 	jnc	short syscreat_3
  1503 0000D14A E9D8000000          <1> 	jmp	syscreat_err
  1504                              <1> 
  1505                              <1> syscreat_3:
  1506                              <1> 	; 16/10/2016
  1507 0000D14F 803D[3B840100]00    <1> 	cmp	byte [SWP_inv_fname], 0
  1508 0000D156 776C                <1> 	ja	short  syscreat_inv_fname ; invalid file name !
  1509                              <1> 
  1510                              <1> 	; Here, we have a valid path and also a valid file name
  1511                              <1> 	; (Working dir has been changed if the path
  1512                              <1> 	;  -file name string- had contained a dir name.)
  1513                              <1> 
  1514 0000D158 6631C0              <1> 	xor	ax, ax 
  1515                              <1> 	;mov	esi, FindFile_Name
  1516 0000D15B E8E0B8FFFF          <1> 	call	find_first_file
  1517 0000D160 59                  <1> 	pop	ecx
  1518                              <1> 		; ESI = Directory Entry (FindFile_DirEntry) Location
  1519                              <1> 		; EDI = Directory Buffer Directory Entry Location
  1520                              <1> 		; EAX = File Size
  1521                              <1> 		;  BL = Attributes of The File/Directory
  1522                              <1> 		;  BH = Long Name Yes/No Status (>0 is YES)
  1523                              <1> 		;  DX > 0 : Ambiguous filename chars are used
  1524 0000D161 7269                <1> 	jc	short syscreat_1 ; file not found (the good!) 
  1525                              <1> 				 ; or another error (the bad!) 
  1526                              <1> 
  1527                              <1> 	; (& the uggly!) truncate file to zero length before open
  1528                              <1> 
  1529                              <1> 	;'*' and '?' already checked at 'set_working_path' stage
  1530                              <1> 	;and	dx, dx
  1531                              <1> 	;jnz	short sysmkdir_err ; permission denied 
  1532                              <1> 				   ; invalid filename chars
  1533                              <1> 
  1534                              <1> 	;test	cl, 10h ; subdirectory ?
  1535                              <1> 	;jnz	short sysmkdir_err	
  1536                              <1> 
  1537                              <1> 	; BL = File Attributes:	
  1538                              <1> 	;     	      bit 0 (1) - Read only file (R)
  1539                              <1> 	;             bit 1 (1) - Hidden file (H)
  1540                              <1>         ;             bit 2 (1) - System file (R)
  1541                              <1> 	;             bit 3 (1) - Volume label/name (V)
  1542                              <1>         ;             bit 4 (1) - Subdirectory (D)
  1543                              <1> 	;	      bit 5 (1) - File has been archived	 	
  1544                              <1> 
  1545                              <1> 	; * existing directory must not be truncated
  1546                              <1> 	;   (we don't know it is empty or not, at this stage) 
  1547                              <1> 	; * existing volume name (or a long name) can not be
  1548                              <1> 	;   re-created or truncated by 'syscreat' 	
  1549                              <1> 	; * A file with S, H, R attributes must not be truncated
  1550                              <1> 	;   (change attributes to normal, if you need truncate it)
  1551                              <1> 
  1552 0000D163 F6C31F              <1> 	test	bl, 00011111b  ; check attributes of existing file
  1553 0000D166 754E                <1> 	jnz	short sysmkdir_err
  1554                              <1> 
  1555                              <1> 	;; normal file, OK to continue...
  1556                              <1> 
  1557                              <1> 	; ESI = FindFile_DirEntry
  1558 0000D168 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI] ; 20
  1559 0000D16C C1E010              <1> 	shl	eax, 16 ; 13/11/2017
  1560 0000D16F 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO] ; 26 
  1561                              <1> 	; EAX = First cluster to be truncated/unlinked
  1562 0000D173 57                  <1> 	push	edi
  1563 0000D174 51                  <1> 	push	ecx
  1564 0000D175 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1565 0000D17A 29C9                <1> 	sub	ecx, ecx
  1566 0000D17C 8A2D[4A780100]      <1> 	mov	ch, [Current_Drv]
  1567 0000D182 01CE                <1> 	add	esi, ecx
  1568                              <1> 	; ESI = Logical dos drive description table address
  1569 0000D184 E8DEF7FFFF          <1> 	call	truncate_cluster_chain
  1570 0000D189 59                  <1> 	pop	ecx
  1571 0000D18A 5F                  <1> 	pop	edi
  1572 0000D18B 7230                <1> 	jc	short syscreate_truncate_err
  1573                              <1> 
  1574                              <1> 	; 26/10/2016
  1575                              <1> 	; EDI = Directory entry address in directory buffer
  1576                              <1> 	; Update directory entry
  1577 0000D18D E819DDFFFF          <1> 	call	convert_current_date_time
  1578                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
  1579                              <1>         ; 	    AX = Time in dos dir entry format	
  1580 0000D192 66894716            <1> 	mov	[edi+DirEntry_WrtTime], ax
  1581 0000D196 66895718            <1> 	mov	[edi+DirEntry_WrtDate], dx	
  1582 0000D19A 66895712            <1> 	mov	[edi+DirEntry_LastAccDate], dx
  1583 0000D19E 31C0                <1> 	xor	eax, eax ; file size = 0 
  1584 0000D1A0 89471C              <1> 	mov	[edi+DirEntry_FileSize], eax ; 0
  1585 0000D1A3 C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; data changed sign	
  1586 0000D1AA BE[3C810100]        <1> 	mov	esi, FindFile_DirEntry
  1587 0000D1AF B201                <1> 	mov	dl, 1 ; open file for writing
  1588 0000D1B1 E9AB000000          <1> 	jmp	sysopen_2 ; 08/08/2022
  1589                              <1> 
  1590                              <1> sysmkdir_err:
  1591                              <1> 	; 1 = write, 2 = read & write, >2 = invalid
  1592 0000D1B6 B80B000000          <1>         mov	eax, ERR_FILE_ACCESS  ; 11 ; 'permission denied !'
  1593 0000D1BB EB74                <1>         jmp	short sysopen_err
  1594                              <1> 
  1595                              <1> syscreate_truncate_err:
  1596 0000D1BD B812000000          <1> 	mov	eax, ERR_DRV_WRITE ; 18 ; 'disk write error !'
  1597 0000D1C2 EB6D                <1>         jmp	short sysopen_err
  1598                              <1> 
  1599                              <1> syscreat_inv_fname:  ; invalid file name chars 
  1600                              <1> 	; 16/10/2016
  1601 0000D1C4 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME  ; 26 ; invalid file name chars 
  1602 0000D1C9 59                  <1> 	pop	ecx
  1603 0000D1CA EB65                <1> 	jmp	short sysopen_err
  1604                              <1> 
  1605                              <1> syscreat_1:
  1606                              <1> 	; Error code in EAX
  1607 0000D1CC 3C02                <1>         cmp	al, 02h ; 'File not found' error
  1608 0000D1CE 7561                <1>         jne	short sysopen_err
  1609                              <1> 
  1610 0000D1D0 F6C110              <1> 	test	cl, 10h ; Directory
  1611                              <1> 	;jnz	sysmkdir_2
  1612                              <1> 	; 23/07/2022
  1613 0000D1D3 7405                <1> 	jz	short syscreat_2
  1614 0000D1D5 E992010000          <1> 	jmp	sysmkdir_2
  1615                              <1> 
  1616                              <1> syscreat_2:
  1617 0000D1DA BE[2C810100]        <1> 	mov	esi, FindFile_Name 
  1618                              <1>         ;xor	edx, edx
  1619 0000D1DF 31C0                <1>         xor	eax, eax ; File Size  = 0
  1620 0000D1E1 31DB                <1> 	xor	ebx, ebx
  1621 0000D1E3 4B                  <1> 	dec 	ebx ; FFFFFFFFh -> create empty file 
  1622                              <1> 	            ;              (only for FAT fs) 
  1623                              <1> 	; CL = File Attributes
  1624 0000D1E4 E897ECFFFF          <1> 	call	create_file
  1625 0000D1E9 7246                <1> 	jc	short sysopen_err
  1626                              <1> 		; EAX = New file's first cluster
  1627                              <1> 		; ESI = Logical Dos Drv Descr. Table Addr.
  1628                              <1> 		; EBX = offset CreateFile_Size
  1629                              <1> 		; ECX = Sectors per cluster (<256) 
  1630                              <1> 		; EDX = Directory entry index/number (<65536)
  1631                              <1> 	; 26/10/2016
  1632                              <1> 	;mov	esi, Directory_Buffer
  1633                              <1> 	;shl	dx, 5 ; *32
  1634                              <1> 	;add	esi, edx
  1635                              <1> 	;; esi = directory entry address in directory buffer
  1636                              <1> 
  1637                              <1> 	; Here, directory entry has been created but last
  1638                              <1> 	; modification date & time of the parent dir has not
  1639                              <1> 	; been updated, yet! 
  1640                              <1> 	; (Note: Directory and FAT buffers have been updated...)
  1641                              <1>  	
  1642 0000D1EB E8E8DDFFFF          <1> 	call	update_parent_dir_lmdt ; now, it is OK too!
  1643                              <1> 
  1644                              <1> 	; 25/10/2016
  1645 0000D1F0 66B80018            <1> 	mov	ax, 1800h
  1646 0000D1F4 BE[2C810100]        <1> 	mov	esi, FindFile_Name
  1647 0000D1F9 E842B8FFFF          <1> 	call	find_first_file
  1648 0000D1FE 7231                <1> 	jc	short sysopen_err
  1649                              <1> 
  1650                              <1> 	; Only possible error after here is 
  1651                              <1> 	; "too many open files !" error.
  1652                              <1> 	;
  1653                              <1> 	; If "syscreat" will return with that error,
  1654                              <1> 	; (the file has been created but it could not be opened)
  1655                              <1> 	; the user must retry to open this file again
  1656                              <1> 	; or must close another file before using 
  1657                              <1> 	; "sysopen" system call.
  1658                              <1> 
  1659 0000D200 B201                <1> 	mov	dl, 1 ; open file for writing
  1660                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
  1661                              <1> 	; EAX = File Size (= 0)
  1662 0000D202 EB5D                <1> 	jmp	short sysopen_2
  1663                              <1> 
  1664                              <1> sysopen: ;<open file>
  1665                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
  1666                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  1667                              <1> 	;	(temporary modifications)
  1668                              <1> 	; 26/10/2016
  1669                              <1> 	; 24/10/2016
  1670                              <1> 	; 17/10/2016
  1671                              <1> 	; 15/10/2016
  1672                              <1> 	; 06/10/2016, 07/10/2016, 08/10/2016
  1673                              <1> 	; 05/10/2016 (TRDOS 386 = TRDOS v2.0) 
  1674                              <1> 	;	     -derived from INT_21H.ASM-
  1675                              <1> 	;            ("loc_INT21h_open_file")
  1676                              <1>         ; 	26/02/2011 
  1677                              <1>         ;	INT 21h Function AH = 3Dh
  1678                              <1>         ;	Open File
  1679                              <1>         ;	INPUT
  1680                              <1>         ;	   AL= File Access Value
  1681                              <1> 	;     	     0- Open for reading
  1682                              <1> 	;            1- Open for writing
  1683                              <1>         ;            2- Open for reading and writing
  1684                              <1>         ;          DS:DX= Pointer to filename (ASCIIZ)
  1685                              <1>         ;
  1686                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  1687                              <1> 	; 22/05/2013 - 27/05/2013 (Retro UNIX 8086 v1)
  1688                              <1> 	;
  1689                              <1> 	; 'sysopen' opens a file in following manner:
  1690                              <1> 	;    1) The second argument in a sysopen says whether to
  1691                              <1> 	;	open the file ro read (0) or write (>0).
  1692                              <1> 	;    2) I-node of the particular file is obtained via 'namei'.
  1693                              <1> 	;    3) The file is opened by 'iopen'.
  1694                              <1> 	;    4) Next housekeeping is performed on the fsp table
  1695                              <1> 	;	and the user's open file list - u.fp.
  1696                              <1> 	;	a) u.fp and fsp are scanned for the next available slot.
  1697                              <1> 	;	b) An entry for the file is created in the fsp table.
  1698                              <1> 	;	c) The number of this entry is put on u.fp list.
  1699                              <1> 	;	d) The file descriptor index to u.fp list is pointed
  1700                              <1> 	;	   to by u.r0.
  1701                              <1> 	;
  1702                              <1> 	; Calling sequence:
  1703                              <1> 	;	sysopen; name; mode
  1704                              <1> 	; Arguments:
  1705                              <1> 	;	name - file name or path name
  1706                              <1> 	;	mode - 0 to open for reading
  1707                              <1> 	;	       1 to open for writing
  1708                              <1> 	; Inputs: (arguments)
  1709                              <1> 	; Outputs: *u.r0 - index to u.fp list (the file descriptor)
  1710                              <1> 	;		  is put into r0's location on the stack.	
  1711                              <1> 	; ...............................................................
  1712                              <1> 	;				
  1713                              <1> 	; Retro UNIX 8086 v1 modification: 
  1714                              <1> 	;       'sysopen' system call has two arguments; so,
  1715                              <1> 	;	* 1st argument, name is pointed to by BX register
  1716                              <1> 	;	* 2nd argument, mode is in CX register
  1717                              <1> 	;
  1718                              <1> 	;	AX register (will be restored via 'u.r0') will return
  1719                              <1> 	;	to the user with the file descriptor/number 
  1720                              <1> 	;	(index to u.fp list).
  1721                              <1> 	;
  1722                              <1> 	;call	arg2
  1723                              <1> 	; * name - 'u.namep' points to address of file/path name
  1724                              <1> 	;          in the user's program segment ('u.segmnt')
  1725                              <1> 	;          with offset in BX register (as sysopen argument 1).
  1726                              <1> 	; * mode - sysopen argument 2 is in CX register 
  1727                              <1> 	;          which is on top of stack.
  1728                              <1> 	;
  1729                              <1> 	; jsr r0,arg2 / get sys args into u.namep and on stack
  1730                              <1> 	;
  1731                              <1>        	; system call registers: ebx, ecx (through 'sysenter')
  1732                              <1> 	;
  1733                              <1> 	; TRDOS 386 (05/10/2016)
  1734                              <1> 	;	
  1735                              <1>         ; INPUT ->
  1736                              <1>         ;	   CL = File Access Value (Open Mode)
  1737                              <1> 	;     	      0 - Open file for reading
  1738                              <1> 	;             1 - Open file for writing
  1739                              <1>         ;             2 - Open device for reading
  1740                              <1> 	;	      3 - Open device for writing
  1741                              <1>         ;          EBX = Pointer to filename/devicename (ASCIIZ)
  1742                              <1> 	; OUTPUT ->
  1743                              <1> 	;          eax = File/Device Handle/Number (index) (AL)
  1744                              <1> 	;          cf = 1 -> Error code in AL
  1745                              <1> 	;
  1746                              <1> 	; Modified Registers: EAX (at the return of system call)
  1747                              <1> 	;  
  1748                              <1> 
  1749 0000D204 80F901              <1> 	cmp	cl, 1 ; read file (0), write file (1)
  1750 0000D207 7614                <1> 	jna	short sysopen_0
  1751                              <1> 
  1752                              <1> 	; 17/04/2021 (temporary)
  1753                              <1> 	;cmp	cl, 3
  1754                              <1> 	;jna	sysopen_device
  1755                              <1> 
  1756                              <1> 	; Invalid access code
  1757 0000D209 B817000000          <1> 	mov	eax, ERR_INV_PARAMETER
  1758                              <1> 	;jmp	sysopen_dev_err
  1759                              <1> 
  1760                              <1> sysopen_dev_err:
  1761 0000D20E A3[1C010300]        <1> 	mov	[u.r0], eax
  1762 0000D213 A3[84010300]        <1> 	mov	[u.error], eax
  1763 0000D218 E9E2FAFFFF          <1> 	jmp	error
  1764                              <1> 
  1765                              <1> sysopen_0:
  1766                              <1> 	;mov	[u.namep], ebx
  1767 0000D21D 51                  <1> 	push	ecx
  1768 0000D21E 89DE                <1> 	mov	esi, ebx
  1769                              <1> 	; file name is forced, change directory as temporary
  1770                              <1> 	;mov	ax, 1
  1771                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
  1772                              <1> 	;call	set_working_path 
  1773 0000D220 E8444F0000          <1> 	call	set_working_path_x ; 17/10/2016	
  1774 0000D225 731E                <1> 	jnc	short sysopen_1
  1775                              <1> 
  1776                              <1> syscreat_err: ; ecx = file attributes (for 'syscreat')
  1777 0000D227 59                  <1> 	pop	ecx ; open mode  
  1778 0000D228 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
  1779 0000D22A 7505                <1> 	jnz	short sysopen_err
  1780                              <1> 	; eax = 0
  1781 0000D22C B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
  1782                              <1> sysopen_err:
  1783 0000D231 A3[1C010300]        <1> 	mov	[u.r0], eax
  1784 0000D236 A3[84010300]        <1> 	mov	[u.error], eax
  1785 0000D23B E8FE4F0000          <1> 	call 	reset_working_path
  1786 0000D240 E9BAFAFFFF          <1> 	jmp	error
  1787                              <1> 
  1788                              <1> sysopen_1:
  1789                              <1> 	;mov	esi, FindFile_Name
  1790 0000D245 66B80018            <1>         mov	ax, 1800h ; Only files 
  1791 0000D249 E8F2B7FFFF          <1> 	call	find_first_file
  1792 0000D24E 5A                  <1> 	pop	edx
  1793 0000D24F 72E0                <1> 	jc	short sysopen_err ; eax = 2 (File not found !)
  1794                              <1> 
  1795                              <1> 	; check_open_file_attr_access_code
  1796                              <1> 
  1797 0000D251 F6C307              <1>         test	bl, 7  ; system, hidden, readonly 
  1798 0000D254 740B                <1>         jz	short sysopen_2
  1799                              <1> 
  1800 0000D256 20D2                <1> 	and	dl, dl ; 0 = read mode
  1801 0000D258 7407                <1> 	jz	short sysopen_2
  1802                              <1> 
  1803                              <1> 	; 1 = write, 2 = read & write, >2 = invalid
  1804 0000D25A B80B000000          <1>         mov	eax, ERR_FILE_ACCESS ; 11 = 'permission denied !'
  1805 0000D25F EBD0                <1>         jmp	short sysopen_err
  1806                              <1> 
  1807                              <1> sysopen_2:
  1808                              <1> 	; esi = Directory Entry (FindFile_DirEntry) Location
  1809 0000D261 89F3                <1> 	mov	ebx, esi
  1810 0000D263 31F6                <1>         xor     esi, esi ; 0
  1811 0000D265 31FF                <1>         xor     edi, edi ; 0
  1812                              <1> sysopen_3: ; scan the list of entries in fsp table
  1813 0000D267 80BE[26010300]00    <1>         cmp     byte [esi+u.fp], 0
  1814 0000D26E 760F                <1>         jna     short sysopen_4 ; empty slot
  1815 0000D270 6646                <1>         inc     si
  1816 0000D272 6683FE0A            <1>         cmp     si, 10
  1817 0000D276 72EF                <1> 	jb	short sysopen_3
  1818                              <1> toomanyf:
  1819 0000D278 B80D000000          <1> 	mov	eax, ERR_TOO_MANY_FILES ; too many open files !
  1820 0000D27D EBB2                <1> 	jmp	short sysopen_err
  1821                              <1> 
  1822                              <1> sysopen_4: 
  1823 0000D27F 80BF[E4840100]00    <1>         cmp     byte [edi+OF_MODE], 0 ; Scan open files table 
  1824 0000D286 760A                <1> 	jna     short sysopen_5
  1825 0000D288 6647                <1> 	inc	di
  1826 0000D28A 6683FF20            <1> 	cmp     di, OPENFILES ; max. number of open files (sytem)
  1827 0000D28E 72EF                <1> 	jb	short sysopen_4
  1828 0000D290 EBE6                <1> 	jmp	short toomanyf
  1829                              <1> 
  1830                              <1> sysopen_5:
  1831 0000D292 FEC2                <1> 	inc	dl
  1832 0000D294 8897[E4840100]      <1>         mov     [edi+OF_MODE], dl
  1833 0000D29A 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
  1834 0000D2A0 8897[C4840100]      <1>         mov     [edi+OF_DRIVE], dl ; Logical DOS drive number
  1835                              <1> 	;shl	di, 2 ; *4 (dword offset)
  1836                              <1> 	; 23/07/2022
  1837 0000D2A6 C1E702              <1> 	shl	edi, 2
  1838                              <1> 
  1839 0000D2A9 8987[C4850100]      <1> 	mov	[edi+OF_SIZE], eax ; File size in bytes
  1840                              <1> 
  1841 0000D2AF 668B4314            <1>         mov 	ax, [ebx+DirEntry_FstClusHI]
  1842 0000D2B3 C1E010              <1> 	shl	eax, 16
  1843 0000D2B6 668B431A            <1> 	mov 	ax, [ebx+DirEntry_FstClusLO]
  1844 0000D2BA 8987[44840100]      <1> 	mov     [edi+OF_FCLUSTER], eax ; First cluster
  1845 0000D2C0 8987[C4870100]      <1> 	mov     [edi+OF_CCLUSTER], eax ; Current cluster
  1846                              <1> 
  1847 0000D2C6 31DB                <1>         xor	ebx, ebx
  1848 0000D2C8 899F[44850100]      <1>         mov     [edi+OF_POINTER], ebx ; offset pointer (0)
  1849 0000D2CE 899F[44880100]      <1>         mov     [edi+OF_CCINDEX], ebx ; cluster index (0)
  1850                              <1> 
  1851 0000D2D4 A1[5C810100]        <1> 	mov	eax, [FindFile_DirFirstCluster]
  1852 0000D2D9 8987[44860100]      <1> 	mov	[edi+OF_DIRFCLUSTER], eax
  1853                              <1> 
  1854 0000D2DF A1[60810100]        <1> 	mov	eax, [FindFile_DirCluster]
  1855 0000D2E4 8987[C4860100]      <1> 	mov	[edi+OF_DIRCLUSTER], eax
  1856                              <1> 
  1857                              <1> 	; Get (& Save) Volume ID 
  1858                              <1> 	; Important for files of removable drives
  1859                              <1> 	; (In order to check the drive has same volume/disk)
  1860 0000D2EA 88D7                <1> 	mov	bh, dl
  1861 0000D2EC 81C300010900        <1>         add	ebx, Logical_DOSDisks
  1862 0000D2F2 8A4303              <1>         mov	al, [ebx+LD_FATType]
  1863 0000D2F5 3C01                <1>         cmp	al, 1
  1864 0000D2F7 7209                <1>         jb	short sysopen_6_fs
  1865 0000D2F9 3C02                <1>         cmp	al, 2
  1866 0000D2FB 770A                <1>         ja	short sysopen_6_fat32
  1867                              <1> sysopen_6_fat:
  1868 0000D2FD 8B432D              <1>         mov	eax, [ebx+LD_BPB+VolumeID]
  1869 0000D300 EB08                <1>         jmp	short sysopen_7
  1870                              <1> sysopen_6_fs:
  1871 0000D302 8B4328              <1>         mov	eax, [ebx+LD_FS_VolumeSerial]
  1872 0000D305 EB03                <1>         jmp	short sysopen_7
  1873                              <1> sysopen_6_fat32:
  1874 0000D307 8B4349              <1>         mov	eax, [ebx+LD_BPB+FAT32_VolID]
  1875                              <1> sysopen_7:
  1876 0000D30A A3[40780100]        <1>         mov	[Current_VolSerial], eax
  1877                              <1> 
  1878 0000D30F 8987[44870100]      <1> 	mov	[edi+OF_VOLUMEID], eax
  1879                              <1> 
  1880                              <1> 	; 24/10/2016
  1881                              <1> 	;shr	di, 1 ; 4/2, word offset
  1882                              <1> 	; 23/07/2022
  1883 0000D315 D1EF                <1> 	shr	edi, 1
  1884 0000D317 668B1D[64810100]    <1> 	mov	bx, [FindFile_DirEntryNumber]
  1885 0000D31E 66899F[C4880100]    <1> 	mov	[edi+OF_DIRENTRY], bx
  1886                              <1> 
  1887 0000D325 31D2                <1> 	xor	edx, edx
  1888                              <1> 	;;shr	di, 2 ; /4 (byte offset)
  1889                              <1> 	;shr	di, 1 ; 2/2, byte offset
  1890                              <1> 	; 23/07/2022
  1891 0000D327 D1EF                <1> 	shr	edi, 1
  1892 0000D329 8897[24850100]      <1> 	mov	byte [edi+OF_OPENCOUNT], dl ; 0
  1893 0000D32F 8897[04850100]      <1> 	mov	byte [edi+OF_STATUS], dl ; 0
  1894                              <1> 
  1895 0000D335 89FB                <1> 	mov	ebx, edi
  1896 0000D337 FEC3                <1> 	inc	bl
  1897                              <1> 
  1898 0000D339 889E[26010300]      <1>         mov     [esi+u.fp], bl ; Open File Entry Number
  1899 0000D33F 8935[1C010300]      <1> 	mov     [u.r0], esi ; move index to u.fp list 
  1900                              <1> 			    ; into eax on stack
  1901                              <1> 
  1902 0000D345 E8F44E0000          <1>         call 	reset_working_path
  1903                              <1>         
  1904 0000D34A E9D0F9FFFF          <1> 	jmp	sysret
  1905                              <1> 
  1906                              <1> 
  1907                              <1> ; fsp table (original UNIX v1)
  1908                              <1> ;
  1909                              <1> ;Entry
  1910                              <1> ;          15                                      0
  1911                              <1> ;  1     |---|---------------------------------------|
  1912                              <1> ;        |r/w|       i-number of open file           |
  1913                              <1> ;        |---|---------------------------------------| 
  1914                              <1> ;        |               device number               |
  1915                              <1> ;        |-------------------------------------------|
  1916                              <1> ;    (*) | offset pointer, i.e., r/w pointer to file |
  1917                              <1> ;        |-------------------------------------------| 
  1918                              <1> ;        |  flag that says    | number of processes  |
  1919                              <1> ;        |   file deleted     | that have file open  |
  1920                              <1> ;        |-------------------------------------------| 
  1921                              <1> ;  2     |                                           |
  1922                              <1> ;        |-------------------------------------------| 
  1923                              <1> ;        |                                           |
  1924                              <1> ;        |-------------------------------------------|
  1925                              <1> ;        |                                           |
  1926                              <1> ;        |-------------------------------------------|
  1927                              <1> ;        |                                           |
  1928                              <1> ;        |-------------------------------------------| 
  1929                              <1> ;  3     |                                           | 
  1930                              <1> ;        |                                           |  
  1931                              <1> ;
  1932                              <1> ; (*) Retro UNIX 386 v1 modification: 32 bit offset pointer 
  1933                              <1> 
  1934                              <1> ; 27/03/2020 - Retro UNIX 386 v2 - FSP (OPEN FILES) TABLE 
  1935                              <1> 
  1936                              <1> ;Entry
  1937                              <1> ;         15                    7                   0
  1938                              <1> ;  1     |-------------------------------------------|
  1939                              <1> ;        |   	     i-number of open file           |
  1940                              <1> ;        |-------------------------------------------| 
  1941                              <1> ;        |        high word of 32 bit i-number       |
  1942                              <1> ;        |-------------------------------------------|
  1943                              <1> ;        | open mode & status  |   device number     |
  1944                              <1> ;        |-------------------------------------------|
  1945                              <1> ;        |    reserved byte    |     open count      |
  1946                              <1> ;        |-------------------------------------------| 
  1947                              <1> ;        | offset pointer, i.e., r/w pointer to file |
  1948                              <1> ;        |-------------------------------------------|
  1949                              <1> ;        |   64 bit file offset pointer (bit 16-31)  | 
  1950                              <1> ;        |-------------------------------------------|
  1951                              <1> ;        |   64 bit file offset pointer (bit 32-47)  | 
  1952                              <1> ;        |-------------------------------------------|
  1953                              <1> ;        |   64 bit file offset pointer (bit 48-63)  | 
  1954                              <1> ;        |-------------------------------------------|
  1955                              <1> ;  2     |                                           |
  1956                              <1> ;        |-------------------------------------------| 
  1957                              <1> ;        |                                           |
  1958                              <1> ;        |-------------------------------------------|
  1959                              <1> ;        |                                           |
  1960                              <1> ;        |-------------------------------------------|
  1961                              <1> ;        |                                           |
  1962                              <1> ;        |-------------------------------------------| 
  1963                              <1> ;        |                                           | 
  1964                              <1> 
  1965                              <1> ; 23/07/2022 - TRDOS 386 Kernel v2.0.5
  1966                              <1> ; OPENFILES equ 10 (sysdefs.s)
  1967                              <1> ;; 06/10/2016
  1968                              <1> ;; Open File Parameters (trdoskx.s)
  1969                              <1> ;OF_FCLUSTER:	resd OPENFILES  ; First clusters of open files
  1970                              <1> ;OF_DRIVE:	resb OPENFILES  ; Logical DOS drive numbers of open files 
  1971                              <1> ;OF_MODE:	resb OPENFILES  ; Open mode (1 = read, 2 = write, 3 = r&w) 
  1972                              <1> ;OF_STATUS:	resb OPENFILES  ; (bit 0 = read, bit 1 = write)
  1973                              <1> ;OF_OPENCOUNT:	resb OPENFILES  ; Open counts of open files
  1974                              <1> ;OF_POINTER:	resd OPENFILES	; File seek/read/write pointer
  1975                              <1> ;OF_SIZE:	resd OPENFILES	; File sizes of open files (in bytes)
  1976                              <1> ;OF_DIRFCLUSTER: resd OPENFILES  ; Directory First Clusters of open files
  1977                              <1> ;OF_DIRCLUSTER:	resd OPENFILES  ; Directory (Entry) Clusters of open files
  1978                              <1> ;OF_VOLUMEID:	resd OPENFILES  ; Vol ID for removable drives of open files
  1979                              <1> ;OF_CCLUSTER:	resd OPENFILES  ; Current clusters of open files
  1980                              <1> ;OF_CCINDEX:	resd OPENFILES  ; Cluster index numbers of current clusters
  1981                              <1> ;; 24/10/2016
  1982                              <1> ;OF_DIRENTRY:	resw OPENFILES  ; Directory entry index no. in dir cluster
  1983                              <1> 
  1984                              <1> ; 17/04/2021
  1985                              <1> ; ('sysopen_device' procedure is disabled as temporary)
  1986                              <1> 
  1987                              <1> ;sysopen_device:
  1988                              <1> ;	; 15/10/2016
  1989                              <1> ;	; 08/10/2016
  1990                              <1> ;	; 07/10/2016 (TRDOS 386 = TRDOS v2.0)
  1991                              <1> ;	push	ecx ; open mode
  1992                              <1> ;	mov	ebp, esp
  1993                              <1> ;	mov	ecx, 16 ; transfer length = 16 bytes 
  1994                              <1> ;	sub	esp, ecx
  1995                              <1> ;	mov	edi, esp ; destination address 
  1996                              <1> ;	mov 	esi, ebx ; dev name in user's memory space
  1997                              <1> ;	call	transfer_from_user_buffer
  1998                              <1> ;	jnc	short sysopen_dev_0
  1999                              <1> ;	; eax = ERR_OUT_OF_MEMORY = 4 = ERR_MINOR_IM
  2000                              <1> ;	pop	ecx
  2001                              <1> ;sysopen_dev_err:
  2002                              <1> ;	mov	[u.r0], eax
  2003                              <1> ;	mov	[u.error], eax
  2004                              <1> ;	jmp	error
  2005                              <1> ;sysopen_dev_0:
  2006                              <1> ;	mov	esi, edi ; Device name addr (max. 16 bytes, ASCIIZ) 
  2007                              <1> ;			 ; for example: "tty, TTY, /dev/tty"
  2008                              <1> ;	call	get_device_number
  2009                              <1> ;	mov	esp, ebp
  2010                              <1> ;	pop	ecx
  2011                              <1> ;	jnc	short sysopen_dev_1
  2012                              <1> ;	mov	eax, ERR_INV_DEV_NAME ; 24 ; 'invalid device name !'
  2013                              <1> ;	jmp	short sysopen_dev_err
  2014                              <1> ;sysopen_dev_1:
  2015                              <1> ;	; eax = Device Number (AL)
  2016                              <1> ;	;  cl = Open mode (2 = device read, 3 = device write)
  2017                              <1> ;       xor     ebx, ebx ; 0
  2018                              <1> ;sysopen_dev_2: ; scan the list of entries
  2019                              <1> ;       cmp     [ebx+u.fp], bl ; 0
  2020                              <1> ;       jna     short sysopen_dev_3 ; empty slot
  2021                              <1> ;       inc     bl
  2022                              <1> ;       cmp     bl, 10
  2023                              <1> ;	jb	short sysopen_dev_2
  2024                              <1> ;	;
  2025                              <1> ;	mov	eax, ERR_TOO_MANY_FILES ; too many open files !
  2026                              <1> ;	jmp	short sysopen_dev_err
  2027                              <1> ;sysopen_dev_3:
  2028                              <1> ;	mov 	[u.r0], ebx ; File/Device index/handle/descriptor
  2029                              <1> ;	; eax = device number (entry offset)
  2030                              <1> ;	mov	ch, [eax+DEV_ACCESS] ; bit 0 = accessable by users
  2031                              <1> ;				     ; bit 1 = read access perm
  2032                              <1> ;				     ; bit 2 = write access perm
  2033                              <1> ;				     ; bit 3 = IOCTL permit to users
  2034                              <1> ;				     ; bit 4 = block device if set
  2035                              <1> ;				     ; bit 5 = 16 bit or 1024 byte
  2036                              <1> ;				     ; bit 6 = 32 bit or 2048 byte
  2037                              <1> ;				     ; bit 7 = installable device drv
  2038                              <1> ;	test 	ch, 1 ; accessable by normal users (except root)
  2039                              <1> ;	jnz	short sysopen_dev_4 ; yes, permission has been given
  2040                              <1> ;	cmp	byte [u.uid], 0 ; root?
  2041                              <1> ;	jna	short sysopen_dev_4 ; superuser can open all devices
  2042                              <1> ;sysopen_dev_perm_err:
  2043                              <1> ;	mov	eax, ERR_DEV_ACCESS  ; 11 = 'permission denied !'
  2044                              <1> ;	jmp	short sysopen_dev_err
  2045                              <1> ;sysopen_dev_4:
  2046                              <1> ;	shr	ch, 1 ; result: 1 = read, 2 = write, 3 = r & w 
  2047                              <1> ;	dec	cl  ; result: 1 = read, 2 = write
  2048                              <1> ;	test	cl, ch
  2049                              <1> ;	jz	short sysopen_dev_perm_err 
  2050                              <1> ;
  2051                              <1> ;	shl	ch, 1 ; bit 0 = 0
  2052                              <1> ;	; eax = device number (entry offset)
  2053                              <1> ;	call	device_open
  2054                              <1> ;	jc	short sysopen_dev_perm_err 
  2055                              <1> ;
  2056                              <1> ;	; eax = device number (entry offset)
  2057                              <1> ;	or	al, 80h ; set device bit (set bit 7 to 1)
  2058                              <1> ;	mov	ebx, [u.r0]
  2059                              <1> ;	mov	[ebx+u.fp], al	; bit 7 (=1) points to device	
  2060                              <1> ;	
  2061                              <1> ;	jmp	sysret
  2062                              <1> 
  2063                              <1> sysmkdir: ; < make directory >
  2064                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5 
  2065                              <1> 	; 15/10/2016
  2066                              <1> 	; 10/10/2016 (TRDOS 386 = TRDOS v2.0) 
  2067                              <1> 	;	     -derived from INT_21H.ASM-
  2068                              <1> 	;            ("loc_INT21h_create_file")
  2069                              <1>         ; 	10/07/2011 (12/03/2011)
  2070                              <1>         ;	INT 21h Function AH = 3Ch
  2071                              <1>         ;	Create File
  2072                              <1>         ;	INPUT
  2073                              <1>         ;	   CX = Attributes
  2074                              <1>         ;          DS:DX= Address of zero terminaned path name
  2075                              <1>         ;
  2076                              <1>         ;
  2077                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  2078                              <1> 	; 27/05/2013 - 02/08/2013 (Retro UNIX 8086 v1)
  2079                              <1> 	;
  2080                              <1> 	; 'sysmkdir' creates an empty directory whose name is
  2081                              <1> 	; pointed to by arg 1. The mode of the directory is arg 2.	
  2082                              <1> 	; The special entries '.' and '..' are not present.
  2083                              <1> 	; Errors are indicated if the directory already exists or		
  2084                              <1> 	; user is not the super user. 
  2085                              <1> 	;
  2086                              <1> 	; Calling sequence:
  2087                              <1> 	;	sysmkdir; name; mode
  2088                              <1> 	; Arguments:
  2089                              <1> 	;	name - points to the name of the directory
  2090                              <1> 	;	mode - mode of the directory
  2091                              <1> 	; Inputs: (arguments)
  2092                              <1> 	; Outputs: -
  2093                              <1> 	;    (sets 'directory' flag to 1; 
  2094                              <1> 	;    'set user id on execution' and 'executable' flags to 0)
  2095                              <1> 	; ...............................................................
  2096                              <1> 	;				
  2097                              <1> 	; Retro UNIX 8086 v1 modification: 
  2098                              <1> 	;       'sysmkdir' system call has two arguments; so,
  2099                              <1> 	;	* 1st argument, name is pointed to by BX register
  2100                              <1> 	;	* 2nd argument, mode is in CX register
  2101                              <1> 	;
  2102                              <1> 	; TRDOS 386 (10/10/2016)
  2103                              <1> 	;	
  2104                              <1>         ; INPUT ->
  2105                              <1>         ;	   CL = Directory Attributes
  2106                              <1> 	;     	      bit 0 (1) - Read only file/dir (R)
  2107                              <1> 	;             bit 1 (1) - Hidden file/dir (H)
  2108                              <1>         ;             bit 2 (1) - System file/dir (R)
  2109                              <1> 	;             bit 3 (1) - Volume label/name (V)
  2110                              <1>         ;             bit 4 (1) - Subdirectory (D)
  2111                              <1> 	;	      bit 5 (1) - File/Dir has been archived (A)
  2112                              <1> 	;	   CX = 0 -> create normal directory	 	
  2113                              <1>         ;          EBX = Pointer to directory name (ASCIIZ) -path-
  2114                              <1> 	;	
  2115                              <1> 	; OUTPUT ->
  2116                              <1> 	;          eax = First cluster of the new directory
  2117                              <1> 	;          cf = 1 -> Error code in AL
  2118                              <1> 	;
  2119                              <1> 	; Modified Registers: EAX (at the return of system call)
  2120                              <1> 	;  
  2121                              <1> 	; Note: If the file or directory is existing
  2122                              <1> 	;	an access error will be returned. 
  2123                              <1> 
  2124 0000D34F 6621C9              <1> 	and	cx, cx ; if cx = 0 -> create a normal subdir
  2125 0000D352 7414                <1> 	jz	short sysmkdir_1
  2126                              <1> 
  2127 0000D354 F6C110              <1> 	test	cl, 10h ; if dir flags set, also use other flags
  2128                              <1> 	;jnz	sysmkdir_0 ; jump to head of 'syscreat'
  2129                              <1> 	; 23/07/2022
  2130 0000D357 7405                <1> 	jz	short sysmkdir_invf
  2131                              <1> sysmkdir_3:
  2132 0000D359 E9D3FDFFFF          <1> 	jmp	sysmkdir_0
  2133                              <1> 
  2134                              <1> sysmkdir_invf:
  2135                              <1> 	; CX has wrong flags
  2136 0000D35E B817000000          <1> 	mov 	eax, ERR_INV_FLAGS
  2137 0000D363 E9A6FEFFFF          <1> 	jmp	sysopen_dev_err
  2138                              <1> 
  2139                              <1> sysmkdir_1:
  2140 0000D368 B110                <1> 	mov	cl, 10h ; set subdir flag and reset other flags
  2141                              <1> 	;jmp	sysmkdir_0
  2142                              <1> 	; 23/07/2022
  2143 0000D36A EBED                <1> 	jmp	short sysmkdir_3 ; jump to head of 'syscreat'
  2144                              <1> sysmkdir_2: 
  2145                              <1> 	; jump from 'syscreat' ; from 'syscreat_1'
  2146                              <1> 	;  CL = Directory attributes/flags  
  2147 0000D36C BE[2C810100]        <1> 	mov	esi, FindFile_Name 
  2148 0000D371 E882D8FFFF          <1> 	call	make_sub_directory
  2149                              <1> 	;jc	sysopen_err       ; NOTE: Old type (TRDOS 8086)
  2150                              <1> 				  ; error codes must be modified
  2151                              <1> 				  ; for next TRDOS 386 versions
  2152                              <1> 				  ; (10/10/2016)
  2153                              <1> 				  ; Old (MSDOS type)
  2154                              <1> 				  ; error codes (2011):
  2155                              <1> 				  ;  2 = file not found
  2156                              <1> 				  ;  3 = directory not found
  2157                              <1> 				  ;  5 = access denied
  2158                              <1> 				  ; 12 = no more files
  2159                              <1> 			          ; 19 = disk write protected   
  2160                              <1> 				  ; 39 = insufficient disk space
  2161                              <1> 				  ; 'sysdefs.s' ; 10/10/2016  	
  2162                              <1> 	; 23/07/2022
  2163 0000D376 7305                <1> 	jnc	short sysmkdir_4
  2164 0000D378 E9B4FEFFFF          <1> 	jmp	sysopen_err
  2165                              <1> 
  2166                              <1> sysmkdir_4:	
  2167 0000D37D A3[1C010300]        <1> 	mov	[u.r0], eax ; New sub dir's first cluster
  2168 0000D382 E8B74E0000          <1>         call 	reset_working_path
  2169 0000D387 E993F9FFFF          <1> 	jmp	sysret	
  2170                              <1> 
  2171                              <1> sysclose: ;<close file>
  2172                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
  2173                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0) 
  2174                              <1> 	;
  2175                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  2176                              <1> 	; 22/05/2013 - 26/05/2013 (Retro UNIX 8086 v1)
  2177                              <1> 	;
  2178                              <1> 	; 'sysclose', given a file descriptor in 'u.r0', closes the
  2179                              <1> 	; associated file. The file descriptor (index to 'u.fp' list)
  2180                              <1> 	; is put in r1 and 'fclose' is called.
  2181                              <1> 	;
  2182                              <1> 	; Calling sequence:
  2183                              <1> 	;	sysclose
  2184                              <1> 	; Arguments:
  2185                              <1> 	;	-  
  2186                              <1> 	; Inputs: *u.r0 - file descriptor
  2187                              <1> 	; Outputs: -
  2188                              <1> 	; ...............................................................
  2189                              <1> 	;				
  2190                              <1> 	; Retro UNIX 8086 v1 modification:
  2191                              <1> 	;	 The user/application program puts file descriptor
  2192                              <1> 	;        in BX register as 'sysclose' system call argument.
  2193                              <1> 	; 	 (argument transfer method 1)
  2194                              <1> 
  2195                              <1> 	; TRDOS 386 (06/10/2016)
  2196                              <1> 	;	
  2197                              <1>         ; INPUT ->
  2198                              <1>         ;	   EBX = File Handle/Number (file index) (AL)
  2199                              <1> 	; OUTPUT ->
  2200                              <1> 	;          cf = 0 -> EAX = 0
  2201                              <1> 	;          cf = 1 -> Error code in EAX (ERR_FILE_NOT_OPEN)
  2202                              <1> 	;
  2203                              <1> 	; Modified Registers: EAX (at the return of system call)
  2204                              <1> 	;  
  2205                              <1> 
  2206 0000D38C 89D8                <1> 	mov 	eax, ebx
  2207 0000D38E 31DB                <1> 	xor	ebx, ebx	
  2208 0000D390 891D[1C010300]      <1> 	mov	[u.r0], ebx ; 0  ; return value of EAX
  2209 0000D396 E831310000          <1> 	call 	fclose
  2210                              <1> 	;jnc	sysret
  2211                              <1> 	; 23/07/2022
  2212 0000D39B 7205                <1> 	jc	short sysclose_err
  2213 0000D39D E97DF9FFFF          <1> 	jmp	sysret
  2214                              <1> sysclose_err:
  2215 0000D3A2 B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN ; file not open !
  2216 0000D3A7 A3[84010300]        <1> 	mov	[u.error], eax ;
  2217 0000D3AC A3[1C010300]        <1> 	mov	[u.r0], eax ; ! invalid handle !
  2218 0000D3B1 E949F9FFFF          <1> 	jmp	error
  2219                              <1> 
  2220                              <1> sysread: ; < read from file >
  2221                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
  2222                              <1> 	;	     -derived from INT_21H.ASM-
  2223                              <1> 	;            ("loc_INT21h_read_file")
  2224                              <1>         ; 	13/03/2011 (05/03/2011)
  2225                              <1>         ;	INT 21h Function AH = 3Fh
  2226                              <1>         ;	Read from a File
  2227                              <1>         ;	INPUT
  2228                              <1> 	;	   BX = File Handle
  2229                              <1>         ;	   CX = Number of bytes to read
  2230                              <1>         ;          DS:DX= Buffer address
  2231                              <1>         ;
  2232                              <1> 	; Note: TRDOS 386 'sysread' has been derived from 
  2233                              <1> 	;	Retro UNIX 386 v1 'sysread', except a few 
  2234                              <1> 	;	code modifications.
  2235                              <1> 	;
  2236                              <1> 	; 13/05/2015 (Retro UNIX 386 v1)
  2237                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  2238                              <1> 	; 23/05/2013 (Retro UNIX 8086 v1)
  2239                              <1> 	;
  2240                              <1> 	; 'sysread' is given a buffer to read into and the number of
  2241                              <1> 	; characters to be read. If finds the file from the file
  2242                              <1> 	; descriptor located in *u.r0 (r0). This file descriptor
  2243                              <1> 	; is returned from a successful open call (sysopen).
  2244                              <1> 	; The i-number of file is obtained via 'rw1' and the data
  2245                              <1> 	; is read into core via 'readi'.
  2246                              <1> 	;
  2247                              <1> 	; Calling sequence:
  2248                              <1> 	;	sysread; buffer; nchars
  2249                              <1> 	; Arguments:
  2250                              <1> 	;	buffer - location of contiguous bytes where 
  2251                              <1> 	;		 input will be placed.
  2252                              <1> 	;	nchars - number of bytes or characters to be read.
  2253                              <1> 	; Inputs: *u.r0 - file descriptor (& arguments)
  2254                              <1> 	; Outputs: *u.r0 - number of bytes read.	
  2255                              <1> 	; ...............................................................
  2256                              <1> 	;				
  2257                              <1> 	; Retro UNIX 8086 v1 modification: 
  2258                              <1> 	;       'sysread' system call has three arguments; so,
  2259                              <1> 	;	* 1st argument, file descriptor is in BX register
  2260                              <1> 	;	* 2nd argument, buffer address/offset in CX register
  2261                              <1> 	;	* 3rd argument, number of bytes is in DX register
  2262                              <1> 	;
  2263                              <1> 	;	AX register (will be restored via 'u.r0') will return
  2264                              <1> 	;	to the user with number of bytes read. 
  2265                              <1> 	;
  2266                              <1> 	; TRDOS 386 (05/10/2016)
  2267                              <1> 	;	
  2268                              <1>         ; INPUT ->
  2269                              <1>         ;	   EBX = File handle (descriptor/index)
  2270                              <1> 	;	   ECX = Buffer address		
  2271                              <1>         ;          EDX = Number of bytes
  2272                              <1> 	; OUTPUT ->
  2273                              <1> 	;          EAX = Number of bytes have been read
  2274                              <1> 	;          cf = 1 -> Error code in AL
  2275                              <1> 	;
  2276                              <1> 	; Modified Registers: EAX (at the return of system call)
  2277                              <1> 	; 
  2278                              <1> 
  2279                              <1> 	; EBX = File descriptor
  2280 0000D3B6 E85F310000          <1> 	call	getf1 
  2281 0000D3BB 7273                <1> 	jc	short device_read ; read data from device
  2282                              <1> 	; EAX = First cluster of the file
  2283                              <1> 
  2284 0000D3BD E83F000000          <1> 	call	rw1
  2285 0000D3C2 730A                <1> 	jnc	short sysread_0
  2286                              <1> 
  2287 0000D3C4 A3[1C010300]        <1> 	mov	[u.r0], eax ; error code
  2288 0000D3C9 E931F9FFFF          <1> 	jmp	error
  2289                              <1> 	 
  2290                              <1> sysread_0:
  2291 0000D3CE E8CC340000          <1> 	call	readi
  2292 0000D3D3 EB1D                <1> 	jmp	short rw0
  2293                              <1> 
  2294                              <1> syswrite: ; < write to file >
  2295                              <1> 	; 23/10/2016
  2296                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
  2297                              <1> 	;	     -derived from INT_21H.ASM-
  2298                              <1> 	;            ("loc_INT21h_write_file")
  2299                              <1>         ; 	13/03/2011 (05/03/2011)
  2300                              <1>         ;	INT 21h Function AH = 40h
  2301                              <1>         ;	Write to a File
  2302                              <1>         ;	INPUT
  2303                              <1> 	;	   BX = File Handle
  2304                              <1>         ;	   CX = Number of bytes to write
  2305                              <1>         ;          DS:DX= Buffer address
  2306                              <1>         ;
  2307                              <1> 	; Note: TRDOS 386 'sysrwrite' has been derived from 
  2308                              <1> 	;	Retro UNIX 386 v1 'syswrite', except a few 
  2309                              <1> 	;	code modifications.
  2310                              <1> 	;
  2311                              <1> 
  2312                              <1> 	; 13/05/2015 (Retro UNIX 386 v1)
  2313                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  2314                              <1> 	; 23/05/2013 (Retro UNIX 8086 v1)
  2315                              <1> 	;
  2316                              <1> 	; 'syswrite' is given a buffer to write onto an output file
  2317                              <1> 	; and the number of characters to write. If finds the file
  2318                              <1> 	; from the file descriptor located in *u.r0 (r0). This file 
  2319                              <1> 	; descriptor is returned from a successful open or create call
  2320                              <1> 	; (sysopen or syscreat). The i-number of file is obtained via
  2321                              <1> 	; 'rw1' and buffer is written on the output file via 'write'.
  2322                              <1> 	;
  2323                              <1> 	; Calling sequence:
  2324                              <1> 	;	syswrite; buffer; nchars
  2325                              <1> 	; Arguments:
  2326                              <1> 	;	buffer - location of contiguous bytes to be writtten.
  2327                              <1> 	;	nchars - number of characters to be written.
  2328                              <1> 	; Inputs: *u.r0 - file descriptor (& arguments)
  2329                              <1> 	; Outputs: *u.r0 - number of bytes written.	
  2330                              <1> 	; ...............................................................
  2331                              <1> 	;				
  2332                              <1> 	; Retro UNIX 8086 v1 modification: 
  2333                              <1> 	;       'syswrite' system call has three arguments; so,
  2334                              <1> 	;	* 1st argument, file descriptor is in BX register
  2335                              <1> 	;	* 2nd argument, buffer address/offset in CX register
  2336                              <1> 	;	* 3rd argument, number of bytes is in DX register
  2337                              <1> 	;
  2338                              <1> 	;	AX register (will be restored via 'u.r0') will return
  2339                              <1> 	;	to the user with number of bytes written. 
  2340                              <1> 	;
  2341                              <1> 	; INPUT ->
  2342                              <1>         ;	   EBX = File handle (descriptor/index)
  2343                              <1> 	;	   ECX = Buffer address		
  2344                              <1>         ;          EDX = Number of bytes
  2345                              <1> 	; OUTPUT ->
  2346                              <1> 	;          EAX = Number of bytes have been written
  2347                              <1> 	;          cf = 1 -> Error code in AL
  2348                              <1> 	;
  2349                              <1> 	; Modified Registers: EAX (at the return of system call)
  2350                              <1> 	;  
  2351                              <1> 
  2352                              <1> 	; EBX = File descriptor
  2353 0000D3D5 E840310000          <1> 	call	getf1 
  2354 0000D3DA 7254                <1> 	jc	short device_write ; write data to device
  2355                              <1> 	; EAX = First cluster of the file
  2356                              <1> 	; EBX = File number  (Open file number) ; 23/10/2016
  2357                              <1> 
  2358 0000D3DC E820000000          <1> 	call	rw1
  2359 0000D3E1 730A                <1> 	jnc	short syswrite_0
  2360 0000D3E3 A3[1C010300]        <1> 	mov	[u.r0], eax ; error code
  2361 0000D3E8 E912F9FFFF          <1> 	jmp	error
  2362                              <1> 	 
  2363                              <1> syswrite_0:
  2364 0000D3ED E8C63B0000          <1> 	call	writei
  2365                              <1> rw0: ; 1:
  2366 0000D3F2 A1[48010300]        <1>         mov	eax, [u.nread]
  2367 0000D3F7 A3[1C010300]        <1> 	mov	[u.r0], eax
  2368 0000D3FC E91EF9FFFF          <1> 	jmp	sysret
  2369                              <1> rw1:	
  2370                              <1> 	; 17/04/2021 (TRDOS 386 v2.0.4)
  2371                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
  2372                              <1> 	; 14/05/2015 (Retro UNIX 386 v1)
  2373                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  2374                              <1> 	; 23/05/2013 - 24/05/2013 (Retro UNIX 8086 v1)
  2375                              <1> 	; System call registers: ebx, ecx, edx (through 'sysenter')
  2376                              <1> 	;
  2377                              <1> 	; EBX = File descriptor
  2378                              <1> 	;call	getf1 ; calling point in 'getf' from 'rw1'
  2379                              <1> 	;jc	short device_rw ; read/write data from/to device
  2380                              <1> 	; EAX = First cluster of the file
  2381                              <1> 
  2382 0000D401 83F802              <1> 	cmp 	eax, 2
  2383 0000D404 7217                <1> 	jb	short rw2
  2384                              <1> 	;
  2385 0000D406 890D[40010300]      <1> 	mov	[u.base], ecx 	; buffer address/offset 
  2386                              <1> 				;(in the user's virtual memory space)
  2387 0000D40C 8915[44010300]      <1> 	mov	[u.count], edx 
  2388                              <1> 
  2389 0000D412 C705[84010300]0000- <1>         mov	dword [u.error], 0 ; reset the last error code
  2389 0000D41A 0000                <1>
  2390 0000D41C C3                  <1> 	retn
  2391                              <1> rw2:
  2392 0000D41D B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN ; file not open !
  2393                              <1> 	;mov	dword [u.error], eax
  2394                              <1> 	;retn
  2395                              <1> 	; 17/04/2021
  2396 0000D422 EB06                <1> 	jmp	short rw4
  2397                              <1> rw3: 
  2398 0000D424 B80B000000          <1> 	mov	eax, ERR_FILE_ACCESS ; permission denied !
  2399 0000D429 F9                  <1> 	stc
  2400                              <1> rw4:	; 17/04/2021
  2401 0000D42A A3[84010300]        <1> 	mov	dword [u.error], eax
  2402 0000D42F C3                  <1> 	retn
  2403                              <1> 
  2404                              <1> 	; 17/04/2021 (temporary)
  2405                              <1> device_write:
  2406                              <1> device_read:
  2407                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  2408                              <1> 	;	(temporary modifications)
  2409                              <1> 	;
  2410                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0)
  2411                              <1> 	; cl = DEV_OPENMODE ; open mode
  2412                              <1> 	; ch = DEV_ACCESS   ; access flags   
  2413                              <1> 	; al = DEV_DRIVER   ; device number (eax)
  2414                              <1> 
  2415                              <1> 	; 17/04/2021 (temporary)
  2416 0000D430 EBEB                <1> 	jmp	short rw2 ; file not open
  2417                              <1> 
  2418                              <1> ;	test	cl, 1 ; 1 = read, 2 = write, 3 = read&write
  2419                              <1> ;	jz	short rw3
  2420                              <1> ;
  2421                              <1> ;	mov	ebx, eax
  2422                              <1> ;	shl	bx, 2 ; *4
  2423                              <1> ;
  2424                              <1> ;	test	ch, 80h ; bit 7, installable device driver flag
  2425                              <1> ;	jz	short d_read_2 ; Kernel device
  2426                              <1> ;	; installable device
  2427                              <1> ;d_read_1:
  2428                              <1> ;       jmp	dword [ebx+IDEV_RADDR-4]
  2429                              <1> ;d_read_2:
  2430                              <1> ;	jmp	dword [ebx+KDEV_RADDR-4]
  2431                              <1> 
  2432                              <1> ;device_write:
  2433                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
  2434                              <1> 	;	(temporary modifications)
  2435                              <1> 	;
  2436                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0)
  2437                              <1> 	; cl = DEV_OPENMODE ; open mode
  2438                              <1> 	; ch = DEV_ACCESS   ; access flags   
  2439                              <1> 	; al = DEV_DRIVER   ; device number (eax)
  2440                              <1> 
  2441                              <1> 	; 17/04/2021 (temporary)
  2442                              <1> 	;jmp	short rw2 ; file not open
  2443                              <1> 
  2444                              <1> ;	test	cl, 2 ; 1 = read, 2 = write, 3 = read&write
  2445                              <1> ;	jz	short rw3	
  2446                              <1> ;
  2447                              <1> ;	mov	ebx, eax
  2448                              <1> ;	shl	bx, 2 ; *4
  2449                              <1> ;
  2450                              <1> ;	test	ch, 80h ; bit 7, installable device driver flag
  2451                              <1> ;	jz	short d_write_2 ; Kernel device
  2452                              <1> ;	; installable device
  2453                              <1> ;d_write_1:
  2454                              <1> ;       jmp	dword [ebx+IDEV_WADDR-4]
  2455                              <1> ;d_write_2:
  2456                              <1> ;	jmp	dword [ebx+KDEV_WADDR-4]
  2457                              <1> 
  2458                              <1> systimer:
  2459                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
  2460                              <1> 	; 02/01/2017
  2461                              <1> 	; 21/12/2016
  2462                              <1> 	; 19/12/2016
  2463                              <1> 	; 10/12/2016 (callback)
  2464                              <1> 	; 10/06/2016
  2465                              <1> 	; 07/06/2016
  2466                              <1> 	; 06/06/2016
  2467                              <1> 	; 21/05/2016
  2468                              <1> 	; 19/05/2016
  2469                              <1> 	; 18/05/2016 - TRDOS 386 (TRDOS v2.0)
  2470                              <1> 	; (TRDOS 386 feature only!)
  2471                              <1> 	;
  2472                              <1> 	; (start or stop timer event(s))	
  2473                              <1> 	;
  2474                              <1> 	; INPUT ->
  2475                              <1> 	;	BL = Signal return byte (response byte)
  2476                              <1> 	;	     (Any requested value between 0 and 255)
  2477                              <1> 	;	     (Kernel will put it at the requested address)
  2478                              <1> 	;	BH = Time count unit
  2479                              <1> 	;	     0 = Stop timer event
  2480                              <1> 	;	     1 = 18.2 ticks per second
  2481                              <1> 	;	     2 = 10 milliseconds
  2482                              <1> 	;	     3 = 1 second (for real time clock interrupt)
  2483                              <1> 	;	     4 = time/tick count in current time count unit
  2484                              <1> 	;	    // 10/12/2016
  2485                              <1> 	;	    80h = Stop timer event (callback method)
  2486                              <1> 	;	    81h = 18.2 ticks per second, callback method
  2487                              <1> 	;	    82h = 10 milliseconds, callback method
  2488                              <1> 	;	    83h = 1 second (for RTC int), callback method
  2489                              <1> 	;	    84h = current time count unit, callback method
  2490                              <1> 	;
  2491                              <1> 	;	    Note: Only 03h or 83h will set real time clock
  2492                              <1> 	;		  (RTC) events (Others are for PIT events)!
  2493                              <1> 	;	
  2494                              <1> 	;	NOTE: If callback (user service) method is used,
  2495                              <1> 	;	    EDX will point to the return address (of service
  2496                              <1> 	;	    procedure) in user's space instead of signal 
  2497                              <1> 	;	    response byte address. (TRDOS 386 kernel will
  2498                              <1> 	;	    direct the cpu to that address -in user's space-
  2499                              <1> 	;	    at the return of system call or interrupt 
  2500                              <1> 	;	    just after the adjusted count/time is elapsed.)
  2501                              <1> 	;	    User's sevice routine must be ended with a
  2502                              <1> 	;	    'iret'. Normal return addresses from system 
  2503                              <1> 	;	    calls or and interrupts will be kept same except
  2504                              <1> 	;	    the timer returns.
  2505                              <1>      	;
  2506                              <1> 	;	BH = 0 -> Stop timer event
  2507                              <1> 	;	BL = Timer event number (1 to 255) if BH = 0
  2508                              <1> 	;	     If BL = 0, all timer events (which are belongs
  2509                              <1> 	;	      to running process) will be stopped
  2510                              <1> 	;	ECX = Time/Tick count (depending on time count unit)
  2511                              <1> 	;	EDX = Signal return (Response) byte address
  2512                              <1> 	;	      (virtual address in user's memory space)
  2513                              <1> 	; OUTPUT ->
  2514                              <1> 	;	AL = Timer event number	(1 to 255) (max. value = 16)
  2515                              <1> 	;	IF BH Input = 0 & CF = 0 & AL = 0 -> 
  2516                              <1> 	;	     timer event(s) has/have been stopped/finished
  2517                              <1> 	;	CF = 1 & AL = 0 -> no timer setting space to set
  2518                              <1> 	;	CF = 1 & AL > 0 -> timer count unit is not usable
  2519                              <1> 	;
  2520                              <1> 	;	NOTE: To modify a time count for a user function,
  2521                              <1> 	;	      at first, current timer event must be stopped
  2522                              <1> 	;	      then a new timer event (which is related with
  2523                              <1> 	;	      same user function) must be started.
  2524                              <1> 	;		
  2525                              <1> 	;	      Signal return (response) byte may be used for 
  2526                              <1> 	;	      several purposes. Kernel will put this value 
  2527                              <1> 	;	      to requested address during timer interrupt,
  2528                              <1> 	;	      program/user can check this value to understand
  2529                              <1> 	;	      which event has been occurred and what is changed.
  2530                              <1> 	;	      (Multi timer events can share same signal address)
  2531                              <1> 	;	
  2532                              <1> 	;	NOTE: If the process is running while the time count
  2533                              <1> 	;	      is reached, kernel will put signal return (response)
  2534                              <1> 	;	      byte value at requested address during timer
  2535                              <1> 	;	      interrupt and the process will continue to run.
  2536                              <1> 	;	      Program/process must call (jump to) it's timer event
  2537                              <1> 	;	      function as required, for checking the timer event
  2538                              <1> 	;	      status via signal return (response) byte address. 
  2539                              <1> 	;
  2540                              <1> 	;	      If the process is not running (waiting or sleeping
  2541                              <1> 	;	      or released) while the time count is reached,
  2542                              <1> 	;	      it is restarted from where it left, to ensure
  2543                              <1> 	;	      proper multi media (video, audio, clock, timer)
  2544                              <1> 	;	      functionality.
  2545                              <1> 	;
  2546                              <1> 	;	      (It is better to use 'syswait' or 'syssleep',
  2547                              <1> 	;	      or 'sysrele' system call just after the timer
  2548                              <1> 	;	      function. Otherwise, timer events may block other
  2549                              <1> 	;	      processes which are not using timer events.)  	 		 			 		 	
  2550                              <1> 	;	     	      		 			
  2551                              <1> 	; Timer Event Structure: (max. 16 timer events, 16*16 bytes)
  2552                              <1> 	;       Owner:	        resb 1 ; 0 = free
  2553                              <1> 	;		  	       ;>0 = process number (u.uno)
  2554                              <1> 	;	Calback:	resb 1 ; 1 = callback, 0 = response byte
  2555                              <1> 	;	Interrupt:      resb 1 ; 0 = Timer interrupt (or none)
  2556                              <1> 	;		   	       ; 1 = Real Time Clock interrupt 
  2557                              <1> 	;	Response:       resb 1 ; 0 to 255, signal return value
  2558                              <1> 	;	Count Limit:	resd 1 ; count of ticks (total/set)
  2559                              <1> 	;	Current Count: 	resd 1 ; count of ticks (current)
  2560                              <1> 	;	Response Addr:  resd 1 ; response byte (pointer) address
  2561                              <1> 	;
  2562                              <1> 
  2563                              <1> 	; 19/12/2016 (timer callback)
  2564 0000D432 C605[1C890100]00    <1> 	mov	byte [tcallback], 0 
  2565 0000D439 C605[1D890100]00    <1> 	mov	byte [trtc], 0
  2566 0000D440 C705[8C010300]0000- <1> 	mov	dword [u.tcb], 0 ; this is not necessary...
  2566 0000D448 0000                <1>
  2567                              <1> 
  2568 0000D44A 80FF80              <1> 	cmp	bh, 80h
  2569 0000D44D 7224                <1> 	jb	short systimer_cb2
  2570 0000D44F 7704                <1> 	ja	short systimer_cb0
  2571                              <1> 
  2572 0000D451 31D2                <1> 	xor	edx, edx ; 0, reset callback address
  2573 0000D453 EB0B                <1> 	jmp	short systimer_cb1
  2574                              <1> 
  2575                              <1> systimer_cb0:
  2576 0000D455 80FF84              <1> 	cmp	bh, 84h	
  2577 0000D458 7764                <1> 	ja	short systimer_5 ;  undefined, error
  2578                              <1> 
  2579                              <1> 	;mov	byte [tcallback], 1 ; 19/12/2016
  2580 0000D45A FE05[1C890100]      <1> 	inc	byte [tcallback]
  2581                              <1> 
  2582                              <1> systimer_cb1:
  2583 0000D460 0FB635[6D010300]    <1> 	movzx	esi, byte [u.uno] ; process number
  2584                              <1> 	;shl	si, 2	
  2585                              <1> 	; 23/07/2022
  2586 0000D467 C1E602              <1> 	shl	esi, 2
  2587 0000D46A 8996[BC000300]      <1> 	mov	[esi+p.tcb-4], edx ; set process timer callback address
  2588                              <1> 				   ; (overwrite prev value if it is set!)
  2589 0000D470 80E77F              <1> 	and	bh, 7Fh
  2590                              <1> 
  2591                              <1> systimer_cb2:
  2592 0000D473 80FF02              <1> 	cmp	bh, 2
  2593 0000D476 7446                <1>         je      short systimer_5  ; only 18.2 ticks per second is usable
  2594                              <1> 				  ; 10 milliseconds (100 Hertz) timer 
  2595                              <1> 				  ; will be set later (18/05/2016)
  2596 0000D478 774C                <1>         ja      short systimer_6 
  2597                              <1> 
  2598 0000D47A 20FF                <1> 	and	bh, bh
  2599                              <1> 	;jz	systimer_9        ; stop timer event(s)
  2600                              <1> 	; 23/07/2022
  2601 0000D47C 7505                <1> 	jnz	short systimer_19
  2602 0000D47E E9BA000000          <1> 	jmp	systimer_9
  2603                              <1> 
  2604                              <1> 	; bh = 1 (timer interrupt, 18.2 Hz, IBM PC/AT ROMBIOS default)
  2605                              <1> 
  2606                              <1> systimer_19:
  2607 0000D483 B00A                <1> 	mov	al, 10 ; (*)
  2608                              <1> 
  2609                              <1> systimer_0:
  2610 0000D485 B710                <1> 	mov	bh, 16
  2611                              <1> 	;
  2612 0000D487 383D[17840100]      <1> 	cmp	[timer_events], bh ; 16 ; 07/06/2016
  2613 0000D48D 7319                <1> 	jnb 	short systimer_3  ; max. 16 timer events
  2614                              <1> 	;
  2615 0000D48F 50                  <1> 	push	eax ; (*)
  2616                              <1> 
  2617 0000D490 BF[2C020300]        <1> 	mov	edi, timer_set  ; beginning address of timer events
  2618                              <1> 				; setting space
  2619 0000D495 30C0                <1> 	xor	al, al ; 0
  2620                              <1> systimer_1:
  2621 0000D497 FEC0                <1> 	inc	al
  2622 0000D499 803F00              <1> 	cmp	byte [edi], 0 	; is it free space ?
  2623 0000D49C 7639                <1> 	jna	short systimer_7 ; yes
  2624 0000D49E FECF                <1> 	dec	bh
  2625 0000D4A0 7405                <1> 	jz	short systimer_2
  2626 0000D4A2 83C710              <1> 	add	edi, 16
  2627 0000D4A5 EBF0                <1> 	jmp	short  systimer_1 ; next event space
  2628                              <1> 
  2629                              <1> systimer_2:
  2630 0000D4A7 58                  <1> 	pop	eax ; (*) discard
  2631                              <1> systimer_3:
  2632 0000D4A8 C605[1C010300]00    <1> 	mov	byte [u.r0], 0
  2633                              <1> systimer_4:
  2634 0000D4AF C705[84010300]1B00- <1>         mov     dword [u.error], ERR_MISC
  2634 0000D4B7 0000                <1>
  2635                              <1>                                 ; one of miscellaneous/other errors
  2636 0000D4B9 E941F8FFFF          <1> 	jmp	error ; cf -> 1
  2637                              <1> 
  2638                              <1> systimer_5:
  2639 0000D4BE 883D[1C010300]      <1> 	mov	[u.r0], bh ; Time count unit (=2 or >3)
  2640 0000D4C4 EBE9                <1> 	jmp	short systimer_4 ; 07/06/2016
  2641                              <1> 
  2642                              <1> systimer_6:
  2643 0000D4C6 80FF04              <1> 	cmp	bh, 4
  2644 0000D4C9 77F3                <1>         ja      short systimer_5  ; undefined time count unit
  2645                              <1> 	;jb	short systimer_16	
  2646                              <1> 
  2647                              <1> 	;mov	al, 1	; default (use current timer unit)
  2648                              <1> 			; countdown value is in ECX ! 
  2649                              <1> 			; max. value of ecx = 4294967296/10
  2650                              <1>         ;jmp    short systimer_0
  2651                              <1> 	;jmp	short systimer_19	
  2652 0000D4CB 74B6                <1> 	je	short systimer_19
  2653                              <1> 
  2654                              <1> systimer_16:
  2655                              <1> 	; bh = 3
  2656                              <1> 	; timer event via real time clock interrupt
  2657                              <1> 	; interrupt/update frequency: 1 Hz (1 tick per second)
  2658                              <1> 	
  2659 0000D4CD B0B6                <1> 	mov	al, 182 ; (*) ; 18.2 * 10
  2660 0000D4CF FE05[1D890100]      <1> 	inc	byte [trtc] ; timer event via real time clock
  2661 0000D4D5 EBAE                <1>         jmp     short systimer_0
  2662                              <1> 
  2663                              <1> systimer_7:
  2664 0000D4D7 A2[1C010300]        <1> 	mov	[u.r0], al ; timer event number
  2665                              <1> 	;
  2666                              <1> 	; edi = address of empty timer event area
  2667 0000D4DC A0[6D010300]        <1> 	mov	al, [u.uno]
  2668 0000D4E1 FA                  <1> 	cli 	; disable interrupts 
  2669 0000D4E2 AA                  <1> 	stosb	; process number
  2670 0000D4E3 A0[1C890100]        <1> 	mov	al, [tcallback] ; timer callback flag
  2671 0000D4E8 AA                  <1> 	stosb 	; 1= callback method, 0= signal response byte method
  2672 0000D4E9 A0[1D890100]        <1> 	mov	al, [trtc] ; timer interrupt type
  2673 0000D4EE AA                  <1> 	stosb	; 1= real time clock, 0= programmable interval timer
  2674 0000D4EF 88D8                <1> 	mov	al, bl ; Signal return (Response) value
  2675 0000D4F1 AA                  <1> 	stosb   ; response byte
  2676 0000D4F2 58                  <1> 	pop	eax ; (*) ; 10 or 182
  2677 0000D4F3 89D3                <1> 	mov	ebx, edx ; virtual address for response/signal byte
  2678 0000D4F5 F7E1                <1> 	mul	ecx
  2679                              <1> 	; (eax = 10 * count of 18.2 Hz timer ticks)
  2680                              <1> 	; (count down step = 10)
  2681 0000D4F7 AB                  <1> 	stosd  ; count limit (reset value)
  2682 0000D4F8 AB                  <1> 	stosd  ; current count value
  2683                              <1> 
  2684                              <1> 	; 19/12/2016
  2685 0000D4F9 803D[1C890100]00    <1> 	cmp	byte [tcallback], 0 ; timer callback method ?
  2686 0000D500 7604                <1> 	jna	short systimer_17 ; no	
  2687 0000D502 89D8                <1> 	mov	eax, ebx ; virtual address for callback routine 
  2688 0000D504 EB0D                <1> 	jmp	short systimer_18
  2689                              <1> 
  2690                              <1> systimer_17: ; signal response byte method
  2691                              <1> 	; ebx = virtual address
  2692                              <1> 	; [u.pgdir] = page directory's physical address
  2693                              <1> 	; 20/02/2017
  2694 0000D506 FE05[1E890100]      <1> 	inc	 byte [no_page_swap] ; 1 
  2695                              <1> 			; Do not add this page to swap queue
  2696                              <1> 			; and remove it from swap queue if it is
  2697                              <1> 			; on the queue.
  2698 0000D50C E8A685FFFF          <1> 	call	get_physical_addr
  2699 0000D511 721A                <1> 	jc	short systimer_8 ; 07/06/2016
  2700                              <1> 	; eax = physical address of the virtual address in user's space
  2701                              <1> systimer_18:
  2702 0000D513 AB                  <1> 	stosd	; response addr (physical) or callback addr (virtual)
  2703 0000D514 FE05[17840100]      <1> 	inc	byte [timer_events] ; 07/06/201
  2704                              <1> 	; 02/01/2017
  2705 0000D51A 0FB605[6D010300]    <1> 	movzx	eax, byte [u.uno]
  2706 0000D521 FE80[AF000300]      <1> 	inc	byte [eax+p.timer-1]	
  2707                              <1> 	;
  2708 0000D527 FB                  <1> 	sti 	; enable interrupts
  2709 0000D528 E9F2F7FFFF          <1> 	jmp	sysret
  2710                              <1> 
  2711                              <1> systimer_8:
  2712                              <1> 	; 10/06/2016
  2713                              <1> 	; 07/06/2016
  2714 0000D52D 28C0                <1> 	sub	al, al ; 0
  2715 0000D52F 8847F4              <1> 	mov	[edi-12], al ; clear process number (free timer event)
  2716                              <1> 	;mov	dword [edi], eax ; 0
  2717 0000D532 FB                  <1> 	sti
  2718 0000D533 A2[1C010300]        <1> 	mov	[u.r0], al ; 0
  2719 0000D538 E9C2F7FFFF          <1> 	jmp	error
  2720                              <1> 
  2721                              <1> systimer_9:
  2722                              <1> 	; 10/06/2016
  2723                              <1> 	; 07/06/2016
  2724 0000D53D 28C0                <1> 	sub	al, al
  2725 0000D53F A2[1C010300]        <1> 	mov	byte [u.r0], al ; 0
  2726 0000D544 3805[17840100]      <1> 	cmp     byte [timer_events], al ;  0
  2727 0000D54A 7631                <1> 	jna	short systimer_12
  2728                              <1> 
  2729                              <1> 	; Note: ecx and edx are undefined here
  2730                              <1> 	;	(for stop timer function)
  2731                              <1> 
  2732 0000D54C BE[2C020300]        <1> 	mov	esi, timer_set  ; beginning address of timer events
  2733                              <1> 				; setting space	 
  2734 0000D551 A0[6D010300]        <1> 	mov	al, [u.uno]
  2735                              <1> 	
  2736 0000D556 B710                <1> 	mov	bh, 16
  2737                              <1> 
  2738 0000D558 08DB                <1> 	or	bl, bl
  2739 0000D55A 7544                <1> 	jnz	short systimer_15
  2740                              <1> 
  2741                              <1> 	; clear timer event areas belong to current process
  2742                              <1> 	; (for stopping all timer events belong to current process) 
  2743 0000D55C FA                  <1> 	cli 	; disable interrupts
  2744                              <1> systimer_10:
  2745                              <1> 	; 10/06/2016
  2746                              <1> 	; 07/06/2016 	
  2747 0000D55D 8A26                <1> 	mov	ah, [esi]
  2748 0000D55F 08E4                <1> 	or	ah, ah ; 0 ?
  2749 0000D561 7411                <1> 	jz	short systimer_11
  2750 0000D563 38C4                <1> 	cmp	ah, al ; is the process number (owner) same ?
  2751 0000D565 750D                <1>         jne     short systimer_11 ; no
  2752                              <1> 
  2753                              <1> 	;mov	byte [esi], 0
  2754 0000D567 66C7060000          <1> 	mov	word [esi], 0 ; clear
  2755                              <1> 	;mov	dword [esi+12], 0 ; clear
  2756                              <1> 
  2757 0000D56C FE0D[17840100]      <1> 	dec	byte [timer_events]
  2758 0000D572 7409                <1> 	jz	short systimer_12
  2759                              <1> 
  2760                              <1> systimer_11:
  2761 0000D574 FECF                <1> 	dec	bh
  2762 0000D576 7405                <1> 	jz	short systimer_12
  2763 0000D578 83C610              <1> 	add	esi, 16
  2764 0000D57B EBE0                <1> 	jmp	short systimer_10
  2765                              <1> 
  2766                              <1> systimer_12:
  2767 0000D57D 0FB635[6D010300]    <1> 	movzx	esi, byte [u.uno]
  2768 0000D584 08DB                <1> 	or	bl, bl ; all timer events or one timer event ?
  2769 0000D586 740C                <1> 	jz	short systimer_13
  2770 0000D588 8A9E[AF000300]      <1> 	mov	bl, [esi+p.timer-1]
  2771 0000D58E 20DB                <1> 	and	bl, bl	; previous number of timer events for the process
  2772 0000D590 7408                <1> 	jz	short systimer_14
  2773 0000D592 FECB                <1> 	dec	bl  ; previous number of timer events for the process - 1
  2774                              <1> systimer_13:
  2775 0000D594 889E[AF000300]      <1> 	mov	[esi+p.timer-1], bl ; 0 ; no timer events for process
  2776                              <1> systimer_14:
  2777 0000D59A FB                  <1> 	sti	; enable interrupts
  2778 0000D59B E97FF7FFFF          <1> 	jmp	sysret
  2779                              <1> 
  2780                              <1> systimer_15:
  2781 0000D5A0 38FB                <1> 	cmp	bl, bh ; 16
  2782                              <1>         ;ja	systimer_4      ; max. 16 timer events !
  2783                              <1> 	; 23/07/2022
  2784 0000D5A2 7605                <1> 	jna	short systimer_21
  2785                              <1> systimer_20:
  2786 0000D5A4 E906FFFFFF          <1> 	jmp	systimer_4
  2787                              <1> systimer_21:	; 23/07/2022
  2788 0000D5A9 88DA                <1> 	mov	dl, bl
  2789 0000D5AB FECA                <1> 	dec	dl  ; 16 -> 15 ... 1 -> 0 
  2790 0000D5AD C0E204              <1> 	shl	dl, 4 ; * 16
  2791 0000D5B0 0FB6FA              <1> 	movzx	edi, dl
  2792 0000D5B3 01F7                <1> 	add	edi, esi ; timer_set 
  2793                              <1> 	
  2794 0000D5B5 3A07                <1> 	cmp	al, [edi] ; process number
  2795                              <1>         ;jne	systimer_4
  2796                              <1> 	; 23/07/2022
  2797 0000D5B7 75EB                <1> 	jne	short systimer_20 ; jmp systimer_4
  2798                              <1> 	
  2799                              <1> 	; same process ID
  2800 0000D5B9 FA                  <1> 	cli	; disable interrupts
  2801                              <1>  	; 10/06/2016 ; 02/01/2017
  2802                              <1> 	;mov	byte [edi], 0 
  2803 0000D5BA 66C7070000          <1> 	mov	word [edi], 0 ; clear
  2804                              <1> 	;mov	dword [edi+12], 0 ; clear
  2805 0000D5BF FE0D[17840100]      <1> 	dec	byte [timer_events]
  2806 0000D5C5 EBB6                <1> 	jmp	short systimer_12
  2807                              <1> 
  2808                              <1> sysvideo: ; VIDEO DATA TRANSFER FUNCTIONS
  2809                              <1> 	; 11/08/2022
  2810                              <1> 	; 08/08/2022
  2811                              <1> 	; 23/07/2022 (TRDOS 386 v2.0.5)
  2812                              <1> 	; 06/03/2021
  2813                              <1> 	; 02/03/2021
  2814                              <1> 	; 28/02/2021
  2815                              <1> 	; 27/02/2021
  2816                              <1> 	; 26/02/2021
  2817                              <1> 	; 25/02/2021
  2818                              <1> 	; 21/02/2021, 22/02/2021, 23/02/2021
  2819                              <1> 	; 15/02/2021, 16/02/2021, 18/02/2021
  2820                              <1> 	; 10/02/2021, 11/02/2021, 12/02/2021
  2821                              <1> 	; 07/02/2021, 08/02/2021
  2822                              <1> 	; 01/02/2021, 02/02/2021, 05/02/2021
  2823                              <1> 	; 29/01/2021, 30/01/2021, 31/01/2021
  2824                              <1> 	; 23/01/2021, 24/01/2021, 28/01/2021
  2825                              <1> 	; 18/01/2021, 19/01/2021, 22/01/2021
  2826                              <1> 	; 04/01/2021, 10/01/2021, 11/01/2021
  2827                              <1> 	; 01/01/2021, 02/01/2021, 03/01/2021
  2828                              <1> 	; 28/12/2020, 29/12/2020, 30/12/2020
  2829                              <1> 	; 25/12/2020, 26/12/2020
  2830                              <1> 	; 21/12/2020, 23/12/2020
  2831                              <1> 	; 12/12/2020, 14/12/2020
  2832                              <1> 	; 10/12/2020, 11/12/2020
  2833                              <1> 	; 03/12/2020, 04/12/2020
  2834                              <1> 	; 22/11/2020, 23/11/2020
  2835                              <1> 	; 21/11/2020 (TRDOS 386 v2.0.3)
  2836                              <1> 	; 12/05/2017
  2837                              <1> 	; 11/07/2016
  2838                              <1> 	; 13/06/2016
  2839                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
  2840                              <1> 	;
  2841                              <1> 	; VIDEO DATA TRANSFER FUNCTIONS:
  2842                              <1> 	;
  2843                              <1> 	; Inputs:
  2844                              <1> 	;		; 07/02/2021
  2845                              <1> 	;	BH = 0 = VIDEO BIOS Mode 3, tty/text mode data transfers
  2846                              <1> 	;	     BL = 
  2847                              <1> 	;		Bits 0&1, Transfer direction
  2848                              <1> 	;	     	 	0 - System to system
  2849                              <1> 	;			1 - User to system
  2850                              <1> 	;			2 - System to user
  2851                              <1> 	;			3 - Exhange (Swap) - 28/01/2021
  2852                              <1> 	;		Bits 2, Transfer Type
  2853                              <1> 	;			0 - Display page (complete) transfer
  2854                              <1> 	;	     		1 - Display page window (col,row) transfer
  2855                              <1> 	;		; 28/01/2021
  2856                              <1> 	;		Bits 3..7 - Reserved, undefined (must be 0)
  2857                              <1> 	;	        ; 28/01/2021	
  2858                              <1> 	;	     /// BL = 0 -> System to system (display page) transfer
  2859                              <1> 	;		 CL = Source page (0FFh = current video page)
  2860                              <1> 	;		 DL = Destination page (0FFh = current video page)
  2861                              <1> 	;		 (Note: Nothing to do if src & dest are same page)
  2862                              <1> 	;	     /// BL = 1&2 -> user to system & system to user transfer
  2863                              <1> 	;		 ECX = User's buffer address
  2864                              <1> 	;		 DL = Video page (0FFh = current video page)
  2865                              <1> 	;	     /// BL = 3 -> exchange (swap) display page ; 28/01/2021
  2866                              <1> 	;		 ECX = User's buffer address
  2867                              <1> 	;		 DL = Video page (0FFh = current video page)
  2868                              <1> 	;		 EDI = Swap address in user's memory (must be > 0)
  2869                              <1> 	;	     /// BL = 5&6&7 -> user to system, system to user transfer 
  2870                              <1> 	;		(system window is in current/active display page)
  2871                              <1> 	;		 ESI = User's buffer address
  2872                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2873                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2874                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2875                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2876                              <1>         ;                If BL = 5 or BL bit 0 & bit 1 are 1 ; 28/01/2021
  2877                              <1> 	;		 EDI = Swap address (in user's memory space)
  2878                              <1> 	;		 (If swap address > 0, previous content of the window
  2879                              <1> 	;		 will be saved into swap area in user's memory space)
  2880                              <1> 	;	     /// BL = 4 -> system to system transfer
  2881                              <1> 	;		 ESI = System's source buffer (video page) address
  2882                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2883                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2884                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2885                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2886                              <1> 	;		 EDI = System's destination buffer (video page) addr
  2887                              <1> 	;
  2888                              <1> 	;		; 06/02/2021
  2889                              <1> 	;		; 05/02/2021
  2890                              <1> 	;		; 01/02/2021, 02/02/2021
  2891                              <1> 	;		; 30/01/2021, 31/02/2021
  2892                              <1> 	;		; 29/01/2021 (major modification)
  2893                              <1> 	;		; 23/11/2020 (major modification)
  2894                              <1> 	;		; 22/11/2020 (bugfixes and extensions)
  2895                              <1> 	;	BH = 1 = VGA Graphics (0A0000h) data transfers
  2896                              <1> 	;		BL bit 7
  2897                              <1> 	;		   resolution (screen width) option
  2898                              <1> 	;		   0 = 320 pixels
  2899                              <1> 	;		   1 = 640 pixels
  2900                              <1> 	;		.. followings are same with SVGA transfer function
  2901                              <1> 	;		BL bit 6
  2902                              <1> 	;		   direction option
  2903                              <1> 	;		   0 = user to system (video memory)
  2904                              <1> 	;		   1 = system to user
  2905                              <1> 	;		BL bit 5
  2906                              <1> 	;		   masked/direct (non-masked) operations
  2907                              <1> 	;		   1 = masked, 0 = non-masked (direct)
  2908                              <1> 	;		BL bit 4
  2909                              <1> 	;		   page/window option
  2910                              <1> 	;		   1 = window, 0 = display page (screen)
  2911                              <1> 	;		BL bit 0 to 3 (pixel operation types)
  2912                              <1> 	;		   0 = Copy pixels (colors) ((mask color))
  2913                              <1> 	;		   1 = Change (New, Fill) color
  2914                              <1> 	;		   2 = Add color
  2915                              <1> 	;		   3 = Sub color
  2916                              <1> 	;		   4 = OR color
  2917                              <1> 	;		   5 = AND color
  2918                              <1> 	;		   6 = XOR color
  2919                              <1> 	;		   7 = NOT color
  2920                              <1> 	;		   8 = NEG color
  2921                              <1> 	;		   9 = INC color
  2922                              <1> 	;		  10 = DEC color
  2923                              <1> 	;		  11 = Mix (Average) colors
  2924                              <1> 	;		  12 = Replace pixel colors
  2925                              <1> 	;		  13 = Copy pixel block(s)
  2926                              <1> 	;		  14 = Write line(s)
  2927                              <1> 	;		  15 = Write character (font)
  2928                              <1> 	;
  2929                              <1> 	;	   Input Registers for pixel operations:
  2930                              <1> 	;		 Same with LFB data transfer function below
  2931                              <1> 	;
  2932                              <1> 	;		; 25/02/2021		
  2933                              <1> 	;		; 05/02/2021, 06/02/2021
  2934                              <1> 	;		; 01/02/2021, 02/02/2021
  2935                              <1> 	;		; 30/01/2021, 31/02/2021
  2936                              <1> 	; 		; 29/01/2021 (major modification)
  2937                              <1> 	;		; 23/11/2020 (major modification)
  2938                              <1> 	;		; 22/11/2020 (bugfixes and extensions)
  2939                              <1> 	;	BH = 2 = Super VGA, LINEAR FRAME BUFFER data transfers
  2940                              <1> 	;		BL bit 7
  2941                              <1> 	;		   unused (invalid), must be 0
  2942                              <1> 	;		BL bit 6
  2943                              <1> 	;		   direction option
  2944                              <1> 	;		   0 = user to system (video memory)
  2945                              <1> 	;		   1 = system to user
  2946                              <1> 	;		BL bit 5
  2947                              <1> 	;		   masked/direct (non-masked) operations
  2948                              <1> 	;		   1 = masked, 0 = non-masked (direct)
  2949                              <1> 	;		BL bit 4
  2950                              <1> 	;		   page/window option
  2951                              <1> 	;		   1 = window, 0 = display page (screen)
  2952                              <1> 	;		BL bit 0 to 3 (pixel operation types)
  2953                              <1> 	;		   0 = Copy pixels (colors) ((mask color))
  2954                              <1> 	;		   1 = Change (New, Fill) color
  2955                              <1> 	;		   2 = Add color
  2956                              <1> 	;		   3 = Sub color
  2957                              <1> 	;		   4 = OR color
  2958                              <1> 	;		   5 = AND color
  2959                              <1> 	;		   6 = XOR color
  2960                              <1> 	;		   7 = NOT color
  2961                              <1> 	;		   8 = NEG color
  2962                              <1> 	;		   9 = INC color
  2963                              <1> 	;		  10 = DEC color
  2964                              <1> 	;		  11 = Mix (Average) colors
  2965                              <1> 	;		  12 = Replace pixel colors
  2966                              <1> 	;		  13 = Copy pixel block(s)
  2967                              <1> 	;		  14 = Write line(s)
  2968                              <1> 	;		  15 = Write character (font)
  2969                              <1> 	;
  2970                              <1> 	;	   Note: If HW of EBX > 0, it is VESA VBE mode number
  2971                              <1> 	;		 otherwise, function will be applied
  2972                              <1> 	;		 to current (VESA VBE) video mode.
  2973                              <1> 	;		
  2974                              <1> 	;	   Input Registers for pixel operations:
  2975                              <1> 	;		-- user to system & system to system --
  2976                              <1> 	;		-- (BL = 0 to 0Fh) -- non-masked, screen --
  2977                              <1> 	;		-- (BL = 10h to 1Fh) -- non-masked, window --
  2978                              <1> 	;		-- (BL = 20h to 2Fh) -- masked, screen --
  2979                              <1> 	;		-- (BL = 30h to 3Fh) -- masked, window --
  2980                              <1> 	;		(*) window, (**) masked (***) sys to sys
  2981                              <1> 	;		for BL bit 0 to 3
  2982                              <1> 	;		00h: COPY PIXELS
  2983                              <1> 	;		  If BL bit 4 = 0 ; 21/02/2021
  2984                              <1> 	;		     full screen copy	
  2985                              <1>    	;		     ECX & EDX will not be used
  2986                              <1> 	;		    (user buffer must fit to display page)	  	
  2987                              <1> 	;		  If BL bit 4 = 1 ; 21/02/2021		
  2988                              <1> 	;		    ECX = start position (row, column) (*)
  2989                              <1> 	;			  (HW = row, CX = column)
  2990                              <1> 	;		    EDX = size (rows, colums) (*)
  2991                              <1> 	;			  (HW = rows, DX = columns)
  2992                              <1> 	;		          (0 -> invalid)
  2993                              <1> 	;		          (1 -> horizontal or vertical line)
  2994                              <1> 	;		    ESI = user's buffer address
  2995                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
  2996                              <1> 	;			  (this color will be excluded)
  2997                              <1> 	;		01h: CHANGE PIXEL COLORS
  2998                              <1> 	;		02h: ADD PIXEL COLORS
  2999                              <1> 	;		03h: SUB PIXEL COLORS
  3000                              <1> 	;		04h: OR PIXEL COLORS
  3001                              <1> 	;		05h: AND PIXEL COLORS
  3002                              <1> 	;		06h: XOR PIXEL COLORS
  3003                              <1> 	;		0Bh: MIX PIXEL COLORS
  3004                              <1> 	;		     CL = color (8 bit, 256 colors)
  3005                              <1> 	;		    ECX = color (16 bit and true colors)
  3006                              <1> 	;		    EDX = start position (row, column) (*)
  3007                              <1> 	;			 (HW = row, DX = column)
  3008                              <1> 	;		    ESI = size (rows, colums) (*)
  3009                              <1> 	;			  (HW = rows, SI = columns)
  3010                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
  3011                              <1> 	;			  (this color will be excluded)
  3012                              <1> 	;		07h: NOT PIXEL COLORS
  3013                              <1> 	;		08h: NEG PIXEL COLORS
  3014                              <1> 	;		09h: INC PIXEL COLORS
  3015                              <1> 	;		0Ah: DEC PIXEL COLORS
  3016                              <1> 	;		    ECX = start position (row, column) (*)
  3017                              <1> 	;			  (HW = row, CX = column)
  3018                              <1> 	;		    EDX = size (rows, colums) (*)
  3019                              <1> 	;			  (HW = rows, DX = columns)
  3020                              <1> 	;		          (0 -> invalid)
  3021                              <1> 	;		          (1 -> horizontal or vertical line)
  3022                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
  3023                              <1> 	;			  (this color will be excluded)
  3024                              <1> 	;		0Ch: REPLACE PIXEL COLORS
  3025                              <1> 	;		     CL = current color (8 bit, 256 colors)
  3026                              <1> 	;		    ECX = current color (16 bit and true colors)
  3027                              <1> 	;		     DL = new color (8 bit, 256 colors)
  3028                              <1> 	;		    EDX = new color (16 bit and true colors)
  3029                              <1> 	;		    ESI = start position (row, column) (*)
  3030                              <1> 	;			  (HW = row, SI = column)
  3031                              <1> 	;		    EDI = size (rows, colums) (*)
  3032                              <1> 	;			  (HW = rows, DI = columns)
  3033                              <1> 	;		0Dh: COPY PIXEL BLOCK(S) -full screen-
  3034                              <1> 	;		   -If BL bit 5 is 0-
  3035                              <1> 	;		    ECX = start position (row, column) (*)
  3036                              <1> 	;			  (HW = row, CX = column)
  3037                              <1> 	;		    EDX = size (rows, colums) (*)
  3038                              <1> 	;			  (HW = rows, DX = columns)
  3039                              <1> 	;		          (0 -> invalid)
  3040                              <1> 	;		          (1 -> horizontal or vertical line)
  3041                              <1> 	;		    ESI = destination (row, column) (***)
  3042                              <1> 	;		   -If BL bit 5 is 1-
  3043                              <1> 	;	               CL = color (8 bit, 256 colors)
  3044                              <1> 	;		      ECX = color (16 bit and true colors)
  3045                              <1> 	;	   	      EDX = count of blocks (not bytes)
  3046                              <1> 	;			    (limit: 2048 blocks)
  3047                              <1> 	;		      ESI = user's buffer address 
  3048                              <1> 	;			  contains 64 bits block data
  3049                              <1> 	;			  BLOCK ADDRESS - (row, col), dword
  3050                              <1> 	;			  (first 32 bits)
  3051                              <1> 	;			  BLOCK SIZE - (rows, cols), dword
  3052                              <1> 	;			  (second 32 bits)
  3053                              <1> 	;		; 10/02/2021
  3054                              <1> 	;		0Eh: WRITE LINE(s) -full screen- 
  3055                              <1> 	;		   -If BL bit 5 is 0-	
  3056                              <1> 	; 		    CL = color (8 bit, 256 colors)
  3057                              <1> 	; 		   ECX = color (16 bit and true colors)
  3058                              <1> 	; 		    DX = low 12 bits - size (length)
  3059                              <1> 	;			 high 4 bits - direction or type
  3060                              <1> 	;			     0 - Horizontal line
  3061                              <1> 	;			     1 - Vertical line
  3062                              <1> 	;			   > 1 - undefined, invalid
  3063                              <1> 	; 		   ESI = start position (row, column)
  3064                              <1> 	;			 (HW = row, SI = column)
  3065                              <1> 	;		   -If BL bit 5 is 1-
  3066                              <1> 	;		     CL = color (8 bit, 256 colors)
  3067                              <1> 	;		    ECX = color (16 bit and true colors)
  3068                              <1> 	;		     DX = number of lines (in user buffer)
  3069                              <1> 	;			   (limit: 2048 lines)	
  3070                              <1> 	;		    ESI = user's buffer
  3071                              <1> 	;		          contains 64 bit data for lines
  3072                              <1> 	;			   START POINT: 32 bit (row, col)
  3073                              <1> 	;			   LENGTH: 32 bit
  3074                              <1> 	;			   high 16 bits - 0
  3075                              <1> 	;			   bit 0-11 - length
  3076                              <1> 	;			   bit 12-15 - type (length)
  3077                              <1> 	;		0Fh: WRITE CHARACTER (FONT)
  3078                              <1> 	;		     CL = char's color (8 bit, 256 colors)
  3079                              <1> 	;		    ECX = char's color (16 bit and true colors)
  3080                              <1> 	;		     DL = Character's ASCII code
  3081                              <1> 	;		     DH bit 0 -> font height
  3082                              <1> 	;			  0 -> 8x16 character font
  3083                              <1> 	;			  1 -> 8x8 character font
  3084                              <1> 	;		     DH bit 1 & 2 -> scale	
  3085                              <1> 	;			  0 = 1/1 (8 pixels per char row)
  3086                              <1> 	;			  1 = 2/1 (16 pixels per char row)
  3087                              <1> 	;			  2 = 3/1 (24 pixels per char row)
  3088                              <1> 	;			  3 = 4/1 (32 pixels per char row) 
  3089                              <1> 	;		     DH bit 6 -> [ufont] option (1 = use [ufont])
  3090                              <1> 	;		     If DH bit 7 = 1
  3091                              <1> 	;			 USER FONT (from user buffer)
  3092                              <1> 	;			    DL = 0 -> 8x8 (width: 1 byte per row)
  3093                              <1> 	;			    DL = 1 -> 8x16
  3094                              <1> 	;			    DL = 2 -> 16x16 (width: 2 bytes)
  3095                              <1> 	;			    DL = 3 -> 16x32
  3096                              <1> 	;			    DL = 4 -> 24x24 (width: 3 bytes)
  3097                              <1> 	;			    DL = 5 -> 24x48
  3098                              <1> 	;			    DL = 6 -> 32x32 (width: 4 bytes)
  3099                              <1> 	;			    DL = 7 -> 32x64
  3100                              <1> 	;			    DL > 7 -> invalid (unused)
  3101                              <1> 	;			 EDI = user's font buffer address
  3102                              <1> 	;			    (NOTE: byte order is as row0,row1,row2..)
  3103                              <1> 	; 		    ESI = start position (row, column) (*)
  3104                              <1> 	;			     (HW = row, SI = column)
  3105                              <1> 	;
  3106                              <1> 	;		-- system to user --
  3107                              <1> 	;		   BL (bit 0 to 7) 
  3108                              <1> 	;	 	40h: COPY PIXELS (full screen, display page)
  3109                              <1> 	;		    EDI = user's buffer address
  3110                              <1> 	;		41h: COPY PIXELS (window)
  3111                              <1> 	;		    ECX = start position (row, column) (*)
  3112                              <1> 	;			  (HW = row, CX = column)
  3113                              <1> 	;		    EDX = size (rows, colums) (*)
  3114                              <1> 	;			  (HW = rows, DX = columns)
  3115                              <1> 	;		          (<=1 -> horizontal or vertical line)
  3116                              <1> 	;		    EDI = user's buffer address
  3117                              <1> 	;
  3118                              <1> 	;		Example: (29/01/2021)
  3119                              <1> 	;		    ecx = 00400064h (start at row 64, column 100) 
  3120                              <1> 	;		    edx = 00320048h (size: 50 rows, 72 columns)
  3121                              <1> 	;				    (end at row 114, column 172)
  3122                              <1> 	;		    If video memory starts at 0A0000h
  3123                              <1> 	;		    and if resolution is 320x200 (256 colors) ..
  3124                              <1> 	;		    window start offset: (64*320)+100 = 20580
  3125                              <1> 	;		    window size: 16072 bytes (pixels) 
  3126                              <1> 	;		    window end offset: 20580+16072 = 36652
  3127                              <1> 	;		    window start address: 0A0000h+564h = 0A5064h
  3128                              <1> 	; Outputs:
  3129                              <1> 	;	EAX = transfer/byte count
  3130                              <1> 	;
  3131                              <1> 	;	NOTE: If the source or destination address passes out of
  3132                              <1> 	;	video pages (display memory limits), data will not be transferred
  3133                              <1> 	;	and EAX will return as 0.
  3134                              <1> 	;
  3135                              <1> 	; 08/02/2021
  3136                              <1> 	; 07/02/2021	
  3137                              <1> 	; 04/01/2021
  3138                              <1> 	; PIXEL READ/WRITE (in current/active video mode)
  3139                              <1> 	;
  3140                              <1> 	;	BH = 3 = Read/Write pixel(s) -for all graphics modes-
  3141                              <1> 	;	     BL = 
  3142                              <1> 	;		0 = Read pixel
  3143                              <1> 	;		1 = Write pixel
  3144                              <1> 	;	     	2 = swap pixel colors
  3145                              <1> 	;		3 = mix pixel colors
  3146                              <1> 	;	     29/01/2021	
  3147                              <1> 	;		4 = read pixels from user defined positions 
  3148                              <1> 	;		5 = write single color pixels to user defined positions
  3149                              <1> 	;		6 = write multi color pixels to user defined positions 
  3150                              <1> 	; 
  3151                              <1> 	;	      > 6 = invalid/unimplemented	
  3152                              <1> 	;	
  3153                              <1> 	;	     .. for BL = 0 to 5		
  3154                              <1> 	;	     CL = color for writing pixel(s) or
  3155                              <1>  	;	     ECX = color for writing pixel(s) in true color modes
  3156                              <1> 	;
  3157                              <1> 	;	     EDX = Offset from start of video memory (0A0000h)
  3158                              <1> 	;		   or start of linear frame buffer
  3159                              <1> 	;
  3160                              <1> 	;	     07/02/2021	
  3161                              <1> 	;	     .. for BL = 4
  3162                              <1> 	;	     EDI = user's destination buffer address for pixel colors 	
  3163                              <1> 	;	     29/01/2021
  3164                              <1> 	;	     .. for BL = 4 & 5		
  3165                              <1> 	;	     ESI = user's source buffer address for BL = 4 & 5
  3166                              <1> 	;	     (buffer contains dword offset positions for pixels)
  3167                              <1> 	;	     EDX = number of pixels
  3168                              <1> 	;	     .. for BL = 6	 		
  3169                              <1> 	;	     ESI = user's buffer address for BL = 6
  3170                              <1> 	;	     (buffer contains dword offset position and dword color
  3171                              <1> 	;	      value for each pixel)
  3172                              <1> 	;	     EDX = number of pixels  
  3173                              <1> 	;	
  3174                              <1> 	; Note:
  3175                              <1> 	;	Pixel read/write will be performed in current video mode. 
  3176                              <1> 	;	If [CRT_MODE] < 0FFh, 0A0000h will be used 
  3177                              <1> 	;	   as video memory and limit will be 65536
  3178                              <1> 	;	   (new/mix pixel color will be in CL)  	
  3179                              <1> 	;	if [CRT_MODE] = 0FFh (VESA VBE video mode)
  3180                              <1> 	;	   LFB base address will be used as video memory
  3181                              <1> 	;	   and limit will be video page size
  3182                              <1> 	;	   (new/mix pixel color will be in CL)  
  3183                              <1> 	;
  3184                              <1> 	; Outputs:
  3185                              <1> 	;	EAX = pixel color (according to BL and ECX input)
  3186                              <1> 	;	EAX = 0 (pixel color is 0 or there is an error)
  3187                              <1> 	;	     (BL will return as 0FFh if there is an error)
  3188                              <1> 	;	; 29/01/2021 	
  3189                              <1> 	;	EAX = number of pixels (for BL input = 4&5&6)
  3190                              <1> 	;
  3191                              <1> 	; DIRECT (STANDARD VGA/CGA) DISPLAY MEMORY ACCESS FUNCTIONS:
  3192                              <1> 	;
  3193                              <1> 	;	BH = 4 = CGA direct video memory (0B8000h, 32K) access
  3194                              <1> 	;		Page directory & page tables of the user's
  3195                              <1> 	;		program will be updated to direct access to
  3196                              <1> 	;		0B8000h (32K) video (CGA, color) memory; if
  3197                              <1> 	;		there is not a permission conflict or lock!  
  3198                              <1> 	;	        (User's program/process will have permission to
  3199                              <1> 	;		access locked display memory if the owner is
  3200                              <1> 	;		it's parent.)
  3201                              <1>         ;
  3202                              <1> 	;	    Screen width = 320	
  3203                              <1> 	;
  3204                              <1> 	;	BH = 5 = VGA direct video memory (0A0000h, 64K) access
  3205                              <1> 	;		Page directory & page tables of the user's
  3206                              <1> 	;		program will be updated to direct access to
  3207                              <1> 	;		0A0000h (64K) video (VGA) memory; if there is not
  3208                              <1> 	;		a permission conflict or lock!  
  3209                              <1> 	;	        (User's program/process will have permission to
  3210                              <1> 	;		access locked display memory if the owner is
  3211                              <1> 	;		it's parent.)
  3212                              <1> 	;	
  3213                              <1> 	;	    ; 23/11/2020		
  3214                              <1> 	;	    Screen width options = 320, 640, 800 
  3215                              <1> 	;			
  3216                              <1> 	; Outputs:
  3217                              <1> 	;	EAX = Display memory address for direct access
  3218                              <1> 	;	      0A0000h for VGA, 0B8000h for CGA	
  3219                              <1> 	;	(Display memory size: 32K for CGA, 64K for VGA)
  3220                              <1> 	; 	EAX = 0 if display page access permission has been denied.
  3221                              <1> 	;	      (Locked!) 	
  3222                              <1> 	;	      	 	
  3223                              <1> 	; LINEAR FRAME BUFFER ACCESS FUNCTIONS:
  3224                              <1> 	;
  3225                              <1> 	;	BH = 6 = Linear Frame Buffer direct video memory access
  3226                              <1> 	;
  3227                              <1> 	;		Page directory & page tables of the user's
  3228                              <1> 	;		program will be updated to direct access to
  3229                              <1> 	;		the configured LFB (Linear Frame Buffer) address,
  3230                              <1> 	;		if there is not a permission conflict or lock!  
  3231                              <1> 	;	        (User's program/process will have permission to
  3232                              <1> 	;		access locked display memory if the owner is
  3233                              <1> 	;		it's parent.)
  3234                              <1> 	;
  3235                              <1> 	;	   ; 10/12/2020
  3236                              <1> 	;	   BL = 0FFh -> Direct LFB access for current video mode
  3237                              <1> 	;	   BL = XXh < 0FFh -> Direct LFB access
  3238                              <1> 	; 			      for VESA video mode 1XXh	
  3239                              <1> 	;		
  3240                              <1> 	;		Return: EAX = Linear Frame Buffer address
  3241                              <1> 	;			(EAX = 0 -> error)
  3242                              <1> 	;		     If EAX > 0
  3243                              <1> 	;			EDX = Frame Buffer Size in bytes
  3244                              <1> 	;		         BH = Requested Video Mode - 100h
  3245                              <1> 	;		              (VESA VBE video modes)	
  3246                              <1> 	;		         BL = bits per pixel
  3247                              <1> 	;			      8 = 256 colors, 8
  3248                              <1> 	;		             16 = 65536 colors, 5-6(G)-5 
  3249                              <1> 	;		             24 = RGB, 16M colors, 8-8-8
  3250                              <1> 	;		             32 = RGB + alpha bytes, 8-8-8-8
  3251                              <1> 	;		     If BH = 0FFh
  3252                              <1> 	;		        BL = VGA/CGA video mode (also EAX = 0)
  3253                              <1> 	;
  3254                              <1> 	;		** Function will return with EAX = 0 if the mode
  3255                              <1> 	;		is not a valid VESA VBE video mode as 1??h ** 	
  3256                              <1> 	;
  3257                              <1> 	;		ECX = Pixel resolution
  3258                              <1> 	;		      CX = Width (320, 640, 800, 1024, 1366, 1920)
  3259                              <1> 	;		      High 16 bits of ECX = Height 
  3260                              <1> 	;
  3261                              <1> 	; 	23/11/2020
  3262                              <1> 	; ***	GET VIDEO MODE & LINEAR FRAME BUFFER INFO   
  3263                              <1> 	;	(This function -7- also is used for VGA and CGA modes)
  3264                              <1> 	; 	
  3265                              <1> 	;	BH = 7 = Get Linear Frame Buffer info
  3266                              <1> 	;
  3267                              <1> 	;	   ; 22/01/2021	
  3268                              <1> 	;	   ; 10/12/2020
  3269                              <1> 	;	   BL = any -not used- (22/01/2021)
  3270                              <1> 	;	
  3271                              <1> 	;		Return:
  3272                              <1> 	;		EAX = Frame Buffer Address (0 = is not in use)
  3273                              <1> 	;		EDX = Frame Buffer Size in bytes
  3274                              <1> 	;		 BH = Current Video Mode - 100h  ; 22/01/2021
  3275                              <1> 	;		     (VESA VBE video modes)	
  3276                              <1> 	;		 BL = bits per pixel
  3277                              <1> 	;			8 = 256 colors, 8
  3278                              <1> 	;		       16 = 65536 colors, 5-6(G)-5 
  3279                              <1> 	;		       24 = RGB, 16M colors, 8-8-8
  3280                              <1> 	;		       32 = RGB + alpha bytes, 8-8-8-8
  3281                              <1> 	;		If BH = 0FFh
  3282                              <1> 	;		   BL = VGA/CGA video mode (also EAX = 0)
  3283                              <1> 	;
  3284                              <1> 	;		Note:	
  3285                              <1> 	;		Alpha byte will be used as virtual color index.
  3286                              <1> 	;		(32 bit pixel colors.. byte 0,1,2 rgb and 3 alpha)
  3287                              <1> 	;
  3288                              <1> 	;		** Function will return with EAX = 0 if the mode
  3289                              <1> 	;		is not a valid VESA VBE video mode as 1??h ** 	
  3290                              <1> 	;
  3291                              <1> 	;		ECX = Pixel resolution
  3292                              <1> 	;		      CX = Width (320, 640, 800, 1024, 1366, 1920)
  3293                              <1> 	;		      High 16 bits of ECX = Height  
  3294                              <1> 	;
  3295                              <1> 	;	NOTE: Each process will have it's own frame buffer
  3296                              <1> 	;	      address and resolution parameters in 'u' area.
  3297                              <1> 	;	      Then, if the current frame buffer & resolution
  3298                              <1> 	;	      is different, frame buffer r/w functions
  3299                              <1> 	;	      will use scale factor to convert process's
  3300                              <1>         ;             pixel coordinates to actual screen coordinates.
  3301                              <1> 	;	      resolution -> dimensional scale
  3302                              <1> 	;	      color size -> color scale
  3303                              <1> 	;	     * RGB (TRUE) colors to 256 colors conversion:
  3304                              <1>         ;             TRUE Colors -> 8,8,8 (R,G,B; byte 0 is R)
  3305                              <1> 	;	      256 colors -> 2,2,2,2 (R,G,B,L; bit 0&1 is R)
  3306                              <1> 	; 		  bit 6&7 -> luminosity base level (0,1,2,3)
  3307                              <1> 	;		  bit 4&5 -> blue level (0,1,2,3)
  3308                              <1> 	;		  bit 2%3 -> green level (0,1,2,3)
  3309                              <1> 	;		  bit 0&1 -> red level (0,1,2,3)
  3310                              <1> 	;	      Example: total red level : luminosity + red level
  3311                              <1> 	;	      Luminosity base level: 0 -> 16
  3312                              <1> 	;		 		     1 -> 32
  3313                              <1> 	;				     2 -> 64
  3314                              <1> 	;				     3 -> 128
  3315                              <1> 	;	      Color level:	
  3316                              <1> 	;				    0 -> 0
  3317                              <1> 	;				    1 -> luminosity level
  3318                              <1> 	;				    2 -> luminosity level + 64
  3319                              <1> 	;				    3 -> 255
  3320                              <1> 	;	     Luminosity base level = min (R,G,B)
  3321                              <1> 	;			if it is <16, it will be set to 16
  3322                              <1> 	;	     Color levels: Color values are fixed to (nearest) 
  3323                              <1> 	;		   one of all possible set level (step) values
  3324                              <1> 	;		   (according to luminosity base level); then
  3325                              <1> 	;		   color levels are set to R-L, G-L, B-L.
  3326                              <1> 	;	 For example: If luminosity base level is 32
  3327                              <1> 	;		  all possible set values are 0, 32, 96, 255.
  3328                              <1> 	;
  3329                              <1> 	;	    * RGB (TRUE) colors to 16 colors conversion:
  3330                              <1> 	;	    16 colors: R,B,G,L bits (4 bits)
  3331                              <1> 	;	    	   If any one of R,G,B >= 128 L = 1	
  3332                              <1>  	;		   If max. value of (R,G,B) >= 32, it is 1
  3333                              <1> 	;		      else all color bits (R&G&B&L) are 0
  3334                              <1> 	;		   If the second value >= max. value / 2
  3335                              <1> 	;		      it is 1
  3336                              <1> 	;		   If the third value >= max. value / 2
  3337                              <1> 	;		      it is 1
  3338                              <1> 	;	    Example: R = 132, G = 64, B = 78
  3339                              <1> 	;		     L = 1, R = 1
  3340                              <1> 	;		     G < 66 --> G = 0
  3341                              <1> 	;		     B >= 66 --> B = 1
  3342                              <1> 	;
  3343                              <1> 	; 10/12/2020
  3344                              <1> 	; SET VIDEO MODE (& RETURN LFB INFO for VESA VBE VIDEO MODES)
  3345                              <1> 	;	
  3346                              <1> 	;	BH = 8 = Set Video Mode
  3347                              <1> 	;		
  3348                              <1> 	;		BL = Requested Video Mode (method)
  3349                              <1> 	;		If BL = 0FFh
  3350                              <1> 	;		   CX = VESA VBE Video Mode
  3351                              <1> 	;		   ; 11/12/2020
  3352                              <1> 	;		   If EDX > 0 -> LFB INFO (user) buffer addr
  3353                              <1> 	;		If BL < 0FFh, it is VGA/CGA video mode and
  3354                              <1> 	;			CX & EDX will not be used
  3355                              <1> 	;
  3356                              <1> 	;	    NOTE: The last VESA VBE video mode is 11Bh but
  3357                              <1> 	;	    TRDOS 386 will permit to set video mode upto 11Fh.
  3358                              <1> 	;	    Above 11Fh, from 140h to 1FEh, it will be accepted
  3359                              <1> 	;	    as Bochs/Plex86 emulator video mode and it will be
  3360                              <1> 	;	    used only if [vbe3] = 2 and detected
  3361                              <1> 	;	    video bios is BOCHS/PLEX86/QEMU/VIRTUALBOX vbios.
  3362                              <1> 	;	 	  	 		 	
  3363                              <1> 	; Outputs:
  3364                              <1> 	;	EAX = Requested (Proper) video mode number + 1
  3365                              <1> 	;	      ("dec eax" by user will give requested video mode),
  3366                              <1> 	;
  3367                              <1> 	;	If BL input is 0FFh
  3368                              <1> 	;	   EDX = LFBINFO table/structure (in user's buffer addr)
  3369                              <1> 	;	   EDX = 0 -> Invalid LFBINFO (do not use it)
  3370                              <1> 	;
  3371                              <1> 	;	EAX = 0 -> Error (but EDX will not be changed)
  3372                              <1> 	;
  3373                              <1> 	; 03/12/2020
  3374                              <1> 	; VESA VBE3 VIDEO BIOS (32 bit) PROTECTED MODE INTERFACE SETTINGS
  3375                              <1> 	;	
  3376                              <1> 	;	BH = 9 = set/get VBE3 Protected Mode Interface parameters
  3377                              <1> 	;		
  3378                              <1> 	;		BL = 0 - Disable protected mode interface
  3379                              <1> 	;			([pmi32] = 0)
  3380                              <1> 	;		 	Return: AL = 1	
  3381                              <1> 	;		BL = 1 - Enable protected mode Interface
  3382                              <1> 	;			([pmi32] = 1)
  3383                              <1> 	;			Return: AL = 2
  3384                              <1> 	;		BL = 2 - Get protected mode interface status
  3385                              <1> 	;			Return: AL = [pmi32] + 1 (AL = 1 or 2)
  3386                              <1> 	;
  3387                              <1> 	;		If [vbe3] <> 3 --> AL = 0
  3388                              <1> 	;
  3389                              <1> 	;		; 17/01/2021
  3390                              <1> 	;		BL = 3 - Disable/Cancel restore permission to user
  3391                              <1> 	;			Return: AL = 1 (if disabled) or 0
  3392                              <1> 	;		BL = 4 - Enable/Give restore permission to user
  3393                              <1> 	;			Return: AL = 2 (if enabled) or 0
  3394                              <1> 	;		BL = 5 - Get video state save/restore status
  3395                              <1> 	;			 (permission status)
  3396                              <1> 	;		        Return: AL = Status (enabled = 1)
  3397                              <1> 	;				; 22/01/2021
  3398                              <1> 	;				AH = state options ([srvso])
  3399                              <1> 	;		BL = 6 - Return VESA VBE number/status
  3400                              <1> 	;		        Return: AX = status
  3401                              <1> 	;			      if AH =  2, AL > 0 : Emulator
  3402                              <1> 	;				 AH =  3, VESA VBE3 video bios
  3403                              <1> 	;		; 28/02/2021 	 
  3404                              <1> 	;		BL = 7 - Set true color mode as 32bpp (default)
  3405                              <1> 	;			Return: AX = 32 (if VBE3) 
  3406                              <1> 	;		NOTE: Initial/default value is 32bpp for vbe3.
  3407                              <1> 	;			Return: AX = 0 -> error 	 
  3408                              <1> 	;		BL = 8 - Set true color mode as 24bpp (default)
  3409                              <1> 	;			Return: AX = 24
  3410                              <1> 	;			;Return: AX = 0 -> error 
  3411                              <1> 	;		BL = 9 - Return default/current true color mode
  3412                              <1> 	;			Return: AX = 32 (32 bpp)
  3413                              <1> 	;			Return: AX = 24 (24 bpp)
  3414                              <1> 	;			Return: AX = 0 -> error (not VESA bios)
  3415                              <1> 	;		 
  3416                              <1> 	;		BL > 9 : not implemented (28/02/2021)
  3417                              <1> 	;
  3418                              <1> 	;	; 19/01/2021 ([u.uid] check)	
  3419                              <1> 	;	Note: Enabling/Disabling are done by root ([u.uid] = 0)
  3420                              <1> 	;	      while [multi_tasking] = 0.
  3421                              <1> 	;
  3422                              <1>     	; 23/12/2020
  3423                              <1> 	; VIDEO MEMORY MAPPING:
  3424                              <1> 	;	BH = 10 = Map video memory to user's buffer
  3425                              <1> 	;
  3426                              <1> 	;	   BL = 0 : CGA memory (0B8000h) map (32K)
  3427                              <1> 	;	   BL = 1 : VGA memory (0A0000h) map (64K)
  3428                              <1> 	;	   BL = 2 : SVGA memory (LFB) map to user's buffer
  3429                              <1> 	;
  3430                              <1> 	;	ECX = User's buffer addr (low 12 bits will be cleared)
  3431                              <1> 	;	EDX = Buffer size in bytes (if BL = 2)
  3432                              <1> 	;		(will be trimmed if LFB size < EDX)
  3433                              <1> 	; Return:				
  3434                              <1>         ;	EAX = physical address of video memory (buffer)
  3435                              <1> 	;	EBX = mapped (actual) size of video memory (bytes)
  3436                              <1> 	;	ECX = virtual start address of user's video buffer 
  3437                              <1> 	;	EDX is same with EDX input
  3438                              <1> 	;
  3439                              <1> 	;	(Note: Memory page boundaries will be applied 
  3440                              <1> 	;	 to buffer size and buff start addr by rounding down.
  3441                              <1> 	;	 Rounded size & address values must not be zero.) 
  3442                              <1> 	;	-Normally, it is expected to request mapping by using
  3443                              <1> 	;	 correct buffer size of current or desired video mode-
  3444                              <1> 	;
  3445                              <1> 	;	EAX = 0 -> error ! memory can not mapped to user
  3446                              <1> 	;
  3447                              <1> 	; 04/01/2021
  3448                              <1> 	; SET/READ COLOR PALETTE (set/read DAC color registers)
  3449                              <1> 	;	((256 colors (8bpp) VGA/CGA video hardware feature))
  3450                              <1> 	;
  3451                              <1> 	;	BH = 11 = Set/Read DAC color registers
  3452                              <1> 	;
  3453                              <1> 	;	   (BL<4 Original method for std VGA video hardware)
  3454                              <1> 	;	   BL = 0 : Read all DAC color registers (256 colors)
  3455                              <1> 	;	       (6 bit colors, in RGB order)
  3456                              <1> 	;	   BL = 1 : Set all DAC color registers (256 colors)
  3457                              <1> 	;	       (6 bit colors, in RGB order)
  3458                              <1> 	;	   BL = 2 : Read single DAC color register
  3459                              <1> 	;	       (6 bit color, in RGB order)
  3460                              <1> 	;		((EAX will return with color value))
  3461                              <1> 	;		CL = DAC color register (index)
  3462                              <1> 	;	   BL = 3 : Set/Write single DAC color register
  3463                              <1> 	;	       (6 bit color, in RGB order, bit 6&7 are 0)
  3464                              <1> 	;		ECX byte 0 - DAC color register
  3465                              <1> 	;		ECX byte 1 - Red (6 bit)
  3466                              <1> 	;		ECX byte 2 - Green (6 bit)
  3467                              <1> 	;		ECX byte 3 - Blue (6 bit)
  3468                              <1> 	;	   (BL>3 Alternative method for BMP files etc.)	
  3469                              <1> 	;	   BL = 4 : Read all DAC color registers (256 colors)
  3470                              <1> 	;	       (8 bit colors, in BGR order, bit 0&1 is 0)
  3471                              <1> 	;	   BL = 5 : Set all DAC color registers (256 colors)
  3472                              <1> 	;	       (8 bit colors, in BGR order, bit 0&1 is 0)
  3473                              <1> 	;	   BL = 6 : Read single DAC color register
  3474                              <1> 	;	       (8 bit color, in BGR order, bit 0&1 is 0)
  3475                              <1> 	;		((EAX will return with color value))
  3476                              <1> 	;		CL = DAC color register (index)
  3477                              <1> 	;	   BL = 7 : Set/Write single DAC color register
  3478                              <1> 	;	       (8 bit color, bit 0&1 are 0)
  3479                              <1> 	;		ECX byte 0 - DAC color register
  3480                              <1> 	;		ECX byte 1 - Blue (8 bit)
  3481                              <1> 	;		ECX byte 2 - Green (8 bit)
  3482                              <1> 	;		ECX byte 3 - Red (8 bit)
  3483                              <1> 	;
  3484                              <1> 	;	  BL > 7 : invalid (not implemented)
  3485                              <1> 	;
  3486                              <1> 	;   if BL bit 2 is 1, 6 bit colors converted to 8 bit colors
  3487                              <1> 	;	(low two bits of color bytes will be 0)
  3488                              <1> 	;     ((color byte 00111111b will be converted to 11111100b))
  3489                              <1> 	;	and RGB byte order will be 
  3490                              <1> 	;		byte 0 - Blue (low 2 bits are 0)
  3491                              <1> 	;		byte 1 - Green (low 2 bits are 0)
  3492                              <1> 	;		byte 2 - Red (low 2 bits are 0)
  3493                              <1> 	;		byte 3 - pad (or zero byte)
  3494                              <1> 	;	and 256 colors buffer size must be 256*4 = 1024 bytes
  3495                              <1> 	;   if BL bit 2 is 0, 6 bit colors will be used directly
  3496                              <1> 	;	  (high two bits of 8 bit color bytes will be 0)
  3497                              <1> 	;     ((dac color 111111b will be converted to 00111111b))
  3498                              <1> 	;		byte 0 - Red (high 2 bits are 0)
  3499                              <1> 	;		byte 1 - Green (high 2 bits are 0)
  3500                              <1> 	;		byte 2 - Blue (high 2 bits are 0)
  3501                              <1> 	;	and 256 colors buffer size must be 256*3 = 768 bytes
  3502                              <1> 	;
  3503                              <1> 	;	ECX = User's buffer addr (256*3 = 768 bytes) or
  3504                              <1> 	;	      Color 
  3505                              <1> 	;
  3506                              <1> 	; Return:				
  3507                              <1>         ;	EAX = buffer size (for BL input = 0,1,4,5)
  3508                              <1> 	;	      or color value (for BL input = 2,3,6,7)
  3509                              <1> 	;
  3510                              <1> 	; 10/01/2021
  3511                              <1> 	; SET/READ FONT DATA
  3512                              <1> 	;
  3513                              <1> 	;	BH = 12 = Set/Read Character Font Data
  3514                              <1> 	;
  3515                              <1> 	;	   BL = 0 : Disable system font overwrite
  3516                              <1> 	;	   BL = 1 : Enable system font overwrite
  3517                              <1> 	;	   BL = 2 : Read system font 8x8
  3518                              <1> 	;	   BL = 3 : Read system font 8x14
  3519                              <1> 	;	   BL = 4 : Read system font 8x16
  3520                              <1> 	;	   BL = 5 : Read user defined font 8x8
  3521                              <1> 	;	   BL = 6 : Read user defined font 8x16
  3522                              <1> 	;	   BL = 7 : Write system font 8x8
  3523                              <1> 	;	   BL = 8 : Write system font 8x14
  3524                              <1> 	;	   BL = 9 : Write system font 8x16
  3525                              <1> 	;	   BL = 10 : Write user defined font 8x8
  3526                              <1> 	;	   BL = 11 : Write user defined font 8x16
  3527                              <1> 	;
  3528                              <1> 	;	  BL > 11 : invalid (not implemented)
  3529                              <1> 	;
  3530                              <1> 	;	For BL = 1 to 11
  3531                              <1> 	;	   ECX = number of characters (<= 256)
  3532                              <1> 	;	   EDX = first character (ascii code in DL)
  3533                              <1> 	;	   ESI = user's buffer address
  3534                              <1> 	;
  3535                              <1> 	; Return:				
  3536                              <1>         ;	EAX = number of characters (ecx input)
  3537                              <1> 	;	EAX = 0 -> error
  3538                              <1> 	;	(EAX = 256 for BL = 0 and 1 if successful)
  3539                              <1> 	;	
  3540                              <1> 	; Note: system font overwrite permission will be
  3541                              <1> 	;       given if [multi_tasking] = 0 
  3542                              <1> 	;	and [u.uid] = 0 (BL = 1) ; 19/01/2021
  3543                              <1> 	;       and if [ufont] bit 7 is 1 (BL = 7,8,9)
  3544                              <1> 	;
  3545                              <1> 	; 18/01/2021
  3546                              <1> 	; SAVE/RESTORE STANDARD VGA VIDEO STATE
  3547                              <1> 	;
  3548                              <1> 	;	BH = 13 = Save/Restore std VGA video state
  3549                              <1> 	;
  3550                              <1> 	;	   BL = 0 : Save VGA state (without DAC regs)
  3551                              <1> 	;		Return: EAX = VideoStateID (>0)
  3552                              <1> 	;			EAX = 0 (failed!)
  3553                              <1> 	;	       (size: 110 bytes for TRDOS 386 v2.0.3)
  3554                              <1> 	;	   BL = 1 : Restore VGA state (without DAC regs)
  3555                              <1> 	;		ECX = VideoStateID (to be verified)
  3556                              <1> 	;	        Return: EAX = Restore size (>0)
  3557                              <1> 	;	   BL = 2 : Save VGA state (complete)
  3558                              <1> 	;		Return: EAX = VideoStateID (>0)
  3559                              <1> 	;			EAX = 0 (failed!)
  3560                              <1> 	;	       (size: 882 bytes for TRDOS 386 v2.0.3) 
  3561                              <1> 	;	   BL = 3 : Restore VGA state (complete)
  3562                              <1> 	;		ECX = VideoStateID (to be verified)
  3563                              <1> 	;	        Return: EAX = Restore size (>0)
  3564                              <1> 	;
  3565                              <1> 	;	* Above options are for saving
  3566                              <1> 	;	*       video state to system memory
  3567                              <1> 	;	*	(location: VBE3VIDEOSTATE, 2048 bytes)
  3568                              <1> 	;	
  3569                              <1> 	;	   BL = 4 : Save VGA state (without DAC regs)
  3570                              <1> 	;		ECX = buffer address  
  3571                              <1> 	;		Return: EAX = transfer count
  3572                              <1> 	;	       (size: 110 bytes for TRDOS 386 v2.0.3)
  3573                              <1> 	;		ECX = buffer address  
  3574                              <1> 	;	   BL = 5 : Restore VGA state (without DAC regs)
  3575                              <1> 	;		ECX = buffer address  
  3576                              <1> 	;	        Return: EAX = transfer count
  3577                              <1> 	;	   BL = 6 : Save VGA state (complete)
  3578                              <1> 	;		ECX = buffer address  
  3579                              <1> 	;		Return: EAX = transfer count
  3580                              <1> 	;	       (size: 882 bytes for TRDOS 386 v2.0.3)
  3581                              <1> 	;	   BL = 7 : Restore VGA state (complete)
  3582                              <1> 	;		ECX = buffer address  
  3583                              <1> 	;	        Return: EAX = transfer count
  3584                              <1> 	;
  3585                              <1> 	;	* Above options are for saving
  3586                              <1> 	;	*       video state to user's buffer
  3587                              <1> 	;	*	(buffer size: 110 bytes or 882 bytes)
  3588                              <1> 	;
  3589                              <1> 	;	  BL > 7 : invalid (not implemented)
  3590                              <1> 	;
  3591                              <1> 	; 18/01/2021
  3592                              <1> 	; SAVE/RESTORE SUPER VGA (VESA VBE 2/3) VIDEO STATE
  3593                              <1> 	;
  3594                              <1> 	;	BH = 14 = Save/Restore SVGA video state
  3595                              <1> 	;
  3596                              <1> 	;	   BL = options
  3597                              <1> 	;		bit 0 - Save (0) or Restore (1)	
  3598                              <1> 	;		bit 1 - controller hardware state
  3599                              <1> 	;		bit 2 - BIOS data state
  3600                              <1> 	;		bit 3 - DAC state
  3601                              <1> 	;		bit 4 - (extended) Register state
  3602                              <1> 	;		bit 5 - system (0) or user (1) memory
  3603                              <1> 	;		bit 6 - verify without transfer
  3604                              <1> 	;		bit 7 - not used (must be 0)
  3605                              <1> 	;			
  3606                              <1> 	;	     if bit 0 = 0 and bit 5 = 0
  3607                              <1> 	;		Return:	EAX = VideoStateID (>0)	
  3608                              <1> 	;	     if bit 0 = 1
  3609                              <1> 	;		ECX = VideoStateID (bit 5 = 0)
  3610                              <1> 	;		Return: EAX = restore (transfer) size
  3611                              <1> 	;	     if bit 5 = 1
  3612                              <1> 	;		ECX = Buffer address
  3613                              <1> 	;		Return: EAX = transfer count (size)
  3614                              <1> 	;
  3615                              <1> 	;	     ECX = Buffer address or VideoStateID
  3616                              <1> 	;
  3617                              <1> 	;	  BL > 127 : invalid (not implemented)
  3618                              <1> 	;
  3619                              <1> 	;  Note: Required buffer size may be > 2048 bytes
  3620                              <1> 	;	 (function fails when buff size > 2048 bytes)
  3621                              <1> 	;	 proper option must be used
  3622                              <1> 	;
  3623                              <1> 	; 18/01/2021
  3624                              <1> 	; READ VESA EDID (EXTENDED DISPLAY IDENTIFICATION DATA)
  3625                              <1> 	;
  3626                              <1> 	;	BH = 15 = Read VESA EDID for connected monitor  
  3627                              <1> 	;		  (copy EDID to user)	
  3628                              <1> 	;
  3629                              <1> 	;	   BL = any
  3630                              <1> 	;
  3631                              <1> 	;	Input:
  3632                              <1> 	;	    ECX = user's (EDID) buffer address 
  3633                              <1> 	;		 (buffer size: 128 bytes)
  3634                              <1> 	;	Output:
  3635                              <1> 	;	    EAX = 128 (EDID size)
  3636                              <1> 	;	    or EAX = 0 -> Error!
  3637                              <1> 	;	       (EDID not ready or buffer addr error)	
  3638                              <1> 	;
  3639                              <1>  	
  3640                              <1> 	; 16/05/2016
  3641 0000D5C7 31C0                <1> 	xor	eax, eax
  3642 0000D5C9 A3[1C010300]        <1> 	mov	[u.r0], eax
  3643 0000D5CE 20FF                <1> 	and	bh, bh
  3644                              <1> 	;jnz	sysvideo_13 ; 11/07/2016
  3645                              <1> 	; 23/07/2022
  3646 0000D5D0 7405                <1> 	jz	short sysvideo_40
  3647 0000D5D2 E974020000          <1> 	jmp	sysvideo_13
  3648                              <1> 
  3649                              <1> sysvideo_40:	; 23/07/2022
  3650                              <1> 	;; 21/11/2020 (TRDOS 386 v2.0.3)
  3651                              <1> 	;; tty/text mode transfers are only for video mode 3
  3652                              <1> 
  3653                              <1> 	; 22/11/2020
  3654                              <1> 	;cmp	byte [CRT_MODE], 3 ; 80x25 text, 16 colors
  3655                              <1> 	;jne	sysret ; invalid (nothing to do), [u.r0] = 0	
  3656                              <1> 	
  3657                              <1> 	; 23/11/2020
  3658                              <1> 	; bit 7,6,5,4 of BL are reserved and it must be 0
  3659                              <1> 	;	 	 for current 'sysvideo' version
  3660                              <1> 	;test	bl, 0F0h
  3661                              <1> 	;;jnz	sysret ; invalid (undefined) ! 
  3662                              <1> 	;; 28/01/2021
  3663                              <1> 	;jnz	short sysvideo_1_2 ; invalid (undefined) !
  3664                              <1> 	; 28/01/2021
  3665 0000D5D7 80FB07              <1> 	cmp	bl, 7
  3666 0000D5DA 776E                <1> 	ja	short sysvideo_1_2 ; invalid (undefined) !	
  3667                              <1> 
  3668                              <1> 	; Video mode 0, 80*25 text mode, CGA 16 colors  
  3669                              <1> 	; [CRT_MODE] = 3
  3670                              <1> 	;mov	bh, bl
  3671                              <1> 	;shr	bh, 2 ; 4..7 -> 1, 8..11 -> 2, 12..15 -> 3
  3672                              <1> 	;; 21/11/2020
  3673                              <1> 	;;and	bh, bh
  3674                              <1>         ;jnz	sysvideo_4  ; Display page window transfer etc.
  3675                              <1> 
  3676                              <1> 	; 28/01/2021
  3677 0000D5DC F6C304              <1> 	test	bl, 4 ; bit 2
  3678                              <1> 	;jnz	sysvideo_4 ; Display page window transfer
  3679                              <1> 	; 23/07/2022
  3680 0000D5DF 7405                <1> 	jz	short sysvideo_41
  3681 0000D5E1 E9A1000000          <1> 	jmp	sysvideo_4
  3682                              <1> sysvideo_41:	; 23/07/2022
  3683                              <1> 	; Display page (complete) transfer
  3684 0000D5E6 80FA07              <1> 	cmp	dl, 7
  3685                              <1> 	;jnz	sysret ; invalid (nothing to do), [u.r0] = 0
  3686 0000D5E9 760A                <1> 	jna	short sysvideo_0 ; 28/01/2021	
  3687 0000D5EB FEC2                <1> 	inc	dl ; 0FFh -> 0 ("use current video page")
  3688 0000D5ED 755B                <1> 	jnz	short sysvideo_1_2  ; invalid
  3689                              <1> 	; dl = 0 -> use current current page
  3690 0000D5EF 8A15[B6770100]      <1> 	mov	dl, [ACTIVE_PAGE]
  3691                              <1> sysvideo_0:
  3692                              <1> 	; 28/01/2021 
  3693 0000D5F5 80FB03              <1> 	cmp	bl, 3
  3694 0000D5F8 7206                <1> 	jb	short sysvideo_0_0
  3695 0000D5FA 09FF                <1> 	or	edi, edi
  3696 0000D5FC 744C                <1> 	jz	short sysvideo_1_2  ; invalid
  3697 0000D5FE 89FE                <1> 	mov	esi, edi ; save swap/exchange buffer addr
  3698                              <1> 	; ecx = user buffer for new video page content
  3699                              <1> 	; esi = user (swap) buffer for saving current video page  
  3700                              <1> sysvideo_0_0:
  3701 0000D600 BF00800B00          <1> 	mov	edi, 0B8000h
  3702                              <1> 	; dl = display page number, destination
  3703 0000D605 66B80010            <1> 	mov	ax, 4096 ; 21/11/2020
  3704 0000D609 20D2                <1> 	and	dl, dl
  3705 0000D60B 7408                <1> 	jz	short sysvideo_1
  3706                              <1> 	; 07/02/2021
  3707 0000D60D 88D6                <1> 	mov	dh, dl
  3708                              <1> sysvideo_0_1:
  3709                              <1> 	; page length = 4096 bytes (but page content is 80*25*2 bytes)
  3710 0000D60F 01C7                <1> 	add	edi, eax ; 21//11/2020 ([CRT_LEN] = 1000h for mode 3)
  3711 0000D611 FECE                <1> 	dec	dh
  3712 0000D613 75FA                <1> 	jnz	short sysvideo_0_1
  3713                              <1> sysvideo_1:	
  3714 0000D615 80E303              <1> 	and	bl, 3
  3715 0000D618 7535                <1> 	jnz	short sysvideo_2 ; user to system display page transfer
  3716                              <1> 	; system to system video page (content) transfer
  3717                              <1> 	; cl = display page number, source
  3718 0000D61A 80F907              <1> 	cmp	cl, 7
  3719                              <1> 	;ja	sysret ; invalid (nothing to do), [u.r0] = 0
  3720 0000D61D 760A                <1> 	jna	short sysvideo_1_0
  3721 0000D61F FEC1                <1> 	inc	cl ; 0FFh -> 0 ("use current video page")
  3722 0000D621 7527                <1> 	jnz	short sysvideo_1_2  ; invalid
  3723 0000D623 8A0D[B6770100]      <1> 	mov	cl, [ACTIVE_PAGE]
  3724                              <1> sysvideo_1_0:
  3725                              <1> 	; 28/01/2021
  3726 0000D629 38D1                <1> 	cmp	cl, dl
  3727 0000D62B 741D                <1> 	je	short sysvideo_1_2  ; same video page !
  3728                              <1> 
  3729                              <1> 	; system to system video/display page transfer (mode 0)
  3730                              <1> 	; 21/11/2020
  3731                              <1> 	;mov	esi, 0B8000h
  3732                              <1> 	;movzx	eax, cl
  3733                              <1> 	;mov	edx, 4096 ; [CRT_LEN] = 1000h for video mode 3
  3734                              <1> 	;mov	ecx, edx
  3735                              <1> 	;mul	edx
  3736                              <1> 	;add	esi, eax
  3737                              <1> 	; 28/01/2021
  3738                              <1> 	;movzx	esi, cl
  3739                              <1> 	;shl	si, 12 ; * 4096
  3740                              <1> 	;add	esi, 0B8000h 
  3741                              <1> 	
  3742                              <1> 	; 28/01/2021
  3743 0000D62D A3[1C010300]        <1> 	mov	[u.r0], eax ; 4096
  3744 0000D632 BE00800B00          <1> 	mov	esi, 0B8000h
  3745 0000D637 08C9                <1> 	or	cl, cl
  3746 0000D639 7409                <1> 	jz	short sysvideo_1_1
  3747                              <1> 	; 07/02/2021
  3748                              <1> 	;mov	al, cl ; display/video page
  3749                              <1> 	;xor	ah, ah
  3750                              <1> 	;shl	ax, 12 ; * 4096
  3751                              <1> 	; 23/07/2022
  3752 0000D63B 30C0                <1>  	xor	al, al
  3753                              <1> 	;xor	eax, eax
  3754 0000D63D 88CC                <1> 	mov	ah, cl ; CL * 256
  3755 0000D63F C1E004              <1> 	shl	eax, 4 ; * 16 = CL * 4096
  3756 0000D642 01C6                <1> 	add	esi, eax
  3757                              <1> sysvideo_1_1:
  3758                              <1> 	; 21/11/2020
  3759                              <1> 	;;mov	ecx, 4096
  3760                              <1> 	;mov	ecx, eax ; 4096
  3761                              <1> 	;;mov	[u.r0], ecx ; 4096 bytes
  3762                              <1> 	; 28/01/2021	
  3763                              <1> 	;mov	[u.r0], cx
  3764 0000D644 31C9                <1> 	xor	ecx, ecx
  3765 0000D646 B504                <1> 	mov	ch, 4 ; mov ecx, 1024
  3766                              <1> 	;shr	cx, 2 ; / 4
  3767 0000D648 F3A5                <1> 	rep	movsd
  3768                              <1> sysvideo_1_2:
  3769 0000D64A E9D0F6FFFF          <1> 	jmp	sysret
  3770                              <1> sysvideo_2:  
  3771 0000D64F 80FB02              <1> 	cmp	bl, 2
  3772                              <1>         ;ja	sysret; invalid (user to user), [u.r0] = 0
  3773                              <1> 	; 28/01/2021
  3774 0000D652 7226                <1> 	jb	short sysvideo_3 ; user to system
  3775 0000D654 7404                <1> 	je	short sysvideo_2_0 ; system to user
  3776                              <1> 	; bl = 3
  3777 0000D656 89CA                <1> 	mov	edx, ecx ; save user's buffer addr
  3778 0000D658 89F1                <1> 	mov	ecx, esi ; save swap address
  3779                              <1> sysvideo_2_0:
  3780                              <1> 	; bl = 2 (or bl = 3, stage 1)
  3781                              <1> 	; system to user video/display page transfer (mode 0)
  3782 0000D65A 89FE                <1> 	mov	esi, edi
  3783 0000D65C 89CF                <1> 	mov	edi, ecx ; user buffer ; 28/01/2021
  3784                              <1> 	; 21/11/2020
  3785 0000D65E 89C1                <1> 	mov	ecx, eax ; 4096
  3786 0000D660 E8F4360000          <1> 	call	transfer_to_user_buffer ; fast transfer
  3787                              <1> 	;jc	sysret ; [u.r0] = 0
  3788 0000D665 72E3                <1> 	jc	short sysvideo_1_2 ; 28/01/2021
  3789                              <1> 	; 28/01/2021
  3790 0000D667 80FB03              <1> 	cmp	bl, 3
  3791 0000D66A 7408                <1> 	je	short sysvideo_2_2
  3792                              <1> sysvideo_2_1:
  3793                              <1> 	; 21/11/2020
  3794 0000D66C 890D[1C010300]      <1> 	mov	[u.r0], ecx
  3795                              <1> 	;;mov	[u.r0], cx
  3796                              <1> 	;jmp	sysret
  3797 0000D672 EBD6                <1> 	jmp	short sysvideo_1_2
  3798                              <1> 
  3799                              <1> sysvideo_2_2:
  3800                              <1> 	; bl = 3 (exchange/swap) complete display page
  3801                              <1> 	; esi = video page start address
  3802                              <1> 	; edx = user's buffer address
  3803                              <1> 	
  3804                              <1> 	;mov	ecx, 4096
  3805 0000D674 89F7                <1> 	mov	edi, esi ; video page start address
  3806 0000D676 89D6                <1> 	mov	esi, edx ; user's (new page) buffer address
  3807 0000D678 EB04                <1> 	jmp	short sysvideo_2_3
  3808                              <1> sysvideo_3: 
  3809                              <1> 	; bl = 1 (or bl = 3, stage 2)
  3810                              <1> 	; user to system video/display page transfer (mode 0)	
  3811 0000D67A 89CE                <1> 	mov	esi, ecx ; user buffer
  3812                              <1> 	; edi = video page address
  3813                              <1> 	; 21/11/2020
  3814 0000D67C 89C1                <1> 	mov	ecx, eax ; 4096
  3815                              <1> sysvideo_2_3:
  3816 0000D67E E820370000          <1> 	call	transfer_from_user_buffer ; fast transfer
  3817                              <1> 	;jc	sysret ; [u.r0] = 0
  3818 0000D683 72C5                <1> 	jc	short sysvideo_1_2 ; 28/01/2021
  3819 0000D685 EBE5                <1> 	jmp	short sysvideo_2_1
  3820                              <1> 
  3821                              <1> 	; 21/11/2020
  3822                              <1> 	;mov	[u.r0], ecx
  3823                              <1> 	;;mov	[u.r0], cx
  3824                              <1> 	;;jmp	sysret
  3825                              <1> 	;jmp	short sysvideo_1_2 ; 28/01/2021
  3826                              <1> 
  3827                              <1> sysvideo_4:
  3828                              <1> 	; 23/07/2022
  3829                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
  3830                              <1> 
  3831                              <1> 	; Display page window transfer etc.
  3832 0000D687 80E303              <1> 	and	bl, 3
  3833                              <1>         ;jnz	sysvideo_9 ; user to system or system to user
  3834                              <1> 	; 23/07/2022
  3835 0000D68A 7405                <1> 	jz	short sysvideo_4_0
  3836 0000D68C E9E3000000          <1> 	jmp	sysvideo_9
  3837                              <1> sysvideo_4_0:
  3838                              <1> 	; 21/11/2020
  3839                              <1> 	; system to system video/display page window transfer (mode 0)
  3840 0000D691 81FE00800B00        <1> 	cmp	esi, 0B8000h	; source buffer address (system)
  3841                              <1> 	;jb	sysret
  3842                              <1> 	; 23/07/2022
  3843 0000D697 7245                <1> 	jb	short sysvideo_4_3  ; jmp sysret
  3844 0000D699 81FE00000C00        <1> 	cmp	esi, 0B8000h+(4096*8)
  3845                              <1> 	; 23/07/2022
  3846                              <1> 	;jnb	sysret
  3847 0000D69F 733D                <1> 	jnb	short sysvideo_4_3  ; jmp sysret
  3848 0000D6A1 81FF00800B00        <1> 	cmp	edi, 0B8000h	; destination buffer address (system)	
  3849                              <1> 	;jb	sysret
  3850                              <1> 	; 23/07/2022
  3851 0000D6A7 7235                <1> 	jb	short sysvideo_4_3  ; jmp sysret
  3852 0000D6A9 81FF00000C00        <1>         cmp     edi, 0B8000h+(4096*8)
  3853                              <1> 	; 23/07/2022
  3854                              <1> 	;jnb	sysret
  3855 0000D6AF 732D                <1> 	jnb	short sysvideo_4_3  ; jmp sysret
  3856                              <1> 	;
  3857 0000D6B1 51                  <1> 	push	ecx ; X1 and Y1 position - top left column, row
  3858 0000D6B2 0FB7C1              <1> 	movzx	eax, cx ; top left column
  3859                              <1> 	; 21/11/2020
  3860 0000D6B5 C1E910              <1> 	shr	ecx, 16 ; top row
  3861 0000D6B8 740E                <1> 	jz	short sysvideo_4_1 ; bypass following code
  3862 0000D6BA 52                  <1> 	push	edx ; X2 and Y2 position - bottom right column, row
  3863 0000D6BB 50                  <1> 	push	eax
  3864 0000D6BC 66B8A000            <1> 	mov	ax, 80*2 ; 80 colums, 160 bytes per row
  3865 0000D6C0 F7E1                <1> 	mul	ecx
  3866                              <1> 		; eax = offset for start row number 
  3867 0000D6C2 01C6                <1> 	add	esi, eax
  3868 0000D6C4 01C7                <1> 	add	edi, eax
  3869 0000D6C6 58                  <1> 	pop	eax
  3870 0000D6C7 5A                  <1> 	pop	edx
  3871                              <1> sysvideo_4_1:
  3872                              <1> 	;shl	ax, 1 ; * 2 ; convert start column number to offset
  3873                              <1> 	; 23/07/2022
  3874 0000D6C8 D1E0                <1> 	shl	eax, 1
  3875 0000D6CA 7404                <1> 	jz	short sysvideo_4_2	
  3876 0000D6CC 01C6                <1> 	add	esi, eax
  3877 0000D6CE 01C7                <1> 	add	edi, eax
  3878                              <1> 		; esi = source page window start offset
  3879                              <1> 		; edi = destination page window start offset
  3880                              <1> sysvideo_4_2:
  3881 0000D6D0 59                  <1> 	pop	ecx
  3882                              <1> 	;mov	eax, 0B8000h+(80*25*2*8)
  3883                              <1> 	; 21/11/2020
  3884 0000D6D1 B800000C00          <1> 	mov	eax, 0B8000h+(4096*8)
  3885 0000D6D6 39C6                <1> 	cmp	esi, eax
  3886                              <1> 	;jnb	sysret ; out of video page
  3887                              <1> 	; 23/07/2022
  3888 0000D6D8 7304                <1> 	jnb	short sysvideo_4_3  ; jmp sysret
  3889 0000D6DA 39C6                <1> 	cmp	esi, eax
  3890                              <1> 	;jnb	sysret  ;out of video page
  3891                              <1> 	; 23/07/2022
  3892 0000D6DC 7205                <1> 	jb	short sysvideo_4_4
  3893                              <1> sysvideo_4_3:
  3894 0000D6DE E93CF6FFFF          <1> 	jmp	sysret
  3895                              <1> sysvideo_4_4:
  3896 0000D6E3 56                  <1> 	push	esi ; ****
  3897 0000D6E4 57                  <1> 	push	edi ; ***
  3898 0000D6E5 52                  <1> 	push	edx ; **
  3899 0000D6E6 51                  <1> 	push	ecx ; *
  3900 0000D6E7 C1E910              <1> 	shr	ecx, 16 ; top row
  3901 0000D6EA C1EA10              <1> 	shr	edx, 16 ; bottom row
  3902                              <1> 	; 21/11/2020
  3903                              <1> 	;cmp	ecx, 24 ; max. 25 rows
  3904 0000D6ED 6683F918            <1> 	cmp	cx, 24
  3905 0000D6F1 7778                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0
  3906                              <1> 	;cmp	edx, 24 ; max. 25 rows
  3907 0000D6F3 6683FA18            <1> 	cmp	dx, 24
  3908 0000D6F7 7772                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0		
  3909 0000D6F9 28CA                <1> 	sub	dl, cl ; end >= start
  3910 0000D6FB 726E                <1> 	jc	short sysvideo_6 ; invalid, [u.r0] = 0
  3911                              <1> 	; 21/11/2020
  3912 0000D6FD 89D3                <1> 	mov	ebx, edx ; row count - 1
  3913 0000D6FF 7415                <1> 	jz	short sysvideo_4_5
  3914 0000D701 50                  <1> 	push	eax ; *****
  3915 0000D702 B8A0000000          <1> 	mov	eax, 80*2 ; bytes per row
  3916 0000D707 F7E3                <1> 	mul	ebx ; 21/11/2020
  3917                              <1> 		; eax = window end offset 
  3918                              <1> 		; (for the last row, before adding column bytes)
  3919 0000D709 01C6                <1> 	add	esi, eax
  3920 0000D70B 01C7                <1> 	add	edi, eax
  3921 0000D70D 58                  <1> 	pop	eax ; ***** ; mode 3 video memory end (0C000h)
  3922 0000D70E 39C6                <1> 	cmp	esi, eax
  3923                              <1> 	;ja	short sysvideo_6 ; invalid, [u.r0] = 0
  3924 0000D710 7359                <1> 	jnb	short sysvideo_6 ; 21/11/2020
  3925 0000D712 39C7                <1> 	cmp	edi, eax
  3926                              <1> 	;ja	short sysvideo_6 ; invalid, [u.r0] = 0
  3927 0000D714 7355                <1> 	jnb	short sysvideo_6 ; 21/11/2020
  3928                              <1> sysvideo_4_5:
  3929 0000D716 59                  <1> 	pop	ecx ; *
  3930 0000D717 5A                  <1> 	pop	edx ; **
  3931 0000D718 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
  3932 0000D71E 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  3933                              <1> 	; 21/11/2020
  3934                              <1> 	;cmp	ecx, 79 ; max. 80 columns
  3935 0000D724 6683F94F            <1> 	cmp	cx, 79
  3936 0000D728 7743                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  3937                              <1> 	;cmp	edx, 79 ; max. 80 columns
  3938 0000D72A 6683FA4F            <1> 	cmp	dx, 79 
  3939 0000D72E 773D                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  3940 0000D730 28CA                <1> 	sub	dl, cl
  3941 0000D732 7639                <1> 	jna	short sysvideo_7 ; invalid, [u.r0] = 0
  3942                              <1> 	; 21/11/2020
  3943 0000D734 740E                <1> 	jz	short sysvideo_4_6 
  3944                              <1> 	; edx = column count (width) - 1
  3945 0000D736 D0E2                <1> 	shl	dl, 1 ; * 2 ; byte offset (in end row)
  3946 0000D738 01D6                <1> 	add	esi, edx
  3947 0000D73A 01D7                <1> 	add	edi, edx
  3948                              <1> 		; esi = source page window end offset
  3949                              <1> 		; edi = destination page window end offset
  3950 0000D73C 39C6                <1> 	cmp	esi, eax ; video memory end
  3951                              <1> 	;ja	short sysvideo_7
  3952 0000D73E 732D                <1> 	jnb	short sysvideo_7 ; 21/11/2020
  3953 0000D740 39C7                <1> 	cmp	edi, eax ; video memory end
  3954                              <1> 	;ja	short sysvideo_7
  3955 0000D742 7329                <1> 	jnb	short sysvideo_7 ; 21/11/2020
  3956                              <1> sysvideo_4_6:
  3957 0000D744 5F                  <1> 	pop	edi ; ***
  3958 0000D745 5E                  <1> 	pop	esi ; ****
  3959 0000D746 FEC3                <1> 	inc	bl ; row count - 1 -> row count	
  3960 0000D748 FEC2                <1> 	inc	dl ; column count
  3961 0000D74A 88D7                <1> 	mov	bh, dl
  3962 0000D74C D0E2                <1> 	shl	dl, 1 ; convert column count to byte offset
  3963                              <1> 	; 21/11/2020
  3964                              <1> 	; esi = source page window start offset
  3965                              <1> 	; edi = destination page window start offset
  3966 0000D74E B8A0000000          <1> 	mov	eax, 80*2 ; bytes per row
  3967                              <1> 	; Note: 160 bytes per row (even if move count < 160)
  3968                              <1> sysvideo_5:	
  3969 0000D753 88F9                <1> 	mov	cl, bh ; move/transfer -word- count per row
  3970 0000D755 0115[1C010300]      <1> 	add	[u.r0], edx ; transfer count in bytes
  3971 0000D75B F366A5              <1> 	rep	movsw
  3972 0000D75E 01C6                <1> 	add	esi, eax ; + 160 bytes to next row
  3973 0000D760 01C7                <1> 	add	edi, eax ; + 160 bytes to next row
  3974 0000D762 FECB                <1> 	dec	bl ; remain count of rows
  3975 0000D764 75ED                <1> 	jnz	short sysvideo_5
  3976 0000D766 E9B4F5FFFF          <1> 	jmp	sysret
  3977                              <1> 
  3978                              <1> sysvideo_6:
  3979 0000D76B 59                  <1> 	pop	ecx ; *
  3980 0000D76C 5A                  <1> 	pop	edx ; **
  3981                              <1> sysvideo_7:	
  3982 0000D76D 5F                  <1> 	pop	edi ; ***
  3983 0000D76E 5E                  <1> 	pop	esi ; ****
  3984                              <1> sysvideo_8:
  3985 0000D76F E9ABF5FFFF          <1> 	jmp	sysret
  3986                              <1> 
  3987                              <1> sysvideo_9:
  3988                              <1> 	; user to system or system to user window transfer
  3989                              <1> 	; 28/01/2021 (bl = 3 -> swap/exchange)
  3990                              <1> 	;cmp	bl, 2
  3991                              <1> 	;;ja	sysret	; user to user transfer is invalid
  3992                              <1> 	;		; [u.r0] = 0
  3993                              <1> 	;ja	short sysvideo_8 ; 26/12/2020
  3994                              <1> 
  3995                              <1> 	; 28/01/2021
  3996 0000D774 80FB02              <1> 	cmp	bl, 2
  3997 0000D777 7604                <1> 	jna	short sysvideo_9_8 
  3998                              <1> 
  3999                              <1> 	; swap/ exchange video memory and user mem windows
  4000                              <1> 	; edi = swap address in user's memory space
  4001 0000D779 21FF                <1> 	and	edi, edi
  4002 0000D77B 74F2                <1> 	jz	short sysvideo_8 ; invalid ; 28/01/2021
  4003                              <1>  
  4004                              <1> sysvideo_9_8:		
  4005 0000D77D 56                  <1> 	push	esi ; ****
  4006 0000D77E 57                  <1> 	push	edi ; ***
  4007 0000D77F 52                  <1> 	push	edx ; **
  4008 0000D780 51                  <1> 	push	ecx ; *
  4009                              <1> 
  4010 0000D781 C1E910              <1> 	shr	ecx, 16 ; top row
  4011 0000D784 C1EA10              <1> 	shr	edx, 16 ; bottom row
  4012                              <1> 	
  4013                              <1> 	; 21/11/2020
  4014                              <1> 	;cmp	ecx, 24 ; max. 25 rows
  4015 0000D787 6683F918            <1> 	cmp	cx, 24
  4016 0000D78B 77DE                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0
  4017                              <1> 	;cmp	edx, 24 ; max. 25 rows
  4018 0000D78D 6683FA18            <1> 	cmp	dx, 24
  4019 0000D791 77D8                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0	
  4020 0000D793 28CA                <1> 	sub	dl, cl
  4021 0000D795 72D4                <1> 	jc	short sysvideo_6 ; invalid, [u.r0] = 0
  4022                              <1> 
  4023                              <1> 	;mov	ch, cl ; top row
  4024                              <1> 	;mov	cl, [ACTIVE_PAGE]
  4025                              <1> 
  4026                              <1> 	;mov	edi, 80*25*2 ; 4000
  4027                              <1> 	; 21/11/2020
  4028                              <1> 	;mov	edi, 4096 ; [CRT_LEN = 4096 for video mode 3 
  4029                              <1> 	;shl	edi, cl  ; ! wrong for page 2 to page 7 !
  4030                              <1> 	;;add	edi, 0B8000h - 80*25*2
  4031                              <1> 	;add	edi, 0B8000h - 1000h ; - 4096
  4032                              <1> 	
  4033                              <1> 	; 21/11/2020
  4034                              <1> 	;xor	eax, eax
  4035                              <1> 	;mov	edi, 0B8000h
  4036                              <1> 	;and	cl, cl ; is video page = 0 ?
  4037                              <1> 	;jz	short sysvideo_9_1 ; yes
  4038                              <1> 	; eax = 0
  4039                              <1> 
  4040                              <1> ;sysvideo_9_0:
  4041                              <1> 	;add	ax, 4096
  4042                              <1> 	;dec	cl
  4043                              <1> 	;jnz	short sysvideo_9_0
  4044                              <1> 	;add	edi, eax
  4045                              <1> 	;	; edi = video page start address
  4046                              <1> 
  4047                              <1> 	; 21/11/2020
  4048 0000D797 BF00800B00          <1> 	mov	edi, 0B8000h
  4049 0000D79C 803D[B6770100]00    <1> 	cmp	byte [ACTIVE_PAGE], 0
  4050 0000D7A3 760C                <1> 	jna	short sysvideo_9_1
  4051                              <1> stsvideo_9_0:
  4052 0000D7A5 B010                <1> 	mov	al, 16 ; 4096/256
  4053 0000D7A7 F625[B6770100]      <1> 	mul	byte [ACTIVE_PAGE] 
  4054 0000D7AD 86E0                <1> 	xchg	ah, al ; * 256
  4055 0000D7AF 01C7                <1> 	add	edi, eax
  4056                              <1> 		; edi = video page start address
  4057                              <1> sysvideo_9_1:
  4058                              <1> 	; bl = transfer direction 
  4059                              <1> 	;     (1 = from user, 2 = to user)
  4060                              <1> 	;     (3 = swap) ; 28/01/2021
  4061 0000D7B1 88D7                <1> 	mov	bh, dl ; row count - 1
  4062                              <1> 	;mov	dl, ch ; top row
  4063                              <1> 	; 21/11/2020
  4064 0000D7B3 08C9                <1> 	or	cl, cl ; top row number
  4065 0000D7B5 7408                <1> 	jz	short sysvideo_9_2
  4066                              <1> 
  4067                              <1> 	;mov	eax, 80*2
  4068 0000D7B7 66B8A000            <1> 	mov	ax, 80*2 ; 160, bytes per row
  4069 0000D7BB F7E1                <1> 	mul	ecx ; 22/11/2020
  4070 0000D7BD 01C7                <1> 	add	edi, eax
  4071                              <1> 		; edi = window start address for top row
  4072                              <1> sysvideo_9_2:
  4073 0000D7BF 59                  <1> 	pop	ecx ; *
  4074 0000D7C0 5A                  <1> 	pop	edx ; **
  4075 0000D7C1 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
  4076 0000D7C7 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  4077                              <1> 	; 21/11/2020
  4078                              <1> 	;cmp	ecx, 79 ; max. 80 columns
  4079 0000D7CD 6683F94F            <1> 	cmp	cx, 79
  4080 0000D7D1 779A                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  4081                              <1> 	;cmp	edx, 79 ; max. 80 columns
  4082 0000D7D3 6683FA4F            <1> 	cmp	dx, 79
  4083 0000D7D7 7794                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  4084                              <1> 	
  4085 0000D7D9 28CA                <1> 	sub	dl, cl
  4086 0000D7DB 7290                <1> 	jc	short sysvideo_7 ; invalid, [u.r0] = 0
  4087                              <1> 	
  4088 0000D7DD 08C9                <1> 	or	cl, cl ; left column 
  4089 0000D7DF 7404                <1> 	jz	short sysvideo_9_3 ; 0
  4090                              <1> 
  4091                              <1> 	; 21/11/2020
  4092 0000D7E1 D0E1                <1> 	shl	cl, 1  ; column * 2
  4093 0000D7E3 01CF                <1> 	add	edi, ecx
  4094                              <1> 		; edi = window start addr for top left column
  4095                              <1> sysvideo_9_3:
  4096 0000D7E5 88D1                <1> 	mov	cl, dl
  4097 0000D7E7 FEC1                <1> 	inc	cl ; column count
  4098 0000D7E9 D0E1                <1> 	shl	cl, 1 ; column count * 2
  4099                              <1> 		; ecx = transfer count per row
  4100                              <1> 
  4101 0000D7EB 58                  <1> 	pop	eax ; *** (swap address)
  4102 0000D7EC 5E                  <1> 	pop	esi ; ****
  4103                              <1> 
  4104 0000D7ED FEC7                <1> 	inc	bh  ; row count	
  4105                              <1> 	
  4106                              <1> 	;mov	edx, 80*2
  4107 0000D7EF B2A0                <1> 	mov	dl, 80*2  ; bytes per row
  4108                              <1> 	;
  4109                              <1> 	;cmp	bl, 1 ; transfer direction
  4110                              <1> 	;ja	short sysvideo_11 ; system to user transfer
  4111                              <1> 	; 28/01/2021
  4112 0000D7F1 F6C301              <1> 	test	bl, 1
  4113 0000D7F4 7439                <1> 	jz	short sysvideo_11 ; system to user transfer
  4114                              <1> 
  4115                              <1> 	; user to system video/display page window transfer (mode 0)	
  4116 0000D7F6 21C0                <1> 	and	eax, eax ; swap address
  4117 0000D7F8 741B                <1> 	jz	short sysvideo_10 ; no window swap
  4118                              <1> sysvideo_9_7: ; 28/01/2021
  4119                              <1> 	; save previous window content in user's buffer (swap address)
  4120 0000D7FA 56                  <1> 	push	esi ; user buffer
  4121 0000D7FB 57                  <1> 	push	edi ; beginning address of the window
  4122                              <1> 	; 21/11/2020
  4123 0000D7FC 53                  <1> 	push	ebx ; save bh
  4124 0000D7FD 89FE                <1> 	mov	esi, edi
  4125 0000D7FF 89C7                <1> 	mov	edi, eax
  4126                              <1> sysvideo_9_4:
  4127 0000D801 E853350000          <1> 	call	transfer_to_user_buffer ; fast transfer
  4128 0000D806 7208                <1> 	jc	short sysvideo_9_5
  4129                              <1> 	; ecx = actual transfer count (must be same with input)
  4130 0000D808 01D6                <1> 	add	esi, edx ; next row address of (video page) window 
  4131 0000D80A 01CF                <1> 	add	edi, ecx ; next row address of user's window
  4132                              <1> 		; Note: ecx may be less than row length of video page
  4133                              <1> 		; user's window uses offset according to window width
  4134 0000D80C FECF                <1> 	dec	bh
  4135 0000D80E 75F1                <1> 	jnz	short sysvideo_9_4 ; repeat for next row
  4136                              <1> sysvideo_9_5:
  4137 0000D810 5B                  <1> 	pop	ebx ; restore bh
  4138 0000D811 5F                  <1> 	pop	edi
  4139 0000D812 5E                  <1> 	pop	esi
  4140                              <1> 	;jnc	short sysvideo_10
  4141 0000D813 7215                <1> 	jc	short sysvideo_9_6 ; 28/01/2021
  4142                              <1> ;sysvideo_9_6:
  4143                              <1> ;	jmp	sysret ; [u.r0] = 0
  4144                              <1> 
  4145                              <1> sysvideo_10:
  4146                              <1> 	; user to system video/display page window transfer (mode 0)	
  4147                              <1> 	; esi =	user buffer
  4148 0000D815 E889350000          <1> 	call	transfer_from_user_buffer ; fast transfer
  4149                              <1> 	;jc	sysret
  4150 0000D81A 720E                <1> 	jc	short sysvideo_9_6 ; 28/01/2021
  4151                              <1> 	; ecx = actual transfer count (must be same with input)
  4152 0000D81C 010D[1C010300]      <1> 	add	[u.r0], ecx ; actual transfer count
  4153 0000D822 01D7                <1> 	add	edi, edx ; next row address of (video page) window 
  4154 0000D824 01CE                <1> 	add	esi, ecx ; next row address of user's window
  4155                              <1> 		; Note: ecx may be less than row length of video page
  4156                              <1> 		; user's window uses offset according to window width
  4157 0000D826 FECF                <1> 	dec	bh
  4158 0000D828 75EB                <1> 	jnz	short sysvideo_10 ; repeat for next row
  4159                              <1> 	;jmp	sysret
  4160                              <1> sysvideo_9_6:
  4161 0000D82A E9F0F4FFFF          <1> 	jmp	sysret
  4162                              <1> 	
  4163                              <1> sysvideo_11:
  4164                              <1> 	; system to user video/display page window transfer (mode 0)
  4165 0000D82F 87FE                <1> 	xchg	edi, esi
  4166                              <1> sysvideo_12:
  4167                              <1> 	; esi = beginning addr of the (screen, video page) window
  4168                              <1> 	; edi =	user's buffer	
  4169 0000D831 E823350000          <1> 	call	transfer_to_user_buffer ; fast transfer
  4170                              <1> 	;jc	sysret
  4171                              <1> 	; 23/07/2022
  4172 0000D836 72F2                <1> 	jc	short sysvideo_9_6 ; jmp sysret	
  4173                              <1> 
  4174                              <1> 	; ecx = actual transfer count (must be same with input)
  4175 0000D838 010D[1C010300]      <1> 	add	[u.r0], ecx
  4176 0000D83E 01D6                <1> 	add	esi, edx ; next row (edx = 160)
  4177 0000D840 01CF                <1> 	add	edi, ecx ; next row of the user's window 
  4178                              <1> 			 ; (ecx <= 160)
  4179 0000D842 FECF                <1> 	dec	bh
  4180 0000D844 75EB                <1> 	jnz	short sysvideo_12
  4181                              <1> sysvideo_12_0:
  4182 0000D846 E9D4F4FFFF          <1> 	jmp	sysret
  4183                              <1> 
  4184                              <1> sysvideo_13:
  4185                              <1> 	; 28/12/2020
  4186 0000D84B 80FF01              <1> 	cmp	bh, 1
  4187 0000D84E 7752                <1>         ja      short sysvideo_15 ; 23/11/2020
  4188                              <1> 
  4189                              <1> 	; 25/02/2021
  4190                              <1> 	; 12/02/2021
  4191                              <1> 	; 29/01/2021, 31/01/2021
  4192                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
  4193                              <1> 	; (major modification, from mode 13h to all VGA modes,
  4194                              <1> 	;  except super VGA modes and liner frame buffer method)
  4195                              <1> 
  4196                              <1> 	; BH = 1 = VGA Graphics mode (0A0000h) data transfers
  4197                              <1> 
  4198                              <1> 	; 29/01/2021
  4199 0000D850 66B84001            <1> 	mov	ax, 320	; 320 pixels
  4200 0000D854 F6C380              <1> 	test	bl, 80h	; bit 7 (screen width, 640 pixels)		
  4201 0000D857 7407                <1> 	jz	short sysvideo_13_0
  4202                              <1> 	;shl	ax, 1	; 640 pixels
  4203                              <1> 	; 23/07/2022
  4204 0000D859 D1E0                <1> 	shl	eax, 1
  4205                              <1> 	;
  4206 0000D85B 80E37F              <1> 	and	bl, 7Fh
  4207 0000D85E 7405                <1> 	jz	short sysvideo_14
  4208                              <1> sysvideo_13_0:
  4209                              <1> 	; 29/01/2021
  4210 0000D860 80FB41              <1> 	cmp	bl, 41h
  4211 0000D863 77E1                <1> 	ja	short sysvideo_12_0 ; invalid (unknown) sub function
  4212                              <1> sysvideo_14:
  4213 0000D865 66A3[3A100300]      <1> 	mov	[v_width], ax	; save screen width
  4214 0000D86B C705[3E100300]0000- <1> 	mov	dword [v_mem], 0A0000h  ; save video memory address
  4214 0000D873 0A00                <1>
  4215 0000D875 C705[42100300]0000- <1> 	mov	dword [v_siz], 65536	; save video memory size
  4215 0000D87D 0100                <1>
  4216 0000D87F C705[4A100300]0000- <1> 	mov	dword [v_end], 0B0000h	; save end of video page
  4216 0000D887 0B00                <1>
  4217 0000D889 B708                <1> 	mov	bh, 8
  4218 0000D88B 883D[3D100300]      <1> 	mov	[v_bpp], bh ; 8	; bits per pixel (256 colors)
  4219 0000D891 881D[3C100300]      <1> 	mov	[v_ops], bl	; VGA data transfer options
  4220                              <1> 	;mov	[maskbuff], edi ; 25/02/2021 
  4221 0000D897 893D[4E100300]      <1> 	mov	[maskcolor], edi ; 25/02/2021
  4222                              <1> 			; save mask color or bitmask buffer address
  4223 0000D89D E9BE000000          <1> 	jmp	sysvideo_15_7
  4224                              <1> 
  4225                              <1> sysvideo_15:
  4226                              <1> 	; 23/07/2022
  4227                              <1> 	; 28/12/2020
  4228 0000D8A2 80FF02              <1> 	cmp	bh, 2
  4229                              <1>         ;ja	sysvideo_16
  4230                              <1> 	; 23/07/2022
  4231 0000D8A5 7605                <1> 	jna	short sysvideo_15_17
  4232 0000D8A7 E9ED1E0000          <1> 	jmp	sysvideo_16
  4233                              <1> sysvideo_15_17:	; 23/07/2022
  4234                              <1> 	; 25/02/2021
  4235                              <1> 	; 12/02/2021
  4236                              <1> 	; 30/01/2021 - 31/01/2021
  4237                              <1> 	; 01/01/2021 - 29/01/2021
  4238                              <1> 	; 26/12/2020 - 27/12/2020
  4239                              <1> 	; 25/12/2020 (TRDOS 386 v2.0.3)
  4240                              <1> 	;
  4241                              <1> 	; BH = 2 = SVGA (VESA VBE) Graphics mode (LFB) data transfers
  4242                              <1> 
  4243                              <1> 	; 25/12/2020
  4244                              <1> 	; resolution table entry will be saved into EBP register
  4245                              <1> 
  4246 0000D8AC 803D[79090000]02    <1> 	cmp	byte [vbe3], 2 ; VESA VBE 3 video bios 
  4247                              <1> 			  ; or BOCHS/QEMU/VIRTUALBOX emu video bios
  4248 0000D8B3 724E                <1> 	jb	short sysvideo_15_4 ; no, nothing to do !
  4249 0000D8B5 770B                <1> 	ja	short sysvideo_15_0 ; yes
  4250                              <1> 
  4251                              <1> 	; Only Bochs/Plex86 (emu) vbe2 video bios is usable in pmid
  4252                              <1> 	; (if [vbe3] = 2) 
  4253 0000D8B7 A0[7A090000]        <1> 	mov	al, [vbe2bios] ; Bochs vbios sign is from C0h to C5h
  4254 0000D8BC 24F0                <1> 	and	al, 0F0h
  4255 0000D8BE 3CC0                <1> 	cmp	al, 0C0h
  4256 0000D8C0 7541                <1> 	jne	short sysvideo_15_4 ; unknown (vbe2) video bios
  4257                              <1> sysvideo_15_0:
  4258                              <1> 	; 29/01/2021
  4259 0000D8C2 80FB41              <1> 	cmp	bl, 41h
  4260 0000D8C5 773C                <1> 	ja	short sysvideo_15_4 ; invalid (unknown) sub function
  4261                              <1> 	; 29/01/2021
  4262 0000D8C7 881D[3C100300]      <1> 	mov	[v_ops], bl	; SVGA data transfer options
  4263                              <1> 
  4264 0000D8CD 89D8                <1> 	mov	eax, ebx ; hw of ebx is vesa vbe video mode
  4265 0000D8CF C1E810              <1> 	shr	eax, 16 ; ax = vesa vbe video mode
  4266 0000D8D2 7513                <1> 	jnz	short sysvideo_15_2 
  4267                              <1> 	; ax = 0
  4268                              <1> 
  4269                              <1> 	; check & use current video mode
  4270 0000D8D4 803D[CE660000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; extended (SVGA) mode ?
  4271 0000D8DB 7526                <1> 	jne	short sysvideo_15_4 ; no
  4272                              <1> sysvideo_15_1:
  4273                              <1> 	; use current vbe (svga) video mode
  4274 0000D8DD 66A1[D20F0300]      <1> 	mov	ax, [video_mode] ; extended (SVGA, VESA VBE) mode
  4275 0000D8E3 6625FF01            <1> 	and	ax, 1FFh ; vesa vbe video mode: 1XXh
  4276                              <1> sysvideo_15_2:
  4277                              <1> 	; 29/01/2021
  4278                              <1> 	;mov	[maskbuff], edi ; 25/02/2021
  4279 0000D8E7 893D[4E100300]      <1> 	mov	[maskcolor], edi ; 25/02/2021
  4280                              <1> 			; save mask color or bitmask buffer address
  4281 0000D8ED BD[5A6A0000]        <1> 	mov	ebp, b_vbe_modes ; vbe mode table (in 'vidata.s')
  4282                              <1> sysvideo_15_3:
  4283 0000D8F2 663B4500            <1> 	cmp	ax, [ebp]
  4284 0000D8F6 7410                <1> 	je	short sysvideo_15_5
  4285 0000D8F8 83C508              <1> 	add	ebp, 8 ; vbe mode table entry size
  4286 0000D8FB 81FD[1A6B0000]      <1> 	cmp	ebp, end_of_b_vbe_modes
  4287 0000D901 72EF                <1>  	jb	short sysvideo_15_3	
  4288                              <1> sysvideo_15_4:
  4289                              <1> 	; desired video mode is not a valid (implemented)
  4290                              <1> 	;	  extended (VESA VBE, SVGA) video mode
  4291                              <1> 	;
  4292                              <1> 	; nothing to do !
  4293                              <1> 
  4294                              <1>  	; [u.r0] = 0  ; return value of EAX
  4295 0000D903 E917F4FFFF          <1>  	jmp	sysret
  4296                              <1> 
  4297                              <1> sysvideo_15_5:
  4298                              <1> 	; get LFB address
  4299 0000D908 A1[E00F0300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
  4300 0000D90D 09C0                <1> 	or	eax, eax
  4301 0000D90F 7509                <1> 	jnz	short sysvideo_15_6
  4302 0000D911 66A1[060F0000]      <1> 	mov	ax, [def_LFB_addr] ; default LFB addr 
  4303                              <1> 				   ; (for vbe mode 118h)
  4304 0000D917 C1E010              <1> 	shl	eax, 16
  4305                              <1> 	; 27/12/2020
  4306                              <1> 	;jz	short sysvideo_15_4
  4307                              <1> sysvideo_15_6:
  4308                              <1> 	; 29/01/2021
  4309 0000D91A A3[3E100300]        <1> 	mov	[v_mem], eax ; save video memory address
  4310                              <1> 	
  4311                              <1> 	; 27/12/2020
  4312                              <1> 	; 26/12/2020
  4313 0000D91F 8B4502              <1> 	mov	eax, [ebp+2] ; width, height
  4314                              <1> 	; 29/01/2021
  4315 0000D922 66A3[3A100300]      <1> 	mov	[v_width], ax ; save screen width
  4316                              <1> 	; 28/12/2020
  4317 0000D928 8A7D06              <1> 	mov	bh, [ebp+6] ; bpp
  4318                              <1> 	; 28/02/2021
  4319                              <1> 	; check default truecolor bpp value and use
  4320                              <1> 	; 32bpp instead of 24bpp if the default value
  4321                              <1> 	; has been set to 32bpp.
  4322 0000D92B 80FF18              <1> 	cmp	bh, 24
  4323 0000D92E 750B                <1> 	jne	short sysvideo_15_16
  4324 0000D930 803D[4F740100]20    <1> 	cmp	byte [truecolor], 32
  4325                              <1> 		; Default truecolor bpp value,
  4326                              <1> 		; it is 32 for VBE3 video bios
  4327                              <1> 		; (it can be set to 32 or 24)
  4328 0000D937 7502                <1> 	jne	short sysvideo_15_16 ; not VBE3 !
  4329                              <1> 				; or it is set to 24  	
  4330 0000D939 B720                <1> 	mov	bh, 32
  4331                              <1> 	; 28/02/2021
  4332                              <1> sysvideo_15_16:
  4333                              <1> 	; 29/01/2021
  4334 0000D93B 883D[3D100300]      <1> 	mov	[v_bpp], bh ; bits per pixel
  4335                              <1> 
  4336 0000D941 52                  <1> 	push	edx ; *
  4337 0000D942 0FB7D0              <1> 	movzx	edx, ax  ; width
  4338 0000D945 C1E810              <1> 	shr	eax, 16  ; height
  4339 0000D948 F7E2                <1> 	mul	edx
  4340                              <1> 	; eax = linear frame buffer size (pixels)
  4341                              <1> 	; 29/01/2021
  4342 0000D94A A3[42100300]        <1> 	mov	[v_siz], eax ; save video page size
  4343 0000D94F E8FD000000          <1> 	call	pixels_to_byte_count
  4344 0000D954 0305[3E100300]      <1> 	add	eax, [v_mem]
  4345 0000D95A A3[4A100300]        <1> 	mov	[v_end], eax ; save end of video page 
  4346 0000D95F 5A                  <1> 	pop	edx ; *
  4347                              <1> 
  4348                              <1> 	; bh = bits per pixel
  4349                              <1> 	; (bh will not be used after here, 29/01/2021)
  4350                              <1> 
  4351                              <1> 	; bl = pixel operations & options
  4352                              <1> 	; ecx, edx, esi, edi input parameters
  4353                              <1> 	; [maskcolor] = edi input ; 25/02/2021
  4354                              <1> 
  4355                              <1> sysvideo_15_7:
  4356                              <1> 	; 29/01/2021
  4357                              <1> 	;test	byte [v_ops], 40h  ; system to user ?
  4358 0000D960 F6C340              <1> 	test	bl, 40h
  4359 0000D963 7517                <1> 	jnz	short sysvideo_15_9
  4360                              <1> 
  4361 0000D965 31C0                <1> 	xor	eax, eax
  4362 0000D967 88D8                <1> 	mov	al, bl
  4363 0000D969 BB[8FDA0000]        <1> 	mov	ebx, pixel_ops
  4364 0000D96E 240F                <1> 	and	al, 0Fh ; isolate 16 pixel operations
  4365 0000D970 C0E002              <1> 	shl	al, 2 ; * 4 for dword table pointers 
  4366 0000D973 01C3                <1> 	add	ebx, eax
  4367                              <1> 
  4368                              <1> 	; ebx = subroutine address
  4369                              <1> 
  4370                              <1> 	; ecx, edx, esi, edi input parameters
  4371                              <1> 	; [maskbuff] = edi input
  4372                              <1> 	; [maskcolor] = edi input ; 25/02/2021
  4373                              <1> 
  4374 0000D975 FF13                <1> 	call	[ebx]		
  4375                              <1> sysvideo_15_8:
  4376 0000D977 E9A3F3FFFF          <1> 	jmp	sysret
  4377                              <1> 
  4378                              <1> sysvideo_15_9:
  4379                              <1> 	; system to user display page or window copy
  4380                              <1> 	;test	byte [v_ops], 1 ; window copy ?
  4381 0000D97C F6C301              <1> 	test	bl, 1	
  4382 0000D97F 7521                <1> 	jnz	short sysvideo_15_10
  4383                              <1> 
  4384                              <1> 	; display page (full screen copy)
  4385 0000D981 8B35[3E100300]      <1> 	mov	esi, [v_mem] ; LFB start address
  4386 0000D987 A1[42100300]        <1> 	mov	eax, [v_siz]
  4387 0000D98C E8C0000000          <1> 	call	pixels_to_byte_count
  4388 0000D991 89C1                <1> 	mov	ecx, eax ; transfer count in bytes
  4389                              <1> 	;edi = user's buffer address
  4390 0000D993 E8C1330000          <1> 	call	transfer_to_user_buffer
  4391 0000D998 72DD                <1> 	jc	short sysvideo_15_8	
  4392 0000D99A 890D[1C010300]      <1> 	mov	[u.r0], ecx
  4393 0000D9A0 EBD5                <1> 	jmp	short sysvideo_15_8
  4394                              <1> 
  4395                              <1> sysvideo_15_10:
  4396 0000D9A2 E820000000          <1> 	call	sysvideo_15_12 ; window preparations
  4397 0000D9A7 72CE                <1> 	jc	short sysvideo_15_8
  4398                              <1> 
  4399 0000D9A9 8B35[46100300]      <1> 	mov	esi, [v_str]
  4400                              <1> sysvideo_15_11:
  4401                              <1> 	; esi = window's current row address (video mem)
  4402                              <1> 	; edi = current row (virtual) addr in user's buff
  4403                              <1> 	; ecx = transfer count per row
  4404 0000D9AF E8A5330000          <1> 	call	transfer_to_user_buffer
  4405 0000D9B4 72C1                <1> 	jc	short sysvideo_15_8
  4406 0000D9B6 010D[1C010300]      <1>  	add	[u.r0], ecx
  4407 0000D9BC 4B                  <1> 	dec	ebx
  4408 0000D9BD 74B8                <1> 	jz	short sysvideo_15_8 ; ok.
  4409                              <1> 	; next row
  4410 0000D9BF 01CF                <1> 	add	edi, ecx ; next row in user's buffer
  4411 0000D9C1 01D6                <1> 	add	esi, edx ; next row of window (system)
  4412 0000D9C3 EBEA                <1> 	jmp	short sysvideo_15_11
  4413                              <1> 
  4414                              <1> sysvideo_15_14:
  4415 0000D9C5 F9                  <1> 	stc	 ; error !
  4416                              <1> sysvideo_15_15:
  4417 0000D9C6 C3                  <1> 	retn
  4418                              <1> 
  4419                              <1> sysvideo_15_12:
  4420                              <1> 	; 30/01/2021
  4421                              <1> 	; 29/01/2021
  4422                              <1> 	; Window address preparations for window copy
  4423 0000D9C7 6621D2              <1> 	and	dx, dx
  4424 0000D9CA 74F9                <1> 	jz	short sysvideo_15_14 ; invalid (zero columns)
  4425                              <1> 	;test	edx, 0FFFF0000h
  4426                              <1> 	;jz	short sysvideo_15_14 ; invalid (zero rows)
  4427 0000D9CC 81FA00000100        <1> 	cmp	edx, 65536
  4428 0000D9D2 72F2                <1> 	jb	short sysvideo_15_15 ; invalid (zero rows)
  4429 0000D9D4 89C8                <1> 	mov	eax, ecx ; start position (row, column)
  4430 0000D9D6 E899000000          <1> 	call	calc_pixel_offset
  4431 0000D9DB 3B05[42100300]      <1> 	cmp	eax, [v_siz]
  4432 0000D9E1 73E2                <1> 	jnb	short sysvideo_15_14 ; out of display page
  4433                              <1> 				; nothing to do
  4434 0000D9E3 E869000000          <1> 	call	pixels_to_byte_count
  4435 0000D9E8 0305[3E100300]      <1> 	add	eax, [v_mem]
  4436 0000D9EE A3[46100300]        <1> 	mov	[v_str], eax ; window start address
  4437                              <1> 			     ; (addr of top left corner)
  4438                              <1> 	; check column limit
  4439 0000D9F3 89C8                <1> 	mov	eax, ecx
  4440 0000D9F5 6601D0              <1> 	add	ax, dx  ; add columns to start column
  4441 0000D9F8 72CC                <1> 	jc	short sysvideo_15_15 ; cf = 1
  4442 0000D9FA 663B05[3A100300]    <1> 	cmp	ax, [v_width]
  4443 0000DA01 77C2                <1> 	ja	short sysvideo_15_14
  4444                              <1> 
  4445 0000DA03 89D0                <1> 	mov	eax, edx ; size
  4446 0000DA05 2D00000100          <1> 	sub	eax, 65536 ; row count -> 0 based row #
  4447 0000DA0A E865000000          <1> 	call	calc_pixel_offset
  4448 0000DA0F 3B05[42100300]      <1> 	cmp	eax, [v_siz] ; video (display) page size
  4449 0000DA15 77AE                <1> 	ja	short sysvideo_15_14 ; out of display page
  4450                              <1> 				; nothing to do
  4451 0000DA17 E835000000          <1> 	call	pixels_to_byte_count
  4452 0000DA1C 0305[46100300]      <1> 	add	eax, [v_str] ; window start address
  4453 0000DA22 3B05[4A100300]      <1> 	cmp	eax, [v_end] ; window end address (+1)
  4454                              <1> 			 ; (addr of bottom right corner +1)	
  4455 0000DA28 779B                <1> 	ja	short sysvideo_15_14 ; out of display page
  4456                              <1> 				; nothing to do
  4457 0000DA2A 89D3                <1> 	mov	ebx, edx
  4458 0000DA2C C1EB10              <1> 	shr	ebx, 16 
  4459                              <1> 	; ebx = row count
  4460 0000DA2F 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  4461                              <1> 	; edx = transfer count per row (from user's buffer)
  4462                              <1> 	;	(in pixels, window width)
  4463 0000DA35 89D0                <1> 	mov	eax, edx
  4464 0000DA37 A3[52100300]        <1> 	mov	[pixcount], eax ; 27/02/2021
  4465 0000DA3C E810000000          <1> 	call	pixels_to_byte_count
  4466 0000DA41 89C1                <1> 	mov	ecx, eax
  4467                              <1> 	; ecx = transfer count per row (from user's buffer)
  4468                              <1> 	;	(in bytes, window width)
  4469 0000DA43 66A1[3A100300]      <1> 	mov	ax, [v_width]
  4470 0000DA49 E803000000          <1> 	call	pixels_to_byte_count
  4471 0000DA4E 89C2                <1> 	mov	edx, eax
  4472                              <1> 	; edx = byte count per row
  4473 0000DA50 C3                  <1> 	retn ; cf = 0
  4474                              <1> 
  4475                              <1> pixels_to_byte_count:
  4476                              <1> 	; 29/01/2021
  4477                              <1> 	; INPUT:
  4478                              <1> 	;   eax = pixel count
  4479                              <1> 	; OUTPUT:
  4480                              <1> 	;   eax = byte count
  4481                              <1> 	;
  4482 0000DA51 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8
  4483 0000DA58 7619                <1> 	jna	short pixtobc_3 ; 8 bit colors
  4484 0000DA5A 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24
  4485 0000DA61 720A                <1> 	jb	short pixtobc_1 ; 16 bit colors
  4486 0000DA63 770B                <1> 	ja	short pixtobc_2 ; 32 bit colors
  4487                              <1> 	; 24 bit pixels
  4488                              <1> 	; eax = eax * 3
  4489                              <1> 	;push	edx
  4490                              <1> 	;mov	edx, eax
  4491                              <1> 	;shl	eax, 1
  4492                              <1> 	;add	eax, edx
  4493                              <1> 	;pop	edx
  4494 0000DA65 50                  <1> 	push	eax
  4495 0000DA66 D1E0                <1> 	shl	eax, 1
  4496 0000DA68 010424              <1> 	add	[esp], eax
  4497 0000DA6B 58                  <1> 	pop	eax
  4498 0000DA6C C3                  <1> 	retn		
  4499                              <1> pixtobc_1:
  4500                              <1> 	; 32 bit pixels
  4501                              <1> 	; eax = eax * 2
  4502 0000DA6D D1E0                <1> 	shl	eax, 1
  4503 0000DA6F C3                  <1> 	retn
  4504                              <1> pixtobc_2:
  4505                              <1> 	; 16 bit pixels
  4506                              <1> 	; eax = eax * 4
  4507 0000DA70 C1E002              <1> 	shl	eax, 2
  4508                              <1> pixtobc_3:
  4509 0000DA73 C3                  <1> 	retn
  4510                              <1> 
  4511                              <1> calc_pixel_offset:
  4512                              <1> 	; 29/01/2021
  4513                              <1> 	; INPUT:
  4514                              <1> 	;   eax = pixel position (row, column)
  4515                              <1> 	; OUTPUT:
  4516                              <1> 	;   eax = pixel offset (linear address)
  4517                              <1> 	;
  4518 0000DA74 52                  <1> 	push	edx
  4519 0000DA75 50                  <1> 	push	eax
  4520 0000DA76 C1E810              <1> 	shr	eax, 16
  4521 0000DA79 7409                <1> 	jz	short cpixo_0
  4522                              <1> 	; eax = row 
  4523 0000DA7B 0FB715[3A100300]    <1> 	movzx	edx, word [v_width]
  4524 0000DA82 F7E2                <1> 	mul	edx
  4525                              <1> cpixo_0:
  4526                              <1> 	; eax = row * screen width
  4527 0000DA84 5A                  <1> 	pop	edx
  4528 0000DA85 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  4529                              <1> 	; edx = column
  4530 0000DA8B 01D0                <1> 	add	eax, edx
  4531                              <1> 	; eax = (row * screen width) + column		
  4532 0000DA8D 5A                  <1> 	pop	edx
  4533 0000DA8E C3                  <1> 	retn
  4534                              <1> 
  4535                              <1> 	; 02/02/2021
  4536                              <1> 	; 29/01/2021
  4537                              <1> pixel_ops:
  4538 0000DA8F [CFDA0000]          <1> 	dd	pix_op_cpy ; copy pixels (user to system)
  4539 0000DA93 [1AE00000]          <1> 	dd	pix_op_new ; change (new, fill) color
  4540 0000DA97 [37DB0000]          <1> 	dd	pix_op_add ; add color (up to 0FFh)
  4541 0000DA9B [E9DB0000]          <1> 	dd	pix_op_sub ; sub color (down to 0)
  4542 0000DA9F [04DE0000]          <1> 	dd	pix_op_orc ; or color
  4543 0000DAA3 [B6DE0000]          <1> 	dd	pix_op_and ; and color
  4544 0000DAA7 [68DF0000]          <1> 	dd	pix_op_xor ; xor color
  4545 0000DAAB [DEE00000]          <1> 	dd	pix_op_not ; not color
  4546 0000DAAF [88E10000]          <1> 	dd	pix_op_neg ; neg color
  4547 0000DAB3 [32E20000]          <1> 	dd	pix_op_inc ; inc color
  4548 0000DAB7 [DCE20000]          <1> 	dd	pix_op_dec ; dec color
  4549 0000DABB [9BDC0000]          <1> 	dd	pix_op_mix ; mix color
  4550 0000DABF [62DD0000]          <1> 	dd	pix_op_rpl ; replace color
  4551 0000DAC3 [86E30000]          <1> 	dd	pix_op_blk ; copy pixel block(s) (sys)
  4552 0000DAC7 [34E40000]          <1> 	dd	pix_op_lin ; write line(s)
  4553 0000DACB [17E80000]          <1> 	dd	pix_op_chr ; write character (font)
  4554                              <1> 
  4555                              <1> pix_op_cpy:
  4556                              <1> 	; 21/02/2021
  4557                              <1> 	; 06/02/2021
  4558                              <1> 	; 30/01/2021
  4559                              <1> 	; COPY PIXELS
  4560                              <1> 	;
  4561                              <1> 	; INPUT:
  4562                              <1> 	;  If bit 4 of BL or [v_ops] = 1 -window copy-
  4563                              <1> 	;  ECX = start position (row, column)
  4564                              <1> 	;        (HW = row, CX = column)
  4565                              <1> 	;  EDX = size (rows, colums)
  4566                              <1> 	;        (HW = rows, DX = columns)
  4567                              <1> 	;	 (0 -> invalid 	
  4568                              <1> 	;        (1 -> horizontal or vertical line)
  4569                              <1> 	;  If bit 4 of BL or [v_ops] = 0 -full screen-
  4570                              <1> 	;     ECX and EDX will not be used
  4571                              <1>   	;  ESI = user's buffer address
  4572                              <1> 	;  [maskcolor] = mask color (to be excluded)
  4573                              <1> 	;
  4574                              <1> 	; OUTPUT:
  4575                              <1> 	; 	[u.r0] will be > 0 if succesful
  4576                              <1> 
  4577 0000DACF F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4578 0000DAD6 752E                <1> 	jnz	short pix_op_cpy_w ; window
  4579                              <1> 
  4580 0000DAD8 8B3D[3E100300]      <1> 	mov	edi, [v_mem] ; 21/02/2021
  4581                              <1> 	
  4582                              <1> 	; Copy user's buffer content do display page
  4583                              <1> 	; (full screen copy)
  4584 0000DADE A1[42100300]        <1> 	mov	eax, [v_siz] ; video page size
  4585 0000DAE3 E869FFFFFF          <1> 	call	pixels_to_byte_count
  4586 0000DAE8 89C1                <1> 	mov	ecx, eax ; transfer count
  4587                              <1> 	; esi = user's buffer address (virtual)
  4588 0000DAEA F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked copy ?
  4589 0000DAF1 7405                <1> 	jz	short pix_op_cpy_0 ; no	
  4590 0000DAF3 E96F0F0000          <1> 	jmp	m_pix_op_cpy ; copy pixels except mask color
  4591                              <1> pix_op_cpy_0:
  4592                              <1> 	; esi = user buffer for full screen copy
  4593                              <1> 	; edi = start of video memory 
  4594                              <1> 	;	(start of display page)
  4595                              <1> 	; ecx = byte count (display page size in bytes)
  4596 0000DAF8 E8A6320000          <1> 	call	transfer_from_user_buffer
  4597 0000DAFD 7206                <1> 	jc	short pix_op_cpy_1
  4598 0000DAFF 890D[1C010300]      <1> 	mov	[u.r0], ecx
  4599                              <1> pix_op_cpy_1:
  4600 0000DB05 C3                  <1> 	retn	; 06/02/2021
  4601                              <1> 
  4602                              <1> pix_op_cpy_w:
  4603 0000DB06 E8BCFEFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  4604 0000DB0B 72F8                <1> 	jc	short pix_op_cpy_1
  4605                              <1> 	; ecx = bytes per row (to be applied)
  4606                              <1> 	; edx = screen width in bytes
  4607                              <1> 	; ebx = row count
  4608 0000DB0D 8B3D[46100300]      <1> 	mov	edi, [v_str]
  4609 0000DB13 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked copy ?
  4610 0000DB1A 7405                <1> 	jz	short pix_op_cpy_w_0 ; no
  4611 0000DB1C E909100000          <1> 	jmp	m_pix_op_cpy_w ; window copy except mask color
  4612                              <1> pix_op_cpy_w_0:
  4613                              <1> 	; esi = current row (virtual) addr in user's buff
  4614                              <1> 	; edi = window's current row address (video mem)
  4615                              <1> 	; ecx = transfer count per row
  4616 0000DB21 E87D320000          <1> 	call	transfer_from_user_buffer
  4617 0000DB26 72DD                <1> 	jc	short pix_op_cpy_1
  4618 0000DB28 010D[1C010300]      <1>  	add	[u.r0], ecx
  4619 0000DB2E 4B                  <1> 	dec	ebx
  4620 0000DB2F 74D4                <1> 	jz	short pix_op_cpy_1 ; ok.
  4621                              <1> 	; next row
  4622 0000DB31 01CE                <1> 	add	esi, ecx ; next row in user's buffer
  4623 0000DB33 01D7                <1> 	add	edi, edx ; next row of window (system)
  4624 0000DB35 EBEA                <1> 	jmp	short pix_op_cpy_w_0
  4625                              <1> 
  4626                              <1> pix_op_add:
  4627                              <1> 	; 31/01/2021
  4628                              <1> 	; 30/01/2021
  4629                              <1> 	; ADD COLOR
  4630                              <1> 	;
  4631                              <1> 	; INPUT:
  4632                              <1> 	;   CL = color (8 bit, 256 colors)
  4633                              <1> 	;  ECX = color (16 bit and true colors)
  4634                              <1> 	;  EDX = start position (row, column)
  4635                              <1> 	;        (HW = row, DX = column)
  4636                              <1> 	;  ESI = size (rows, colums)
  4637                              <1> 	;        (HW = rows, SI = columns)
  4638                              <1> 	;
  4639                              <1> 	;  [maskcolor] = mask color (to be excluded)
  4640                              <1> 	;
  4641                              <1> 	; OUTPUT:
  4642                              <1> 	; 	[u.r0] will be > 0 if succesful
  4643                              <1> 	
  4644 0000DB37 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4645 0000DB3E 7555                <1> 	jnz	short pix_op_add_w ; window
  4646                              <1> 	
  4647 0000DB40 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  4648 0000DB46 89FE                <1> 	mov	esi, edi
  4649                              <1> 	; ecx = color (CL, CX, ECX)
  4650 0000DB48 89C8                <1> 	mov	eax, ecx
  4651 0000DB4A 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  4652                              <1> 
  4653 0000DB50 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color adding ?
  4654 0000DB57 7405                <1> 	jz	short pix_op_add_0 ; no
  4655 0000DB59 E9CB100000          <1> 	jmp	m_pix_op_add ; add color except mask color
  4656                              <1> pix_op_add_0:
  4657 0000DB5E 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4658 0000DB65 7707                <1> 	ja	short pix_op_add_1
  4659                              <1> 
  4660                              <1> 	; 256 colors (8bpp)
  4661 0000DB67 E84C0A0000          <1> 	call	pix_op_add_8
  4662 0000DB6C EB1E                <1> 	jmp	short pix_op_add_4	
  4663                              <1> 			
  4664                              <1> pix_op_add_1:
  4665 0000DB6E 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4666 0000DB75 7710                <1> 	ja	short pix_op_add_3 ; 32bpp	
  4667 0000DB77 7207                <1> 	jb	short pix_op_add_2 ; 16bpp
  4668                              <1> 	
  4669                              <1> 	; 24 bit true colors
  4670 0000DB79 E85A0A0000          <1> 	call	pix_op_add_24
  4671 0000DB7E EB0C                <1> 	jmp	short pix_op_add_4
  4672                              <1> 
  4673                              <1> 	; 65536 colors (16bpp)
  4674                              <1> pix_op_add_2:
  4675 0000DB80 E8410A0000          <1> 	call	pix_op_add_16
  4676 0000DB85 EB05                <1> 	jmp	short pix_op_add_4
  4677                              <1> 
  4678                              <1> 	; 32 bit true colors
  4679                              <1> pix_op_add_3:
  4680 0000DB87 E86C0A0000          <1> 	call	pix_op_add_32
  4681                              <1> pix_op_add_4:
  4682 0000DB8C 29F7                <1> 	sub	edi, esi
  4683 0000DB8E 893D[1C010300]      <1> 	mov	[u.r0], edi	
  4684                              <1> pix_op_add_5:
  4685 0000DB94 C3                  <1> 	retn		
  4686                              <1> 
  4687                              <1> pix_op_add_w:
  4688                              <1> 	; 31/01/2021
  4689 0000DB95 51                  <1> 	push	ecx ; * ; color
  4690 0000DB96 89D1                <1> 	mov	ecx, edx ; win start pos
  4691 0000DB98 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  4692 0000DB9A E828FEFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  4693 0000DB9F 58                  <1> 	pop	eax ; * ; color
  4694 0000DBA0 72F2                <1> 	jc	short pix_op_add_5
  4695                              <1> 
  4696 0000DBA2 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color adding ?
  4697 0000DBA9 7405                <1> 	jz	short pix_op_add_w_0 ; no
  4698 0000DBAB E927110000          <1> 	jmp	m_pix_op_add_w 
  4699                              <1> 			; window add color except mask color
  4700                              <1> pix_op_add_w_0:
  4701                              <1> 	; ecx = bytes per row (to be applied)
  4702                              <1> 	; edx = screen width in bytes
  4703                              <1> 	; ebx = row count
  4704                              <1> 	; eax = color
  4705                              <1> 
  4706 0000DBB0 8B3D[46100300]      <1> 	mov	edi, [v_str]
  4707 0000DBB6 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4708 0000DBBD 7707                <1> 	ja	short pix_op_add_w_1
  4709                              <1> 
  4710                              <1> 	; 256 colors (8bpp)
  4711 0000DBBF BD[B8E50000]        <1> 	mov	ebp, pix_op_add_8
  4712 0000DBC4 EB1E                <1> 	jmp	short pix_op_add_w_4
  4713                              <1> 			
  4714                              <1> pix_op_add_w_1:
  4715 0000DBC6 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4716 0000DBCD 7710                <1> 	ja	short pix_op_add_w_3 ; 32bpp
  4717 0000DBCF 7207                <1> 	jb	short pix_op_add_w_2 ; 16bpp
  4718                              <1> 
  4719                              <1> 	; 24 bit true colors
  4720 0000DBD1 BD[D8E50000]        <1> 	mov	ebp, pix_op_add_24
  4721 0000DBD6 EB0C                <1> 	jmp	short pix_op_add_w_4
  4722                              <1> 
  4723                              <1> 	; 65536 colors (16bpp)
  4724                              <1> pix_op_add_w_2:
  4725 0000DBD8 BD[C6E50000]        <1> 	mov	ebp, pix_op_add_16
  4726 0000DBDD EB05                <1> 	jmp	short pix_op_add_w_4
  4727                              <1> 
  4728                              <1> 	; 32 bit true colors
  4729                              <1> pix_op_add_w_3:
  4730 0000DBDF BD[F8E50000]        <1> 	mov	ebp, pix_op_add_32
  4731                              <1> pix_op_add_w_4:
  4732 0000DBE4 E95F010000          <1> 	jmp	pix_op_add_w_x
  4733                              <1> 
  4734                              <1> pix_op_sub:
  4735                              <1> 	; 31/01/2021
  4736                              <1> 	; SUB COLOR
  4737                              <1> 	;
  4738                              <1> 	; INPUT:
  4739                              <1> 	;   CL = color (8 bit, 256 colors)
  4740                              <1> 	;  ECX = color (16 bit and true colors)
  4741                              <1> 	;  EDX = start position (row, column)
  4742                              <1> 	;        (HW = row, DX = column)
  4743                              <1> 	;  ESI = size (rows, colums)
  4744                              <1> 	;        (HW = rows, SI = columns)
  4745                              <1> 	;
  4746                              <1> 	;  [maskcolor] = mask color (to be excluded)
  4747                              <1> 	;
  4748                              <1> 	; OUTPUT:
  4749                              <1> 	; 	[u.r0] will be > 0 if succesful
  4750                              <1> 	
  4751 0000DBE9 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4752 0000DBF0 7555                <1> 	jnz	short pix_op_sub_w ; window
  4753                              <1> 	
  4754 0000DBF2 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  4755 0000DBF8 89FE                <1> 	mov	esi, edi
  4756                              <1> 	; ecx = color (CL, CX, ECX)
  4757 0000DBFA 89C8                <1> 	mov	eax, ecx
  4758 0000DBFC 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  4759                              <1> 
  4760 0000DC02 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color subtract ?
  4761 0000DC09 7405                <1> 	jz	short pix_op_sub_0 ; no
  4762 0000DC0B E9FA100000          <1> 	jmp	m_pix_op_sub ; sub color except mask color
  4763                              <1> pix_op_sub_0:
  4764 0000DC10 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4765 0000DC17 7707                <1> 	ja	short pix_op_sub_1
  4766                              <1> 
  4767                              <1> 	; 256 colors (8bpp)
  4768 0000DC19 E8E9090000          <1> 	call	pix_op_sub_8
  4769 0000DC1E EB1E                <1> 	jmp	short pix_op_sub_4	
  4770                              <1> 			
  4771                              <1> pix_op_sub_1:
  4772 0000DC20 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4773 0000DC27 7710                <1> 	ja	short pix_op_sub_3 ; 32bpp	
  4774 0000DC29 7207                <1> 	jb	short pix_op_sub_2 ; 16bpp
  4775                              <1> 	
  4776                              <1> 	; 24 bit true colors
  4777 0000DC2B E8FA090000          <1> 	call	pix_op_sub_24
  4778 0000DC30 EB0C                <1> 	jmp	short pix_op_sub_4
  4779                              <1> 
  4780                              <1> 	; 65536 colors (16bpp)
  4781                              <1> pix_op_sub_2:
  4782 0000DC32 E8E0090000          <1> 	call	pix_op_sub_16
  4783 0000DC37 EB05                <1> 	jmp	short pix_op_sub_4
  4784                              <1> 
  4785                              <1> 	; 32 bit true colors
  4786                              <1> pix_op_sub_3:
  4787 0000DC39 E8060A0000          <1> 	call	pix_op_sub_32
  4788                              <1> pix_op_sub_4:
  4789 0000DC3E 29F7                <1> 	sub	edi, esi
  4790 0000DC40 893D[1C010300]      <1> 	mov	[u.r0], edi	
  4791                              <1> pix_op_sub_5:
  4792 0000DC46 C3                  <1> 	retn		
  4793                              <1> 
  4794                              <1> pix_op_sub_w:
  4795                              <1> 	; 31/01/2021
  4796 0000DC47 51                  <1> 	push	ecx ; * ; color
  4797 0000DC48 89D1                <1> 	mov	ecx, edx ; win start pos
  4798 0000DC4A 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  4799 0000DC4C E876FDFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  4800 0000DC51 58                  <1> 	pop	eax ; * ; color
  4801 0000DC52 72F2                <1> 	jc	short pix_op_sub_5
  4802                              <1> 
  4803 0000DC54 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color subtract ?
  4804 0000DC5B 7405                <1> 	jz	short pix_op_sub_w_0 ; no
  4805 0000DC5D E94B110000          <1> 	jmp	m_pix_op_sub_w 
  4806                              <1> 			; window sub color except mask color
  4807                              <1> pix_op_sub_w_0:
  4808                              <1> 	; ecx = bytes per row (to be applied)
  4809                              <1> 	; edx = screen width in bytes
  4810                              <1> 	; ebx = row count
  4811                              <1> 	; eax = color
  4812                              <1> 
  4813 0000DC62 8B3D[46100300]      <1> 	mov	edi, [v_str]
  4814 0000DC68 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4815 0000DC6F 7707                <1> 	ja	short pix_op_sub_w_1
  4816                              <1> 
  4817                              <1> 	; 256 colors (8bpp)
  4818 0000DC71 BD[07E60000]        <1> 	mov	ebp, pix_op_sub_8
  4819 0000DC76 EB1E                <1> 	jmp	short pix_op_sub_w_4
  4820                              <1> 			
  4821                              <1> pix_op_sub_w_1:
  4822 0000DC78 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4823 0000DC7F 7710                <1> 	ja	short pix_op_sub_w_3 ; 32bpp
  4824 0000DC81 7207                <1> 	jb	short pix_op_sub_w_2 ; 16bpp
  4825                              <1> 
  4826                              <1> 	; 24 bit true colors
  4827 0000DC83 BD[2AE60000]        <1> 	mov	ebp, pix_op_sub_24
  4828 0000DC88 EB0C                <1> 	jmp	short pix_op_sub_w_4
  4829                              <1> 
  4830                              <1> 	; 65536 colors (16bpp)
  4831                              <1> pix_op_sub_w_2:
  4832 0000DC8A BD[17E60000]        <1> 	mov	ebp, pix_op_sub_16
  4833 0000DC8F EB05                <1> 	jmp	short pix_op_sub_w_4
  4834                              <1> 
  4835                              <1> 	; 32 bit true colors
  4836                              <1> pix_op_sub_w_3:
  4837 0000DC91 BD[44E60000]        <1> 	mov	ebp, pix_op_sub_32
  4838                              <1> pix_op_sub_w_4:
  4839 0000DC96 E9AD000000          <1> 	jmp	pix_op_sub_w_x
  4840                              <1> 
  4841                              <1> pix_op_mix:
  4842                              <1> 	; 31/01/2021
  4843                              <1> 	; MIX COLOR
  4844                              <1> 	;
  4845                              <1> 	; INPUT:
  4846                              <1> 	;   CL = color (8 bit, 256 colors)
  4847                              <1> 	;  ECX = color (16 bit and true colors)
  4848                              <1> 	;  EDX = start position (row, column)
  4849                              <1> 	;        (HW = row, DX = column)
  4850                              <1> 	;  ESI = size (rows, colums)
  4851                              <1> 	;        (HW = rows, SI = columns)
  4852                              <1> 	;
  4853                              <1> 	;  [maskcolor] = mask color (to be excluded)
  4854                              <1> 	;
  4855                              <1> 	; OUTPUT:
  4856                              <1> 	; 	[u.r0] will be > 0 if succesful
  4857                              <1> 	
  4858 0000DC9B F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4859 0000DCA2 7555                <1> 	jnz	short pix_op_mix_w ; window
  4860                              <1> 	
  4861 0000DCA4 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  4862 0000DCAA 89FE                <1> 	mov	esi, edi
  4863                              <1> 	; ecx = color (CL, CX, ECX)
  4864 0000DCAC 89C8                <1> 	mov	eax, ecx
  4865 0000DCAE 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  4866                              <1> 
  4867 0000DCB4 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color mix ?
  4868 0000DCBB 7405                <1> 	jz	short pix_op_mix_0 ; no
  4869 0000DCBD E91E110000          <1> 	jmp	m_pix_op_mix ; mix colors except mask color
  4870                              <1> pix_op_mix_0:
  4871 0000DCC2 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4872 0000DCC9 7707                <1> 	ja	short pix_op_mix_1
  4873                              <1> 
  4874                              <1> 	; 256 colors (8bpp)
  4875 0000DCCB E8F3090000          <1> 	call	pix_op_mix_8
  4876 0000DCD0 EB1E                <1> 	jmp	short pix_op_mix_4	
  4877                              <1> 			
  4878                              <1> pix_op_mix_1:
  4879 0000DCD2 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4880 0000DCD9 7710                <1> 	ja	short pix_op_mix_3 ; 32bpp	
  4881 0000DCDB 7207                <1> 	jb	short pix_op_mix_2 ; 16bpp
  4882                              <1> 	
  4883                              <1> 	; 24 bit true colors
  4884 0000DCDD E8FC090000          <1> 	call	pix_op_mix_24
  4885 0000DCE2 EB0C                <1> 	jmp	short pix_op_mix_4
  4886                              <1> 
  4887                              <1> 	; 65536 colors (16bpp)
  4888                              <1> pix_op_mix_2:
  4889 0000DCE4 E8E6090000          <1> 	call	pix_op_mix_16
  4890 0000DCE9 EB05                <1> 	jmp	short pix_op_mix_4
  4891                              <1> 
  4892                              <1> 	; 32 bit true colors
  4893                              <1> pix_op_mix_3:
  4894 0000DCEB E80A0A0000          <1> 	call	pix_op_mix_32
  4895                              <1> pix_op_mix_4:
  4896 0000DCF0 29F7                <1> 	sub	edi, esi
  4897 0000DCF2 893D[1C010300]      <1> 	mov	[u.r0], edi	
  4898                              <1> pix_op_mix_5:
  4899 0000DCF8 C3                  <1> 	retn		
  4900                              <1> 
  4901                              <1> pix_op_mix_w:
  4902                              <1> 	; 31/01/2021
  4903 0000DCF9 51                  <1> 	push	ecx ; * ; color
  4904 0000DCFA 89D1                <1> 	mov	ecx, edx ; win start pos
  4905 0000DCFC 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  4906 0000DCFE E8C4FCFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  4907 0000DD03 58                  <1> 	pop	eax ; * ; color
  4908 0000DD04 72F2                <1> 	jc	short pix_op_mix_5
  4909                              <1> 
  4910 0000DD06 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color mix ?
  4911 0000DD0D 7405                <1> 	jz	short pix_op_mix_w_0 ; no
  4912 0000DD0F E969110000          <1> 	jmp	m_pix_op_mix_w 
  4913                              <1> 			; window mix colors except mask color
  4914                              <1> pix_op_mix_w_0:
  4915                              <1> 	; ecx = bytes per row (to be applied)
  4916                              <1> 	; edx = screen width in bytes
  4917                              <1> 	; ebx = row count
  4918                              <1> 	; eax = color
  4919                              <1> 
  4920 0000DD14 8B3D[46100300]      <1> 	mov	edi, [v_str]
  4921 0000DD1A 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4922 0000DD21 7707                <1> 	ja	short pix_op_mix_w_1
  4923                              <1> 
  4924                              <1> 	; 256 colors (8bpp)
  4925 0000DD23 BD[C3E60000]        <1> 	mov	ebp, pix_op_mix_8
  4926 0000DD28 EB1E                <1> 	jmp	short pix_op_mix_w_x
  4927                              <1> 			
  4928                              <1> pix_op_mix_w_1:
  4929 0000DD2A 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4930 0000DD31 7710                <1> 	ja	short pix_op_mix_w_3 ; 32bpp
  4931 0000DD33 7207                <1> 	jb	short pix_op_mix_w_2 ; 16bpp
  4932                              <1> 
  4933                              <1> 	; 24 bit true colors
  4934 0000DD35 BD[DEE60000]        <1> 	mov	ebp, pix_op_mix_24
  4935 0000DD3A EB0C                <1> 	jmp	short pix_op_mix_w_x
  4936                              <1> 
  4937                              <1> 	; 65536 colors (16bpp)
  4938                              <1> pix_op_mix_w_2:
  4939 0000DD3C BD[CFE60000]        <1> 	mov	ebp, pix_op_mix_16
  4940 0000DD41 EB05                <1> 	jmp	short pix_op_mix_w_x
  4941                              <1> 
  4942                              <1> 	; 32 bit true colors
  4943                              <1> pix_op_mix_w_3:
  4944 0000DD43 BD[FAE60000]        <1> 	mov	ebp, pix_op_mix_32
  4945                              <1> 	;jmp	short pix_op_mix_w_x
  4946                              <1> 
  4947                              <1> pix_op_mix_w_x:
  4948                              <1> pix_op_add_w_x:
  4949                              <1> pix_op_sub_w_x:
  4950                              <1> pix_op_rpl_w_x:
  4951                              <1> pix_op_orc_w_x:
  4952                              <1> pix_op_and_w_x:
  4953                              <1> pix_op_xor_w_x:
  4954                              <1> 	; 27/02/2021
  4955                              <1> 	; 31/01/2021
  4956                              <1> 	; ecx = bytes per row (to be applied)
  4957                              <1> 	; edx = windows (screen) width in bytes
  4958                              <1> 	; ebx = row count
  4959                              <1> 	; eax = color
  4960                              <1> 	; ebp = pixel operation subroutine address
  4961 0000DD48 52                  <1> 	push	edx
  4962 0000DD49 51                  <1> 	push	ecx
  4963 0000DD4A 57                  <1> 	push	edi
  4964 0000DD4B 8B0D[52100300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021
  4965 0000DD51 FFD5                <1> 	call	ebp ; call pixel-row operation
  4966 0000DD53 5F                  <1> 	pop	edi
  4967 0000DD54 59                  <1> 	pop	ecx ; bytes per row
  4968 0000DD55 010D[1C010300]      <1> 	add	[u.r0], ecx
  4969 0000DD5B 5A                  <1> 	pop	edx
  4970 0000DD5C 01D7                <1> 	add	edi, edx ; next row
  4971 0000DD5E 4B                  <1> 	dec	ebx
  4972 0000DD5F 75E7                <1> 	jnz	short pix_op_mix_w_x
  4973 0000DD61 C3                  <1> 	retn
  4974                              <1> 
  4975                              <1> pix_op_rpl:
  4976                              <1> 	; 01/02/2021
  4977                              <1> 	; REPLACE COLOR
  4978                              <1> 	;
  4979                              <1> 	; INPUT:
  4980                              <1> 	;   CL = old/current color (8 bit, 256 colors)
  4981                              <1> 	;  ECX = old/current color (16 bit and true colors)
  4982                              <1> 	;   DL = new color (8 bit, 256 colors)
  4983                              <1> 	;  EDX = new color (16 bit and true colors)
  4984                              <1> 	;  ESI = start position (row, column)
  4985                              <1> 	;        (HW = row, DX = column)
  4986                              <1> 	;  EDI = size (rows, colums)
  4987                              <1> 	;        (HW = rows, SI = columns)
  4988                              <1> 	; OUTPUT:
  4989                              <1> 	; 	[u.r0] will be > 0 if succesful
  4990                              <1> 	
  4991 0000DD62 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4992 0000DD69 754D                <1> 	jnz	short pix_op_rpl_w ; window
  4993                              <1> 	
  4994 0000DD6B 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  4995 0000DD71 89FE                <1> 	mov	esi, edi
  4996                              <1> 	; ecx = old color (CL, CX, ECX) -to be replaced with-
  4997                              <1> 	; edx = new color (CL, CX, ECX) -new one-
  4998 0000DD73 89D0                <1> 	mov	eax, edx ; new color
  4999 0000DD75 890D[4E100300]      <1> 	mov	[maskcolor], ecx ; old color
  5000 0000DD7B 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5001                              <1> pix_op_rpl_0:
  5002 0000DD81 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5003 0000DD88 7707                <1> 	ja	short pix_op_rpl_1
  5004                              <1> 
  5005                              <1> 	; 256 colors (8bpp)
  5006 0000DD8A E82F0A0000          <1> 	call	pix_op_rpl_8
  5007 0000DD8F EB1E                <1> 	jmp	short pix_op_rpl_4
  5008                              <1> 			
  5009                              <1> pix_op_rpl_1:
  5010 0000DD91 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5011 0000DD98 7710                <1> 	ja	short pix_op_rpl_3 ; 32bpp	
  5012 0000DD9A 7207                <1> 	jb	short pix_op_rpl_2 ; 16bpp
  5013                              <1> 
  5014                              <1> 	; 24 bit true colors
  5015 0000DD9C E8400A0000          <1> 	call	pix_op_rpl_24
  5016 0000DDA1 EB0C                <1> 	jmp	short pix_op_rpl_4
  5017                              <1> 
  5018                              <1> 	; 65536 colors (16bpp)
  5019                              <1> pix_op_rpl_2:
  5020 0000DDA3 E8260A0000          <1> 	call	pix_op_rpl_16
  5021 0000DDA8 EB05                <1> 	jmp	short pix_op_rpl_4
  5022                              <1> 
  5023                              <1> 	; 32 bit true colors	
  5024                              <1> pix_op_rpl_3:
  5025 0000DDAA E8540A0000          <1> 	call	pix_op_rpl_32
  5026                              <1> pix_op_rpl_4:
  5027 0000DDAF 29F7                <1> 	sub	edi, esi
  5028 0000DDB1 893D[1C010300]      <1> 	mov	[u.r0], edi	
  5029                              <1> pix_op_rpl_5:
  5030 0000DDB7 C3                  <1> 	retn
  5031                              <1> 
  5032                              <1> pix_op_rpl_w:
  5033                              <1> 	; 01/02/2021
  5034 0000DDB8 890D[4E100300]      <1> 	mov	[maskcolor], ecx ; old color
  5035 0000DDBE 52                  <1> 	push	edx ; * ; new color
  5036 0000DDBF 89F1                <1> 	mov	ecx, esi ; win start pos
  5037 0000DDC1 89FA                <1> 	mov	edx, edi ; size (rows, cols)
  5038 0000DDC3 E8FFFBFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5039 0000DDC8 58                  <1> 	pop	eax ; * ; new color
  5040 0000DDC9 72EC                <1> 	jc	short pix_op_rpl_5
  5041                              <1> 
  5042                              <1> 	; replace window color
  5043                              <1> pix_op_rpl_w_0:
  5044                              <1> 	; ecx = bytes per row (to be applied)
  5045                              <1> 	; edx = screen width in bytes
  5046                              <1> 	; ebx = row count
  5047                              <1> 	; eax = new color
  5048                              <1> 	; [maskcolor] = old color
  5049                              <1>  
  5050 0000DDCB 8B3D[46100300]      <1> 	mov	edi, [v_str]
  5051                              <1> 
  5052 0000DDD1 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5053 0000DDD8 7707                <1> 	ja	short pix_op_rpl_w_1
  5054                              <1> 
  5055                              <1> 	; 256 colors (8bpp)
  5056 0000DDDA BD[BEE70000]        <1> 	mov	ebp, pix_op_rpl_8
  5057 0000DDDF EB1E                <1> 	jmp	short pix_op_rpl_w_4
  5058                              <1> 			
  5059                              <1> pix_op_rpl_w_1:
  5060 0000DDE1 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5061 0000DDE8 7710                <1> 	ja	short pix_op_rpl_w_3 ; 32bpp
  5062 0000DDEA 7207                <1> 	jb	short pix_op_rpl_w_2 ; 16bpp
  5063                              <1> 
  5064                              <1> 	; 24 bit true colors
  5065 0000DDEC BD[E1E70000]        <1> 	mov	ebp, pix_op_rpl_24
  5066 0000DDF1 EB0C                <1> 	jmp	short pix_op_rpl_w_4
  5067                              <1> 
  5068                              <1> 	; 65536 colors (16bpp)
  5069                              <1> pix_op_rpl_w_2:
  5070 0000DDF3 BD[CEE70000]        <1> 	mov	ebp, pix_op_rpl_16
  5071 0000DDF8 EB05                <1> 	jmp	short pix_op_rpl_w_4
  5072                              <1> 
  5073                              <1> 	; 32 bit true colors
  5074                              <1> pix_op_rpl_w_3:
  5075 0000DDFA BD[03E80000]        <1> 	mov	ebp, pix_op_rpl_32
  5076                              <1> pix_op_rpl_w_4:
  5077 0000DDFF E944FFFFFF          <1> 	jmp	pix_op_rpl_w_x
  5078                              <1> 
  5079                              <1> pix_op_orc:
  5080                              <1> 	; 31/01/2021
  5081                              <1> 	; OR COLOR
  5082                              <1> 	;
  5083                              <1> 	; INPUT:
  5084                              <1> 	;   CL = color (8 bit, 256 colors)
  5085                              <1> 	;  ECX = color (16 bit and true colors)
  5086                              <1> 	;  EDX = start position (row, column)
  5087                              <1> 	;        (HW = row, DX = column)
  5088                              <1> 	;  ESI = size (rows, colums)
  5089                              <1> 	;        (HW = rows, SI = columns)
  5090                              <1> 	;
  5091                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5092                              <1> 	;
  5093                              <1> 	; OUTPUT:
  5094                              <1> 	; 	[u.r0] will be > 0 if succesful
  5095                              <1> 	
  5096 0000DE04 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5097 0000DE0B 7555                <1> 	jnz	short pix_op_or_w ; window
  5098                              <1> 	
  5099 0000DE0D 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  5100 0000DE13 89FE                <1> 	mov	esi, edi
  5101                              <1> 	; ecx = color (CL, CX, ECX)
  5102 0000DE15 89C8                <1> 	mov	eax, ecx
  5103 0000DE17 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5104                              <1> 
  5105 0000DE1D F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'or' ?
  5106 0000DE24 7405                <1> 	jz	short pix_op_or_0 ; no
  5107 0000DE26 E945110000          <1> 	jmp	m_pix_op_or ; 'or' color except mask color
  5108                              <1> pix_op_or_0:
  5109 0000DE2B 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5110 0000DE32 7707                <1> 	ja	short pix_op_or_1
  5111                              <1> 
  5112                              <1> 	; 256 colors (8bpp)
  5113 0000DE34 E81B080000          <1> 	call	pix_op_or_8
  5114 0000DE39 EB1E                <1> 	jmp	short pix_op_or_4	
  5115                              <1> 			
  5116                              <1> pix_op_or_1:
  5117 0000DE3B 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5118 0000DE42 7710                <1> 	ja	short pix_op_or_3 ; 32bpp	
  5119 0000DE44 7207                <1> 	jb	short pix_op_or_2 ; 16bpp
  5120                              <1> 	
  5121                              <1> 	; 24 bit true colors
  5122 0000DE46 E817080000          <1> 	call	pix_op_or_24
  5123 0000DE4B EB0C                <1> 	jmp	short pix_op_or_4
  5124                              <1> 
  5125                              <1> 	; 65536 colors (16bpp)
  5126                              <1> pix_op_or_2:
  5127 0000DE4D E808080000          <1> 	call	pix_op_or_16
  5128 0000DE52 EB05                <1> 	jmp	short pix_op_or_4
  5129                              <1> 
  5130                              <1> 	; 32 bit true colors
  5131                              <1> pix_op_or_3:
  5132 0000DE54 E818080000          <1> 	call	pix_op_or_32
  5133                              <1> pix_op_or_4:
  5134 0000DE59 29F7                <1> 	sub	edi, esi
  5135 0000DE5B 893D[1C010300]      <1> 	mov	[u.r0], edi	
  5136                              <1> pix_op_or_5:
  5137 0000DE61 C3                  <1> 	retn		
  5138                              <1> 
  5139                              <1> pix_op_or_w:
  5140                              <1> 	; 31/01/2021
  5141 0000DE62 51                  <1> 	push	ecx ; * ; color
  5142 0000DE63 89D1                <1> 	mov	ecx, edx ; win start pos
  5143 0000DE65 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  5144 0000DE67 E85BFBFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5145 0000DE6C 58                  <1> 	pop	eax ; * ; color
  5146 0000DE6D 72F2                <1> 	jc	short pix_op_or_5
  5147                              <1> 
  5148 0000DE6F F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'or' ?
  5149 0000DE76 7405                <1> 	jz	short pix_op_or_w_0 ; no
  5150 0000DE78 E980110000          <1> 	jmp	m_pix_op_or_w 
  5151                              <1> 			; window 'or' color except mask color
  5152                              <1> pix_op_or_w_0:
  5153                              <1> 	; ecx = bytes per row (to be applied)
  5154                              <1> 	; edx = screen width in bytes
  5155                              <1> 	; ebx = row count
  5156                              <1> 	; eax = color
  5157                              <1> 
  5158 0000DE7D 8B3D[46100300]      <1> 	mov	edi, [v_str]
  5159 0000DE83 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5160 0000DE8A 7707                <1> 	ja	short pix_op_or_w_1
  5161                              <1> 
  5162                              <1> 	; 256 colors (8bpp)
  5163 0000DE8C BD[54E60000]        <1> 	mov	ebp, pix_op_or_8
  5164 0000DE91 EB1E                <1> 	jmp	short pix_op_or_w_4
  5165                              <1> 			
  5166                              <1> pix_op_or_w_1:
  5167 0000DE93 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5168 0000DE9A 7710                <1> 	ja	short pix_op_or_w_3 ; 32bpp
  5169 0000DE9C 7207                <1> 	jb	short pix_op_or_w_2 ; 16bpp
  5170                              <1> 
  5171                              <1> 	; 24 bit true colors
  5172 0000DE9E BD[62E60000]        <1> 	mov	ebp, pix_op_or_24
  5173 0000DEA3 EB0C                <1> 	jmp	short pix_op_or_w_4
  5174                              <1> 
  5175                              <1> 	; 65536 colors (16bpp)
  5176                              <1> pix_op_or_w_2:
  5177 0000DEA5 BD[5AE60000]        <1> 	mov	ebp, pix_op_or_16
  5178 0000DEAA EB05                <1> 	jmp	short pix_op_or_w_4
  5179                              <1> 
  5180                              <1> 	; 32 bit true colors
  5181                              <1> pix_op_or_w_3:
  5182 0000DEAC BD[71E60000]        <1> 	mov	ebp, pix_op_or_32
  5183                              <1> pix_op_or_w_4:
  5184 0000DEB1 E992FEFFFF          <1> 	jmp	pix_op_orc_w_x
  5185                              <1> 
  5186                              <1> pix_op_and:
  5187                              <1> 	; 31/01/2021
  5188                              <1> 	; AND COLOR
  5189                              <1> 	;
  5190                              <1> 	; INPUT:
  5191                              <1> 	;   CL = color (8 bit, 256 colors)
  5192                              <1> 	;  ECX = color (16 bit and true colors)
  5193                              <1> 	;  EDX = start position (row, column)
  5194                              <1> 	;        (HW = row, DX = column)
  5195                              <1> 	;  ESI = size (rows, colums)
  5196                              <1> 	;        (HW = rows, SI = columns)
  5197                              <1> 	;
  5198                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5199                              <1> 	;
  5200                              <1> 	; OUTPUT:
  5201                              <1> 	; 	[u.r0] will be > 0 if succesful
  5202                              <1> 	
  5203 0000DEB6 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5204 0000DEBD 7555                <1> 	jnz	short pix_op_and_w ; window
  5205                              <1> 	
  5206 0000DEBF 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  5207 0000DEC5 89FE                <1> 	mov	esi, edi
  5208                              <1> 	; ecx = color (CL, CX, ECX)
  5209 0000DEC7 89C8                <1> 	mov	eax, ecx
  5210 0000DEC9 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5211                              <1> 
  5212 0000DECF F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'and' ?
  5213 0000DED6 7405                <1> 	jz	short pix_op_and_0 ; no
  5214 0000DED8 E9D30F0000          <1> 	jmp	m_pix_op_and ; 'and' color except mask color
  5215                              <1> pix_op_and_0:
  5216 0000DEDD 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5217 0000DEE4 7707                <1> 	ja	short pix_op_and_1
  5218                              <1> 
  5219                              <1> 	; 256 colors (8bpp)
  5220 0000DEE6 E88E070000          <1> 	call	pix_op_and_8
  5221 0000DEEB EB1E                <1> 	jmp	short pix_op_and_4	
  5222                              <1> 			
  5223                              <1> pix_op_and_1:
  5224 0000DEED 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5225 0000DEF4 7710                <1> 	ja	short pix_op_and_3 ; 32bpp	
  5226 0000DEF6 7207                <1> 	jb	short pix_op_and_2 ; 16bpp
  5227                              <1> 	
  5228                              <1> 	; 24 bit true colors
  5229 0000DEF8 E88A070000          <1> 	call	pix_op_and_24
  5230 0000DEFD EB0C                <1> 	jmp	short pix_op_and_4
  5231                              <1> 
  5232                              <1> 	; 65536 colors (16bpp)
  5233                              <1> pix_op_and_2:
  5234 0000DEFF E87B070000          <1> 	call	pix_op_and_16
  5235 0000DF04 EB05                <1> 	jmp	short pix_op_and_4
  5236                              <1> 
  5237                              <1> 	; 32 bit true colors
  5238                              <1> pix_op_and_3:
  5239 0000DF06 E88B070000          <1> 	call	pix_op_and_32
  5240                              <1> pix_op_and_4:
  5241 0000DF0B 29F7                <1> 	sub	edi, esi
  5242 0000DF0D 893D[1C010300]      <1> 	mov	[u.r0], edi	
  5243                              <1> pix_op_and_5:
  5244 0000DF13 C3                  <1> 	retn		
  5245                              <1> 
  5246                              <1> pix_op_and_w:
  5247                              <1> 	; 31/01/2021
  5248 0000DF14 51                  <1> 	push	ecx ; * ; color
  5249 0000DF15 89D1                <1> 	mov	ecx, edx ; win start pos
  5250 0000DF17 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  5251 0000DF19 E8A9FAFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5252 0000DF1E 58                  <1> 	pop	eax ; * ; color
  5253 0000DF1F 72F2                <1> 	jc	short pix_op_and_5
  5254                              <1> 
  5255 0000DF21 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'and' ?
  5256 0000DF28 7405                <1> 	jz	short pix_op_and_w_0 ; no
  5257 0000DF2A E90E100000          <1> 	jmp	m_pix_op_and_w 
  5258                              <1> 			; window 'and' color except mask color
  5259                              <1> pix_op_and_w_0:
  5260                              <1> 	; ecx = bytes per row (to be applied)
  5261                              <1> 	; edx = screen width in bytes
  5262                              <1> 	; ebx = row count
  5263                              <1> 	; eax = color
  5264                              <1> 
  5265 0000DF2F 8B3D[46100300]      <1> 	mov	edi, [v_str]
  5266 0000DF35 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5267 0000DF3C 7707                <1> 	ja	short pix_op_and_w_1
  5268                              <1> 
  5269                              <1> 	; 256 colors (8bpp)
  5270 0000DF3E BD[79E60000]        <1> 	mov	ebp, pix_op_and_8
  5271 0000DF43 EB1E                <1> 	jmp	short pix_op_and_w_4
  5272                              <1> 			
  5273                              <1> pix_op_and_w_1:
  5274 0000DF45 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5275 0000DF4C 7710                <1> 	ja	short pix_op_and_w_3 ; 32bpp
  5276 0000DF4E 7207                <1> 	jb	short pix_op_and_w_2 ; 16bpp
  5277                              <1> 
  5278                              <1> 	; 24 bit true colors
  5279 0000DF50 BD[87E60000]        <1> 	mov	ebp, pix_op_and_24
  5280 0000DF55 EB0C                <1> 	jmp	short pix_op_and_w_4
  5281                              <1> 
  5282                              <1> 	; 65536 colors (16bpp)
  5283                              <1> pix_op_and_w_2:
  5284 0000DF57 BD[7FE60000]        <1> 	mov	ebp, pix_op_and_16
  5285 0000DF5C EB05                <1> 	jmp	short pix_op_and_w_4
  5286                              <1> 
  5287                              <1> 	; 32 bit true colors
  5288                              <1> pix_op_and_w_3:
  5289 0000DF5E BD[96E60000]        <1> 	mov	ebp, pix_op_and_32
  5290                              <1> pix_op_and_w_4:
  5291 0000DF63 E9E0FDFFFF          <1> 	jmp	pix_op_and_w_x
  5292                              <1> 
  5293                              <1> pix_op_xor:
  5294                              <1> 	; 31/01/2021
  5295                              <1> 	; XOR COLOR
  5296                              <1> 	;
  5297                              <1> 	; INPUT:
  5298                              <1> 	;   CL = color (8 bit, 256 colors)
  5299                              <1> 	;  ECX = color (16 bit and true colors)
  5300                              <1> 	;  EDX = start position (row, column)
  5301                              <1> 	;        (HW = row, DX = column)
  5302                              <1> 	;  ESI = size (rows, colums)
  5303                              <1> 	;        (HW = rows, SI = columns)
  5304                              <1> 	;
  5305                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5306                              <1> 	;
  5307                              <1> 	; OUTPUT:
  5308                              <1> 	; 	[u.r0] will be > 0 if succesful
  5309                              <1> 	
  5310 0000DF68 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5311 0000DF6F 7555                <1> 	jnz	short pix_op_xor_w ; window
  5312                              <1> 	
  5313 0000DF71 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  5314 0000DF77 89FE                <1> 	mov	esi, edi
  5315                              <1> 	; ecx = color (CL, CX, ECX)
  5316 0000DF79 89C8                <1> 	mov	eax, ecx
  5317 0000DF7B 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5318                              <1> 
  5319 0000DF81 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'xor' ?
  5320 0000DF88 7405                <1> 	jz	short pix_op_xor_0 ; no
  5321 0000DF8A E9A1100000          <1> 	jmp	m_pix_op_xor ; 'xor' color except mask color
  5322                              <1> pix_op_xor_0:
  5323 0000DF8F 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5324 0000DF96 7707                <1> 	ja	short pix_op_xor_1
  5325                              <1> 
  5326                              <1> 	; 256 colors (8bpp)
  5327 0000DF98 E801070000          <1> 	call	pix_op_xor_8
  5328 0000DF9D EB1E                <1> 	jmp	short pix_op_xor_4	
  5329                              <1> 			
  5330                              <1> pix_op_xor_1:
  5331 0000DF9F 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5332 0000DFA6 7710                <1> 	ja	short pix_op_xor_3 ; 32bpp	
  5333 0000DFA8 7207                <1> 	jb	short pix_op_xor_2 ; 16bpp
  5334                              <1> 	
  5335                              <1> 	; 24 bit true colors
  5336 0000DFAA E8FD060000          <1> 	call	pix_op_xor_24
  5337 0000DFAF EB0C                <1> 	jmp	short pix_op_xor_4
  5338                              <1> 
  5339                              <1> 	; 65536 colors (16bpp)
  5340                              <1> pix_op_xor_2:
  5341 0000DFB1 E8EE060000          <1> 	call	pix_op_xor_16
  5342 0000DFB6 EB05                <1> 	jmp	short pix_op_xor_4
  5343                              <1> 
  5344                              <1> 	; 32 bit true colors
  5345                              <1> pix_op_xor_3:
  5346 0000DFB8 E8FE060000          <1> 	call	pix_op_xor_32
  5347                              <1> pix_op_xor_4:
  5348 0000DFBD 29F7                <1> 	sub	edi, esi
  5349 0000DFBF 893D[1C010300]      <1> 	mov	[u.r0], edi	
  5350                              <1> pix_op_xor_5:
  5351 0000DFC5 C3                  <1> 	retn		
  5352                              <1> 
  5353                              <1> pix_op_xor_w:
  5354                              <1> 	; 31/01/2021
  5355 0000DFC6 51                  <1> 	push	ecx ; * ; color
  5356 0000DFC7 89D1                <1> 	mov	ecx, edx ; win start pos
  5357 0000DFC9 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  5358 0000DFCB E8F7F9FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5359 0000DFD0 58                  <1> 	pop	eax ; * ; color
  5360 0000DFD1 72F2                <1> 	jc	short pix_op_xor_5
  5361                              <1> 
  5362 0000DFD3 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'xor' ?
  5363 0000DFDA 7405                <1> 	jz	short pix_op_xor_w_0 ; no
  5364 0000DFDC E9DC100000          <1> 	jmp	m_pix_op_xor_w 
  5365                              <1> 			; window 'xor' color except mask color
  5366                              <1> pix_op_xor_w_0:
  5367                              <1> 	; ecx = bytes per row (to be applied)
  5368                              <1> 	; edx = screen width in bytes
  5369                              <1> 	; ebx = row count
  5370                              <1> 	; eax = color
  5371                              <1> 
  5372 0000DFE1 8B3D[46100300]      <1> 	mov	edi, [v_str]
  5373 0000DFE7 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5374 0000DFEE 7707                <1> 	ja	short pix_op_xor_w_1
  5375                              <1> 
  5376                              <1> 	; 256 colors (8bpp)
  5377 0000DFF0 BD[9EE60000]        <1> 	mov	ebp, pix_op_xor_8
  5378 0000DFF5 EB1E                <1> 	jmp	short pix_op_xor_w_4
  5379                              <1> 			
  5380                              <1> pix_op_xor_w_1:
  5381 0000DFF7 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5382 0000DFFE 7710                <1> 	ja	short pix_op_xor_w_3 ; 32bpp
  5383 0000E000 7207                <1> 	jb	short pix_op_xor_w_2 ; 16bpp
  5384                              <1> 
  5385                              <1> 	; 24 bit true colors
  5386 0000E002 BD[ACE60000]        <1> 	mov	ebp, pix_op_xor_24
  5387 0000E007 EB0C                <1> 	jmp	short pix_op_xor_w_4
  5388                              <1> 
  5389                              <1> 	; 65536 colors (16bpp)
  5390                              <1> pix_op_xor_w_2:
  5391 0000E009 BD[A4E60000]        <1> 	mov	ebp, pix_op_xor_16
  5392 0000E00E EB05                <1> 	jmp	short pix_op_xor_w_4
  5393                              <1> 
  5394                              <1> 	; 32 bit true colors
  5395                              <1> pix_op_xor_w_3:
  5396 0000E010 BD[BBE60000]        <1> 	mov	ebp, pix_op_xor_32
  5397                              <1> pix_op_xor_w_4:
  5398 0000E015 E92EFDFFFF          <1> 	jmp	pix_op_xor_w_x
  5399                              <1> 
  5400                              <1> pix_op_new:
  5401                              <1> 	; 31/01/2021
  5402                              <1> 	; 30/01/2021
  5403                              <1> 	; CHANGE COLOR
  5404                              <1> 	;
  5405                              <1> 	; INPUT:
  5406                              <1> 	;   CL = color (8 bit, 256 colors)
  5407                              <1> 	;  ECX = color (16 bit and true colors)
  5408                              <1> 	;  EDX = start position (row, column)
  5409                              <1> 	;        (HW = row, DX = column)
  5410                              <1> 	;  ESI = size (rows, colums)
  5411                              <1> 	;        (HW = rows, SI = columns)
  5412                              <1> 	;
  5413                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5414                              <1> 	;
  5415                              <1> 	; OUTPUT:
  5416                              <1> 	; 	[u.r0] will be > 0 if succesful
  5417                              <1> 	
  5418 0000E01A F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5419 0000E021 7554                <1> 	jnz	short pix_op_new_w ; window
  5420                              <1> 	
  5421 0000E023 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  5422 0000E029 89FE                <1> 	mov	esi, edi
  5423                              <1> 	; ecx = color (CL, CX, ECX)
  5424 0000E02B 89C8                <1> 	mov	eax, ecx
  5425 0000E02D 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5426                              <1> 
  5427 0000E033 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color change ?
  5428 0000E03A 7405                <1> 	jz	short pix_op_new_0 ; no
  5429 0000E03C E90A0B0000          <1> 	jmp	m_pix_op_new ; change color except mask color
  5430                              <1> pix_op_new_0:
  5431 0000E041 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5432 0000E048 7706                <1> 	ja	short pix_op_new_2
  5433                              <1> 
  5434                              <1> 	; 256 colors (8bpp)
  5435                              <1> pix_op_new_1:
  5436 0000E04A 88C4                <1> 	mov	ah, al
  5437 0000E04C D1E9                <1> 	shr	ecx, 1	
  5438 0000E04E EB12                <1> 	jmp	short pix_op_new_3
  5439                              <1> 			
  5440                              <1> pix_op_new_2:
  5441 0000E050 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5442 0000E057 7713                <1> 	ja	short pix_op_new_4 ; 32bpp	
  5443 0000E059 7207                <1> 	jb	short pix_op_new_3 ; 16bpp
  5444                              <1> 
  5445                              <1> 	; 31/01/2021
  5446                              <1> 	
  5447                              <1> 	; 24 bit true colors
  5448 0000E05B E849050000          <1> 	call	pix_op_new_24
  5449                              <1> 
  5450 0000E060 EB0C                <1> 	jmp	short pix_op_new_5
  5451                              <1> 
  5452                              <1> 	; 65536 colors (16bpp)
  5453                              <1> pix_op_new_3:
  5454 0000E062 89C2                <1> 	mov	edx, eax
  5455 0000E064 C1E010              <1> 	shl	eax, 16
  5456 0000E067 6689D0              <1> 	mov	ax, dx
  5457 0000E06A D1E9                <1> 	shr	ecx, 1 ; dword counts
  5458                              <1> 	; 32 bit true colors	
  5459                              <1> pix_op_new_4:
  5460 0000E06C F3AB                <1> 	rep	stosd
  5461                              <1> pix_op_new_5:
  5462 0000E06E 29F7                <1> 	sub	edi, esi
  5463 0000E070 893D[1C010300]      <1> 	mov	[u.r0], edi	
  5464                              <1> pix_op_new_6:
  5465 0000E076 C3                  <1> 	retn		
  5466                              <1> 
  5467                              <1> pix_op_new_w:
  5468                              <1> 	; 31/01/2021
  5469                              <1> 	; 30/01/2021
  5470 0000E077 51                  <1> 	push	ecx ; * ; color
  5471 0000E078 89D1                <1> 	mov	ecx, edx ; win start pos
  5472 0000E07A 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  5473 0000E07C E846F9FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5474 0000E081 58                  <1> 	pop	eax ; * ; color
  5475 0000E082 72F2                <1> 	jc	short pix_op_new_6
  5476                              <1> 
  5477 0000E084 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color change ?
  5478 0000E08B 7405                <1> 	jz	short pix_op_new_w_0 ; no
  5479 0000E08D E9470B0000          <1> 	jmp	m_pix_op_new_w 
  5480                              <1> 			; window chg color except mask color
  5481                              <1> pix_op_new_w_0:
  5482                              <1> 	; ecx = bytes per row (to be applied)
  5483                              <1> 	; edx = screen width in bytes
  5484                              <1> 	; ebx = row count
  5485                              <1> 	; eax = color
  5486                              <1> 
  5487 0000E092 8B3D[46100300]      <1> 	mov	edi, [v_str]
  5488                              <1> 
  5489 0000E098 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5490 0000E09F 7707                <1> 	ja	short pix_op_new_w_1
  5491                              <1> 
  5492                              <1> 	; 256 colors (8bpp)
  5493 0000E0A1 BD[A2E50000]        <1> 	mov	ebp, pix_op_new_8
  5494 0000E0A6 EB1E                <1> 	jmp	short pix_op_new_w_x
  5495                              <1> 			
  5496                              <1> pix_op_new_w_1:
  5497 0000E0A8 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5498 0000E0AF 7710                <1> 	ja	short pix_op_new_w_3 ; 32bpp
  5499 0000E0B1 7207                <1> 	jb	short pix_op_new_w_2 ; 16bpp
  5500                              <1> 
  5501                              <1> 	; 24 bit true colors
  5502 0000E0B3 BD[A9E50000]        <1> 	mov	ebp, pix_op_new_24
  5503 0000E0B8 EB0C                <1> 	jmp	short pix_op_new_w_x
  5504                              <1> 
  5505                              <1> 	; 65536 colors (16bpp)
  5506                              <1> pix_op_new_w_2:
  5507 0000E0BA BD[A5E50000]        <1> 	mov	ebp, pix_op_new_16
  5508 0000E0BF EB05                <1> 	jmp	short pix_op_new_w_x
  5509                              <1> 
  5510                              <1> 	; 32 bit true colors
  5511                              <1> pix_op_new_w_3:
  5512 0000E0C1 BD[B5E50000]        <1> 	mov	ebp, pix_op_new_32
  5513                              <1> 	;jmp	short pix_op_new_w_x
  5514                              <1> 
  5515                              <1> pix_op_new_w_x:
  5516                              <1> pix_op_not_w_x:
  5517                              <1> pix_op_neg_w_x:
  5518                              <1> pix_op_inc_w_x:
  5519                              <1> pix_op_dec_w_x:
  5520                              <1> 	; 27/02/2021
  5521                              <1> 	; 01/02/2021
  5522                              <1> 	; 31/01/2021
  5523                              <1> 	; ecx = bytes per row (to be applied)
  5524                              <1> 	; edx = windows (screen) width in bytes
  5525                              <1> 	; ebx = row count
  5526                              <1> 	; eax = color
  5527                              <1> 	; ebp = pixel operation subroutine address
  5528                              <1> 	;push	edx ; 01/02/2021
  5529 0000E0C6 51                  <1> 	push	ecx
  5530 0000E0C7 57                  <1> 	push	edi
  5531 0000E0C8 8B0D[52100300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021
  5532 0000E0CE FFD5                <1> 	call	ebp ; call pixel-row operation
  5533 0000E0D0 5F                  <1> 	pop	edi
  5534 0000E0D1 59                  <1> 	pop	ecx ; bytes per row
  5535 0000E0D2 010D[1C010300]      <1> 	add	[u.r0], ecx
  5536                              <1> 	;pop	edx ; 01/02/2021
  5537 0000E0D8 01D7                <1> 	add	edi, edx ; next row
  5538 0000E0DA 4B                  <1> 	dec	ebx
  5539 0000E0DB 75E9                <1> 	jnz	short pix_op_new_w_x
  5540 0000E0DD C3                  <1> 	retn
  5541                              <1> 
  5542                              <1> pix_op_not:
  5543                              <1> 	; 31/01/2021
  5544                              <1> 	; NOT COLOR
  5545                              <1> 	;
  5546                              <1> 	; INPUT:
  5547                              <1> 	;  ECX = start position (row, column)
  5548                              <1> 	;        (HW = row, CX = column)
  5549                              <1> 	;  EDX = size (rows, colums)
  5550                              <1> 	;        (HW = rows, DX = columns)
  5551                              <1> 	;	 (0 -> invalid 	
  5552                              <1> 	;        (1 -> horizontal or vertical line)
  5553                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5554                              <1> 	;
  5555                              <1> 	; OUTPUT:
  5556                              <1> 	; 	[u.r0] will be > 0 if succesful
  5557                              <1> 	
  5558 0000E0DE F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5559 0000E0E5 7553                <1> 	jnz	short pix_op_not_w ; window
  5560                              <1> 	
  5561 0000E0E7 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  5562 0000E0ED 89FE                <1> 	mov	esi, edi
  5563 0000E0EF 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5564                              <1> 
  5565 0000E0F5 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'not' ?
  5566 0000E0FC 7405                <1> 	jz	short pix_op_not_0 ; no
  5567 0000E0FE E9ED0F0000          <1> 	jmp	m_pix_op_not ; 'not' color except mask color
  5568                              <1> pix_op_not_0:
  5569 0000E103 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5570 0000E10A 7707                <1> 	ja	short pix_op_not_1
  5571                              <1> 
  5572                              <1> 	; 256 colors (8bpp)
  5573 0000E10C E8F5050000          <1> 	call	pix_op_not_8
  5574 0000E111 EB1E                <1> 	jmp	short pix_op_not_4
  5575                              <1> 			
  5576                              <1> pix_op_not_1:
  5577 0000E113 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5578 0000E11A 7710                <1> 	ja	short pix_op_not_3 ; 32bpp	
  5579 0000E11C 7207                <1> 	jb	short pix_op_not_2 ; 16bpp
  5580                              <1> 
  5581                              <1> 	; 24 bit true colors
  5582 0000E11E E8F1050000          <1> 	call	pix_op_not_24
  5583 0000E123 EB0C                <1> 	jmp	short pix_op_not_4
  5584                              <1> 
  5585                              <1> 	; 65536 colors (16bpp)
  5586                              <1> pix_op_not_2:
  5587 0000E125 E8E2050000          <1> 	call	pix_op_not_16
  5588 0000E12A EB05                <1> 	jmp	short pix_op_not_4
  5589                              <1> 
  5590                              <1> 	; 32 bit true colors	
  5591                              <1> pix_op_not_3:
  5592 0000E12C E8EE050000          <1> 	call	pix_op_not_32
  5593                              <1> pix_op_not_4:
  5594 0000E131 29F7                <1> 	sub	edi, esi
  5595 0000E133 893D[1C010300]      <1> 	mov	[u.r0], edi	
  5596                              <1> pix_op_not_5:
  5597 0000E139 C3                  <1> 	retn
  5598                              <1> 
  5599                              <1> pix_op_not_w:
  5600                              <1> 	; 31/01/2021
  5601                              <1> 	; ecx = win start pos (row, column)
  5602                              <1> 	; edx = size (rows, columns)
  5603 0000E13A E888F8FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5604 0000E13F 72F8                <1> 	jc	short pix_op_not_5
  5605                              <1> 
  5606 0000E141 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked color 'not' ?
  5607 0000E148 7405                <1> 	jz	short pix_op_not_w_0 ; no
  5608 0000E14A E926100000          <1> 	jmp	m_pix_op_not_w 
  5609                              <1> 			; window 'not' color except mask color
  5610                              <1> pix_op_not_w_0:
  5611                              <1> 	; ecx = bytes per row (to be applied)
  5612                              <1> 	; edx = screen width in bytes
  5613                              <1> 	; ebx = row count
  5614                              <1> 
  5615 0000E14F 8B3D[46100300]      <1> 	mov	edi, [v_str]
  5616                              <1> 
  5617 0000E155 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5618 0000E15C 7707                <1> 	ja	short pix_op_not_w_1
  5619                              <1> 
  5620                              <1> 	; 256 colors (8bpp)
  5621 0000E15E BD[06E70000]        <1> 	mov	ebp, pix_op_not_8
  5622 0000E163 EB1E                <1> 	jmp	short pix_op_not_w_4
  5623                              <1> 			
  5624                              <1> pix_op_not_w_1:
  5625 0000E165 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5626 0000E16C 7710                <1> 	ja	short pix_op_not_w_3 ; 32bpp
  5627 0000E16E 7207                <1> 	jb	short pix_op_not_w_2 ; 16bpp
  5628                              <1> 
  5629                              <1> 	; 24 bit true colors
  5630 0000E170 BD[14E70000]        <1> 	mov	ebp, pix_op_not_24
  5631 0000E175 EB0C                <1> 	jmp	short pix_op_not_w_4
  5632                              <1> 
  5633                              <1> 	; 65536 colors (16bpp)
  5634                              <1> pix_op_not_w_2:
  5635 0000E177 BD[0CE70000]        <1> 	mov	ebp, pix_op_not_16
  5636 0000E17C EB05                <1> 	jmp	short pix_op_not_w_4
  5637                              <1> 
  5638                              <1> 	; 32 bit true colors
  5639                              <1> pix_op_not_w_3:
  5640 0000E17E BD[1FE70000]        <1> 	mov	ebp, pix_op_not_32
  5641                              <1> pix_op_not_w_4:
  5642 0000E183 E93EFFFFFF          <1> 	jmp	pix_op_not_w_x
  5643                              <1> 
  5644                              <1> pix_op_neg:
  5645                              <1> 	; 31/01/2021
  5646                              <1> 	; NEGATE COLOR
  5647                              <1> 	;
  5648                              <1> 	; INPUT:
  5649                              <1> 	;  ECX = start position (row, column)
  5650                              <1> 	;        (HW = row, CX = column)
  5651                              <1> 	;  EDX = size (rows, colums)
  5652                              <1> 	;        (HW = rows, DX = columns)
  5653                              <1> 	;	 (0 -> invalid 	
  5654                              <1> 	;        (1 -> horizontal or vertical line)
  5655                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5656                              <1> 	;
  5657                              <1> 	; OUTPUT:
  5658                              <1> 	; 	[u.r0] will be > 0 if succesful
  5659                              <1> 	
  5660 0000E188 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5661 0000E18F 7553                <1> 	jnz	short pix_op_neg_w ; window
  5662                              <1> 	
  5663 0000E191 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  5664 0000E197 89FE                <1> 	mov	esi, edi
  5665 0000E199 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5666                              <1> 
  5667 0000E19F F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked negate color ?
  5668 0000E1A6 7405                <1> 	jz	short pix_op_neg_0 ; no
  5669 0000E1A8 E9FB0F0000          <1> 	jmp	m_pix_op_neg ; 'neg' color except mask color
  5670                              <1> pix_op_neg_0:
  5671 0000E1AD 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5672 0000E1B4 7707                <1> 	ja	short pix_op_neg_1
  5673                              <1> 
  5674                              <1> 	; 256 colors (8bpp)
  5675 0000E1B6 E86C050000          <1> 	call	pix_op_neg_8
  5676 0000E1BB EB1E                <1> 	jmp	short pix_op_neg_4
  5677                              <1> 			
  5678                              <1> pix_op_neg_1:
  5679 0000E1BD 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5680 0000E1C4 7710                <1> 	ja	short pix_op_neg_3 ; 32bpp	
  5681 0000E1C6 7207                <1> 	jb	short pix_op_neg_2 ; 16bpp
  5682                              <1> 
  5683                              <1> 	; 24 bit true colors
  5684 0000E1C8 E868050000          <1> 	call	pix_op_neg_24
  5685 0000E1CD EB0C                <1> 	jmp	short pix_op_neg_4
  5686                              <1> 
  5687                              <1> 	; 65536 colors (16bpp)
  5688                              <1> pix_op_neg_2:
  5689 0000E1CF E859050000          <1> 	call	pix_op_neg_16
  5690 0000E1D4 EB05                <1> 	jmp	short pix_op_neg_4
  5691                              <1> 
  5692                              <1> 	; 32 bit true colors	
  5693                              <1> pix_op_neg_3:
  5694 0000E1D6 E86C050000          <1> 	call	pix_op_neg_32
  5695                              <1> pix_op_neg_4:
  5696 0000E1DB 29F7                <1> 	sub	edi, esi
  5697 0000E1DD 893D[1C010300]      <1> 	mov	[u.r0], edi	
  5698                              <1> pix_op_neg_5:
  5699 0000E1E3 C3                  <1> 	retn
  5700                              <1> 
  5701                              <1> pix_op_neg_w:
  5702                              <1> 	; 31/01/2021
  5703                              <1> 	; ecx = win start pos (row, column)
  5704                              <1> 	; edx = size (rows, columns)
  5705 0000E1E4 E8DEF7FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5706 0000E1E9 72F8                <1> 	jc	short pix_op_neg_5
  5707                              <1> 
  5708 0000E1EB F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked negate color ?
  5709 0000E1F2 7405                <1> 	jz	short pix_op_neg_w_0 ; no
  5710 0000E1F4 E934100000          <1> 	jmp	m_pix_op_neg_w 
  5711                              <1> 			; window 'neg' color except mask color
  5712                              <1> pix_op_neg_w_0:
  5713                              <1> 	; ecx = bytes per row (to be applied)
  5714                              <1> 	; edx = screen width in bytes
  5715                              <1> 	; ebx = row count
  5716                              <1> 
  5717 0000E1F9 8B3D[46100300]      <1> 	mov	edi, [v_str]
  5718                              <1> 
  5719 0000E1FF 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5720 0000E206 7707                <1> 	ja	short pix_op_neg_w_1
  5721                              <1> 
  5722                              <1> 	; 256 colors (8bpp)
  5723 0000E208 BD[27E70000]        <1> 	mov	ebp, pix_op_neg_8
  5724 0000E20D EB1E                <1> 	jmp	short pix_op_neg_w_4
  5725                              <1> 			
  5726                              <1> pix_op_neg_w_1:
  5727 0000E20F 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5728 0000E216 7710                <1> 	ja	short pix_op_neg_w_3 ; 32bpp
  5729 0000E218 7207                <1> 	jb	short pix_op_neg_w_2 ; 16bpp
  5730                              <1> 
  5731                              <1> 	; 24 bit true colors
  5732 0000E21A BD[35E70000]        <1> 	mov	ebp, pix_op_neg_24
  5733 0000E21F EB0C                <1> 	jmp	short pix_op_neg_w_4
  5734                              <1> 
  5735                              <1> 	; 65536 colors (16bpp)
  5736                              <1> pix_op_neg_w_2:
  5737 0000E221 BD[2DE70000]        <1> 	mov	ebp, pix_op_neg_16
  5738 0000E226 EB05                <1> 	jmp	short pix_op_neg_w_4
  5739                              <1> 
  5740                              <1> 	; 32 bit true colors
  5741                              <1> pix_op_neg_w_3:
  5742 0000E228 BD[47E70000]        <1> 	mov	ebp, pix_op_neg_32
  5743                              <1> pix_op_neg_w_4:
  5744 0000E22D E994FEFFFF          <1> 	jmp	pix_op_neg_w_x
  5745                              <1> 
  5746                              <1> pix_op_inc:
  5747                              <1> 	; 31/01/2021
  5748                              <1> 	; INCREASE COLOR
  5749                              <1> 	;
  5750                              <1> 	; INPUT:
  5751                              <1> 	;  ECX = start position (row, column)
  5752                              <1> 	;        (HW = row, CX = column)
  5753                              <1> 	;  EDX = size (rows, colums)
  5754                              <1> 	;        (HW = rows, DX = columns)
  5755                              <1> 	;	 (0 -> invalid 	
  5756                              <1> 	;        (1 -> horizontal or vertical line)
  5757                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5758                              <1> 	;
  5759                              <1> 	; OUTPUT:
  5760                              <1> 	; 	[u.r0] will be > 0 if succesful
  5761                              <1> 	
  5762 0000E232 F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5763 0000E239 7553                <1> 	jnz	short pix_op_inc_w ; window
  5764                              <1> 	
  5765 0000E23B 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  5766 0000E241 89FE                <1> 	mov	esi, edi
  5767 0000E243 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5768                              <1> 
  5769 0000E249 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked increase color ?
  5770 0000E250 7405                <1> 	jz	short pix_op_inc_0 ; no
  5771 0000E252 E909100000          <1> 	jmp	m_pix_op_inc ; 'inc' color except mask color
  5772                              <1> pix_op_inc_0:
  5773 0000E257 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5774 0000E25E 7707                <1> 	ja	short pix_op_inc_1
  5775                              <1> 
  5776                              <1> 	; 256 colors (8bpp)
  5777 0000E260 E8EA040000          <1> 	call	pix_op_inc_8
  5778 0000E265 EB1E                <1> 	jmp	short pix_op_inc_4
  5779                              <1> 			
  5780                              <1> pix_op_inc_1:
  5781 0000E267 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5782 0000E26E 7710                <1> 	ja	short pix_op_inc_3 ; 32bpp	
  5783 0000E270 7207                <1> 	jb	short pix_op_inc_2 ; 16bpp
  5784                              <1> 
  5785                              <1> 	; 24 bit true colors
  5786 0000E272 E8EF040000          <1> 	call	pix_op_inc_24
  5787 0000E277 EB0C                <1> 	jmp	short pix_op_inc_4
  5788                              <1> 
  5789                              <1> 	; 65536 colors (16bpp)
  5790                              <1> pix_op_inc_2:
  5791 0000E279 E8DB040000          <1> 	call	pix_op_inc_16
  5792 0000E27E EB05                <1> 	jmp	short pix_op_inc_4
  5793                              <1> 
  5794                              <1> 	; 32 bit true colors	
  5795                              <1> pix_op_inc_3:
  5796 0000E280 E8F5040000          <1> 	call	pix_op_inc_32
  5797                              <1> pix_op_inc_4:
  5798 0000E285 29F7                <1> 	sub	edi, esi
  5799 0000E287 893D[1C010300]      <1> 	mov	[u.r0], edi	
  5800                              <1> pix_op_inc_5:
  5801 0000E28D C3                  <1> 	retn			
  5802                              <1> 
  5803                              <1> pix_op_inc_w:
  5804                              <1> 	; 31/01/2021
  5805                              <1> 	; ecx = win start pos (row, column)
  5806                              <1> 	; edx = size (rows, columns)
  5807 0000E28E E834F7FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5808 0000E293 72F8                <1> 	jc	short pix_op_inc_5
  5809                              <1> 
  5810 0000E295 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked increase color ?
  5811 0000E29C 7405                <1> 	jz	short pix_op_inc_w_0 ; no
  5812 0000E29E E956100000          <1> 	jmp	m_pix_op_inc_w 
  5813                              <1> 			; window 'inc' color except mask color
  5814                              <1> pix_op_inc_w_0:
  5815                              <1> 	; ecx = bytes per row (to be applied)
  5816                              <1> 	; edx = screen width in bytes
  5817                              <1> 	; ebx = row count
  5818                              <1> 
  5819 0000E2A3 8B3D[46100300]      <1> 	mov	edi, [v_str]
  5820                              <1> 
  5821 0000E2A9 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5822 0000E2B0 7707                <1> 	ja	short pix_op_inc_w_1
  5823                              <1> 
  5824                              <1> 	; 256 colors (8bpp)
  5825 0000E2B2 BD[4FE70000]        <1> 	mov	ebp, pix_op_inc_8
  5826 0000E2B7 EB1E                <1> 	jmp	short pix_op_inc_w_4
  5827                              <1> 			
  5828                              <1> pix_op_inc_w_1:
  5829 0000E2B9 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5830 0000E2C0 7710                <1> 	ja	short pix_op_inc_w_3 ; 32bpp
  5831 0000E2C2 7207                <1> 	jb	short pix_op_inc_w_2 ; 16bpp
  5832                              <1> 
  5833                              <1> 	; 24 bit true colors
  5834 0000E2C4 BD[66E70000]        <1> 	mov	ebp, pix_op_inc_24
  5835 0000E2C9 EB0C                <1> 	jmp	short pix_op_inc_w_4
  5836                              <1> 
  5837                              <1> 	; 65536 colors (16bpp)
  5838                              <1> pix_op_inc_w_2:
  5839 0000E2CB BD[59E70000]        <1> 	mov	ebp, pix_op_inc_16
  5840 0000E2D0 EB05                <1> 	jmp	short pix_op_inc_w_4
  5841                              <1> 
  5842                              <1> 	; 32 bit true colors
  5843                              <1> pix_op_inc_w_3:
  5844 0000E2D2 BD[7AE70000]        <1> 	mov	ebp, pix_op_inc_32
  5845                              <1> pix_op_inc_w_4:
  5846 0000E2D7 E9EAFDFFFF          <1> 	jmp	pix_op_inc_w_x
  5847                              <1> 
  5848                              <1> pix_op_dec:
  5849                              <1> 	; 31/01/2021
  5850                              <1> 	; DECREASE COLOR
  5851                              <1> 	;
  5852                              <1> 	; INPUT:
  5853                              <1> 	;  ECX = start position (row, column)
  5854                              <1> 	;        (HW = row, CX = column)
  5855                              <1> 	;  EDX = size (rows, colums)
  5856                              <1> 	;        (HW = rows, DX = columns)
  5857                              <1> 	;	 (0 -> invalid 	
  5858                              <1> 	;        (1 -> horizontal or vertical line)
  5859                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5860                              <1> 	;
  5861                              <1> 	; OUTPUT:
  5862                              <1> 	; 	[u.r0] will be > 0 if succesful
  5863                              <1> 	
  5864 0000E2DC F605[3C100300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5865 0000E2E3 7553                <1> 	jnz	short pix_op_dec_w ; window
  5866                              <1> 	
  5867 0000E2E5 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  5868 0000E2EB 89FE                <1> 	mov	esi, edi
  5869 0000E2ED 8B0D[42100300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5870                              <1> 
  5871 0000E2F3 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked decrease color ?
  5872 0000E2FA 7405                <1> 	jz	short pix_op_dec_0 ; no
  5873 0000E2FC E92B100000          <1> 	jmp	m_pix_op_dec ; 'dec' color except mask color
  5874                              <1> pix_op_dec_0:
  5875 0000E301 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5876 0000E308 7707                <1> 	ja	short pix_op_dec_1
  5877                              <1> 
  5878                              <1> 	; 256 colors (8bpp)
  5879 0000E30A E877040000          <1> 	call	pix_op_dec_8
  5880 0000E30F EB1E                <1> 	jmp	short pix_op_dec_4
  5881                              <1> 			
  5882                              <1> pix_op_dec_1:
  5883 0000E311 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5884 0000E318 7710                <1> 	ja	short pix_op_dec_3 ; 32bpp	
  5885 0000E31A 7207                <1> 	jb	short pix_op_dec_2 ; 16bpp
  5886                              <1> 
  5887                              <1> 	; 24 bit true colors
  5888 0000E31C E87C040000          <1> 	call	pix_op_dec_24
  5889 0000E321 EB0C                <1> 	jmp	short pix_op_dec_4
  5890                              <1> 
  5891                              <1> 	; 65536 colors (16bpp)
  5892                              <1> pix_op_dec_2:
  5893 0000E323 E868040000          <1> 	call	pix_op_dec_16
  5894 0000E328 EB05                <1> 	jmp	short pix_op_dec_4
  5895                              <1> 
  5896                              <1> 	; 32 bit true colors	
  5897                              <1> pix_op_dec_3:
  5898 0000E32A E881040000          <1> 	call	pix_op_dec_32
  5899                              <1> pix_op_dec_4:
  5900 0000E32F 29F7                <1> 	sub	edi, esi
  5901 0000E331 893D[1C010300]      <1> 	mov	[u.r0], edi	
  5902                              <1> pix_op_dec_5:
  5903 0000E337 C3                  <1> 	retn			
  5904                              <1> 
  5905                              <1> pix_op_dec_w:
  5906                              <1> 	; 31/01/2021
  5907                              <1> 	; ecx = win start pos (row, column)
  5908                              <1> 	; edx = size (rows, columns)
  5909 0000E338 E88AF6FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5910 0000E33D 72F8                <1> 	jc	short pix_op_dec_5
  5911                              <1> 
  5912 0000E33F F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked decrease color ?
  5913 0000E346 7405                <1> 	jz	short pix_op_dec_w_0 ; no
  5914 0000E348 E973100000          <1> 	jmp	m_pix_op_dec_w 
  5915                              <1> 			; window 'dec' color except mask color
  5916                              <1> pix_op_dec_w_0:
  5917                              <1> 	; ecx = bytes per row (to be applied)
  5918                              <1> 	; edx = screen width in bytes
  5919                              <1> 	; ebx = row count
  5920                              <1> 
  5921 0000E34D 8B3D[46100300]      <1> 	mov	edi, [v_str]
  5922                              <1> 
  5923 0000E353 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5924 0000E35A 7707                <1> 	ja	short pix_op_dec_w_1
  5925                              <1> 
  5926                              <1> 	; 256 colors (8bpp)
  5927 0000E35C BD[86E70000]        <1> 	mov	ebp, pix_op_dec_8
  5928 0000E361 EB1E                <1> 	jmp	short pix_op_dec_w_4
  5929                              <1> 			
  5930                              <1> pix_op_dec_w_1:
  5931 0000E363 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5932 0000E36A 7710                <1> 	ja	short pix_op_dec_w_3 ; 32bpp
  5933 0000E36C 7207                <1> 	jb	short pix_op_dec_w_2 ; 16bpp
  5934                              <1> 
  5935                              <1> 	; 24 bit true colors
  5936 0000E36E BD[9DE70000]        <1> 	mov	ebp, pix_op_dec_24
  5937 0000E373 EB0C                <1> 	jmp	short pix_op_dec_w_4
  5938                              <1> 
  5939                              <1> 	; 65536 colors (16bpp)
  5940                              <1> pix_op_dec_w_2:
  5941 0000E375 BD[90E70000]        <1> 	mov	ebp, pix_op_dec_16
  5942 0000E37A EB05                <1> 	jmp	short pix_op_dec_w_4
  5943                              <1> 
  5944                              <1> 	; 32 bit true colors
  5945                              <1> pix_op_dec_w_3:
  5946 0000E37C BD[B0E70000]        <1> 	mov	ebp, pix_op_dec_32
  5947                              <1> pix_op_dec_w_4:
  5948 0000E381 E940FDFFFF          <1> 	jmp	pix_op_dec_w_x
  5949                              <1> 
  5950                              <1> pix_op_blk:
  5951                              <1> 	; 11/08/2022 (TRDOS 386 Kernel v2.0.5)
  5952                              <1> 	; 23/01/2021
  5953                              <1> 	; 22/02/2021
  5954                              <1> 	; 02/02/2021
  5955                              <1> 	; COPY PIXEL BLOCK -system to system-
  5956                              <1> 	; WRITE PIXEL BLOCKS -user to system-
  5957                              <1> 	;
  5958                              <1> 	; INPUT:
  5959                              <1> 	;   -If BL bit 5 is 0-	
  5960                              <1> 	;    ECX = start position (row, column) (*)
  5961                              <1> 	;    (HW = row, CX = column)
  5962                              <1> 	;    EDX = size (rows, colums) (*)
  5963                              <1> 	;    (HW = rows, DX = columns)
  5964                              <1> 	;         (0 -> invalid)
  5965                              <1> 	;         (1 -> horizontal or vertical line)
  5966                              <1> 	;    ESI = destination (row, column) (***)
  5967                              <1> 	;   -If BL bit 5 is 1-	
  5968                              <1> 	;     CL = color (8 bit, 256 colors)
  5969                              <1> 	;    ECX = color (16 bit and true colors)
  5970                              <1> 	;    EDX = count of blocks (not bytes)
  5971                              <1> 	;	 (limit: 2048 blocks/windows)	  	
  5972                              <1> 	;    ESI = user's buffer address 
  5973                              <1> 	;	  contains 64 bit block data
  5974                              <1> 	;	  BLOCK ADDRESS - (row, col), dword
  5975                              <1> 	;	  (first 32 bits)
  5976                              <1> 	;	  BLOCK SIZE - (rows, cols), dword
  5977                              <1> 	;	  (second 32 bits)
  5978                              <1> 	; OUTPUT:
  5979                              <1> 	; 	[u.r0] will be > 0 if succesful
  5980                              <1> 
  5981                              <1> 	; Window option ([v_ops] bit 4) will be ignored  	
  5982                              <1> 	; (Function is used for display page coordinates)
  5983                              <1> 
  5984 0000E386 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked or direct ?
  5985 0000E38D 755A                <1> 	jnz	short pix_op_blk_u ; blocks from user's buffer
  5986                              <1> 
  5987 0000E38F 89F0                <1> 	mov	eax, esi ; destination position (row, col)
  5988 0000E391 E8DEF6FFFF          <1> 	call	calc_pixel_offset
  5989 0000E396 3B05[42100300]      <1> 	cmp	eax, [v_siz]
  5990 0000E39C 734A                <1> 	jnb	short pix_op_blk_retn ; out of display page
  5991 0000E39E 89C6                <1> 	mov	esi, eax
  5992 0000E3A0 E8ACF6FFFF          <1> 	call	pixels_to_byte_count
  5993 0000E3A5 89C7                <1> 	mov	edi, eax
  5994 0000E3A7 89D0                <1> 	mov	eax, edx  ; size
  5995 0000E3A9 E8C6F6FFFF          <1> 	call	calc_pixel_offset
  5996                              <1> 	; 22/02/2021
  5997 0000E3AE 3B05[42100300]      <1> 	cmp	eax, [v_siz]
  5998 0000E3B4 7732                <1> 	ja	short pix_op_blk_retn ; out of display page
  5999 0000E3B6 01C6                <1> 	add	esi, eax
  6000 0000E3B8 3B35[42100300]      <1> 	cmp	esi, [v_siz]
  6001 0000E3BE 7728                <1> 	ja	short pix_op_blk_retn ; out of display page
  6002                              <1> 
  6003 0000E3C0 033D[3E100300]      <1> 	add	edi, [v_mem] ; destination address
  6004                              <1> 	
  6005                              <1> 	; 23/01/2021
  6006                              <1> 	;call	pixels_to_byte_count
  6007                              <1> 	;add	edi, eax
  6008                              <1> 	;jc	short pix_op_blk_retn ; out of display page
  6009                              <1> 	;cmp	edi, [v_end]
  6010                              <1> 	;ja	short pix_op_blk_retn ; out of display page
  6011                              <1> 	;sub	edi, eax
  6012                              <1> 
  6013 0000E3C6 E8FCF5FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  6014 0000E3CB 721B                <1> 	jc	short pix_op_blk_retn ; something wrong !?
  6015                              <1> 	; ecx = bytes per row (to be applied)
  6016                              <1> 	; edx = screen width in bytes
  6017                              <1> 	; ebx = row count
  6018                              <1> 
  6019 0000E3CD 8B35[46100300]      <1> 	mov	esi, [v_str] ; source address
  6020                              <1> 
  6021                              <1> 	; Note:
  6022                              <1> 	; ecx & edx are already adjusted for pixel sizes
  6023                              <1> 	; so, following code is proper all pixel sizes
  6024                              <1> 
  6025 0000E3D3 29CA                <1> 	sub	edx, ecx ; screen width - window width
  6026                              <1> pix_op_blk_0:
  6027 0000E3D5 89C8                <1> 	mov	eax, ecx
  6028 0000E3D7 0105[1C010300]      <1> 	add	[u.r0], eax
  6029 0000E3DD F3A4                <1> 	rep	movsb
  6030 0000E3DF 89C1                <1> 	mov	ecx, eax	
  6031 0000E3E1 01D6                <1> 	add	esi, edx ; next row
  6032 0000E3E3 01D7                <1> 	add	edi, edx ; next row
  6033 0000E3E5 4B                  <1> 	dec	ebx
  6034 0000E3E6 75ED                <1> 	jnz	short pix_op_blk_0
  6035                              <1> pix_op_blk_retn:
  6036 0000E3E8 C3                  <1> 	retn
  6037                              <1> 
  6038                              <1> pix_op_blk_u:
  6039                              <1> 	; fill blocks (windows) with desired color
  6040                              <1> 	; according to block definitions in user's buffer
  6041 0000E3E9 81FA00080000        <1> 	cmp	edx, 2048
  6042 0000E3EF 7605                <1> 	jna	short pix_op_blk_u_0
  6043                              <1> 	; Maximum 2048 blocks
  6044 0000E3F1 BA00080000          <1> 	mov	edx, 2048
  6045                              <1> pix_op_blk_u_0:
  6046 0000E3F6 8025[3C100300]DF    <1> 	and	byte [v_ops], ~20h ; clear masked bit
  6047 0000E3FD 890D[4E100300]      <1> 	mov	[maskcolor], ecx ; save pixel color
  6048                              <1> 	; 22/02/2021
  6049                              <1> 	;mov	ebp, edx ; save blocks count
  6050                              <1> 	;push	ebp
  6051                              <1> pix_op_blk_u_next:
  6052 0000E403 52                  <1> 	push	edx
  6053                              <1> 	;mov	ecx, 8
  6054                              <1> 	; 11/08/2022
  6055 0000E404 29C9                <1> 	sub	ecx, ecx
  6056 0000E406 B108                <1> 	mov	cl, 8
  6057 0000E408 BF[56100300]        <1> 	mov	edi, buffer8 ; 8 bytes small buffer
  6058                              <1> 	; esi = user's buffer address
  6059 0000E40D E891290000          <1> 	call	transfer_from_user_buffer
  6060 0000E412 72D4                <1> 	jc	short pix_op_blk_retn
  6061 0000E414 01CE                <1> 	add	esi, ecx ; 22/02/2021
  6062 0000E416 56                  <1> 	push	esi
  6063 0000E417 8B15[56100300]      <1> 	mov	edx, [buffer8] ; block start pos (row,col)
  6064 0000E41D 8B35[5A100300]      <1> 	mov	esi, [buffer8+4] ; block size (rows,cols)
  6065 0000E423 8B0D[4E100300]      <1> 	mov	ecx, [maskcolor]
  6066 0000E429 E849FCFFFF          <1> 	call	pix_op_new_w ; new (change) color (window)
  6067 0000E42E 5E                  <1> 	pop	esi
  6068                              <1> 	;pop	ebp
  6069                              <1> 	;dec	ebp
  6070 0000E42F 5A                  <1> 	pop	edx
  6071 0000E430 4A                  <1> 	dec	edx
  6072 0000E431 75D0                <1> 	jnz	short pix_op_blk_u_next
  6073 0000E433 C3                  <1> 	retn
  6074                              <1> 
  6075                              <1> pix_op_lin:
  6076                              <1> 	; 11/08/2022
  6077                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
  6078                              <1> 	; 12/02/2021
  6079                              <1> 	; 11/02/2021
  6080                              <1> 	; 10/02/2021
  6081                              <1> 	; 05/02/2021
  6082                              <1> 	; 02/02/2021
  6083                              <1> 	; WRITE LINE -direct-
  6084                              <1> 	; WRITE LINE(S) -via user's buffer-
  6085                              <1> 	;
  6086                              <1> 	; INPUT:
  6087                              <1> 	;   -If BL bit 5 is 0-	
  6088                              <1> 	;     CL = color (8 bit, 256 colors)
  6089                              <1> 	;    ECX = color (16 bit and true colors)
  6090                              <1> 	;     DX = low 12 bits - size (length)
  6091                              <1> 	;	   high 4 bits - direction or type
  6092                              <1> 	;	     0 - Horizontal line
  6093                              <1> 	;	     1 - Vertical line
  6094                              <1> 	;	   > 1 - undefined, invalid
  6095                              <1> 	;    ESI = start position (row, column)
  6096                              <1> 	;	  (HW = row, SI = column)
  6097                              <1> 	;   -If BL bit 5 is 1-
  6098                              <1> 	;     CL = color (8 bit, 256 colors)
  6099                              <1> 	;    ECX = color (16 bit and true colors)
  6100                              <1> 	;     DX = number of lines (in user buffer)
  6101                              <1> 	;	   (limit: 2048 lines)	
  6102                              <1> 	;    ESI = user's buffer
  6103                              <1> 	;          contains 64 bit data for lines
  6104                              <1> 	;	   START POINT: 32 bit (row, col)
  6105                              <1> 	;	   LENGTH: 32 bit
  6106                              <1> 	;		   high 16 bits - 0
  6107                              <1> 	;		   bit 0-11 - length
  6108                              <1> 	;	   	   bit 12-15 - type (length)
  6109                              <1> 	; OUTPUT:
  6110                              <1> 	; 	[u.r0] will be > 0 if succesful
  6111                              <1> 
  6112                              <1> 	; Window option ([v_ops] bit 4) will be ignored
  6113                              <1> 	; (Function is used for display page coordinates)
  6114                              <1> 
  6115                              <1> 	; 10/02/2021
  6116 0000E434 F605[3C100300]20    <1> 	test	byte [v_ops], 20h ; masked or direct ?
  6117 0000E43B 7444                <1> 	jz	short pix_op_lin_vh ; direct (v/h lines) 
  6118                              <1> 
  6119                              <1> 	; lines from user's buffer
  6120                              <1> pix_op_lin_u:
  6121                              <1> 	; draw lines with desired color
  6122                              <1> 	; according to line definitions in user's buffer
  6123 0000E43D 81FA00080000        <1> 	cmp	edx, 2048
  6124 0000E443 7605                <1> 	jna	short pix_op_lin_u_0
  6125                              <1> 	; Maximum 2048 lines
  6126 0000E445 BA00080000          <1> 	mov	edx, 2048
  6127                              <1> pix_op_lin_u_0:
  6128 0000E44A 890D[4E100300]      <1> 	mov	[maskcolor], ecx ; save pixel color
  6129 0000E450 89D5                <1> 	mov	ebp, edx ; save line count
  6130                              <1> pix_op_lin_u_next:
  6131                              <1> 	;mov	ecx, 8
  6132                              <1> 	; 11/08/2022
  6133 0000E452 29C9                <1> 	sub	ecx, ecx
  6134 0000E454 B108                <1> 	mov	cl, 8
  6135 0000E456 BF[56100300]        <1> 	mov	edi, buffer8 ; 8 bytes small buffer
  6136                              <1> 	; esi = user's buffer address
  6137 0000E45B E843290000          <1> 	call	transfer_from_user_buffer
  6138 0000E460 721E                <1> 	jc	short pix_op_lin_retn
  6139 0000E462 01CE                <1> 	add	esi, ecx ; 11/02/2021
  6140 0000E464 56                  <1> 	push	esi
  6141 0000E465 8B35[56100300]      <1> 	mov	esi, [buffer8] ; line start pos (row,col)
  6142 0000E46B 8B15[5A100300]      <1> 	mov	edx, [buffer8+4] ; line length
  6143 0000E471 8B0D[4E100300]      <1> 	mov	ecx, [maskcolor]
  6144 0000E477 E805000000          <1> 	call	pix_op_lin_vh ; new (change) color (window)
  6145 0000E47C 5E                  <1> 	pop	esi
  6146 0000E47D 4D                  <1> 	dec	ebp
  6147 0000E47E 75D2                <1> 	jnz	short pix_op_lin_u_next
  6148                              <1> pix_op_lin_retn:
  6149 0000E480 C3                  <1> 	retn
  6150                              <1> 
  6151                              <1> pix_op_lin_vh:
  6152 0000E481 81FA38140000        <1> 	cmp	edx, 1438h ; 1920*1080 (780hx438h) limit
  6153 0000E487 7762                <1> 	ja	short pix_op_lin_err1 ; invalid type 
  6154                              <1> 			    	; (for current version)
  6155 0000E489 66F7C2FF0F          <1> 	test	dx, 0FFFh
  6156 0000E48E 745B                <1> 	jz	short pix_op_lin_err1 ; zero length!
  6157                              <1> 
  6158 0000E490 89F0                <1> 	mov	eax, esi ; start point (row, col)
  6159 0000E492 E8DDF5FFFF          <1> 	call	calc_pixel_offset
  6160 0000E497 3B05[42100300]      <1> 	cmp	eax, [v_siz]
  6161 0000E49D 734C                <1> 	jnb	short pix_op_lin_err1 ; out of display page!
  6162 0000E49F E8ADF5FFFF          <1> 	call	pixels_to_byte_count
  6163 0000E4A4 89C7                <1> 	mov	edi, eax ; start point offset
  6164 0000E4A6 033D[3E100300]      <1> 	add	edi, [v_mem] ; LFB start address
  6165 0000E4AC 89C8                <1> 	mov	eax, ecx ; color
  6166                              <1> 
  6167 0000E4AE F6C610              <1> 	test	dh, 10h
  6168                              <1> 	;jz	pix_op_lin_h ; Horizontal line
  6169                              <1> 	; 23/07/2022
  6170 0000E4B1 7505                <1> 	jnz	short pix_op_lin_v
  6171 0000E4B3 E98A000000          <1> 	jmp	pix_op_lin_h
  6172                              <1> 
  6173                              <1> pix_op_lin_v:
  6174                              <1> 	; Vertical line
  6175 0000E4B8 80E60F              <1> 	and 	dh, 0Fh ; low 12 bits
  6176 0000E4BB 51                  <1> 	push	ecx ; color
  6177 0000E4BC 89D1                <1> 	mov	ecx, edx
  6178 0000E4BE 0FB705[3A100300]    <1> 	movzx	eax, word [v_width]
  6179 0000E4C5 89C3                <1> 	mov	ebx, eax
  6180                              <1> 	; 12/02/2021
  6181 0000E4C7 F7E2                <1> 	mul	edx ; rows * [v_width]
  6182 0000E4C9 01F8                <1> 	add	eax, edi
  6183 0000E4CB 3B05[4A100300]      <1> 	cmp	eax, [v_end]
  6184 0000E4D1 58                  <1> 	pop	eax ; color
  6185 0000E4D2 7717                <1> 	ja	short pix_op_lin_err1 ; out of display page
  6186                              <1> 	; ecx = rows	
  6187 0000E4D4 89CA                <1> 	mov	edx, ecx
  6188                              <1> 
  6189 0000E4D6 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  6190 0000E4DD 770D                <1> 	ja	short pix_op_lin_v_2
  6191                              <1> 	; 256 colors (1 byte per pixel)
  6192 0000E4DF 010D[1C010300]      <1> 	add	[u.r0], ecx ; byte count
  6193                              <1> pix_op_lin_v_1:
  6194 0000E4E5 8807                <1> 	mov	[edi], al
  6195 0000E4E7 01DF                <1> 	add	edi, ebx  ; next row	
  6196 0000E4E9 E2FA                <1> 	loop	pix_op_lin_v_1
  6197                              <1> pix_op_lin_err1:
  6198 0000E4EB C3                  <1> 	retn
  6199                              <1> 
  6200                              <1> pix_op_lin_v_2:
  6201 0000E4EC 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  6202 0000E4F3 773A                <1> 	ja	short pix_op_lin_v_6 ; 32bpp
  6203 0000E4F5 7226                <1> 	jb	short pix_op_lin_v_4 ; 16bpp
  6204                              <1> 	
  6205                              <1> 	; 24 bit true colors
  6206                              <1> 	; * 3
  6207 0000E4F7 53                  <1> 	push	ebx ; screen width in pixels
  6208 0000E4F8 D1E3                <1> 	shl	ebx, 1
  6209 0000E4FA 011C24              <1> 	add	[esp], ebx
  6210 0000E4FD 5B                  <1> 	pop	ebx ; screen width in bytes
  6211 0000E4FE 010D[1C010300]      <1> 	add	[u.r0], ecx
  6212 0000E504 D1E2                <1> 	shl	edx, 1
  6213 0000E506 0115[1C010300]      <1> 	add	[u.r0], edx ; byte count
  6214                              <1> pix_op_lin_v_3:
  6215 0000E50C 668907              <1> 	mov	[edi], ax
  6216 0000E50F C1C810              <1> 	ror	eax, 16
  6217 0000E512 884702              <1> 	mov	[edi+2], al	
  6218 0000E515 C1C010              <1> 	rol	eax, 16
  6219 0000E518 01DF                <1> 	add	edi, ebx  ; next row	
  6220 0000E51A E2F0                <1> 	loop	pix_op_lin_v_3
  6221 0000E51C C3                  <1> 	retn
  6222                              <1> 
  6223                              <1> pix_op_lin_v_4:
  6224                              <1> 	; 16 bit (65536) colors
  6225 0000E51D D1E3                <1> 	shl	ebx, 1
  6226 0000E51F D1E2                <1> 	shl	edx, 1
  6227 0000E521 0115[1C010300]      <1> 	add	[u.r0], edx
  6228                              <1> pix_op_lin_v_5:
  6229 0000E527 668907              <1> 	mov	[edi], ax
  6230 0000E52A 01DF                <1> 	add	edi, ebx  ; next row	
  6231 0000E52C E2F9                <1> 	loop	pix_op_lin_v_5
  6232 0000E52E C3                  <1> 	retn
  6233                              <1> 
  6234                              <1> pix_op_lin_v_6:
  6235                              <1> 	; 32 bit true colors
  6236 0000E52F C1E302              <1> 	shl	ebx, 2
  6237 0000E532 C1E202              <1> 	shl	edx, 2
  6238 0000E535 0115[1C010300]      <1> 	add	[u.r0], edx ; byte count
  6239                              <1> pix_op_lin_v_7:
  6240 0000E53B 8907                <1> 	mov	[edi], eax
  6241 0000E53D 01DF                <1> 	add	edi, ebx  ; next row	
  6242 0000E53F E2FA                <1> 	loop	pix_op_lin_v_7
  6243 0000E541 C3                  <1> 	retn		
  6244                              <1> 
  6245                              <1> pix_op_lin_h:
  6246                              <1> 	; Horizontal line
  6247 0000E542 80E60F              <1> 	and 	dh, 0Fh ; low 12 bits
  6248 0000E545 89D1                <1>   	mov	ecx, edx
  6249 0000E547 6601D6              <1> 	add	si, dx ; start column + columns
  6250 0000E54A 663B35[3A100300]    <1> 	cmp	si, [v_width] ; screen width
  6251 0000E551 7711                <1> 	ja	short pix_op_lin_err2 ; out of columns limit
  6252                              <1> 
  6253 0000E553 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  6254 0000E55A 7709                <1> 	ja	short pix_op_lin_h_1
  6255                              <1> 	; 256 colors (1 byte per pixel)
  6256 0000E55C 010D[1C010300]      <1> 	add	[u.r0], ecx
  6257 0000E562 F3AA                <1> 	rep	stosb
  6258                              <1> pix_op_lin_err2:
  6259 0000E564 C3                  <1> 	retn
  6260                              <1> 
  6261                              <1> pix_op_lin_h_1:
  6262 0000E565 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  6263 0000E56C 7728                <1> 	ja	short pix_op_lin_h_4 ; 32bpp
  6264 0000E56E 721A                <1> 	jb	short pix_op_lin_h_3 ; 16bpp
  6265                              <1> 	
  6266                              <1> 	; 24 bit true colors
  6267                              <1> 	; * 3
  6268 0000E570 0115[1C010300]      <1> 	add	[u.r0], edx
  6269 0000E576 D1E2                <1> 	shl	edx, 1
  6270 0000E578 0115[1C010300]      <1> 	add	[u.r0], edx
  6271                              <1> pix_op_lin_h_2:
  6272 0000E57E 66AB                <1> 	stosw
  6273 0000E580 C1C810              <1> 	ror	eax, 16
  6274 0000E583 AA                  <1> 	stosb	
  6275 0000E584 C1C010              <1> 	rol	eax, 16
  6276 0000E587 E2F5                <1> 	loop	pix_op_lin_h_2
  6277 0000E589 C3                  <1> 	retn
  6278                              <1> 
  6279                              <1> pix_op_lin_h_3:
  6280                              <1> 	; 16 bit (65536) colors
  6281 0000E58A D1E2                <1> 	shl	edx, 1
  6282 0000E58C 0115[1C010300]      <1> 	add	[u.r0], edx
  6283 0000E592 F366AB              <1> 	rep	stosw
  6284 0000E595 C3                  <1> 	retn
  6285                              <1> 
  6286                              <1> pix_op_lin_h_4:
  6287                              <1> 	; 32 bit true colors
  6288 0000E596 C1E202              <1> 	shl	edx, 2
  6289 0000E599 0115[1C010300]      <1> 	add	[u.r0], edx
  6290 0000E59F F3AB                <1> 	rep	stosd
  6291 0000E5A1 C3                  <1> 	retn
  6292                              <1> 
  6293                              <1> pix_op_new_8:
  6294                              <1> 	; 8 bit colors (256 colors)
  6295                              <1> 	; CHANGE PIXEL COLOR
  6296                              <1> 	; ecx = pixel count per row
  6297                              <1> 	;  al = color
  6298                              <1> 	; edi = start pixel address 
  6299                              <1> 
  6300 0000E5A2 F3AA                <1> 	rep	stosb
  6301 0000E5A4 C3                  <1> 	retn
  6302                              <1> 
  6303                              <1> pix_op_new_16:
  6304                              <1> 	; 16 bit colors (65536 colors)
  6305                              <1> 	; CHANGE PIXEL COLOR
  6306                              <1> 	; ecx = pixel count per row
  6307                              <1> 	;  ax = color
  6308                              <1> 	; edi = start pixel address 
  6309                              <1> 
  6310 0000E5A5 F366AB              <1> 	rep	stosw
  6311 0000E5A8 C3                  <1> 	retn
  6312                              <1> 
  6313                              <1> pix_op_new_24:
  6314                              <1> 	; 24 bit true colors
  6315                              <1> 	; CHANGE PIXEL COLOR
  6316                              <1> 	; ecx = pixel count per row
  6317                              <1> 	; eax = color
  6318                              <1> 	; edi = start pixel address 
  6319                              <1> 
  6320 0000E5A9 66AB                <1> 	stosw
  6321 0000E5AB C1C810              <1> 	ror	eax, 16	
  6322 0000E5AE AA                  <1> 	stosb
  6323 0000E5AF C1C010              <1> 	rol	eax, 16
  6324 0000E5B2 E2F5                <1> 	loop	pix_op_new_24
  6325 0000E5B4 C3                  <1> 	retn
  6326                              <1> 
  6327                              <1> pix_op_new_32:
  6328                              <1> 	; 32 bit true colors
  6329                              <1> 	; CHANGE PIXEL COLOR
  6330                              <1> 	; ecx = pixel count per row
  6331                              <1> 	; eax = color
  6332                              <1> 	; edi = start pixel address 
  6333                              <1> 
  6334 0000E5B5 F3AB                <1> 	rep	stosd
  6335 0000E5B7 C3                  <1> 	retn
  6336                              <1> 
  6337                              <1> pix_op_add_8:
  6338                              <1> 	; 8 bit colors (256 colors)
  6339                              <1> 	; ADD PIXEL COLOR
  6340                              <1> 	; ecx = pixel count per row
  6341                              <1> 	;  al = color
  6342                              <1> 	; edi = start pixel address 
  6343                              <1> 
  6344 0000E5B8 88C4                <1> 	mov	ah, al
  6345                              <1> pix_op_add_8_0:
  6346 0000E5BA 0207                <1> 	add	al, [edi]
  6347 0000E5BC 7302                <1> 	jnc	short pix_op_add_8_1
  6348 0000E5BE B0FF                <1> 	mov	al, 0FFh ; Max. value	
  6349                              <1> pix_op_add_8_1:
  6350 0000E5C0 AA                  <1> 	stosb
  6351 0000E5C1 88E0                <1> 	mov	al, ah
  6352 0000E5C3 E2F5                <1> 	loop	pix_op_add_8_0
  6353 0000E5C5 C3                  <1> 	retn
  6354                              <1> 
  6355                              <1> pix_op_add_16:
  6356                              <1> 	; 16 bit colors (65536 colors)
  6357                              <1> 	; ADD PIXEL COLOR
  6358                              <1> 	; ecx = pixel count per row
  6359                              <1> 	;  ax = color
  6360                              <1> 	; edi = start pixel address 
  6361                              <1> 
  6362 0000E5C6 89C2                <1> 	mov	edx, eax
  6363                              <1> pix_op_add_16_0:
  6364 0000E5C8 660307              <1> 	add	ax, [edi]
  6365 0000E5CB 7304                <1> 	jnc	short pix_op_add_16_1
  6366 0000E5CD 66B8FFFF            <1> 	mov	ax, 0FFFFh ; Max. value	
  6367                              <1> pix_op_add_16_1:
  6368 0000E5D1 66AB                <1> 	stosw
  6369 0000E5D3 89D0                <1> 	mov	eax, edx
  6370 0000E5D5 E2F1                <1> 	loop	pix_op_add_16_0
  6371 0000E5D7 C3                  <1> 	retn
  6372                              <1> 
  6373                              <1> pix_op_add_24:
  6374                              <1> 	; 24 bit true colors
  6375                              <1> 	; ADD PIXEL COLOR
  6376                              <1> 	; ecx = pixel count per row
  6377                              <1> 	; eax = color
  6378                              <1> 	; edi = start pixel address 
  6379                              <1> 
  6380 0000E5D8 53                  <1> 	push	ebx
  6381 0000E5D9 BBFFFFFF00          <1> 	mov	ebx, 0FFFFFFh
  6382                              <1> 	;and	eax, ebx ; 0FFFFFFh
  6383 0000E5DE 89C2                <1> 	mov	edx, eax
  6384                              <1> pix_op_add_24_0:
  6385 0000E5E0 8B07                <1> 	mov	eax, [edi]
  6386 0000E5E2 21D8                <1> 	and	eax, ebx ; 0FFFFFFh
  6387 0000E5E4 01D0                <1> 	add	eax, edx
  6388 0000E5E6 39D8                <1> 	cmp	eax, ebx
  6389 0000E5E8 7602                <1> 	jna	short pix_op_add_24_1
  6390 0000E5EA 89D8                <1> 	mov	eax, ebx ; 0FFFFFFh  ; Max. value
  6391                              <1> pix_op_add_24_1: 
  6392 0000E5EC 66AB                <1> 	stosw
  6393 0000E5EE C1E810              <1> 	shr	eax, 16
  6394 0000E5F1 AA                  <1> 	stosb
  6395 0000E5F2 E2EC                <1> 	loop	pix_op_add_24_0
  6396 0000E5F4 89D0                <1> 	mov	eax, edx
  6397 0000E5F6 5B                  <1> 	pop	ebx
  6398 0000E5F7 C3                  <1> 	retn
  6399                              <1> 
  6400                              <1> pix_op_add_32:
  6401                              <1> 	; 32 bit true colors
  6402                              <1> 	; ADD PIXEL COLOR
  6403                              <1> 	; ecx = pixel count per row
  6404                              <1> 	; eax = color
  6405                              <1> 	; edi = start pixel address 
  6406                              <1> 
  6407 0000E5F8 89C2                <1> 	mov	edx, eax
  6408                              <1> pix_op_add_32_0:
  6409 0000E5FA 0307                <1> 	add	eax, [edi]
  6410 0000E5FC 7303                <1> 	jnc	short pix_op_add_32_1
  6411                              <1> 	;mov	eax, 0FFFFFFFFh ; Max. value
  6412 0000E5FE 29C0                <1> 	sub	eax, eax
  6413 0000E600 48                  <1> 	dec	eax	
  6414                              <1> pix_op_add_32_1:
  6415 0000E601 AB                  <1> 	stosd
  6416 0000E602 89D0                <1> 	mov	eax, edx
  6417 0000E604 E2F4                <1> 	loop	pix_op_add_32_0
  6418 0000E606 C3                  <1> 	retn
  6419                              <1> 
  6420                              <1> pix_op_sub_8:
  6421                              <1> 	; 8 bit colors (256 colors)
  6422                              <1> 	; SUBTRACT PIXEL COLOR
  6423                              <1> 	; ecx = pixel count per row
  6424                              <1> 	;  al = color
  6425                              <1> 	; edi = start pixel address 
  6426                              <1> 
  6427 0000E607 88C4                <1> 	mov	ah, al
  6428                              <1> pix_op_sub_8_0:
  6429 0000E609 8A07                <1> 	mov	al, [edi]
  6430 0000E60B 28E0                <1> 	sub	al, ah
  6431 0000E60D 7302                <1> 	jnb	short pix_op_sub_8_1
  6432 0000E60F 30C0                <1> 	xor	al, al ; 0 ; Min. value	
  6433                              <1> pix_op_sub_8_1:
  6434 0000E611 AA                  <1> 	stosb
  6435 0000E612 E2F5                <1> 	loop	pix_op_sub_8_0
  6436 0000E614 88E0                <1> 	mov	al, ah
  6437 0000E616 C3                  <1> 	retn
  6438                              <1> 
  6439                              <1> pix_op_sub_16:
  6440                              <1> 	; 16 bit colors (65536 colors)
  6441                              <1> 	; SUBTRACT PIXEL COLOR
  6442                              <1> 	; ecx = pixel count per row
  6443                              <1> 	;  ax = color
  6444                              <1> 	; edi = start pixel address 
  6445                              <1> 
  6446 0000E617 89C2                <1> 	mov	edx, eax
  6447                              <1> pix_op_sub_16_0:
  6448 0000E619 668B07              <1> 	mov	ax, [edi]
  6449 0000E61C 6629D0              <1> 	sub	ax, dx
  6450 0000E61F 7302                <1> 	jnb	short pix_op_sub_16_1
  6451 0000E621 31C0                <1> 	xor	eax, eax ; 0 ; Min. value	
  6452                              <1> pix_op_sub_16_1:
  6453 0000E623 66AB                <1> 	stosw
  6454 0000E625 E2F2                <1> 	loop	pix_op_sub_16_0
  6455 0000E627 89D0                <1> 	mov	eax, edx
  6456 0000E629 C3                  <1> 	retn
  6457                              <1> 
  6458                              <1> pix_op_sub_24:
  6459                              <1> 	; 24 bit true colors
  6460                              <1> 	; SUBTRACT PIXEL COLOR
  6461                              <1> 	; ecx = pixel count per row
  6462                              <1> 	; eax = color
  6463                              <1> 	; edi = start pixel address 
  6464                              <1> 
  6465                              <1> 	;and	eax, 0FFFFFFh
  6466 0000E62A 89C2                <1> 	mov	edx, eax
  6467                              <1> pix_op_sub_24_0:
  6468 0000E62C 8B07                <1> 	mov	eax, [edi]
  6469                              <1> 	; 27/02/2021
  6470 0000E62E 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  6471 0000E633 29D0                <1> 	sub	eax, edx
  6472 0000E635 7302                <1> 	jnb	short pix_op_sub_24_1
  6473 0000E637 31C0                <1> 	xor	eax, eax ; 0 ; Min. value
  6474                              <1> pix_op_sub_24_1: 
  6475 0000E639 66AB                <1> 	stosw
  6476 0000E63B C1E810              <1> 	shr	eax, 16
  6477 0000E63E AA                  <1> 	stosb
  6478 0000E63F E2EB                <1> 	loop	pix_op_sub_24_0
  6479 0000E641 89D0                <1> 	mov	eax, edx
  6480 0000E643 C3                  <1> 	retn
  6481                              <1> 
  6482                              <1> pix_op_sub_32:
  6483                              <1> 	; 32 bit true colors
  6484                              <1> 	; SUBTRACT PIXEL COLOR
  6485                              <1> 	; ecx = pixel count per row
  6486                              <1> 	; eax = color
  6487                              <1> 	; edi = start pixel address 
  6488                              <1> 
  6489 0000E644 89C2                <1> 	mov	edx, eax
  6490                              <1> pix_op_sub_32_0:
  6491 0000E646 8B07                <1> 	mov	eax, [edi]
  6492 0000E648 29D0                <1> 	sub	eax, edx
  6493 0000E64A 7302                <1> 	jnb	short pix_op_sub_32_1
  6494 0000E64C 31C0                <1> 	xor	eax, eax ; 0 ; Min. value
  6495                              <1> pix_op_sub_32_1:
  6496 0000E64E AB                  <1> 	stosd
  6497 0000E64F E2F5                <1> 	loop	pix_op_sub_32_0
  6498 0000E651 89D0                <1> 	mov	eax, edx
  6499 0000E653 C3                  <1> 	retn
  6500                              <1> 
  6501                              <1> pix_op_or_8:
  6502                              <1> 	; 8 bit colors (256 colors)
  6503                              <1> 	; OR PIXEL COLOR
  6504                              <1> 	; ecx = pixel count per row
  6505                              <1> 	;  al = color
  6506                              <1> 	; edi = start pixel address 
  6507                              <1> 
  6508                              <1> pix_op_or_8_0:
  6509 0000E654 0807                <1> 	or	[edi], al
  6510 0000E656 47                  <1> 	inc	edi
  6511 0000E657 E2FB                <1> 	loop	pix_op_or_8_0
  6512 0000E659 C3                  <1> 	retn
  6513                              <1> 
  6514                              <1> pix_op_or_16:
  6515                              <1> 	; 16 bit colors (65536 colors)
  6516                              <1> 	; OR PIXEL COLOR
  6517                              <1> 	; ecx = pixel count per row
  6518                              <1> 	;  ax = color
  6519                              <1> 	; edi = start pixel address 
  6520                              <1> 
  6521                              <1> pix_op_or_16_0:
  6522 0000E65A 660907              <1> 	or	[edi], ax
  6523 0000E65D 47                  <1> 	inc	edi
  6524 0000E65E 47                  <1> 	inc	edi
  6525 0000E65F E2F9                <1> 	loop	pix_op_or_16_0
  6526 0000E661 C3                  <1> 	retn
  6527                              <1> 
  6528                              <1> pix_op_or_24:
  6529                              <1> 	; 24 bit true colors
  6530                              <1> 	; OR PIXEL COLOR
  6531                              <1> 	; ecx = pixel count per row
  6532                              <1> 	; eax = color
  6533                              <1> 	; edi = start pixel address 
  6534                              <1> 
  6535 0000E662 89C2                <1> 	mov	edx, eax
  6536                              <1> pix_op_or_24_0:
  6537 0000E664 0B07                <1> 	or	eax, [edi]
  6538 0000E666 66AB                <1> 	stosw
  6539 0000E668 C1E810              <1> 	shr	eax, 16
  6540 0000E66B AA                  <1> 	stosb	
  6541 0000E66C 89D0                <1> 	mov	eax, edx
  6542 0000E66E E2F4                <1> 	loop	pix_op_or_24_0
  6543 0000E670 C3                  <1> 	retn
  6544                              <1> 
  6545                              <1> pix_op_or_32:
  6546                              <1> 	; 32 bit true colors
  6547                              <1> 	; OR PIXEL COLOR
  6548                              <1> 	; ecx = pixel count per row
  6549                              <1> 	; eax = color
  6550                              <1> 	; edi = start pixel address 
  6551                              <1> 
  6552                              <1> 	;mov	edx, eax
  6553                              <1> pix_op_or_32_0:
  6554                              <1> 	;or	eax, [edi]
  6555                              <1> 	;stosd
  6556                              <1> 	;mov	eax, edx
  6557 0000E671 0907                <1> 	or	[edi], eax
  6558 0000E673 83C704              <1> 	add	edi, 4
  6559 0000E676 E2F9                <1> 	loop	pix_op_or_32_0
  6560 0000E678 C3                  <1> 	retn
  6561                              <1> 
  6562                              <1> pix_op_and_8:
  6563                              <1> 	; 8 bit colors (256 colors)
  6564                              <1> 	; AND PIXEL COLOR
  6565                              <1> 	; ecx = pixel count per row
  6566                              <1> 	;  al = color
  6567                              <1> 	; edi = start pixel address 
  6568                              <1> 
  6569                              <1> pix_op_and_8_0:
  6570 0000E679 2007                <1> 	and	[edi], al
  6571 0000E67B 47                  <1> 	inc	edi
  6572 0000E67C E2FB                <1> 	loop	pix_op_and_8_0
  6573 0000E67E C3                  <1> 	retn
  6574                              <1> 
  6575                              <1> pix_op_and_16:
  6576                              <1> 	; 16 bit colors (65536 colors)
  6577                              <1> 	; AND PIXEL COLOR
  6578                              <1> 	; ecx = pixel count per row
  6579                              <1> 	;  ax = color
  6580                              <1> 	; edi = start pixel address 
  6581                              <1> 
  6582                              <1> pix_op_and_16_0:
  6583 0000E67F 662107              <1> 	and	[edi], ax
  6584 0000E682 47                  <1> 	inc	edi
  6585 0000E683 47                  <1> 	inc	edi
  6586 0000E684 E2F9                <1> 	loop	pix_op_and_16_0
  6587 0000E686 C3                  <1> 	retn
  6588                              <1> 
  6589                              <1> pix_op_and_24:
  6590                              <1> 	; 24 bit true colors
  6591                              <1> 	; AND PIXEL COLOR
  6592                              <1> 	; ecx = pixel count per row
  6593                              <1> 	; eax = color
  6594                              <1> 	; edi = start pixel address 
  6595                              <1> 
  6596 0000E687 89C2                <1> 	mov	edx, eax
  6597                              <1> pix_op_and_24_0:
  6598 0000E689 2307                <1> 	and	eax, [edi]
  6599 0000E68B 66AB                <1> 	stosw
  6600 0000E68D C1E810              <1> 	shr	eax, 16
  6601 0000E690 AA                  <1> 	stosb	
  6602 0000E691 89D0                <1> 	mov	eax, edx
  6603 0000E693 E2F4                <1> 	loop	pix_op_and_24_0
  6604 0000E695 C3                  <1> 	retn
  6605                              <1> 
  6606                              <1> pix_op_and_32:
  6607                              <1> 	; 32 bit true colors
  6608                              <1> 	; AND PIXEL COLOR
  6609                              <1> 	; ecx = pixel count per row
  6610                              <1> 	; eax = color
  6611                              <1> 	; edi = start pixel address 
  6612                              <1> 
  6613                              <1> 	;mov	edx, eax
  6614                              <1> pix_op_and_32_0:
  6615                              <1> 	;and	eax, [edi]
  6616                              <1> 	;stosd
  6617                              <1> 	;mov	eax, edx
  6618 0000E696 2107                <1> 	and	[edi], eax
  6619 0000E698 83C704              <1> 	add	edi, 4
  6620 0000E69B E2F9                <1> 	loop	pix_op_and_32_0
  6621 0000E69D C3                  <1> 	retn
  6622                              <1> 
  6623                              <1> pix_op_xor_8:
  6624                              <1> 	; 8 bit colors (256 colors)
  6625                              <1> 	; XOR PIXEL COLOR
  6626                              <1> 	; ecx = pixel count per row
  6627                              <1> 	;  al = color
  6628                              <1> 	; edi = start pixel address 
  6629                              <1> 
  6630                              <1> pix_op_xor_8_0:
  6631 0000E69E 3007                <1> 	xor	[edi], al
  6632 0000E6A0 47                  <1> 	inc	edi
  6633 0000E6A1 E2FB                <1> 	loop	pix_op_xor_8_0
  6634 0000E6A3 C3                  <1> 	retn
  6635                              <1> 
  6636                              <1> pix_op_xor_16:
  6637                              <1> 	; 16 bit colors (65536 colors)
  6638                              <1> 	; XOR PIXEL COLOR
  6639                              <1> 	; ecx = pixel count per row
  6640                              <1> 	;  ax = color
  6641                              <1> 	; edi = start pixel address 
  6642                              <1> 
  6643                              <1> pix_op_xor_16_0:
  6644 0000E6A4 663107              <1> 	xor	[edi], ax
  6645 0000E6A7 47                  <1> 	inc	edi
  6646 0000E6A8 47                  <1> 	inc	edi
  6647 0000E6A9 E2F9                <1> 	loop	pix_op_xor_16_0
  6648 0000E6AB C3                  <1> 	retn
  6649                              <1> 
  6650                              <1> pix_op_xor_24:
  6651                              <1> 	; 24 bit true colors
  6652                              <1> 	; XOR PIXEL COLOR
  6653                              <1> 	; ecx = pixel count per row
  6654                              <1> 	; eax = color
  6655                              <1> 	; edi = start pixel address 
  6656                              <1> 
  6657 0000E6AC 89C2                <1> 	mov	edx, eax
  6658                              <1> pix_op_xor_24_0:
  6659 0000E6AE 3307                <1> 	xor	eax, [edi]
  6660 0000E6B0 66AB                <1> 	stosw
  6661 0000E6B2 C1E810              <1> 	shr	eax, 16
  6662 0000E6B5 AA                  <1> 	stosb	
  6663 0000E6B6 89D0                <1> 	mov	eax, edx
  6664 0000E6B8 E2F4                <1> 	loop	pix_op_xor_24_0
  6665 0000E6BA C3                  <1> 	retn
  6666                              <1> 
  6667                              <1> pix_op_xor_32:
  6668                              <1> 	; 32 bit true colors
  6669                              <1> 	; XOR PIXEL COLOR
  6670                              <1> 	; ecx = pixel count per row
  6671                              <1> 	; eax = color
  6672                              <1> 	; edi = start pixel address 
  6673                              <1> 
  6674                              <1> 	;mov	edx, eax
  6675                              <1> pix_op_xor_32_0:
  6676                              <1> 	;xor	eax, [edi]
  6677                              <1> 	;stosd
  6678                              <1> 	;mov	eax, edx
  6679 0000E6BB 3107                <1> 	xor	[edi], eax
  6680 0000E6BD 83C704              <1> 	add	edi, 4
  6681 0000E6C0 E2F9                <1> 	loop	pix_op_xor_32_0
  6682 0000E6C2 C3                  <1> 	retn
  6683                              <1> 
  6684                              <1> pix_op_mix_8:
  6685                              <1> 	; 8 bit colors (256 colors)
  6686                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  6687                              <1> 	; ecx = pixel count per row
  6688                              <1> 	;  al = color
  6689                              <1> 	; edi = start pixel address 
  6690                              <1> 
  6691 0000E6C3 88C4                <1> 	mov	ah, al
  6692                              <1> pix_op_mix_8_0:
  6693 0000E6C5 0207                <1> 	add	al, [edi]
  6694 0000E6C7 D0D8                <1> 	rcr	al, 1
  6695 0000E6C9 AA                  <1> 	stosb
  6696 0000E6CA 88E0                <1> 	mov	al, ah
  6697 0000E6CC E2F7                <1> 	loop	pix_op_mix_8_0
  6698 0000E6CE C3                  <1> 	retn
  6699                              <1> 
  6700                              <1> pix_op_mix_16:
  6701                              <1> 	; 16 bit colors (65536 colors)
  6702                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  6703                              <1> 	; ecx = pixel count per row
  6704                              <1> 	;  ax = color
  6705                              <1> 	; edi = start pixel address 
  6706                              <1> 
  6707 0000E6CF 89C2                <1> 	mov	edx, eax
  6708                              <1> pix_op_mix_16_0:
  6709 0000E6D1 660307              <1> 	add	ax, [edi]
  6710 0000E6D4 66D1D8              <1> 	rcr	ax, 1
  6711 0000E6D7 66AB                <1> 	stosw
  6712 0000E6D9 89D0                <1> 	mov	eax, edx
  6713 0000E6DB E2F4                <1> 	loop	pix_op_mix_16_0
  6714 0000E6DD C3                  <1> 	retn
  6715                              <1> 
  6716                              <1> pix_op_mix_24:
  6717                              <1> 	; 24 bit true colors
  6718                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  6719                              <1> 	; ecx = pixel count per row
  6720                              <1> 	; eax = color
  6721                              <1> 	; edi = start pixel address 
  6722                              <1> 
  6723 0000E6DE 53                  <1> 	push	ebx
  6724 0000E6DF BBFFFFFF00          <1> 	mov	ebx, 0FFFFFFh
  6725                              <1> 	;and	eax, ebx ; 0FFFFFFh
  6726 0000E6E4 89C2                <1> 	mov	edx, eax
  6727                              <1> pix_op_mix_24_0:
  6728 0000E6E6 8B07                <1> 	mov	eax, [edi]
  6729 0000E6E8 21D8                <1> 	and	eax, ebx ; 0FFFFFFh
  6730 0000E6EA 01D0                <1> 	add	eax, edx
  6731 0000E6EC D1E8                <1> 	shr	eax, 1
  6732                              <1> 	;rcr	eax, 1
  6733 0000E6EE 66AB                <1> 	stosw
  6734 0000E6F0 C1E810              <1> 	shr	eax, 16
  6735 0000E6F3 AA                  <1> 	stosb
  6736 0000E6F4 E2F0                <1> 	loop	pix_op_mix_24_0
  6737 0000E6F6 89D0                <1> 	mov	eax, edx
  6738 0000E6F8 5B                  <1> 	pop	ebx
  6739 0000E6F9 C3                  <1> 	retn
  6740                              <1> 
  6741                              <1> pix_op_mix_32:
  6742                              <1> 	; 32 bit true colors
  6743                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  6744                              <1> 	; ecx = pixel count per row
  6745                              <1> 	; eax = color
  6746                              <1> 	; edi = start pixel address 
  6747                              <1> 
  6748 0000E6FA 89C2                <1> 	mov	edx, eax
  6749                              <1> pix_op_mix_32_0:
  6750 0000E6FC 0307                <1> 	add	eax, [edi]
  6751 0000E6FE D1D8                <1> 	rcr	eax, 1	
  6752 0000E700 AB                  <1> 	stosd
  6753 0000E701 89D0                <1> 	mov	eax, edx
  6754 0000E703 E2F7                <1> 	loop	pix_op_mix_32_0
  6755 0000E705 C3                  <1> 	retn
  6756                              <1> 
  6757                              <1> pix_op_not_8:
  6758                              <1> 	; 8 bit colors (256 colors)
  6759                              <1> 	; NOT PIXEL COLOR
  6760                              <1> 	; ecx = pixel count per row
  6761                              <1> 	; edi = start pixel address 
  6762                              <1> 
  6763                              <1> pix_op_not_8_0:
  6764 0000E706 F617                <1> 	not	byte [edi]
  6765 0000E708 47                  <1> 	inc	edi
  6766 0000E709 E2FB                <1> 	loop	pix_op_not_8_0
  6767 0000E70B C3                  <1> 	retn
  6768                              <1> 
  6769                              <1> pix_op_not_16:
  6770                              <1> 	; 16 bit colors (65536 colors)
  6771                              <1> 	; NOT PIXEL COLOR
  6772                              <1> 	; ecx = pixel count per row
  6773                              <1> 	; edi = start pixel address 
  6774                              <1> 
  6775                              <1> pix_op_not_16_0:
  6776 0000E70C 66F717              <1> 	not	word [edi]
  6777 0000E70F 47                  <1> 	inc	edi
  6778 0000E710 47                  <1> 	inc	edi
  6779 0000E711 E2F9                <1> 	loop	pix_op_not_16_0
  6780 0000E713 C3                  <1> 	retn
  6781                              <1> 
  6782                              <1> pix_op_not_24:
  6783                              <1> 	; 24 bit true colors
  6784                              <1> 	; NOT PIXEL COLOR
  6785                              <1> 	; ecx = pixel count per row
  6786                              <1> 	; edi = start pixel address 
  6787                              <1> 
  6788                              <1> pix_op_not_24_0:
  6789 0000E714 66F717              <1> 	not	word [edi]
  6790 0000E717 47                  <1> 	inc	edi
  6791 0000E718 47                  <1> 	inc	edi
  6792 0000E719 F617                <1> 	not	byte [edi]
  6793 0000E71B 47                  <1> 	inc	edi
  6794 0000E71C E2F6                <1> 	loop	pix_op_not_24_0
  6795 0000E71E C3                  <1> 	retn
  6796                              <1> 
  6797                              <1> pix_op_not_32:
  6798                              <1> 	; 32 bit true colors
  6799                              <1> 	; NOT PIXEL COLOR
  6800                              <1> 	; ecx = pixel count per row
  6801                              <1> 	; eax = color
  6802                              <1> 	; edi = start pixel address 
  6803                              <1> pix_op_not_32_0:
  6804 0000E71F F717                <1> 	not	dword [edi]
  6805 0000E721 83C704              <1> 	add	edi, 4
  6806 0000E724 E2F9                <1> 	loop	pix_op_not_32_0
  6807 0000E726 C3                  <1> 	retn
  6808                              <1> 
  6809                              <1> pix_op_neg_8:
  6810                              <1> 	; 8 bit colors (256 colors)
  6811                              <1> 	; NEG PIXEL COLOR
  6812                              <1> 	; ecx = pixel count per row
  6813                              <1> 	; edi = start pixel address 
  6814                              <1> 
  6815                              <1> pix_op_neg_8_0:
  6816 0000E727 F61F                <1> 	neg	byte [edi]
  6817 0000E729 47                  <1> 	inc	edi
  6818 0000E72A E2FB                <1> 	loop	pix_op_neg_8_0
  6819 0000E72C C3                  <1> 	retn
  6820                              <1> 
  6821                              <1> pix_op_neg_16:
  6822                              <1> 	; 16 bit colors (65536 colors)
  6823                              <1> 	; NEG PIXEL COLOR
  6824                              <1> 	; ecx = pixel count per row
  6825                              <1> 	; edi = start pixel address 
  6826                              <1> 
  6827                              <1> pix_op_neg_16_0:
  6828 0000E72D 66F71F              <1> 	neg	word [edi]
  6829 0000E730 47                  <1> 	inc	edi
  6830 0000E731 47                  <1> 	inc	edi
  6831 0000E732 E2F9                <1> 	loop	pix_op_neg_16_0
  6832 0000E734 C3                  <1> 	retn
  6833                              <1> 
  6834                              <1> pix_op_neg_24:
  6835                              <1> 	; 24 bit true colors
  6836                              <1> 	; NEG PIXEL COLOR
  6837                              <1> 	; ecx = pixel count per row
  6838                              <1> 	; edi = start pixel address 
  6839                              <1> 
  6840                              <1> pix_op_neg_24_0:
  6841 0000E735 8B07                <1> 	mov	eax, [edi]
  6842 0000E737 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  6843 0000E73C F7D8                <1> 	neg	eax
  6844 0000E73E 66AB                <1> 	stosw
  6845 0000E740 C1E810              <1> 	shr	eax, 16
  6846 0000E743 AA                  <1> 	stosb
  6847 0000E744 E2EF                <1> 	loop	pix_op_neg_24_0
  6848 0000E746 C3                  <1> 	retn
  6849                              <1> 
  6850                              <1> pix_op_neg_32:
  6851                              <1> 	; 32 bit true colors
  6852                              <1> 	; NEG PIXEL COLOR
  6853                              <1> 	; ecx = pixel count per row
  6854                              <1> 	; eax = color
  6855                              <1> 	; edi = start pixel address 
  6856                              <1> pix_op_neg_32_0:
  6857 0000E747 F71F                <1> 	neg	dword [edi]
  6858 0000E749 83C704              <1> 	add	edi, 4
  6859 0000E74C E2F9                <1> 	loop	pix_op_neg_32_0
  6860 0000E74E C3                  <1> 	retn
  6861                              <1> 
  6862                              <1> pix_op_inc_8:
  6863                              <1> 	; 8 bit colors (256 colors)
  6864                              <1> 	; INCREASE PIXEL COLOR
  6865                              <1> 	; ecx = pixel count per row
  6866                              <1> 	; edi = start pixel address 
  6867                              <1> 
  6868                              <1> pix_op_inc_8_0:
  6869 0000E74F FE07                <1> 	inc	byte [edi]
  6870 0000E751 7502                <1> 	jnz	short pix_op_inc_8_1
  6871                              <1> 	;mov	[edi], 0FFh ; Max. value	
  6872 0000E753 FE0F                <1> 	dec	byte [edi]
  6873                              <1> pix_op_inc_8_1:
  6874 0000E755 47                  <1> 	inc	edi
  6875 0000E756 E2F7                <1> 	loop	pix_op_inc_8_0
  6876 0000E758 C3                  <1> 	retn
  6877                              <1> 
  6878                              <1> pix_op_inc_16:
  6879                              <1> 	; 16 bit colors (65536 colors)
  6880                              <1> 	; INCREASE PIXEL COLOR
  6881                              <1> 	; ecx = pixel count per row
  6882                              <1> 	; edi = start pixel address 
  6883                              <1> 
  6884                              <1> pix_op_inc_16_0:
  6885 0000E759 66FF07              <1> 	inc	word [edi]
  6886 0000E75C 7503                <1> 	jnz	short pix_op_inc_16_1
  6887                              <1> 	;mov	word [edi], 0FFFFh ; Max. value
  6888 0000E75E 66FF0F              <1> 	dec	word [edi]
  6889                              <1> pix_op_inc_16_1:
  6890 0000E761 47                  <1> 	inc	edi
  6891 0000E762 47                  <1> 	inc	edi
  6892 0000E763 E2F4                <1> 	loop	pix_op_inc_16_0
  6893 0000E765 C3                  <1> 	retn
  6894                              <1> 
  6895                              <1> pix_op_inc_24:
  6896                              <1> 	; 24 bit true colors
  6897                              <1> 	; INCREASE PIXEL COLOR
  6898                              <1> 	; ecx = pixel count per row
  6899                              <1> 	; edi = start pixel address 
  6900                              <1> 
  6901                              <1> pix_op_inc_24_0:
  6902 0000E766 8B07                <1> 	mov	eax, [edi]
  6903 0000E768 40                  <1> 	inc	eax
  6904 0000E769 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  6905 0000E76E 7501                <1> 	jnz	short pix_op_inc_24_1
  6906                              <1> 	;mov	eax, 0FFFFFFh  ; Max. value
  6907 0000E770 48                  <1> 	dec	eax ; 0FFFFFFFFh
  6908                              <1> pix_op_inc_24_1: 
  6909 0000E771 66AB                <1> 	stosw
  6910 0000E773 C1E810              <1> 	shr	eax, 16
  6911 0000E776 AA                  <1> 	stosb
  6912 0000E777 E2ED                <1> 	loop	pix_op_inc_24_0
  6913 0000E779 C3                  <1> 	retn
  6914                              <1> 
  6915                              <1> pix_op_inc_32:
  6916                              <1> 	; 32 bit true colors
  6917                              <1> 	; INCREASE PIXEL COLOR
  6918                              <1> 	; ecx = pixel count per row
  6919                              <1> 	; edi = start pixel address 
  6920                              <1> 
  6921                              <1> pix_op_inc_32_0:
  6922 0000E77A FF07                <1> 	inc	dword [edi]
  6923 0000E77C 7502                <1> 	jnz	short pix_op_inc_32_1
  6924                              <1> 	;mov	dword [edi], 0FFFFFFFFh ; Max. value
  6925 0000E77E FF0F                <1> 	dec	dword [edi]
  6926                              <1> pix_op_inc_32_1:
  6927 0000E780 83C704              <1> 	add	edi, 4
  6928 0000E783 E2F5                <1> 	loop	pix_op_inc_32_0
  6929 0000E785 C3                  <1> 	retn
  6930                              <1> 
  6931                              <1> pix_op_dec_8:
  6932                              <1> 	; 8 bit colors (256 colors)
  6933                              <1> 	; DECREASE PIXEL COLOR
  6934                              <1> 	; ecx = pixel count per row
  6935                              <1> 	; edi = start pixel address 
  6936                              <1> 
  6937                              <1> pix_op_dec_8_0:
  6938 0000E786 FE0F                <1> 	dec	byte [edi]
  6939 0000E788 7902                <1> 	jns	short pix_op_dec_8_1
  6940 0000E78A FE07                <1> 	inc	byte [edi] ; 0 ; Min. value	
  6941                              <1> pix_op_dec_8_1:
  6942 0000E78C 47                  <1> 	inc	edi
  6943 0000E78D E2F7                <1> 	loop	pix_op_dec_8_0
  6944 0000E78F C3                  <1> 	retn
  6945                              <1> 
  6946                              <1> pix_op_dec_16:
  6947                              <1> 	; 16 bit colors (65536 colors)
  6948                              <1> 	; DECREASE PIXEL COLOR
  6949                              <1> 	; ecx = pixel count per row
  6950                              <1> 	; edi = start pixel address 
  6951                              <1> 
  6952                              <1> pix_op_dec_16_0:
  6953 0000E790 66FF0F              <1> 	dec	word [edi]
  6954 0000E793 7903                <1> 	jns	short pix_op_dec_16_1
  6955 0000E795 66FF07              <1> 	inc	word [edi] ; 0 ; Min. value	
  6956                              <1> pix_op_dec_16_1:
  6957 0000E798 47                  <1> 	inc edi
  6958 0000E799 47                  <1> 	inc edi
  6959 0000E79A E2F4                <1> 	loop	pix_op_dec_16_0
  6960 0000E79C C3                  <1> 	retn
  6961                              <1> 
  6962                              <1> pix_op_dec_24:
  6963                              <1> 	; 24 bit true colors
  6964                              <1> 	; DECREASE PIXEL COLOR
  6965                              <1> 	; ecx = pixel count per row
  6966                              <1> 	; edi = start pixel address 
  6967                              <1> 
  6968                              <1> pix_op_dec_24_0:
  6969 0000E79D 8B07                <1> 	mov	eax, [edi]
  6970 0000E79F 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  6971 0000E7A4 7401                <1> 	jz	short pix_op_dec_24_1
  6972                              <1> 			; 0 ; Min. value
  6973 0000E7A6 48                  <1> 	dec	eax
  6974                              <1> pix_op_dec_24_1:
  6975 0000E7A7 66AB                <1> 	stosw
  6976 0000E7A9 C1E810              <1> 	shr	eax, 16
  6977 0000E7AC AA                  <1> 	stosb
  6978 0000E7AD E2B7                <1> 	loop	pix_op_inc_24_0
  6979 0000E7AF C3                  <1> 	retn
  6980                              <1> 
  6981                              <1> pix_op_dec_32:
  6982                              <1> 	; 32 bit true colors
  6983                              <1> 	; DECREASE PIXEL COLOR
  6984                              <1> 	; ecx = pixel count per row
  6985                              <1> 	; edi = start pixel address 
  6986                              <1> 
  6987                              <1> pix_op_dec_32_0:
  6988 0000E7B0 FF0F                <1> 	dec	dword [edi]
  6989 0000E7B2 7902                <1> 	jns	short pix_op_dec_32_1
  6990 0000E7B4 FF07                <1> 	inc	dword [edi] ; 0 ; Min. value
  6991                              <1> pix_op_dec_32_1:
  6992 0000E7B6 83C704              <1> 	add	edi, 4
  6993 0000E7B9 E2F5                <1> 	loop	pix_op_dec_32_0
  6994 0000E7BB 89D0                <1> 	mov	eax, edx
  6995 0000E7BD C3                  <1> 	retn
  6996                              <1> 
  6997                              <1> pix_op_rpl_8:
  6998                              <1> 	; 8 bit colors (256 colors)
  6999                              <1> 	; REPLACE PIXEL COLORS
  7000                              <1> 	; ecx = pixel count per row
  7001                              <1> 	;  al = new color
  7002                              <1> 	; byte [maskcolor] = old color
  7003                              <1> 	; edi = start pixel address
  7004                              <1> 
  7005 0000E7BE 8A25[4E100300]      <1> 	mov	ah, [maskcolor]
  7006                              <1> pix_op_rpl_8_0:
  7007 0000E7C4 3A27                <1> 	cmp	ah, [edi]
  7008 0000E7C6 7502                <1> 	jne	short pix_op_rpl_8_1
  7009 0000E7C8 8807                <1> 	mov	[edi], al
  7010                              <1> pix_op_rpl_8_1:
  7011 0000E7CA 47                  <1> 	inc	edi
  7012 0000E7CB E2F7                <1> 	loop	pix_op_rpl_8_0
  7013 0000E7CD C3                  <1> 	retn
  7014                              <1> 
  7015                              <1> pix_op_rpl_16:
  7016                              <1> 	; 16 bit colors (65536 colors)
  7017                              <1> 	; REPLACE PIXEL COLORS
  7018                              <1> 	; ecx = pixel count per row
  7019                              <1> 	;  ax = new color
  7020                              <1> 	; word [maskcolor] = old color
  7021                              <1> 	; edi = start pixel address
  7022                              <1> 
  7023 0000E7CE 8B15[4E100300]      <1> 	mov	edx, [maskcolor]
  7024                              <1> pix_op_rpl_16_0:
  7025 0000E7D4 663B17              <1> 	cmp	dx, [edi]
  7026 0000E7D7 7503                <1> 	jne	short pix_op_rpl_16_1
  7027 0000E7D9 668907              <1> 	mov	[edi], ax
  7028                              <1> pix_op_rpl_16_1:
  7029 0000E7DC 47                  <1> 	inc	edi
  7030 0000E7DD 47                  <1> 	inc	edi
  7031 0000E7DE E2F4                <1> 	loop	pix_op_rpl_16_0
  7032 0000E7E0 C3                  <1> 	retn
  7033                              <1> 
  7034                              <1> pix_op_rpl_24:
  7035                              <1> 	; 24 bit true colors
  7036                              <1> 	; REPLACE PIXEL COLORS
  7037                              <1> 	; ecx = pixel count per row
  7038                              <1> 	; eax = new color
  7039                              <1> 	; [maskcolor] = old color
  7040                              <1> 	; edi = start pixel address
  7041                              <1> 
  7042                              <1> pix_op_rpl_24_0:
  7043 0000E7E1 8B17                <1> 	mov	edx, [edi]
  7044 0000E7E3 81E2FFFFFF00        <1> 	and	edx, 0FFFFFFh
  7045 0000E7E9 3B15[4E100300]      <1> 	cmp	edx, [maskcolor]
  7046 0000E7EF 7406                <1> 	je	short pix_op_rpl_24_1
  7047 0000E7F1 83C703              <1> 	add	edi, 3
  7048 0000E7F4 E2EB                <1> 	loop	pix_op_rpl_24_0
  7049 0000E7F6 C3                  <1> 	retn
  7050                              <1> pix_op_rpl_24_1: 
  7051 0000E7F7 AA                  <1> 	stosb
  7052 0000E7F8 C1C808              <1> 	ror	eax, 8
  7053 0000E7FB 66AB                <1> 	stosw
  7054 0000E7FD C1C008              <1> 	rol	eax, 8
  7055 0000E800 E2DF                <1> 	loop	pix_op_rpl_24_0
  7056 0000E802 C3                  <1> 	retn
  7057                              <1> 
  7058                              <1> pix_op_rpl_32:
  7059                              <1> 	; 32 bit true colors
  7060                              <1> 	; REPLACE PIXEL COLORS
  7061                              <1> 	; ecx = pixel count per row
  7062                              <1> 	; eax = new color
  7063                              <1> 	; [maskcolor] = old color
  7064                              <1> 	; edi = start pixel address
  7065                              <1> 
  7066 0000E803 8B15[4E100300]      <1> 	mov	edx, [maskcolor]
  7067                              <1> pix_op_rpl_32_0:
  7068 0000E809 3B17                <1> 	cmp	edx, [edi]
  7069 0000E80B 7504                <1> 	jne	short pix_op_rpl_32_2
  7070 0000E80D AB                  <1> 	stosd
  7071 0000E80E E2F9                <1> 	loop	pix_op_rpl_32_0
  7072 0000E810 C3                  <1> 	retn	
  7073                              <1> pix_op_rpl_32_2:
  7074 0000E811 83C704              <1> 	add	edi, 4
  7075 0000E814 E2F3                <1> 	loop	pix_op_rpl_32_0
  7076 0000E816 C3                  <1> 	retn
  7077                              <1> 
  7078                              <1> pix_op_chr:
  7079                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
  7080                              <1> 	; 15/02/2021
  7081                              <1> 	; 05/02/2021
  7082                              <1> 	; WRITE CHARACTER (FONT)
  7083                              <1> 	; 05/01/2021 ([ufont])
  7084                              <1> 	; 01/01/2021
  7085                              <1> 	;     CL = char's color (8 bit, 256 colors)
  7086                              <1> 	;    ECX = char's color (16 bit and true colors)
  7087                              <1> 	;     DL = Character's ASCII code
  7088                              <1> 	;     DH bit 0 -> font height
  7089                              <1> 	;	  0 -> 8x16 character font
  7090                              <1> 	;	  1 -> 8x8 character font
  7091                              <1> 	;     DH bit 1 & 2 -> scale	
  7092                              <1> 	;	  0 = 1/1 (8 pixels per char row)
  7093                              <1> 	;	  1 = 2/1 (16 pixels per char row)
  7094                              <1> 	;	  2 = 3/1 (24 pixels per char row)
  7095                              <1> 	;	  3 = 4/1 (32 pixels per char row) 
  7096                              <1> 	;     DH bit 6 -> [ufont] option (1 = use [ufont])
  7097                              <1> 	;     If DH bit 7 = 1
  7098                              <1> 	;	 USER FONT (from user buffer)
  7099                              <1> 	;	    DL = 0 -> 8x8 (width: 1 byte per row)
  7100                              <1> 	;	    DL = 1 -> 8x16
  7101                              <1> 	;	    DL = 2 -> 16x16 (width: 2 bytes)
  7102                              <1> 	;	    DL = 3 -> 16x32
  7103                              <1> 	;	    DL = 4 -> 24x24 (width: 3 bytes)
  7104                              <1> 	;	    DL = 5 -> 24x48
  7105                              <1> 	;	    DL = 6 -> 32x32 (width: 4 bytes)
  7106                              <1> 	;	    DL = 7 -> 32x64
  7107                              <1> 	;	    DL > 7 -> invalid (unused)
  7108                              <1> 	;	 EDI = user's font buffer address
  7109                              <1> 	;	    (NOTE: byte order is as row0,row1,row2..)
  7110                              <1> 	;     ESI = start position (row, column) (*)
  7111                              <1> 	;	     (HW = row, SI = column)
  7112                              <1> 
  7113 0000E817 89F0                <1> 	mov	eax, esi ; start position
  7114 0000E819 E856F2FFFF          <1> 	call	calc_pixel_offset
  7115 0000E81E 3B05[42100300]      <1> 	cmp	eax, [v_siz]
  7116 0000E824 736D                <1> 	jnb	short pix_op_chr_err ; out of display page!
  7117 0000E826 E826F2FFFF          <1> 	call	pixels_to_byte_count
  7118                              <1> 	; eax = font start offset
  7119 0000E82B 0305[3E100300]      <1> 	add	eax, [v_mem] ; LFB start address
  7120 0000E831 A3[46100300]        <1> 	mov	[v_str], eax ; font start address 
  7121                              <1> 
  7122 0000E836 890D[4E100300]      <1> 	mov	[maskcolor], ecx ; save char's color
  7123                              <1> 
  7124 0000E83C 8835[3C100300]      <1> 	mov	[v_ops], dh
  7125                              <1> 
  7126 0000E842 81E6FFFF0000        <1> 	and	esi, 0FFFFh
  7127 0000E848 8935[56100300]      <1> 	mov	[buffer8], esi ; start column
  7128                              <1> 
  7129 0000E84E 31DB                <1> 	xor	ebx, ebx ; 0
  7130 0000E850 31C0                <1> 	xor	eax, eax ; 15/02/2021
  7131                              <1> 
  7132 0000E852 F6C680              <1> 	test	dh, 80h
  7133 0000E855 7577                <1> 	jnz	short pix_op_chr_u ; user font
  7134                              <1> 
  7135 0000E857 80E63F              <1> 	and	dh, 3Fh ; clear bit 6, [UFONT] option bit
  7136 0000E85A 7409                <1> 	jz	short pix_op_chr_0
  7137                              <1> 
  7138 0000E85C 80FE07              <1> 	cmp	dh, 7
  7139 0000E85F 7732                <1> 	ja	short pix_op_chr_err
  7140                              <1> 			 ; invalid (undefined) option 
  7141 0000E861 88F4                <1> 	mov	ah, dh
  7142 0000E863 D0EC                <1> 	shr	ah, 1
  7143                              <1> 	; ah = 0 to 3, scale
  7144                              <1> 	;jmp	short pix_op_chr_font_pixels
  7145                              <1> 
  7146                              <1> pix_op_chr_font_pixels:
  7147                              <1> 	; 05/02/2021
  7148                              <1> 	; write scaled font to buffer
  7149                              <1> 
  7150                              <1> 	; DL = ASCII code of character
  7151                              <1> 	; AH = scale
  7152                              <1> 	; EDI = buffer address (kernel)
  7153                              <1> 
  7154                              <1> pix_op_chr_0:
  7155 0000E865 88D3                <1> 	mov	bl, dl ; 15/02/2021
  7156 0000E867 31C9                <1> 	xor	ecx, ecx
  7157 0000E869 B610                <1> 	mov	dh, 16
  7158 0000E86B F605[3C100300]01    <1> 	test	byte [v_ops], 1 ; 8x8 font ?
  7159 0000E872 7428                <1> 	jz	short pix_op_chr_2 ; 8x16 font 
  7160 0000E874 B608                <1> 	mov	dh, 8
  7161 0000E876 C1E303              <1> 	shl	ebx, 3 ; * 8
  7162 0000E879 F605[3C100300]40    <1> 	test	byte [v_ops], 40h ; [ufont] option
  7163 0000E880 7412                <1> 	jz	short pix_op_chr_1  ; no
  7164                              <1> 	; test 8x8 user font is ready flag
  7165 0000E882 F605[32100300]01    <1> 	test	byte [ufont], 1
  7166 0000E889 7409                <1> 	jz	short pix_op_chr_1 ; no
  7167 0000E88B 81C300500900        <1> 	add	ebx, VGAFONT8USER
  7168 0000E891 EB2C                <1> 	jmp	short pix_op_chr_fpos_0
  7169                              <1> pix_op_chr_err:
  7170 0000E893 C3                  <1> 	retn
  7171                              <1> pix_op_chr_1:
  7172 0000E894 81C3[1C4E0100]      <1> 	add	ebx, vgafont8 ; system font (8x8)
  7173 0000E89A EB23                <1> 	jmp	short pix_op_chr_fpos_0
  7174                              <1> pix_op_chr_2:
  7175 0000E89C C1E304              <1> 	shl	ebx, 4 ; * 16
  7176 0000E89F F605[3C100300]40    <1> 	test	byte [v_ops], 40h ; [ufont] option
  7177 0000E8A6 7411                <1> 	jz	short pix_op_chr_3  ; no
  7178                              <1> 	; test 8x16 user font is ready flag
  7179 0000E8A8 F605[32100300]02    <1> 	test	byte [ufont], 2
  7180 0000E8AF 7408                <1> 	jz	short pix_op_chr_3 ; no
  7181 0000E8B1 81C300400900        <1> 	add	ebx, VGAFONT16USER
  7182 0000E8B7 EB06                <1> 	jmp	short pix_op_chr_fpos_0
  7183                              <1> pix_op_chr_3:
  7184 0000E8B9 81C3[1C640100]      <1> 	add	ebx, vgafont16 ; system font (8x16)
  7185                              <1> pix_op_chr_fpos_0:
  7186 0000E8BF 20E4                <1> 	and	ah, ah
  7187 0000E8C1 754A                <1> 	jnz	short pix_op_chr_fpos_1 ; scale > 1 
  7188                              <1> 	; no scale (scale = 1)
  7189 0000E8C3 89DE                <1> 	mov	esi, ebx ; 15/02/2021
  7190 0000E8C5 88F1                <1> 	mov	cl, dh ; rows/height (16 or 8)	
  7191 0000E8C7 B608                <1> 	mov	dh, 8  ; columns/width
  7192 0000E8C9 E9CB000000          <1> 	jmp	pix_op_chr_f2p
  7193                              <1> pix_op_chr_u:
  7194                              <1> 	; write user defined font 
  7195 0000E8CE 80FE80              <1> 	cmp	dh, 80h
  7196 0000E8D1 75C0                <1> 	jne	short pix_op_chr_err
  7197 0000E8D3 80FA07              <1> 	cmp	dl, 7
  7198 0000E8D6 77BB                <1> 	ja	short pix_op_chr_err
  7199                              <1> 
  7200                              <1> 	; 16/02/2021
  7201 0000E8D8 89FE                <1> 	mov	esi, edi ; user's font buffer
  7202                              <1> 	
  7203                              <1> 	;xor	eax, eax
  7204                              <1> 	; eax = 0 ; 15/02/2021	
  7205 0000E8DA 88D4                <1> 	mov	ah, dl
  7206 0000E8DC D0EC                <1> 	shr	ah, 1
  7207 0000E8DE FEC4                <1> 	inc	ah	
  7208                              <1> 	; ah =  1 to 4
  7209 0000E8E0 88E0                <1> 	mov	al, ah
  7210 0000E8E2 C0E003              <1> 	shl	al, 3 ; * 8
  7211                              <1> 	; al = 8,16,24,32
  7212 0000E8E5 88C3                <1> 	mov	bl, al
  7213 0000E8E7 88C7                <1> 	mov	bh, al
  7214 0000E8E9 F6E4                <1> 	mul	ah
  7215                              <1> 	; ax = 8,32,72,128 bytes 
  7216 0000E8EB F6C201              <1> 	test	dl, 1
  7217 0000E8EE 7404                <1> 	jz	short pix_op_chr_u_0
  7218                              <1> 	;shl	ax, 1 ; *2
  7219                              <1> 	; 23/07/2022
  7220 0000E8F0 D1E0                <1> 	shl	eax, 1
  7221                              <1> 	; ax = 16,32,144,256 bytes
  7222 0000E8F2 D0E7                <1> 	shl	bh, 1
  7223                              <1> pix_op_chr_u_0:
  7224                              <1> 	; eax = byte count
  7225 0000E8F4 89C1                <1> 	mov	ecx, eax
  7226 0000E8F6 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
  7227                              <1> 	; esi = user buffer
  7228 0000E8FB E8A3240000          <1> 	call	transfer_from_user_buffer
  7229 0000E900 7291                <1> 	jc	short pix_op_chr_err
  7230                              <1> 
  7231 0000E902 88F9                <1> 	mov	cl, bh ; rows/height
  7232 0000E904 88DE                <1> 	mov	dh, bl ; columns (width)
  7233 0000E906 89FE                <1> 	mov	esi, edi ; VBE3SAVERESTOREBLOCK
  7234 0000E908 E98C000000          <1> 	jmp	pix_op_chr_f2p
  7235                              <1> 
  7236                              <1> pix_op_chr_fpos_1:
  7237                              <1> 	; 18/02/2021
  7238                              <1> 	; scale > 1
  7239 0000E90D 88F5                <1> 	mov	ch, dh ; 16 or 8
  7240 0000E90F BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
  7241 0000E914 89FE                <1> 	mov	esi, edi
  7242 0000E916 FECC                <1> 	dec	ah
  7243 0000E918 7522                <1> 	jnz	short pix_op_chr_fpos_5 ; scale > 2
  7244                              <1> 	; scale = 2
  7245                              <1> pix_op_chr_fpos_2:	
  7246 0000E91A B108                <1> 	mov	cl, 8
  7247 0000E91C 8A13                <1> 	mov	dl, [ebx]
  7248                              <1> pix_op_chr_fpos_3:
  7249                              <1> 	;shl 	ax, 2
  7250                              <1> 	; 23/07/2022
  7251 0000E91E C1E002              <1> 	shl	eax, 2
  7252 0000E921 D0E2                <1> 	shl	dl, 1
  7253 0000E923 7302                <1> 	jnc	short pix_op_chr_fpos_4
  7254 0000E925 0C03                <1> 	or	al, 3
  7255                              <1> pix_op_chr_fpos_4:
  7256 0000E927 FEC9                <1> 	dec	cl
  7257 0000E929 75F3                <1> 	jnz	short pix_op_chr_fpos_3
  7258 0000E92B 66AB                <1> 	stosw
  7259                              <1> 	; 18/02/2021
  7260 0000E92D 66AB                <1> 	stosw
  7261 0000E92F 43                  <1> 	inc	ebx
  7262 0000E930 FECD                <1> 	dec	ch
  7263 0000E932 75E6                <1> 	jnz	short pix_op_chr_fpos_2
  7264                              <1> 	; scale = 2
  7265 0000E934 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
  7266 0000E936 D0E1                <1> 	shl	cl, 1  ; 32 or 16 rows
  7267 0000E938 B610                <1> 	mov	dh, 16 ; columns (width)
  7268 0000E93A EB5D                <1> 	jmp	short pix_op_chr_f2p
  7269                              <1> pix_op_chr_fpos_5:
  7270 0000E93C FECC                <1> 	dec	ah
  7271 0000E93E 7538                <1> 	jnz	short pix_op_chr_fpos_9 ; scale = 4
  7272                              <1> 	; scale = 3
  7273                              <1> pix_op_chr_fpos_6:	
  7274 0000E940 B108                <1> 	mov	cl, 8
  7275 0000E942 8A13                <1> 	mov	dl, [ebx]
  7276                              <1> pix_op_chr_fpos_7:
  7277 0000E944 C1E003              <1> 	shl 	eax, 3
  7278 0000E947 D0E2                <1> 	shl	dl, 1 ; 18/02/2021
  7279 0000E949 7302                <1> 	jnc	short pix_op_chr_fpos_8
  7280 0000E94B 0C07                <1> 	or	al, 7
  7281                              <1> pix_op_chr_fpos_8:
  7282 0000E94D FEC9                <1> 	dec	cl
  7283 0000E94F 75F3                <1> 	jnz	short pix_op_chr_fpos_7
  7284 0000E951 66AB                <1> 	stosw
  7285                              <1> 	; 18/02/2021
  7286 0000E953 C1C810              <1> 	ror	eax, 16
  7287 0000E956 AA                  <1> 	stosb
  7288 0000E957 C1C010              <1> 	rol	eax, 16
  7289 0000E95A 66AB                <1> 	stosw
  7290 0000E95C C1C810              <1> 	ror	eax, 16
  7291 0000E95F AA                  <1> 	stosb	
  7292 0000E960 C1C010              <1> 	rol	eax, 16
  7293 0000E963 66AB                <1> 	stosw
  7294 0000E965 C1E810              <1> 	shr	eax, 16 ; 27/02/2021
  7295 0000E968 AA                  <1> 	stosb
  7296 0000E969 43                  <1> 	inc	ebx
  7297                              <1> 	; 18/02/2021
  7298 0000E96A FECD                <1> 	dec	ch
  7299 0000E96C 75D2                <1> 	jnz	short pix_op_chr_fpos_6
  7300                              <1> 	; scale = 3
  7301 0000E96E 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
  7302 0000E970 D0E1                <1> 	shl	cl, 1 
  7303 0000E972 00F1                <1> 	add	cl, dh ; 48 or 24 rows
  7304 0000E974 B618                <1> 	mov	dh, 24 ; columns (width)
  7305 0000E976 EB21                <1> 	jmp	short pix_op_chr_f2p
  7306                              <1> 
  7307                              <1> pix_op_chr_fpos_9:
  7308                              <1> 	; scale = 4
  7309 0000E978 B108                <1> 	mov	cl, 8
  7310 0000E97A 8A13                <1> 	mov	dl, [ebx]
  7311                              <1> pix_op_chr_fpos_10:
  7312                              <1> 	; 18/02/2021
  7313 0000E97C C1E004              <1> 	shl 	eax, 4
  7314 0000E97F D0E2                <1> 	shl	dl, 1 ; 18/02/2021
  7315 0000E981 7302                <1> 	jnc	short pix_op_chr_fpos_11
  7316 0000E983 0C0F                <1> 	or	al, 0Fh ; or al, 15
  7317                              <1> pix_op_chr_fpos_11:
  7318 0000E985 FEC9                <1> 	dec	cl
  7319 0000E987 75F3                <1> 	jnz	short pix_op_chr_fpos_10
  7320 0000E989 AB                  <1> 	stosd
  7321                              <1> 	; 18/02/2021
  7322 0000E98A AB                  <1> 	stosd
  7323 0000E98B AB                  <1> 	stosd
  7324 0000E98C AB                  <1> 	stosd
  7325 0000E98D 43                  <1> 	inc	ebx
  7326 0000E98E FECD                <1> 	dec	ch
  7327 0000E990 75E6                <1> 	jnz	short pix_op_chr_fpos_9
  7328                              <1> 	; scale = 4
  7329 0000E992 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
  7330 0000E994 C0E102              <1> 	shl	cl, 2 ; 64 or 32 rows
  7331 0000E997 B620                <1> 	mov	dh, 32 ; columns (width)
  7332                              <1> 	;jmp	short pix_op_chr_f2p
  7333                              <1>  	
  7334                              <1> pix_op_chr_f2p:
  7335                              <1> 	; write font pixels
  7336 0000E999 8B3D[46100300]      <1> 	mov	edi, [v_str]
  7337                              <1> 	; 15/02/2021
  7338                              <1> pix_op_chr_f2p_next:
  7339 0000E99F 80FE08              <1> 	cmp	dh, 8
  7340 0000E9A2 7706                <1> 	ja	short pix_op_chr_f2p_24
  7341                              <1> pix_op_chr_f2p_8:
  7342 0000E9A4 AC                  <1> 	lodsb
  7343 0000E9A5 C1E018              <1> 	shl	eax, 24 ; 15/02/2021
  7344 0000E9A8 EB16                <1> 	jmp	short pix_op_chr_f2p_0
  7345                              <1> pix_op_chr_f2p_24:
  7346 0000E9AA 80FE18              <1> 	cmp	dh, 24
  7347 0000E9AD 7710                <1> 	ja	short pix_op_chr_f2p_32
  7348 0000E9AF 7207                <1> 	jb	short pix_op_chr_f2p_16	
  7349                              <1> 	; 27/02/2021
  7350                              <1> 	;mov	eax, [esi]
  7351 0000E9B1 AD                  <1> 	lodsd
  7352 0000E9B2 C1E008              <1> 	shl	eax, 8
  7353                              <1> 	;add	esi, 3
  7354 0000E9B5 4E                  <1> 	dec	esi
  7355 0000E9B6 EB08                <1> 	jmp	short pix_op_chr_f2p_0
  7356                              <1> pix_op_chr_f2p_16:
  7357 0000E9B8 66AD                <1> 	lodsw
  7358 0000E9BA C1E010              <1> 	shl	eax, 16 ; 15/02/2021
  7359 0000E9BD EB01                <1> 	jmp	short pix_op_chr_f2p_0
  7360                              <1> pix_op_chr_f2p_32:
  7361 0000E9BF AD                  <1> 	lodsd
  7362                              <1> pix_op_chr_f2p_0:
  7363                              <1> 	; EAX = font row (8,16,24,32 pixels)
  7364                              <1> 	;	(bits are shifted to left)
  7365                              <1> 	; CL = rows
  7366                              <1> 	; DH = bits per row (8,16,24,32)
  7367 0000E9C0 8B1D[56100300]      <1> 	mov	ebx, [buffer8] ; start column
  7368 0000E9C6 57                  <1> 	push	edi ; *
  7369 0000E9C7 52                  <1> 	push	edx ; **
  7370                              <1> pix_op_chr_f2p_1:
  7371 0000E9C8 E82E000000          <1> 	call	pix_op_chr_w_pixel
  7372                              <1> pix_op_chr_f2p_2:
  7373 0000E9CD 663B1D[3A100300]    <1> 	cmp	bx, [v_width] ; current column
  7374 0000E9D4 7304                <1> 	jnb	short pix_op_chr_f2p_3
  7375 0000E9D6 FECE                <1> 	dec	dh
  7376 0000E9D8 75EE                <1> 	jnz	short pix_op_chr_f2p_1 ; next bit
  7377                              <1> pix_op_chr_f2p_3:
  7378                              <1> 	;mov	ebx, [buffer8]
  7379 0000E9DA 5A                  <1> 	pop	edx ; **
  7380 0000E9DB 58                  <1> 	pop	eax ; *
  7381 0000E9DC 3B3D[4A100300]      <1> 	cmp	edi, [v_end]
  7382 0000E9E2 7316                <1> 	jnb	short pix_op_chr_f2p_4
  7383 0000E9E4 FEC9                <1> 	dec	cl
  7384 0000E9E6 7412                <1> 	jz	short pix_op_chr_f2p_4
  7385                              <1> 	; 27/02/2021
  7386 0000E9E8 89C7                <1> 	mov	edi, eax
  7387 0000E9EA 0FB705[3A100300]    <1> 	movzx	eax, word [v_width]
  7388 0000E9F1 E85BF0FFFF          <1> 	call	pixels_to_byte_count
  7389 0000E9F6 01C7                <1> 	add	edi, eax ; next position
  7390 0000E9F8 EBA5                <1> 	jmp	short pix_op_chr_f2p_next
  7391                              <1> pix_op_chr_f2p_4:
  7392 0000E9FA C3                  <1> 	retn
  7393                              <1> 
  7394                              <1> pix_op_chr_w_pixel:
  7395                              <1> 	; 15/02/2021
  7396 0000E9FB 89C5                <1> 	mov	ebp, eax
  7397 0000E9FD A1[4E100300]        <1> 	mov	eax, [maskcolor]
  7398 0000EA02 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7399 0000EA09 7711                <1> 	ja	short pix_op_chr_wp_2
  7400                              <1> 	; 256 colors (1 byte per pixel)
  7401 0000EA0B D1E5                <1> 	shl	ebp, 1
  7402 0000EA0D 7302                <1> 	jnc	short pix_op_chr_wp_0
  7403 0000EA0F 8807                <1> 	mov	[edi], al
  7404                              <1> pix_op_chr_wp_0:
  7405 0000EA11 47                  <1> 	inc	edi
  7406 0000EA12 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  7407                              <1> pix_op_chr_wp_1:
  7408 0000EA18 43                  <1> 	inc	ebx
  7409 0000EA19 89E8                <1> 	mov	eax, ebp
  7410 0000EA1B C3                  <1> 	retn
  7411                              <1> pix_op_chr_wp_2:
  7412 0000EA1C 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7413 0000EA23 772E                <1> 	ja	short pix_op_chr_wp_6 ; 32bpp
  7414 0000EA25 721C                <1> 	jb	short pix_op_chr_wp_4 ; 16bpp
  7415                              <1> 	; 24 bit true colors
  7416                              <1> 	; * 3
  7417 0000EA27 D1E5                <1> 	shl	ebp, 1
  7418 0000EA29 7309                <1> 	jnc	short pix_op_chr_wp_3
  7419 0000EA2B 668907              <1> 	mov	[edi], ax
  7420 0000EA2E C1E810              <1> 	shr	eax, 16
  7421 0000EA31 884702              <1> 	mov	[edi+2], al
  7422                              <1> pix_op_chr_wp_3:
  7423 0000EA34 B803000000          <1> 	mov	eax, 3 ; 27/02/2021 
  7424 0000EA39 01C7                <1> 	add	edi, eax  ; add edi, 3
  7425 0000EA3B 0105[1C010300]      <1> 	add	[u.r0], eax ; +3
  7426                              <1> 	
  7427 0000EA41 EBD5                <1> 	jmp	short pix_op_chr_wp_1
  7428                              <1> 
  7429                              <1> pix_op_chr_wp_4:
  7430                              <1> 	; 16 bit (65536) colors
  7431 0000EA43 D1E5                <1> 	shl	ebp, 1
  7432 0000EA45 7303                <1> 	jnc	short pix_op_chr_wp_5
  7433 0000EA47 668907              <1> 	mov	[edi], ax
  7434                              <1> pix_op_chr_wp_5:
  7435 0000EA4A 47                  <1> 	inc	edi
  7436 0000EA4B FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1 
  7437 0000EA51 EBBE                <1> 	jmp	short pix_op_chr_wp_0
  7438                              <1> 
  7439                              <1> pix_op_chr_wp_6:
  7440                              <1> 	; 32 bit true colors
  7441 0000EA53 D1E5                <1> 	shl	ebp, 1
  7442 0000EA55 7302                <1> 	jnc	short pix_op_chr_wp_7
  7443 0000EA57 8907                <1> 	mov	[edi], eax
  7444                              <1> pix_op_chr_wp_7:
  7445 0000EA59 31C0                <1> 	xor	eax, eax
  7446 0000EA5B B004                <1> 	mov	al, 4
  7447 0000EA5D 01C7                <1> 	add	edi, eax ; add edi, 4
  7448 0000EA5F 0105[1C010300]      <1> 	add	[u.r0], eax ; +4
  7449 0000EA65 EBB1                <1> 	jmp	short pix_op_chr_wp_1
  7450                              <1> 
  7451                              <1> m_pix_op_cpy:
  7452                              <1> 	; 26/02/2021
  7453                              <1> 	; 06/02/2021
  7454                              <1> 	; MASKED COPY PIXELS (full screen)
  7455                              <1> 	;
  7456                              <1> 	; jump from pix_op_cpy
  7457                              <1> 	;
  7458                              <1> 	; INPUT:
  7459                              <1> 	;   ecx = transfer count (bytes)
  7460                              <1> 	;   edi = [v_mem] = start address of LFB 
  7461                              <1> 	;   esi = user's buffer address (virtual)
  7462                              <1> 	;
  7463                              <1> 	; OUTPUT:
  7464                              <1> 	;   [u.r0] will be > 0 if succesful
  7465                              <1> 
  7466                              <1> 	; Full screen masked copy
  7467                              <1> 
  7468                              <1> 	; Modified regs: eax, ebx, edx, esi, edi, ecx
  7469                              <1> 
  7470                              <1> m_pix_op_cpy_0:
  7471                              <1> 	;push	ebx ; *** ; 26/02/2021
  7472 0000EA67 57                  <1> 	push	edi ; **
  7473 0000EA68 51                  <1> 	push	ecx ; *
  7474 0000EA69 81F9F8070000        <1> 	cmp	ecx, 2040 ; (3*680) ; 26/02/2021
  7475 0000EA6F 7605                <1> 	jna	short m_pix_op_cpy_1
  7476 0000EA71 B9F8070000          <1> 	mov	ecx, 2040
  7477                              <1> m_pix_op_cpy_1:
  7478 0000EA76 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; temporary buff
  7479 0000EA7B E823230000          <1> 	call	transfer_from_user_buffer
  7480 0000EA80 726C                <1> 	jc	short m_pix_op_cpy_3
  7481 0000EA82 01CE                <1> 	add	esi, ecx
  7482 0000EA84 89F5                <1> 	mov	ebp, esi  ; save user's buffer address
  7483 0000EA86 89FE                <1> 	mov	esi, edi
  7484 0000EA88 89CB                <1> 	mov	ebx, ecx
  7485 0000EA8A 59                  <1> 	pop	ecx ; *
  7486 0000EA8B 29D9                <1> 	sub	ecx, ebx
  7487 0000EA8D 5F                  <1> 	pop	edi ; **
  7488 0000EA8E 31D2                <1> 	xor	edx, edx ; 26/02/2021
  7489 0000EA90 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8
  7490 0000EA97 7435                <1> 	je	short m_pix_op_cpy_1_8
  7491 0000EA99 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24
  7492 0000EAA0 776D                <1> 	ja	short m_pix_op_cpy_1_32
  7493 0000EAA2 724D                <1> 	jb	short m_pix_op_cpy_1_16
  7494                              <1> m_pix_op_cpy_1_24:
  7495                              <1> 	; 24 bit masked copy
  7496                              <1> 	;mov	edx, 3
  7497 0000EAA4 B203                <1> 	mov	dl, 3 ; 26/02/2021
  7498                              <1> m_pix_op_cpy_1_24_0:
  7499 0000EAA6 66AD                <1> 	lodsw
  7500 0000EAA8 C1E010              <1> 	shl	eax, 16
  7501 0000EAAB AC                  <1> 	lodsb
  7502 0000EAAC C1C010              <1> 	rol	eax, 16
  7503 0000EAAF 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  7504 0000EAB5 740F                <1> 	je	short m_pix_op_cpy_1_24_1 ; exclude
  7505 0000EAB7 668907              <1> 	mov	[edi], ax
  7506 0000EABA C1E810              <1> 	shr	eax, 16
  7507 0000EABD 884702              <1> 	mov	[edi+2], al
  7508 0000EAC0 0115[1C010300]      <1> 	add	[u.r0], edx ; +3
  7509                              <1> m_pix_op_cpy_1_24_1:
  7510 0000EAC6 01D7                <1> 	add	edi, edx ; +3
  7511 0000EAC8 29D3                <1> 	sub	ebx, edx ; sub ebx, 3
  7512 0000EACA 77DA                <1> 	ja	short m_pix_op_cpy_1_24_0
  7513 0000EACC EB15                <1>  	jmp	short m_pix_op_cpy_2
  7514                              <1> 
  7515                              <1> m_pix_op_cpy_1_8:
  7516                              <1> 	; 8 bit masked copy
  7517 0000EACE AC                  <1> 	lodsb
  7518 0000EACF 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  7519 0000EAD5 7408                <1> 	je	short m_pix_op_cpy_1_8_1 ; exclude
  7520 0000EAD7 8807                <1> 	mov	[edi], al
  7521 0000EAD9 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  7522                              <1> m_pix_op_cpy_1_8_1:
  7523 0000EADF 47                  <1> 	inc	edi ; +1
  7524 0000EAE0 4B                  <1> 	dec	ebx 	
  7525 0000EAE1 75EB                <1> 	jnz	short m_pix_op_cpy_1_8
  7526                              <1> m_pix_op_cpy_2:
  7527 0000EAE3 89EE                <1> 	mov	esi, ebp ; restore user's buffer addr
  7528 0000EAE5 09C9                <1> 	or	ecx, ecx
  7529                              <1> 	; 26/02/2021
  7530 0000EAE7 7407                <1> 	jz	short m_pix_of_cpy_4
  7531 0000EAE9 E979FFFFFF          <1> 	jmp	m_pix_op_cpy_0
  7532                              <1> m_pix_op_cpy_3:
  7533 0000EAEE 59                  <1> 	pop	ecx ; *
  7534 0000EAEF 5F                  <1> 	pop	edi ; **
  7535                              <1> m_pix_of_cpy_4:
  7536                              <1> 	;pop	ebx ; *** ; 26/02/2021 
  7537 0000EAF0 C3                  <1> 	retn
  7538                              <1> 
  7539                              <1> m_pix_op_cpy_1_16:
  7540                              <1> 	; 16 bit masked copy
  7541                              <1> 	;mov	edx, 2
  7542 0000EAF1 B202                <1> 	mov	dl, 2 ; 26/02/2021
  7543                              <1> m_pix_op_cpy_1_16_0:
  7544 0000EAF3 66AD                <1> 	lodsw
  7545 0000EAF5 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  7546 0000EAFC 7409                <1> 	je	short m_pix_op_cpy_1_16_1 ; exclude
  7547 0000EAFE 668907              <1> 	mov	[edi], ax
  7548 0000EB01 0115[1C010300]      <1> 	add	[u.r0], edx ; +2
  7549                              <1> m_pix_op_cpy_1_16_1:
  7550 0000EB07 01D7                <1> 	add	edi, edx ; +2
  7551 0000EB09 29D3                <1> 	sub	ebx, edx ; sub ebx, 2
  7552 0000EB0B 77E6                <1> 	ja	short m_pix_op_cpy_1_16_0
  7553 0000EB0D EBD4                <1>  	jmp	short m_pix_op_cpy_2
  7554                              <1> 
  7555                              <1> m_pix_op_cpy_1_32:
  7556                              <1> 	; 32 bit masked copy
  7557                              <1> 	;mov	edx, 4
  7558 0000EB0F B204                <1> 	mov	dl, 4 ; 26/02/2021
  7559                              <1> m_pix_op_cpy_1_32_0:
  7560 0000EB11 AD                  <1> 	lodsd
  7561 0000EB12 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  7562 0000EB18 7408                <1> 	je	short m_pix_op_cpy_1_32_1 ; exclude
  7563 0000EB1A 8907                <1> 	mov	[edi], eax
  7564 0000EB1C 0115[1C010300]      <1> 	add	[u.r0], edx ; +4
  7565                              <1> m_pix_op_cpy_1_32_1:
  7566 0000EB22 01D7                <1> 	add	edi, edx ; +4
  7567 0000EB24 29D3                <1> 	sub	ebx, edx ; sub ebx, 4
  7568 0000EB26 77E9                <1> 	ja	short m_pix_op_cpy_1_32_0
  7569 0000EB28 EBB9                <1>  	jmp	short m_pix_op_cpy_2
  7570                              <1> 	
  7571                              <1> m_pix_op_cpy_w:
  7572                              <1> 	; 26/02/2021
  7573                              <1> 	; 06/02/2021
  7574                              <1> 	; MASKED COPY PIXELS (window)
  7575                              <1> 	;
  7576                              <1> 	; jump from pix_op_cpy_w
  7577                              <1> 	;
  7578                              <1> 	; INPUT:
  7579                              <1> 	;   ecx = bytes per row (to be applied)
  7580                              <1> 	;   edx = screen width in bytes
  7581                              <1> 	;   ebx = row count
  7582                              <1> 	;   esi = user's buffer address
  7583                              <1> 	;   [v_str] = window start address
  7584                              <1> 	;
  7585                              <1> 	; OUTPUT:
  7586                              <1> 	;   [u.r0] will be > 0 if succesful
  7587                              <1> 
  7588                              <1> 	; Window masked copy
  7589                              <1> 
  7590                              <1> m_pix_op_cpy_w_0:
  7591 0000EB2A 8B3D[46100300]      <1> 	mov	edi, [v_str]
  7592                              <1> m_pix_op_cpy_w_1:
  7593 0000EB30 57                  <1> 	push	edi
  7594 0000EB31 56                  <1> 	push	esi
  7595 0000EB32 53                  <1> 	push	ebx
  7596 0000EB33 52                  <1> 	push	edx
  7597 0000EB34 51                  <1> 	push	ecx
  7598 0000EB35 E82DFFFFFF          <1> 	call	m_pix_op_cpy ; 26/02/2021
  7599 0000EB3A 59                  <1> 	pop	ecx
  7600 0000EB3B 5A                  <1> 	pop	edx
  7601 0000EB3C 5B                  <1> 	pop	ebx
  7602 0000EB3D 5E                  <1> 	pop	esi
  7603 0000EB3E 5F                  <1> 	pop	edi
  7604 0000EB3F 7209                <1> 	jc	short m_pix_op_cpy_w_2
  7605 0000EB41 4B                  <1> 	dec	ebx
  7606 0000EB42 7406                <1> 	jz	short m_pix_op_cpy_w_2 ; ok.
  7607                              <1> 	; next row
  7608 0000EB44 01CE                <1> 	add	esi, ecx ; next row in user's buffer
  7609 0000EB46 01D7                <1> 	add	edi, edx ; next row of window (system)
  7610 0000EB48 EBE6                <1> 	jmp	short m_pix_op_cpy_w_1
  7611                              <1> m_pix_op_cpy_w_2:
  7612 0000EB4A C3                  <1> 	retn
  7613                              <1> 
  7614                              <1> m_pix_op_new:
  7615                              <1> 	; 06/02/2021
  7616                              <1> 	; CHANGE COLOR (MASKED, full screen)
  7617                              <1> 	;
  7618                              <1> 	; jump from pix_op_new
  7619                              <1> 	;
  7620                              <1> 	; INPUT:
  7621                              <1> 	;   eax = color (AL, AX, EAX)
  7622                              <1> 	;   ecx = [v_siz] ; display page pixel count
  7623                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  7624                              <1> 	;
  7625                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7626                              <1> 	;
  7627                              <1> 	; OUTPUT:
  7628                              <1> 	; 	[u.r0] will be > 0 if succesful
  7629                              <1> 	
  7630                              <1> 	; Full screen
  7631                              <1> m_pix_op_new_0:
  7632 0000EB4B 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7633 0000EB52 7717                <1> 	ja	short m_pix_op_new_1
  7634                              <1> 	; 256 colors (8bpp)
  7635                              <1> 	;jmp	short m_pix_op_new_8
  7636                              <1> m_pix_op_new_8:
  7637                              <1> 	; 8 bit colors (256 colors)
  7638 0000EB54 88C2                <1> 	mov	dl, al ; new color
  7639                              <1> m_pix_op_new_8_0:
  7640 0000EB56 AC                  <1> 	lodsb 
  7641 0000EB57 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  7642 0000EB5D 7408                <1> 	je	short m_pix_op_new_8_1 ; exclude
  7643 0000EB5F 8817                <1> 	mov	[edi], dl
  7644 0000EB61 FF05[1C010300]      <1> 	inc	dword [u.r0]
  7645                              <1> m_pix_op_new_8_1:
  7646 0000EB67 47                  <1> 	inc	edi
  7647 0000EB68 E2EC                <1> 	loop	m_pix_op_new_8_0
  7648 0000EB6A C3                  <1> 	retn
  7649                              <1> m_pix_op_new_1:
  7650 0000EB6B 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7651 0000EB72 774B                <1> 	ja	short m_pix_op_new_3 ; 32bpp	
  7652 0000EB74 722C                <1> 	jb	short m_pix_op_new_2 ; 16bpp
  7653                              <1> 	; 24 bit true colors
  7654                              <1> 	;jmp	short m_pix_op_new_24
  7655                              <1> m_pix_op_new_24:
  7656                              <1> 	; 24 bit true colors
  7657 0000EB76 89C2                <1> 	mov	edx, eax ; new color
  7658                              <1> m_pix_op_new_24_0:
  7659 0000EB78 66AD                <1> 	lodsw
  7660 0000EB7A C1E010              <1> 	shl	eax, 16
  7661 0000EB7D AC                  <1> 	lodsb
  7662 0000EB7E C1C010              <1> 	rol	eax, 16	
  7663 0000EB81 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  7664 0000EB87 7413                <1> 	je	short m_pix_op_new_24_1 ; exclude
  7665 0000EB89 668917              <1> 	mov	[edi], dx
  7666 0000EB8C C1CA10              <1> 	ror	edx, 16
  7667 0000EB8F 885702              <1> 	mov	[edi+2], dl
  7668 0000EB92 C1C210              <1> 	rol	edx, 16
  7669 0000EB95 8305[1C010300]03    <1> 	add	dword [u.r0], 3
  7670                              <1> m_pix_op_new_24_1:
  7671 0000EB9C 83C703              <1> 	add	edi, 3
  7672 0000EB9F E2D7                <1> 	loop	m_pix_op_new_24_0
  7673 0000EBA1 C3                  <1> 	retn
  7674                              <1> 	; 65536 colors (16bpp)
  7675                              <1> m_pix_op_new_2:
  7676                              <1> 	;jmp	short m_pix_op_new_16
  7677                              <1> m_pix_op_new_16:
  7678                              <1> 	; 16 bit colors (65536 colors)
  7679 0000EBA2 89C2                <1> 	mov	edx, eax ; new color
  7680                              <1> m_pix_op_new_16_0:
  7681 0000EBA4 66AD                <1> 	lodsw
  7682 0000EBA6 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  7683 0000EBAD 740A                <1> 	je	short m_pix_op_new_16_1 ; exclude
  7684 0000EBAF 668917              <1> 	mov	[edi], dx
  7685 0000EBB2 8305[1C010300]02    <1> 	add	dword [u.r0], 2
  7686                              <1> m_pix_op_new_16_1:
  7687 0000EBB9 83C702              <1> 	add	edi, 2
  7688 0000EBBC E2E6                <1> 	loop	m_pix_op_new_16_0
  7689 0000EBBE C3                  <1> 	retn
  7690                              <1> m_pix_op_new_3:
  7691                              <1> 	; 32 bit true colors
  7692                              <1> 	;jmp	short m_pix_op_new_32
  7693                              <1> m_pix_op_new_32:
  7694                              <1> 	; 32 bit true colors
  7695 0000EBBF 89C2                <1> 	mov	edx, eax ; new color
  7696                              <1> m_pix_op_new_32_0:
  7697 0000EBC1 AD                  <1> 	lodsd 
  7698 0000EBC2 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  7699 0000EBC8 7409                <1> 	je	short m_pix_op_new_32_1 ; exclude
  7700 0000EBCA 8917                <1> 	mov	[edi], edx
  7701 0000EBCC 8305[1C010300]04    <1> 	add	dword [u.r0], 4
  7702                              <1> m_pix_op_new_32_1:
  7703 0000EBD3 83C704              <1> 	add	edi, 4
  7704 0000EBD6 E2E9                <1> 	loop	m_pix_op_new_32_0
  7705 0000EBD8 C3                  <1> 	retn
  7706                              <1> 
  7707                              <1> m_pix_op_new_w:
  7708                              <1> 	; 06/02/2021
  7709                              <1> 	; CHANGE COLOR (MASKED, window)
  7710                              <1> 	;
  7711                              <1> 	; jump from pix_op_new_w
  7712                              <1> 	;
  7713                              <1> 	; INPUT:
  7714                              <1> 	;   ecx = bytes per row (to be applied)
  7715                              <1> 	;   edx = screen width in bytes
  7716                              <1> 	;   ebx = row count
  7717                              <1> 	;   eax = color
  7718                              <1> 	;
  7719                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7720                              <1> 	;
  7721                              <1> 	; OUTPUT:
  7722                              <1> 	; 	[u.r0] will be > 0 if succesful
  7723                              <1> 
  7724                              <1> 	; Window
  7725                              <1> 	;mov	edi, [v_str] ; LFB start address
  7726                              <1> 	;mov	esi, edi 
  7727                              <1> 
  7728 0000EBD9 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7729 0000EBE0 7707                <1> 	ja	short m_pix_op_new_w_1
  7730                              <1> 
  7731                              <1> 	; 256 colors (8bpp)
  7732 0000EBE2 BD[54EB0000]        <1> 	mov	ebp, m_pix_op_new_8
  7733 0000EBE7 EB1E                <1> 	jmp	short m_pix_op_new_w_x
  7734                              <1> 			
  7735                              <1> m_pix_op_new_w_1:
  7736 0000EBE9 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7737 0000EBF0 7710                <1> 	ja	short m_pix_op_new_w_3 ; 32bpp
  7738 0000EBF2 7207                <1> 	jb	short m_pix_op_new_w_2 ; 16bpp
  7739                              <1> 
  7740                              <1> 	; 24 bit true colors
  7741 0000EBF4 BD[76EB0000]        <1> 	mov	ebp, m_pix_op_new_24
  7742 0000EBF9 EB0C                <1> 	jmp	short m_pix_op_new_w_x
  7743                              <1> 
  7744                              <1> 	; 65536 colors (16bpp)
  7745                              <1> m_pix_op_new_w_2:
  7746 0000EBFB BD[A2EB0000]        <1> 	mov	ebp, m_pix_op_new_16
  7747 0000EC00 EB05                <1> 	jmp	short m_pix_op_new_w_x
  7748                              <1> 
  7749                              <1> 	; 32 bit true colors
  7750                              <1> m_pix_op_new_w_3:
  7751 0000EC02 BD[BFEB0000]        <1> 	mov	ebp, m_pix_op_new_32
  7752                              <1> 	;jmp	short m_pix_op_new_w_x
  7753                              <1> 
  7754                              <1> m_pix_op_new_w_x:
  7755                              <1> m_pix_op_add_w_x:
  7756                              <1> m_pix_op_sub_w_x:
  7757                              <1> m_pix_op_mix_w_x:
  7758                              <1> m_pix_op_and_w_x:
  7759                              <1> m_pix_op_orc_w_x:
  7760                              <1> m_pix_op_xor_w_x:
  7761                              <1> m_pix_op_not_w_x:
  7762                              <1> m_pix_op_neg_w_x:
  7763                              <1> m_pix_op_inc_w_x:
  7764                              <1> m_pix_op_dec_w_x:
  7765                              <1> 	; 27/02/2021
  7766                              <1> 	; 26/02/2021
  7767                              <1> 	; 06/02/2021
  7768                              <1> 	; ecx = bytes per row (to be applied)
  7769                              <1> 	; edx = windows (screen) width in bytes
  7770                              <1> 	; ebx = row count
  7771                              <1> 	; eax = color
  7772                              <1> 	; ebp = pixel operation subroutine address
  7773                              <1> 	; edi = esi = window start address
  7774                              <1> 
  7775 0000EC07 8B3D[46100300]      <1> 	mov	edi, [v_str] ; LFB start address
  7776 0000EC0D 89FE                <1> 	mov	esi, edi
  7777                              <1> m_pix_op_w_x_next:
  7778 0000EC0F 52                  <1> 	push	edx
  7779 0000EC10 51                  <1> 	push	ecx
  7780 0000EC11 56                  <1> 	push	esi
  7781 0000EC12 57                  <1> 	push	edi
  7782 0000EC13 50                  <1> 	push	eax ; 26/02/2021
  7783 0000EC14 8B0D[52100300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021  
  7784 0000EC1A FFD5                <1> 	call	ebp ; call masked pixel-row operation
  7785 0000EC1C 58                  <1> 	pop	eax ; 26/02/2021
  7786 0000EC1D 5F                  <1> 	pop	edi
  7787 0000EC1E 5E                  <1> 	pop	esi
  7788 0000EC1F 59                  <1> 	pop	ecx
  7789 0000EC20 5A                  <1> 	pop	edx
  7790 0000EC21 01D6                <1> 	add	esi, edx ; next row
  7791 0000EC23 01D7                <1> 	add	edi, edx ; next row
  7792 0000EC25 4B                  <1> 	dec	ebx
  7793 0000EC26 75E7                <1> 	jnz	short m_pix_op_w_x_next
  7794 0000EC28 C3                  <1> 	retn
  7795                              <1> 
  7796                              <1> m_pix_op_add:
  7797                              <1> 	; 06/02/2021
  7798                              <1> 	; ADD COLOR (MASKED, full screen)
  7799                              <1> 	;
  7800                              <1> 	; jump from pix_op_add
  7801                              <1> 	;
  7802                              <1> 	; INPUT:
  7803                              <1> 	;   eax = color (AL, AX, EAX)
  7804                              <1> 	;   ecx = [v_siz] ; display page pixel count
  7805                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  7806                              <1> 	;
  7807                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7808                              <1> 	;
  7809                              <1> 	; OUTPUT:
  7810                              <1> 	; 	[u.r0] will be > 0 if succesful
  7811                              <1> 	
  7812                              <1> 	; Full screen
  7813                              <1> m_pix_op_add_0:
  7814 0000EC29 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7815 0000EC30 771C                <1> 	ja	short m_pix_op_add_1
  7816                              <1> 	; 256 colors (8bpp)
  7817                              <1> 	;jmp	short m_pix_op_add_8
  7818                              <1> m_pix_op_add_8:
  7819                              <1> 	; 8 bit colors (256 colors)
  7820 0000EC32 88C2                <1> 	mov	dl, al ; new color
  7821                              <1> m_pix_op_add_8_0:
  7822 0000EC34 AC                  <1> 	lodsb 
  7823 0000EC35 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  7824 0000EC3B 740D                <1> 	je	short m_pix_op_add_8_1 ; exclude
  7825 0000EC3D FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  7826 0000EC43 0017                <1> 	add	[edi], dl
  7827 0000EC45 7303                <1> 	jnc	short m_pix_op_add_8_1
  7828 0000EC47 C607FF              <1> 	mov	byte [edi], 0FFh 
  7829                              <1> m_pix_op_add_8_1:
  7830 0000EC4A 47                  <1> 	inc	edi
  7831 0000EC4B E2E7                <1> 	loop	m_pix_op_add_8_0
  7832 0000EC4D C3                  <1> 	retn
  7833                              <1> m_pix_op_add_1:
  7834 0000EC4E 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7835 0000EC55 775E                <1> 	ja	short m_pix_op_add_3 ; 32bpp	
  7836 0000EC57 7238                <1> 	jb	short m_pix_op_add_2 ; 16bpp
  7837                              <1> 	; 24 bit true colors
  7838                              <1> 	;jmp	short m_pix_op_add_24
  7839                              <1> m_pix_op_add_24:
  7840                              <1> 	; 24 bit true colors
  7841 0000EC59 89C2                <1> 	mov	edx, eax ; new color
  7842 0000EC5B 81CA000000FF        <1> 	or	edx, 0FF000000h
  7843                              <1> m_pix_op_add_24_0:
  7844 0000EC61 66AD                <1> 	lodsw
  7845 0000EC63 C1E010              <1> 	shl	eax, 16
  7846 0000EC66 AC                  <1> 	lodsb
  7847 0000EC67 C1C010              <1> 	rol	eax, 16	
  7848 0000EC6A 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  7849 0000EC70 7419                <1> 	je	short m_pix_op_add_24_2 ; exclude
  7850 0000EC72 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
  7851 0000EC79 01D0                <1> 	add	eax, edx
  7852 0000EC7B 7305                <1> 	jnc	short m_pix_op_add_24_1
  7853 0000EC7D B8FFFFFF00          <1> 	mov	eax, 0FFFFFFh
  7854                              <1> m_pix_op_add_24_1:	
  7855 0000EC82 668907              <1> 	mov	[edi], ax
  7856 0000EC85 C1E810              <1> 	shr	eax, 16
  7857 0000EC88 884702              <1> 	mov	[edi+2], al
  7858                              <1> m_pix_op_add_24_2:
  7859 0000EC8B 83C703              <1> 	add	edi, 3 ; +3
  7860 0000EC8E E2D1                <1> 	loop	m_pix_op_add_24_0
  7861 0000EC90 C3                  <1> 	retn
  7862                              <1> 	; 65536 colors (16bpp)
  7863                              <1> m_pix_op_add_2:
  7864                              <1> 	;jmp	short m_pix_op_add_16
  7865                              <1> m_pix_op_add_16:
  7866                              <1> 	; 16 bit colors (65536 colors)
  7867 0000EC91 89C2                <1> 	mov	edx, eax ; new color
  7868                              <1> m_pix_op_add_16_0:
  7869 0000EC93 66AD                <1> 	lodsw
  7870 0000EC95 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  7871 0000EC9C 7411                <1> 	je	short m_pix_op_add_16_1 ; exclude
  7872 0000EC9E 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
  7873 0000ECA5 660117              <1> 	add	[edi], dx
  7874 0000ECA8 7305                <1> 	jnc	short m_pix_op_add_16_1
  7875 0000ECAA 66C707FFFF          <1> 	mov	word [edi], 0FFFFh
  7876                              <1> m_pix_op_add_16_1:
  7877 0000ECAF 83C702              <1> 	add	edi, 2 ; +2
  7878 0000ECB2 E2DF                <1> 	loop	m_pix_op_add_16_0
  7879 0000ECB4 C3                  <1> 	retn
  7880                              <1> m_pix_op_add_3:
  7881                              <1> 	; 32 bit true colors
  7882                              <1> 	;jmp	short m_pix_op_add_32
  7883                              <1> m_pix_op_add_32:
  7884                              <1> 	; 32 bit true colors
  7885 0000ECB5 89C2                <1> 	mov	edx, eax ; new color
  7886                              <1> m_pix_op_add_32_0:
  7887 0000ECB7 AD                  <1> 	lodsd 
  7888 0000ECB8 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  7889 0000ECBE 7411                <1> 	je	short m_pix_op_add_32_1 ; exclude
  7890 0000ECC0 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
  7891 0000ECC7 0117                <1> 	add	[edi], edx
  7892 0000ECC9 7306                <1> 	jnc	short m_pix_op_add_32_1
  7893 0000ECCB C707FFFFFFFF        <1> 	mov	dword [edi], 0FFFFFFFFh
  7894                              <1> m_pix_op_add_32_1:
  7895 0000ECD1 83C704              <1> 	add	edi, 4 ; +4
  7896 0000ECD4 E2E1                <1> 	loop	m_pix_op_add_32_0
  7897 0000ECD6 C3                  <1> 	retn
  7898                              <1> 
  7899                              <1> m_pix_op_add_w:
  7900                              <1> 	; 06/02/2021
  7901                              <1> 	; ADD COLOR (MASKED, window)
  7902                              <1> 	;
  7903                              <1> 	; jump from pix_op_add_w
  7904                              <1> 	;
  7905                              <1> 	; INPUT:
  7906                              <1> 	;   ecx = bytes per row (to be applied)
  7907                              <1> 	;   edx = screen width in bytes
  7908                              <1> 	;   ebx = row count
  7909                              <1> 	;   eax = color
  7910                              <1> 	;
  7911                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7912                              <1> 	;
  7913                              <1> 	; OUTPUT:
  7914                              <1> 	; 	[u.r0] will be > 0 if succesful
  7915                              <1> 
  7916                              <1> 	; window
  7917                              <1> 	;mov	edi, [v_str] ; LFB start address
  7918                              <1> 	;mov	esi, edi 
  7919                              <1> 
  7920 0000ECD7 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7921 0000ECDE 7707                <1> 	ja	short m_pix_op_add_w_1
  7922                              <1> 
  7923                              <1> 	; 256 colors (8bpp)
  7924 0000ECE0 BD[32EC0000]        <1> 	mov	ebp, m_pix_op_add_8
  7925 0000ECE5 EB1E                <1> 	jmp	short m_pix_op_add_w_4
  7926                              <1> 			
  7927                              <1> m_pix_op_add_w_1:
  7928 0000ECE7 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7929 0000ECEE 7710                <1> 	ja	short m_pix_op_add_w_3 ; 32bpp
  7930 0000ECF0 7207                <1> 	jb	short m_pix_op_add_w_2 ; 16bpp
  7931                              <1> 
  7932                              <1> 	; 24 bit true colors
  7933 0000ECF2 BD[59EC0000]        <1> 	mov	ebp, m_pix_op_add_24
  7934 0000ECF7 EB0C                <1> 	jmp	short m_pix_op_add_w_4
  7935                              <1> 
  7936                              <1> 	; 65536 colors (16bpp)
  7937                              <1> m_pix_op_add_w_2:
  7938 0000ECF9 BD[91EC0000]        <1> 	mov	ebp, m_pix_op_add_16
  7939 0000ECFE EB05                <1> 	jmp	short m_pix_op_add_w_4
  7940                              <1> 
  7941                              <1> 	; 32 bit true colors
  7942                              <1> m_pix_op_add_w_3:
  7943 0000ED00 BD[B5EC0000]        <1> 	mov	ebp, m_pix_op_add_32
  7944                              <1> m_pix_op_add_w_4:
  7945 0000ED05 E9FDFEFFFF          <1> 	jmp	m_pix_op_add_w_x
  7946                              <1> 
  7947                              <1> m_pix_op_sub:
  7948                              <1> 	; 02/03/2021
  7949                              <1> 	; 06/02/2021
  7950                              <1> 	; SUBTRACT COLOR (MASKED, full screen)
  7951                              <1> 	;
  7952                              <1> 	; jump from pix_op_sub
  7953                              <1> 	;
  7954                              <1> 	; INPUT:
  7955                              <1> 	;   eax = color (AL, AX, EAX)
  7956                              <1> 	;   ecx = [v_siz] ; display page pixel count
  7957                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  7958                              <1> 	;
  7959                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7960                              <1> 	;
  7961                              <1> 	; OUTPUT:
  7962                              <1> 	; 	[u.r0] will be > 0 if succesful
  7963                              <1> 	
  7964                              <1> 	; Full screen
  7965                              <1> m_pix_op_sub_0:
  7966 0000ED0A 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7967 0000ED11 771C                <1> 	ja	short m_pix_op_sub_1
  7968                              <1> 	; 256 colors (8bpp)
  7969                              <1> 	;jmp	short m_pix_op_sub_8
  7970                              <1> m_pix_op_sub_8:
  7971                              <1> 	; 8 bit colors (256 colors)
  7972 0000ED13 88C2                <1> 	mov	dl, al ; new color
  7973                              <1> m_pix_op_sub_8_0:
  7974 0000ED15 AC                  <1> 	lodsb 
  7975 0000ED16 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  7976 0000ED1C 740D                <1> 	je	short m_pix_op_sub_8_1 ; exclude
  7977 0000ED1E FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  7978 0000ED24 2817                <1> 	sub	[edi], dl
  7979 0000ED26 7303                <1> 	jnb	short m_pix_op_sub_8_1
  7980 0000ED28 C60700              <1> 	mov	byte [edi], 0 
  7981                              <1> m_pix_op_sub_8_1:
  7982 0000ED2B 47                  <1> 	inc	edi
  7983 0000ED2C E2E7                <1> 	loop	m_pix_op_sub_8_0
  7984 0000ED2E C3                  <1> 	retn
  7985                              <1> m_pix_op_sub_1:
  7986 0000ED2F 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7987 0000ED36 7755                <1> 	ja	short m_pix_op_sub_3 ; 32bpp	
  7988 0000ED38 722F                <1> 	jb	short m_pix_op_sub_2 ; 16bpp
  7989                              <1> 	; 24 bit true colors
  7990                              <1> 	;jmp	short m_pix_op_sub_24
  7991                              <1> m_pix_op_sub_24:
  7992                              <1> 	; 24 bit true colors
  7993 0000ED3A 89C2                <1> 	mov	edx, eax ; new color
  7994                              <1> 	; 02/03/2021
  7995                              <1> m_pix_op_sub_24_0:
  7996 0000ED3C 66AD                <1> 	lodsw
  7997 0000ED3E C1E010              <1> 	shl	eax, 16
  7998 0000ED41 AC                  <1> 	lodsb
  7999 0000ED42 C1C010              <1> 	rol	eax, 16	
  8000 0000ED45 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8001 0000ED4B 7416                <1> 	je	short m_pix_op_sub_24_2 ; exclude
  8002 0000ED4D 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
  8003 0000ED54 29D0                <1> 	sub	eax, edx
  8004 0000ED56 7302                <1> 	jnb	short m_pix_op_sub_24_1
  8005 0000ED58 31C0                <1> 	xor	eax, eax ; 0
  8006                              <1> m_pix_op_sub_24_1:	
  8007 0000ED5A 668907              <1> 	mov	[edi], ax
  8008 0000ED5D C1E810              <1> 	shr	eax, 16
  8009 0000ED60 884702              <1> 	mov	[edi+2], al
  8010                              <1> m_pix_op_sub_24_2:
  8011 0000ED63 83C703              <1> 	add	edi, 3 ; +3
  8012 0000ED66 E2D4                <1> 	loop	m_pix_op_sub_24_0
  8013 0000ED68 C3                  <1> 	retn
  8014                              <1> 	; 65536 colors (16bpp)
  8015                              <1> m_pix_op_sub_2:
  8016                              <1> 	;jmp	short m_pix_op_sub_16
  8017                              <1> m_pix_op_sub_16:
  8018                              <1> 	; 16 bit colors (65536 colors)
  8019 0000ED69 89C2                <1> 	mov	edx, eax ; new color
  8020                              <1> m_pix_op_sub_16_0:
  8021 0000ED6B 66AD                <1> 	lodsw
  8022 0000ED6D 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  8023 0000ED74 7411                <1> 	je	short m_pix_op_sub_16_1 ; exclude
  8024 0000ED76 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
  8025 0000ED7D 662917              <1> 	sub	[edi], dx
  8026 0000ED80 7305                <1> 	jnb	short m_pix_op_sub_16_1
  8027 0000ED82 31C0                <1> 	xor	eax, eax
  8028 0000ED84 668907              <1> 	mov	[edi], ax ; 0
  8029                              <1> m_pix_op_sub_16_1:
  8030 0000ED87 83C702              <1> 	add	edi, 2 ; +2
  8031 0000ED8A E2DF                <1> 	loop	m_pix_op_sub_16_0
  8032 0000ED8C C3                  <1> 	retn
  8033                              <1> m_pix_op_sub_3:
  8034                              <1> 	; 32 bit true colors
  8035                              <1> 	;jmp	short m_pix_op_sub_32
  8036                              <1> m_pix_op_sub_32:
  8037                              <1> 	; 32 bit true colors
  8038 0000ED8D 89C2                <1> 	mov	edx, eax ; new color
  8039                              <1> m_pix_op_sub_32_0:
  8040 0000ED8F AD                  <1> 	lodsd 
  8041 0000ED90 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8042 0000ED96 740F                <1> 	je	short m_pix_op_sub_32_1 ; exclude
  8043 0000ED98 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
  8044 0000ED9F 2917                <1> 	sub	[edi], edx
  8045 0000EDA1 7304                <1> 	jnb	short m_pix_op_sub_32_1
  8046 0000EDA3 31C0                <1> 	xor	eax, eax
  8047 0000EDA5 8907                <1> 	mov	[edi], eax ; 0
  8048                              <1> m_pix_op_sub_32_1:
  8049 0000EDA7 83C704              <1> 	add	edi, 4 ; +4
  8050 0000EDAA E2E3                <1> 	loop	m_pix_op_sub_32_0
  8051 0000EDAC C3                  <1> 	retn
  8052                              <1> 
  8053                              <1> m_pix_op_sub_w:
  8054                              <1> 	; 06/02/2021
  8055                              <1> 	; SUBTRACT COLOR (MASKED, window)
  8056                              <1> 	;
  8057                              <1> 	; jump from pix_op_sub_w
  8058                              <1> 	;
  8059                              <1> 	; INPUT:
  8060                              <1> 	;   ecx = bytes per row (to be applied)
  8061                              <1> 	;   edx = screen width in bytes
  8062                              <1> 	;   ebx = row count
  8063                              <1> 	;   eax = color
  8064                              <1> 	;
  8065                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8066                              <1> 	;
  8067                              <1> 	; OUTPUT:
  8068                              <1> 	; 	[u.r0] will be > 0 if succesful
  8069                              <1> 
  8070                              <1> 	; window
  8071                              <1> 	;mov	edi, [v_str] ; LFB start address
  8072                              <1> 	;mov	esi, edi 
  8073                              <1> 
  8074 0000EDAD 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8075 0000EDB4 7707                <1> 	ja	short m_pix_op_sub_w_1
  8076                              <1> 
  8077                              <1> 	; 256 colors (8bpp)
  8078 0000EDB6 BD[13ED0000]        <1> 	mov	ebp, m_pix_op_sub_8
  8079 0000EDBB EB1E                <1> 	jmp	short m_pix_op_sub_w_4
  8080                              <1> 			
  8081                              <1> m_pix_op_sub_w_1:
  8082 0000EDBD 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8083 0000EDC4 7710                <1> 	ja	short m_pix_op_sub_w_3 ; 32bpp
  8084 0000EDC6 7207                <1> 	jb	short m_pix_op_sub_w_2 ; 16bpp
  8085                              <1> 
  8086                              <1> 	; 24 bit true colors
  8087 0000EDC8 BD[3AED0000]        <1> 	mov	ebp, m_pix_op_sub_24
  8088 0000EDCD EB0C                <1> 	jmp	short m_pix_op_sub_w_4
  8089                              <1> 
  8090                              <1> 	; 65536 colors (16bpp)
  8091                              <1> m_pix_op_sub_w_2:
  8092 0000EDCF BD[69ED0000]        <1> 	mov	ebp, m_pix_op_sub_16
  8093 0000EDD4 EB05                <1> 	jmp	short m_pix_op_sub_w_4
  8094                              <1> 
  8095                              <1> 	; 32 bit true colors
  8096                              <1> m_pix_op_sub_w_3:
  8097 0000EDD6 BD[8DED0000]        <1> 	mov	ebp, m_pix_op_sub_32
  8098                              <1> m_pix_op_sub_w_4:
  8099 0000EDDB E927FEFFFF          <1> 	jmp	m_pix_op_sub_w_x
  8100                              <1> 
  8101                              <1> m_pix_op_mix:
  8102                              <1> 	; 25/02/2021
  8103                              <1> 	; 06/02/2021
  8104                              <1> 	; MIX COLOR (MASKED, full screen)
  8105                              <1> 	;
  8106                              <1> 	; jump from pix_op_mix
  8107                              <1> 	;
  8108                              <1> 	; INPUT:
  8109                              <1> 	;   eax = color (AL, AX, EAX)
  8110                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8111                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8112                              <1> 	;
  8113                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8114                              <1> 	;
  8115                              <1> 	; OUTPUT:
  8116                              <1> 	; 	[u.r0] will be > 0 if succesful
  8117                              <1> 	
  8118                              <1> 	; Full screen
  8119                              <1> m_pix_op_mix_0:
  8120 0000EDE0 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8121 0000EDE7 771B                <1> 	ja	short m_pix_op_mix_1
  8122                              <1> 	; 256 colors (8bpp)
  8123                              <1> 	;jmp	short m_pix_op_mix_8
  8124                              <1> m_pix_op_mix_8:
  8125                              <1> 	; 8 bit colors (256 colors)
  8126 0000EDE9 88C2                <1> 	mov	dl, al ; new (mixing) color
  8127                              <1> m_pix_op_mix_8_0:
  8128 0000EDEB AC                  <1> 	lodsb 
  8129 0000EDEC 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  8130 0000EDF2 740C                <1> 	je	short m_pix_op_mix_8_1 ; exclude
  8131 0000EDF4 00D0                <1> 	add	al, dl ; 25/02/2021
  8132 0000EDF6 D0D8                <1> 	rcr	al, 1	
  8133 0000EDF8 8807                <1> 	mov	[edi], al
  8134 0000EDFA FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  8135                              <1> m_pix_op_mix_8_1:
  8136 0000EE00 47                  <1> 	inc	edi
  8137 0000EE01 E2E8                <1> 	loop	m_pix_op_mix_8_0
  8138 0000EE03 C3                  <1> 	retn
  8139                              <1> m_pix_op_mix_1:
  8140 0000EE04 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8141 0000EE0B 7752                <1> 	ja	short m_pix_op_mix_3 ; 32bpp	
  8142 0000EE0D 722D                <1> 	jb	short m_pix_op_mix_2 ; 16bpp
  8143                              <1> 	; 24 bit true colors
  8144                              <1> 	;jmp	short m_pix_op_mix_24
  8145                              <1> m_pix_op_mix_24:
  8146                              <1> 	; 24 bit true colors
  8147 0000EE0F 89C2                <1> 	mov	edx, eax ; new color
  8148                              <1> 	;and	edx, 0FFFFFFh
  8149                              <1> m_pix_op_mix_24_0:
  8150 0000EE11 66AD                <1> 	lodsw
  8151 0000EE13 C1E010              <1> 	shl	eax, 16
  8152 0000EE16 AC                  <1> 	lodsb
  8153 0000EE17 C1C010              <1> 	rol	eax, 16	
  8154 0000EE1A 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8155 0000EE20 7414                <1> 	je	short m_pix_op_mix_24_1 ; exclude
  8156 0000EE22 01D0                <1> 	add	eax, edx
  8157 0000EE24 D1E8                <1> 	shr	eax, 1
  8158 0000EE26 668907              <1> 	mov	[edi], ax
  8159 0000EE29 C1E810              <1> 	shr	eax, 16
  8160 0000EE2C 884702              <1> 	mov	[edi+2], al
  8161 0000EE2F 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
  8162                              <1> m_pix_op_mix_24_1:
  8163 0000EE36 83C703              <1> 	add	edi, 3 ; +3
  8164 0000EE39 E2D6                <1> 	loop	m_pix_op_mix_24_0
  8165 0000EE3B C3                  <1> 	retn
  8166                              <1> 	; 65536 colors (16bpp)
  8167                              <1> m_pix_op_mix_2:
  8168                              <1> 	;jmp	short m_pix_op_mix_16
  8169                              <1> m_pix_op_mix_16:
  8170                              <1> 	; 16 bit colors (65536 colors)
  8171 0000EE3C 89C2                <1> 	mov	edx, eax ; new color
  8172                              <1> 	;and	edx, 0FFFFh
  8173                              <1> m_pix_op_mix_16_0:
  8174 0000EE3E 66AD                <1> 	lodsw
  8175 0000EE40 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  8176 0000EE47 7410                <1> 	je	short m_pix_op_mix_16_1 ; exclude
  8177 0000EE49 6601D0              <1> 	add	ax, dx
  8178 0000EE4C 66D1D8              <1> 	rcr	ax, 1
  8179 0000EE4F 668907              <1> 	mov	[edi], ax
  8180 0000EE52 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
  8181                              <1> m_pix_op_mix_16_1:
  8182 0000EE59 83C702              <1> 	add	edi, 2 ; +2
  8183 0000EE5C E2E0                <1> 	loop	m_pix_op_mix_16_0
  8184 0000EE5E C3                  <1> 	retn
  8185                              <1> m_pix_op_mix_3:
  8186                              <1> 	; 32 bit true colors
  8187                              <1> 	;jmp	short m_pix_op_mix_32
  8188                              <1> m_pix_op_mix_32:
  8189                              <1> 	; 32 bit true colors
  8190 0000EE5F 89C2                <1> 	mov	edx, eax ; new color
  8191                              <1> m_pix_op_mix_32_0:
  8192 0000EE61 AD                  <1> 	lodsd 
  8193 0000EE62 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8194 0000EE68 740D                <1> 	je	short m_pix_op_mix_32_1 ; exclude
  8195 0000EE6A 01D0                <1> 	add	eax, edx
  8196                              <1> 	; 02/03/2021
  8197 0000EE6C D1D8                <1> 	rcr	eax, 1
  8198 0000EE6E 8907                <1> 	mov	[edi], eax	
  8199 0000EE70 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
  8200                              <1> m_pix_op_mix_32_1:
  8201 0000EE77 83C704              <1> 	add	edi, 4 ; +4
  8202 0000EE7A E2E5                <1> 	loop	m_pix_op_mix_32_0
  8203 0000EE7C C3                  <1> 	retn
  8204                              <1> 
  8205                              <1> m_pix_op_mix_w:
  8206                              <1> 	; 06/02/2021
  8207                              <1> 	; MIX COLOR (MASKED, window)
  8208                              <1> 	;
  8209                              <1> 	; jump from pix_op_mix_w
  8210                              <1> 	;
  8211                              <1> 	; INPUT:
  8212                              <1> 	;   ecx = bytes per row (to be applied)
  8213                              <1> 	;   edx = screen width in bytes
  8214                              <1> 	;   ebx = row count
  8215                              <1> 	;   eax = color
  8216                              <1> 	;
  8217                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8218                              <1> 	;
  8219                              <1> 	; OUTPUT:
  8220                              <1> 	; 	[u.r0] will be > 0 if succesful
  8221                              <1> 
  8222                              <1> 	; window
  8223                              <1> 	;mov	edi, [v_str] ; LFB start address
  8224                              <1> 	;mov	esi, edi 
  8225                              <1> 
  8226 0000EE7D 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8227 0000EE84 7707                <1> 	ja	short m_pix_op_mix_w_1
  8228                              <1> 
  8229                              <1> 	; 256 colors (8bpp)
  8230 0000EE86 BD[E9ED0000]        <1> 	mov	ebp, m_pix_op_mix_8
  8231 0000EE8B EB1E                <1> 	jmp	short m_pix_op_mix_w_4
  8232                              <1> 			
  8233                              <1> m_pix_op_mix_w_1:
  8234 0000EE8D 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8235 0000EE94 7710                <1> 	ja	short m_pix_op_mix_w_3 ; 32bpp
  8236 0000EE96 7207                <1> 	jb	short m_pix_op_mix_w_2 ; 16bpp
  8237                              <1> 
  8238                              <1> 	; 24 bit true colors
  8239 0000EE98 BD[0FEE0000]        <1> 	mov	ebp, m_pix_op_mix_24
  8240 0000EE9D EB0C                <1> 	jmp	short m_pix_op_mix_w_4
  8241                              <1> 
  8242                              <1> 	; 65536 colors (16bpp)
  8243                              <1> m_pix_op_mix_w_2:
  8244 0000EE9F BD[3CEE0000]        <1> 	mov	ebp, m_pix_op_mix_16
  8245 0000EEA4 EB05                <1> 	jmp	short m_pix_op_mix_w_4
  8246                              <1> 
  8247                              <1> 	; 32 bit true colors
  8248                              <1> m_pix_op_mix_w_3:
  8249 0000EEA6 BD[5FEE0000]        <1> 	mov	ebp, m_pix_op_mix_32
  8250                              <1> m_pix_op_mix_w_4:
  8251 0000EEAB E957FDFFFF          <1> 	jmp	m_pix_op_mix_w_x
  8252                              <1> 
  8253                              <1> m_pix_op_and:
  8254                              <1> 	; 06/02/2021
  8255                              <1> 	; AND COLOR (MASKED, full screen)
  8256                              <1> 	;
  8257                              <1> 	; jump from pix_op_and
  8258                              <1> 	;
  8259                              <1> 	; INPUT:
  8260                              <1> 	;   eax = color (AL, AX, EAX)
  8261                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8262                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8263                              <1> 	;
  8264                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8265                              <1> 	;
  8266                              <1> 	; OUTPUT:
  8267                              <1> 	; 	[u.r0] will be > 0 if succesful
  8268                              <1> 	
  8269                              <1> 	; Full screen
  8270                              <1> m_pix_op_and_0:
  8271 0000EEB0 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8272 0000EEB7 7717                <1> 	ja	short m_pix_op_and_1
  8273                              <1> 	; 256 colors (8bpp)
  8274                              <1> 	;jmp	short m_pix_op_and_8
  8275                              <1> m_pix_op_and_8:
  8276                              <1> 	; 8 bit colors (256 colors)
  8277 0000EEB9 88C2                <1> 	mov	dl, al ; new color
  8278                              <1> m_pix_op_and_8_0:
  8279 0000EEBB AC                  <1> 	lodsb 
  8280 0000EEBC 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  8281 0000EEC2 7408                <1> 	je	short m_pix_op_and_8_1 ; exclude
  8282 0000EEC4 2017                <1> 	and	[edi], dl
  8283 0000EEC6 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  8284                              <1> m_pix_op_and_8_1:
  8285 0000EECC 47                  <1> 	inc	edi
  8286 0000EECD E2EC                <1> 	loop	m_pix_op_and_8_0
  8287 0000EECF C3                  <1> 	retn
  8288                              <1> m_pix_op_and_1:
  8289 0000EED0 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8290 0000EED7 774A                <1> 	ja	short m_pix_op_and_3 ; 32bpp	
  8291 0000EED9 722B                <1> 	jb	short m_pix_op_and_2 ; 16bpp
  8292                              <1> 	; 24 bit true colors
  8293                              <1> 	;jmp	short m_pix_op_and_24
  8294                              <1> m_pix_op_and_24:
  8295                              <1> 	; 24 bit true colors
  8296 0000EEDB 89C2                <1> 	mov	edx, eax ; new color
  8297                              <1> 	;and	edx, 0FFFFFFh
  8298                              <1> m_pix_op_and_24_0:
  8299 0000EEDD 66AD                <1> 	lodsw
  8300 0000EEDF C1E010              <1> 	shl	eax, 16
  8301 0000EEE2 AC                  <1> 	lodsb
  8302 0000EEE3 C1C010              <1> 	rol	eax, 16	
  8303 0000EEE6 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8304 0000EEEC 7412                <1> 	je	short m_pix_op_and_24_1 ; exclude
  8305 0000EEEE 21D0                <1> 	and	eax, edx
  8306 0000EEF0 668907              <1> 	mov	[edi], ax
  8307 0000EEF3 C1E810              <1> 	shr	eax, 16
  8308 0000EEF6 884702              <1> 	mov	[edi+2], al
  8309 0000EEF9 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
  8310                              <1> m_pix_op_and_24_1:
  8311 0000EF00 83C703              <1> 	add	edi, 3 ; +3
  8312 0000EF03 E2D8                <1> 	loop	m_pix_op_and_24_0
  8313 0000EF05 C3                  <1> 	retn
  8314                              <1> 	; 65536 colors (16bpp)
  8315                              <1> m_pix_op_and_2:
  8316                              <1> 	;jmp	short m_pix_op_and_16
  8317                              <1> m_pix_op_and_16:
  8318                              <1> 	; 16 bit colors (65536 colors)
  8319 0000EF06 89C2                <1> 	mov	edx, eax ; new color
  8320                              <1> 	;and	edx, 0FFFFh
  8321                              <1> m_pix_op_and_16_0:
  8322 0000EF08 66AD                <1> 	lodsw
  8323 0000EF0A 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  8324 0000EF11 740A                <1> 	je	short m_pix_op_and_16_1 ; exclude
  8325 0000EF13 662117              <1> 	and	[edi], dx
  8326 0000EF16 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
  8327                              <1> m_pix_op_and_16_1:
  8328 0000EF1D 83C702              <1> 	add	edi, 2 ; +2
  8329 0000EF20 E2E6                <1> 	loop	m_pix_op_and_16_0
  8330 0000EF22 C3                  <1> 	retn
  8331                              <1> m_pix_op_and_3:
  8332                              <1> 	; 32 bit true colors
  8333                              <1> 	;jmp	short m_pix_op_and_32
  8334                              <1> m_pix_op_and_32:
  8335                              <1> 	; 32 bit true colors
  8336 0000EF23 89C2                <1> 	mov	edx, eax ; new color
  8337                              <1> m_pix_op_and_32_0:
  8338 0000EF25 AD                  <1> 	lodsd 
  8339 0000EF26 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8340 0000EF2C 7409                <1> 	je	short m_pix_op_and_32_1 ; exclude
  8341 0000EF2E 2117                <1> 	and	[edi], edx ; 25/02/2021	
  8342 0000EF30 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
  8343                              <1> m_pix_op_and_32_1:
  8344 0000EF37 83C704              <1> 	add	edi, 4 ; +4
  8345 0000EF3A E2E9                <1> 	loop	m_pix_op_and_32_0
  8346 0000EF3C C3                  <1> 	retn
  8347                              <1> 
  8348                              <1> m_pix_op_and_w:
  8349                              <1> 	; 06/02/2021
  8350                              <1> 	; AND COLOR (MASKED, window)
  8351                              <1> 	;
  8352                              <1> 	; jump from pix_op_and_w
  8353                              <1> 	;
  8354                              <1> 	; INPUT:
  8355                              <1> 	;   ecx = bytes per row (to be applied)
  8356                              <1> 	;   edx = screen width in bytes
  8357                              <1> 	;   ebx = row count
  8358                              <1> 	;   eax = color
  8359                              <1> 	;
  8360                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8361                              <1> 	;
  8362                              <1> 	; OUTPUT:
  8363                              <1> 	; 	[u.r0] will be > 0 if succesful
  8364                              <1> 
  8365                              <1> 	; window
  8366                              <1> 	;mov	edi, [v_str] ; LFB start address
  8367                              <1> 	;mov	esi, edi 
  8368                              <1> 
  8369 0000EF3D 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8370 0000EF44 7707                <1> 	ja	short m_pix_op_and_w_1
  8371                              <1> 
  8372                              <1> 	; 256 colors (8bpp)
  8373 0000EF46 BD[B9EE0000]        <1> 	mov	ebp, m_pix_op_and_8
  8374 0000EF4B EB1E                <1> 	jmp	short m_pix_op_and_w_4
  8375                              <1> 			
  8376                              <1> m_pix_op_and_w_1:
  8377 0000EF4D 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8378 0000EF54 7710                <1> 	ja	short m_pix_op_and_w_3 ; 32bpp
  8379 0000EF56 7207                <1> 	jb	short m_pix_op_and_w_2 ; 16bpp
  8380                              <1> 
  8381                              <1> 	; 24 bit true colors
  8382 0000EF58 BD[DBEE0000]        <1> 	mov	ebp, m_pix_op_and_24
  8383 0000EF5D EB0C                <1> 	jmp	short m_pix_op_and_w_4
  8384                              <1> 
  8385                              <1> 	; 65536 colors (16bpp)
  8386                              <1> m_pix_op_and_w_2:
  8387 0000EF5F BD[06EF0000]        <1> 	mov	ebp, m_pix_op_and_16
  8388 0000EF64 EB05                <1> 	jmp	short m_pix_op_and_w_4
  8389                              <1> 
  8390                              <1> 	; 32 bit true colors
  8391                              <1> m_pix_op_and_w_3:
  8392 0000EF66 BD[23EF0000]        <1> 	mov	ebp, m_pix_op_and_32
  8393                              <1> m_pix_op_and_w_4:
  8394 0000EF6B E997FCFFFF          <1> 	jmp	m_pix_op_and_w_x
  8395                              <1> 
  8396                              <1> m_pix_op_or:
  8397                              <1> 	; 06/02/2021
  8398                              <1> 	; OR COLOR (MASKED, full screen)
  8399                              <1> 	;
  8400                              <1> 	; jump from pix_op_orc
  8401                              <1> 	;
  8402                              <1> 	; INPUT:
  8403                              <1> 	;   eax = color (AL, AX, EAX)
  8404                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8405                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8406                              <1> 	;
  8407                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8408                              <1> 	;
  8409                              <1> 	; OUTPUT:
  8410                              <1> 	; 	[u.r0] will be > 0 if succesful
  8411                              <1> 	
  8412                              <1> 	; Full screen
  8413                              <1> m_pix_op_or_0:
  8414 0000EF70 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8415 0000EF77 7717                <1> 	ja	short m_pix_op_or_1
  8416                              <1> 	; 256 colors (8bpp)
  8417                              <1> 	;jmp	short m_pix_op_or_8
  8418                              <1> m_pix_op_or_8:
  8419                              <1> 	; 8 bit colors (256 colors)
  8420 0000EF79 88C2                <1> 	mov	dl, al ; new color
  8421                              <1> m_pix_op_or_8_0:
  8422 0000EF7B AC                  <1> 	lodsb 
  8423 0000EF7C 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  8424 0000EF82 7408                <1> 	je	short m_pix_op_or_8_1 ; exclude
  8425 0000EF84 0817                <1> 	or	[edi], dl
  8426 0000EF86 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  8427                              <1> m_pix_op_or_8_1:
  8428 0000EF8C 47                  <1> 	inc	edi
  8429 0000EF8D E2EC                <1> 	loop	m_pix_op_or_8_0
  8430 0000EF8F C3                  <1> 	retn
  8431                              <1> m_pix_op_or_1:
  8432 0000EF90 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8433 0000EF97 774A                <1> 	ja	short m_pix_op_or_3 ; 32bpp	
  8434 0000EF99 722B                <1> 	jb	short m_pix_op_or_2 ; 16bpp
  8435                              <1> 	; 24 bit true colors
  8436                              <1> 	;jmp	short m_pix_op_or_24
  8437                              <1> m_pix_op_or_24:
  8438                              <1> 	; 24 bit true colors
  8439 0000EF9B 89C2                <1> 	mov	edx, eax ; new color
  8440                              <1> 	;and	edx, 0FFFFFFh
  8441                              <1> m_pix_op_or_24_0:
  8442 0000EF9D 66AD                <1> 	lodsw
  8443 0000EF9F C1E010              <1> 	shl	eax, 16
  8444 0000EFA2 AC                  <1> 	lodsb
  8445 0000EFA3 C1C010              <1> 	rol	eax, 16	
  8446 0000EFA6 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8447 0000EFAC 7412                <1> 	je	short m_pix_op_or_24_1 ; exclude
  8448 0000EFAE 09D0                <1> 	or	eax, edx
  8449 0000EFB0 668907              <1> 	mov	[edi], ax
  8450 0000EFB3 C1E810              <1> 	shr	eax, 16
  8451 0000EFB6 884702              <1> 	mov	[edi+2], al
  8452 0000EFB9 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
  8453                              <1> m_pix_op_or_24_1:
  8454 0000EFC0 83C703              <1> 	add	edi, 3 ; +3
  8455 0000EFC3 E2D8                <1> 	loop	m_pix_op_or_24_0
  8456 0000EFC5 C3                  <1> 	retn
  8457                              <1> 	; 65536 colors (16bpp)
  8458                              <1> m_pix_op_or_2:
  8459                              <1> 	;jmp	short m_pix_op_or_16
  8460                              <1> m_pix_op_or_16:
  8461                              <1> 	; 16 bit colors (65536 colors)
  8462 0000EFC6 89C2                <1> 	mov	edx, eax ; new color
  8463                              <1> 	;and	edx, 0FFFFh
  8464                              <1> m_pix_op_or_16_0:
  8465 0000EFC8 66AD                <1> 	lodsw
  8466 0000EFCA 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  8467 0000EFD1 740A                <1> 	je	short m_pix_op_or_16_1 ; exclude
  8468 0000EFD3 660917              <1> 	or	[edi], dx
  8469 0000EFD6 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
  8470                              <1> m_pix_op_or_16_1:
  8471 0000EFDD 83C702              <1> 	add	edi, 2 ; +2
  8472 0000EFE0 E2E6                <1> 	loop	m_pix_op_or_16_0
  8473 0000EFE2 C3                  <1> 	retn
  8474                              <1> m_pix_op_or_3:
  8475                              <1> 	; 32 bit true colors
  8476                              <1> 	;jmp	short m_pix_op_or_32
  8477                              <1> m_pix_op_or_32:
  8478                              <1> 	; 32 bit true colors
  8479 0000EFE3 89C2                <1> 	mov	edx, eax ; new color
  8480                              <1> m_pix_op_or_32_0:
  8481 0000EFE5 AD                  <1> 	lodsd 
  8482 0000EFE6 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8483 0000EFEC 7409                <1> 	je	short m_pix_op_or_32_1 ; exclude
  8484 0000EFEE 0917                <1> 	or	[edi], edx ; 25/02/2021	
  8485 0000EFF0 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
  8486                              <1> m_pix_op_or_32_1:
  8487 0000EFF7 83C704              <1> 	add	edi, 4 ; +4
  8488 0000EFFA E2E9                <1> 	loop	m_pix_op_or_32_0
  8489 0000EFFC C3                  <1> 	retn
  8490                              <1> 
  8491                              <1> m_pix_op_or_w:
  8492                              <1> 	; 06/02/2021
  8493                              <1> 	; MIX COLOR (MASKED, window)
  8494                              <1> 	;
  8495                              <1> 	; jump from pix_op_or_w
  8496                              <1> 	;
  8497                              <1> 	; INPUT:
  8498                              <1> 	;   ecx = bytes per row (to be applied)
  8499                              <1> 	;   edx = screen width in bytes
  8500                              <1> 	;   ebx = row count
  8501                              <1> 	;   eax = color
  8502                              <1> 	;
  8503                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8504                              <1> 	;
  8505                              <1> 	; OUTPUT:
  8506                              <1> 	; 	[u.r0] will be > 0 if succesful
  8507                              <1> 
  8508                              <1> 	; window
  8509                              <1> 	;mov	edi, [v_str] ; LFB start address
  8510                              <1> 	;mov	esi, edi 
  8511                              <1> 
  8512 0000EFFD 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8513 0000F004 7707                <1> 	ja	short m_pix_op_or_w_1
  8514                              <1> 
  8515                              <1> 	; 256 colors (8bpp)
  8516 0000F006 BD[79EF0000]        <1> 	mov	ebp, m_pix_op_or_8
  8517 0000F00B EB1E                <1> 	jmp	short m_pix_op_or_w_4
  8518                              <1> 			
  8519                              <1> m_pix_op_or_w_1:
  8520 0000F00D 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8521 0000F014 7710                <1> 	ja	short m_pix_op_or_w_3 ; 32bpp
  8522 0000F016 7207                <1> 	jb	short m_pix_op_or_w_2 ; 16bpp
  8523                              <1> 
  8524                              <1> 	; 24 bit true colors
  8525 0000F018 BD[9BEF0000]        <1> 	mov	ebp, m_pix_op_or_24
  8526 0000F01D EB0C                <1> 	jmp	short m_pix_op_or_w_4
  8527                              <1> 
  8528                              <1> 	; 65536 colors (16bpp)
  8529                              <1> m_pix_op_or_w_2:
  8530 0000F01F BD[C6EF0000]        <1> 	mov	ebp, m_pix_op_or_16
  8531 0000F024 EB05                <1> 	jmp	short m_pix_op_or_w_4
  8532                              <1> 
  8533                              <1> 	; 32 bit true colors
  8534                              <1> m_pix_op_or_w_3:
  8535 0000F026 BD[E3EF0000]        <1> 	mov	ebp, m_pix_op_or_32
  8536                              <1> m_pix_op_or_w_4:
  8537 0000F02B E9D7FBFFFF          <1> 	jmp	m_pix_op_orc_w_x
  8538                              <1> 
  8539                              <1> m_pix_op_xor:
  8540                              <1> 	; 06/02/2021
  8541                              <1> 	; XOR COLOR (MASKED, full screen)
  8542                              <1> 	;
  8543                              <1> 	; jump from pix_op_xor
  8544                              <1> 	;
  8545                              <1> 	; INPUT:
  8546                              <1> 	;   eax = color (AL, AX, EAX)
  8547                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8548                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8549                              <1> 	;
  8550                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8551                              <1> 	;
  8552                              <1> 	; OUTPUT:
  8553                              <1> 	; 	[u.r0] will be > 0 if succesful
  8554                              <1> 	
  8555                              <1> 	; Full screen
  8556                              <1> m_pix_op_xor_0:
  8557 0000F030 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8558 0000F037 7717                <1> 	ja	short m_pix_op_xor_1
  8559                              <1> 	; 256 colors (8bpp)
  8560                              <1> 	;jmp	short m_pix_op_xor_8
  8561                              <1> m_pix_op_xor_8:
  8562                              <1> 	; 8 bit colors (256 colors)
  8563 0000F039 88C2                <1> 	mov	dl, al ; new color
  8564                              <1> m_pix_op_xor_8_0:
  8565 0000F03B AC                  <1> 	lodsb 
  8566 0000F03C 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  8567 0000F042 7408                <1> 	je	short m_pix_op_xor_8_1 ; exclude
  8568 0000F044 3017                <1> 	xor	[edi], dl
  8569 0000F046 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  8570                              <1> m_pix_op_xor_8_1:
  8571 0000F04C 47                  <1> 	inc	edi
  8572 0000F04D E2EC                <1> 	loop	m_pix_op_xor_8_0
  8573 0000F04F C3                  <1> 	retn
  8574                              <1> m_pix_op_xor_1:
  8575 0000F050 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8576 0000F057 774A                <1> 	ja	short m_pix_op_xor_3 ; 32bpp	
  8577 0000F059 722B                <1> 	jb	short m_pix_op_xor_2 ; 16bpp
  8578                              <1> 	; 24 bit true colors
  8579                              <1> 	;jmp	short m_pix_op_xor_24
  8580                              <1> m_pix_op_xor_24:
  8581                              <1> 	; 24 bit true colors
  8582 0000F05B 89C2                <1> 	mov	edx, eax ; new color
  8583                              <1> 	;and	edx, 0FFFFFFh
  8584                              <1> m_pix_op_xor_24_0:
  8585 0000F05D 66AD                <1> 	lodsw
  8586 0000F05F C1E010              <1> 	shl	eax, 16
  8587 0000F062 AC                  <1> 	lodsb
  8588 0000F063 C1C010              <1> 	rol	eax, 16	
  8589 0000F066 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8590 0000F06C 7412                <1> 	je	short m_pix_op_xor_24_1 ; exclude
  8591 0000F06E 31D0                <1> 	xor	eax, edx
  8592 0000F070 668907              <1> 	mov	[edi], ax
  8593 0000F073 C1E810              <1> 	shr	eax, 16
  8594 0000F076 884702              <1> 	mov	[edi+2], al
  8595 0000F079 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
  8596                              <1> m_pix_op_xor_24_1:
  8597 0000F080 83C703              <1> 	add	edi, 3 ; +3
  8598 0000F083 E2D8                <1> 	loop	m_pix_op_xor_24_0
  8599 0000F085 C3                  <1> 	retn
  8600                              <1> 	; 65536 colors (16bpp)
  8601                              <1> m_pix_op_xor_2:
  8602                              <1> 	;jmp	short m_pix_op_xor_16
  8603                              <1> m_pix_op_xor_16:
  8604                              <1> 	; 16 bit colors (65536 colors)
  8605 0000F086 89C2                <1> 	mov	edx, eax ; new color
  8606                              <1> 	;and	edx, 0FFFFh
  8607                              <1> m_pix_op_xor_16_0:
  8608 0000F088 66AD                <1> 	lodsw
  8609 0000F08A 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  8610 0000F091 740A                <1> 	je	short m_pix_op_xor_16_1 ; exclude
  8611 0000F093 663117              <1> 	xor	[edi], dx
  8612 0000F096 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
  8613                              <1> m_pix_op_xor_16_1:
  8614 0000F09D 83C702              <1> 	add	edi, 2 ; +2
  8615 0000F0A0 E2E6                <1> 	loop	m_pix_op_xor_16_0
  8616 0000F0A2 C3                  <1> 	retn
  8617                              <1> m_pix_op_xor_3:
  8618                              <1> 	; 32 bit true colors
  8619                              <1> 	;jmp	short m_pix_op_xor_32
  8620                              <1> m_pix_op_xor_32:
  8621                              <1> 	; 32 bit true colors
  8622 0000F0A3 89C2                <1> 	mov	edx, eax ; new color
  8623                              <1> m_pix_op_xor_32_0:
  8624 0000F0A5 AD                  <1> 	lodsd 
  8625 0000F0A6 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8626 0000F0AC 7409                <1> 	je	short m_pix_op_xor_32_1 ; exclude
  8627 0000F0AE 3117                <1> 	xor	[edi], edx ; 25/02/2021	
  8628 0000F0B0 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
  8629                              <1> m_pix_op_xor_32_1:
  8630 0000F0B7 83C704              <1> 	add	edi, 4 ; +4
  8631 0000F0BA E2E9                <1> 	loop	m_pix_op_xor_32_0
  8632 0000F0BC C3                  <1> 	retn
  8633                              <1> 
  8634                              <1> m_pix_op_xor_w:
  8635                              <1> 	; 06/02/2021
  8636                              <1> 	; XOR COLOR (MASKED, window)
  8637                              <1> 	;
  8638                              <1> 	; jump from pix_op_xor_w
  8639                              <1> 	;
  8640                              <1> 	; INPUT:
  8641                              <1> 	;   ecx = bytes per row (to be applied)
  8642                              <1> 	;   edx = screen width in bytes
  8643                              <1> 	;   ebx = row count
  8644                              <1> 	;   eax = color
  8645                              <1> 	;
  8646                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8647                              <1> 	;
  8648                              <1> 	; OUTPUT:
  8649                              <1> 	; 	[u.r0] will be > 0 if succesful
  8650                              <1> 
  8651                              <1> 	; window
  8652                              <1> 	;mov	edi, [v_str] ; LFB start address
  8653                              <1> 	;mov	esi, edi 
  8654                              <1> 
  8655 0000F0BD 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8656 0000F0C4 7707                <1> 	ja	short m_pix_op_xor_w_1
  8657                              <1> 
  8658                              <1> 	; 256 colors (8bpp)
  8659 0000F0C6 BD[39F00000]        <1> 	mov	ebp, m_pix_op_xor_8
  8660 0000F0CB EB1E                <1> 	jmp	short m_pix_op_xor_w_4
  8661                              <1> 			
  8662                              <1> m_pix_op_xor_w_1:
  8663 0000F0CD 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8664 0000F0D4 7710                <1> 	ja	short m_pix_op_xor_w_3 ; 32bpp
  8665 0000F0D6 7207                <1> 	jb	short m_pix_op_xor_w_2 ; 16bpp
  8666                              <1> 
  8667                              <1> 	; 24 bit true colors
  8668 0000F0D8 BD[5BF00000]        <1> 	mov	ebp, m_pix_op_xor_24
  8669 0000F0DD EB0C                <1> 	jmp	short m_pix_op_xor_w_4
  8670                              <1> 
  8671                              <1> 	; 65536 colors (16bpp)
  8672                              <1> m_pix_op_xor_w_2:
  8673 0000F0DF BD[86F00000]        <1> 	mov	ebp, m_pix_op_xor_16
  8674 0000F0E4 EB05                <1> 	jmp	short m_pix_op_xor_w_4
  8675                              <1> 
  8676                              <1> 	; 32 bit true colors
  8677                              <1> m_pix_op_xor_w_3:
  8678 0000F0E6 BD[A3F00000]        <1> 	mov	ebp, m_pix_op_xor_32
  8679                              <1> m_pix_op_xor_w_4:
  8680 0000F0EB E917FBFFFF          <1> 	jmp	m_pix_op_xor_w_x
  8681                              <1> 
  8682                              <1> m_pix_op_not:
  8683                              <1> 	; 06/02/2021
  8684                              <1> 	; NOT COLOR (MASKED, full screen)
  8685                              <1> 	;
  8686                              <1> 	; jump from pix_op_not
  8687                              <1> 	;
  8688                              <1> 	; INPUT:
  8689                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8690                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8691                              <1> 	;
  8692                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8693                              <1> 	;
  8694                              <1> 	; OUTPUT:
  8695                              <1> 	; 	[u.r0] will be > 0 if succesful
  8696                              <1> 	
  8697                              <1> 	; Full screen
  8698                              <1> m_pix_op_not_0:
  8699 0000F0F0 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8700 0000F0F7 7715                <1> 	ja	short m_pix_op_not_1
  8701                              <1> 	; 256 colors (8bpp)
  8702                              <1> 	;jmp	short m_pix_op_not_8
  8703                              <1> m_pix_op_not_8:
  8704                              <1> 	; 8 bit colors (256 colors)
  8705 0000F0F9 AC                  <1> 	lodsb 
  8706 0000F0FA 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  8707 0000F100 7408                <1> 	je	short m_pix_op_not_8_1 ; exclude
  8708 0000F102 F617                <1> 	not	byte [edi]
  8709 0000F104 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  8710                              <1> m_pix_op_not_8_1:
  8711 0000F10A 47                  <1> 	inc	edi
  8712 0000F10B E2EC                <1> 	loop	m_pix_op_not_8
  8713 0000F10D C3                  <1> 	retn
  8714                              <1> m_pix_op_not_1:
  8715 0000F10E 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8716 0000F115 7746                <1> 	ja	short m_pix_op_not_3 ; 32bpp	
  8717 0000F117 7229                <1> 	jb	short m_pix_op_not_2 ; 16bpp
  8718                              <1> 	; 24 bit true colors
  8719                              <1> 	;jmp	short m_pix_op_not_24
  8720                              <1> m_pix_op_not_24:
  8721                              <1> 	; 24 bit true colors
  8722 0000F119 66AD                <1> 	lodsw
  8723 0000F11B C1E010              <1> 	shl	eax, 16
  8724 0000F11E AC                  <1> 	lodsb
  8725 0000F11F C1C010              <1> 	rol	eax, 16	
  8726 0000F122 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8727 0000F128 7412                <1> 	je	short m_pix_op_not_24_1 ; exclude
  8728 0000F12A F7D0                <1> 	not	eax
  8729 0000F12C 668907              <1> 	mov	[edi], ax
  8730 0000F12F C1E810              <1> 	shr	eax, 16
  8731 0000F132 884702              <1> 	mov	[edi+2], al
  8732 0000F135 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
  8733                              <1> m_pix_op_not_24_1:
  8734 0000F13C 83C703              <1> 	add	edi, 3 ; +3
  8735 0000F13F E2D8                <1> 	loop	m_pix_op_not_24
  8736 0000F141 C3                  <1> 	retn
  8737                              <1> 	; 65536 colors (16bpp)
  8738                              <1> m_pix_op_not_2:
  8739                              <1> 	;jmp	short m_pix_op_not_16
  8740                              <1> m_pix_op_not_16:
  8741                              <1> 	; 16 bit colors (65536 colors)
  8742 0000F142 66AD                <1> 	lodsw
  8743 0000F144 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  8744 0000F14B 740A                <1> 	je	short m_pix_op_not_16_1 ; exclude
  8745 0000F14D 66F717              <1> 	not	word [edi]
  8746 0000F150 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
  8747                              <1> m_pix_op_not_16_1:
  8748 0000F157 83C702              <1> 	add	edi, 2 ; +2
  8749 0000F15A E2E6                <1> 	loop	m_pix_op_not_16
  8750 0000F15C C3                  <1> 	retn
  8751                              <1> m_pix_op_not_3:
  8752                              <1> 	; 32 bit true colors
  8753                              <1> 	;jmp	short m_pix_op_not_32
  8754                              <1> m_pix_op_not_32:
  8755                              <1> 	; 32 bit true colors
  8756 0000F15D AD                  <1> 	lodsd 
  8757 0000F15E 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8758 0000F164 7409                <1> 	je	short m_pix_op_not_32_1 ; exclude
  8759 0000F166 F717                <1> 	not	dword [edi]	
  8760 0000F168 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
  8761                              <1> m_pix_op_not_32_1:
  8762 0000F16F 83C704              <1> 	add	edi, 4 ; +4
  8763 0000F172 E2E9                <1> 	loop	m_pix_op_not_32
  8764 0000F174 C3                  <1> 	retn
  8765                              <1> 
  8766                              <1> m_pix_op_not_w:
  8767                              <1> 	; 06/02/2021
  8768                              <1> 	; NOT COLOR (MASKED, window)
  8769                              <1> 	;
  8770                              <1> 	; jump from pix_op_not_w
  8771                              <1> 	;
  8772                              <1> 	; INPUT:
  8773                              <1> 	;   ecx = bytes per row (to be applied)
  8774                              <1> 	;   edx = screen width in bytes
  8775                              <1> 	;   ebx = row count
  8776                              <1> 	;
  8777                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8778                              <1> 	;
  8779                              <1> 	; OUTPUT:
  8780                              <1> 	; 	[u.r0] will be > 0 if succesful
  8781                              <1> 
  8782                              <1> 	; window
  8783                              <1> 	;mov	edi, [v_str] ; LFB start address
  8784                              <1> 	;mov	esi, edi 
  8785                              <1> 
  8786 0000F175 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8787 0000F17C 7707                <1> 	ja	short m_pix_op_not_w_1
  8788                              <1> 
  8789                              <1> 	; 256 colors (8bpp)
  8790 0000F17E BD[F9F00000]        <1> 	mov	ebp, m_pix_op_not_8
  8791 0000F183 EB1E                <1> 	jmp	short m_pix_op_not_w_4
  8792                              <1> 			
  8793                              <1> m_pix_op_not_w_1:
  8794 0000F185 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8795 0000F18C 7710                <1> 	ja	short m_pix_op_not_w_3 ; 32bpp
  8796 0000F18E 7207                <1> 	jb	short m_pix_op_not_w_2 ; 16bpp
  8797                              <1> 
  8798                              <1> 	; 24 bit true colors
  8799 0000F190 BD[19F10000]        <1> 	mov	ebp, m_pix_op_not_24
  8800 0000F195 EB0C                <1> 	jmp	short m_pix_op_not_w_4
  8801                              <1> 
  8802                              <1> 	; 65536 colors (16bpp)
  8803                              <1> m_pix_op_not_w_2:
  8804 0000F197 BD[42F10000]        <1> 	mov	ebp, m_pix_op_not_16
  8805 0000F19C EB05                <1> 	jmp	short m_pix_op_not_w_4
  8806                              <1> 
  8807                              <1> 	; 32 bit true colors
  8808                              <1> m_pix_op_not_w_3:
  8809 0000F19E BD[5DF10000]        <1> 	mov	ebp, m_pix_op_not_32
  8810                              <1> m_pix_op_not_w_4:
  8811 0000F1A3 E95FFAFFFF          <1> 	jmp	m_pix_op_not_w_x
  8812                              <1> 
  8813                              <1> m_pix_op_neg:
  8814                              <1> 	; 06/02/2021
  8815                              <1> 	; NEGATIVE COLOR (MASKED, full screen)
  8816                              <1> 	;
  8817                              <1> 	; jump from pix_op_neg
  8818                              <1> 	;
  8819                              <1> 	; INPUT:
  8820                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8821                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8822                              <1> 	;
  8823                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8824                              <1> 	;
  8825                              <1> 	; OUTPUT:
  8826                              <1> 	; 	[u.r0] will be > 0 if succesful
  8827                              <1> 	
  8828                              <1> 	; Full screen
  8829                              <1> m_pix_op_neg_0:
  8830 0000F1A8 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8831 0000F1AF 7715                <1> 	ja	short m_pix_op_neg_1
  8832                              <1> 	; 256 colors (8bpp)
  8833                              <1> 	;jmp	short m_pix_op_neg_8
  8834                              <1> m_pix_op_neg_8:
  8835                              <1> 	; 8 bit colors (256 colors)
  8836 0000F1B1 AC                  <1> 	lodsb 
  8837 0000F1B2 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  8838 0000F1B8 7408                <1> 	je	short m_pix_op_neg_8_1 ; exclude
  8839 0000F1BA F61F                <1> 	neg	byte [edi]
  8840 0000F1BC FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  8841                              <1> m_pix_op_neg_8_1:
  8842 0000F1C2 47                  <1> 	inc	edi
  8843 0000F1C3 E2EC                <1> 	loop	m_pix_op_neg_8
  8844 0000F1C5 C3                  <1> 	retn
  8845                              <1> m_pix_op_neg_1:
  8846 0000F1C6 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8847 0000F1CD 7746                <1> 	ja	short m_pix_op_neg_3 ; 32bpp	
  8848 0000F1CF 7229                <1> 	jb	short m_pix_op_neg_2 ; 16bpp
  8849                              <1> 	; 24 bit true colors
  8850                              <1> 	;jmp	short m_pix_op_neg_24
  8851                              <1> m_pix_op_neg_24:
  8852                              <1> 	; 24 bit true colors
  8853 0000F1D1 66AD                <1> 	lodsw
  8854 0000F1D3 C1E010              <1> 	shl	eax, 16
  8855 0000F1D6 AC                  <1> 	lodsb
  8856 0000F1D7 C1C010              <1> 	rol	eax, 16	
  8857 0000F1DA 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8858 0000F1E0 7412                <1> 	je	short m_pix_op_neg_24_1 ; exclude
  8859 0000F1E2 F7D8                <1> 	neg	eax
  8860 0000F1E4 668907              <1> 	mov	[edi], ax
  8861 0000F1E7 C1E810              <1> 	shr	eax, 16
  8862 0000F1EA 884702              <1> 	mov	[edi+2], al
  8863 0000F1ED 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
  8864                              <1> m_pix_op_neg_24_1:
  8865 0000F1F4 83C703              <1> 	add	edi, 3 ; +3
  8866 0000F1F7 E2D8                <1> 	loop	m_pix_op_neg_24
  8867 0000F1F9 C3                  <1> 	retn
  8868                              <1> 	; 65536 colors (16bpp)
  8869                              <1> m_pix_op_neg_2:
  8870                              <1> 	;jmp	short m_pix_op_neg_16
  8871                              <1> m_pix_op_neg_16:
  8872                              <1> 	; 16 bit colors (65536 colors)
  8873 0000F1FA 66AD                <1> 	lodsw
  8874 0000F1FC 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  8875 0000F203 740A                <1> 	je	short m_pix_op_neg_16_1 ; exclude
  8876 0000F205 66F71F              <1> 	neg	word [edi]
  8877 0000F208 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
  8878                              <1> m_pix_op_neg_16_1:
  8879 0000F20F 83C702              <1> 	add	edi, 2 ; +2
  8880 0000F212 E2E6                <1> 	loop	m_pix_op_neg_16
  8881 0000F214 C3                  <1> 	retn
  8882                              <1> m_pix_op_neg_3:
  8883                              <1> 	; 32 bit true colors
  8884                              <1> 	;jmp	short m_pix_op_neg_32
  8885                              <1> m_pix_op_neg_32:
  8886                              <1> 	; 32 bit true colors
  8887 0000F215 AD                  <1> 	lodsd 
  8888 0000F216 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8889 0000F21C 7409                <1> 	je	short m_pix_op_neg_32_1 ; exclude
  8890 0000F21E F71F                <1> 	neg	dword [edi]	
  8891 0000F220 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
  8892                              <1> m_pix_op_neg_32_1:
  8893 0000F227 83C704              <1> 	add	edi, 4 ; +4
  8894 0000F22A E2E9                <1> 	loop	m_pix_op_neg_32
  8895 0000F22C C3                  <1> 	retn
  8896                              <1> 
  8897                              <1> m_pix_op_neg_w:
  8898                              <1> 	; 06/02/2021
  8899                              <1> 	; NEGATIVE COLOR (MASKED, window)
  8900                              <1> 	;
  8901                              <1> 	; jump from pix_op_neg_w
  8902                              <1> 	;
  8903                              <1> 	; INPUT:
  8904                              <1> 	;   ecx = bytes per row (to be applied)
  8905                              <1> 	;   edx = screen width in bytes
  8906                              <1> 	;   ebx = row count
  8907                              <1> 	;
  8908                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8909                              <1> 	;
  8910                              <1> 	; OUTPUT:
  8911                              <1> 	; 	[u.r0] will be > 0 if succesful
  8912                              <1> 
  8913                              <1> 	; window
  8914                              <1> 	;mov	edi, [v_str] ; LFB start address
  8915                              <1> 	;mov	esi, edi 
  8916                              <1> 
  8917 0000F22D 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8918 0000F234 7707                <1> 	ja	short m_pix_op_neg_w_1
  8919                              <1> 
  8920                              <1> 	; 256 colors (8bpp)
  8921 0000F236 BD[B1F10000]        <1> 	mov	ebp, m_pix_op_neg_8
  8922 0000F23B EB1E                <1> 	jmp	short m_pix_op_neg_w_4
  8923                              <1> 			
  8924                              <1> m_pix_op_neg_w_1:
  8925 0000F23D 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8926 0000F244 7710                <1> 	ja	short m_pix_op_neg_w_3 ; 32bpp
  8927 0000F246 7207                <1> 	jb	short m_pix_op_neg_w_2 ; 16bpp
  8928                              <1> 
  8929                              <1> 	; 24 bit true colors
  8930 0000F248 BD[D1F10000]        <1> 	mov	ebp, m_pix_op_neg_24
  8931 0000F24D EB0C                <1> 	jmp	short m_pix_op_neg_w_4
  8932                              <1> 
  8933                              <1> 	; 65536 colors (16bpp)
  8934                              <1> m_pix_op_neg_w_2:
  8935 0000F24F BD[FAF10000]        <1> 	mov	ebp, m_pix_op_neg_16
  8936 0000F254 EB05                <1> 	jmp	short m_pix_op_neg_w_4
  8937                              <1> 
  8938                              <1> 	; 32 bit true colors
  8939                              <1> m_pix_op_neg_w_3:
  8940 0000F256 BD[15F20000]        <1> 	mov	ebp, m_pix_op_neg_32
  8941                              <1> m_pix_op_neg_w_4:
  8942 0000F25B E9A7F9FFFF          <1> 	jmp	m_pix_op_neg_w_x
  8943                              <1> 
  8944                              <1> m_pix_op_inc:
  8945                              <1> 	; 06/02/2021
  8946                              <1> 	; INCREASE COLOR (MASKED, full screen)
  8947                              <1> 	;
  8948                              <1> 	; jump from pix_op_inc
  8949                              <1> 	;
  8950                              <1> 	; INPUT:
  8951                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8952                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8953                              <1> 	;
  8954                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8955                              <1> 	;
  8956                              <1> 	; OUTPUT:
  8957                              <1> 	; 	[u.r0] will be > 0 if succesful
  8958                              <1> 	
  8959                              <1> 	; Full screen
  8960                              <1> m_pix_op_inc_0:
  8961 0000F260 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8962 0000F267 7719                <1> 	ja	short m_pix_op_inc_1
  8963                              <1> 	; 256 colors (8bpp)
  8964                              <1> 	;jmp	short m_pix_op_inc_8
  8965                              <1> m_pix_op_inc_8:
  8966                              <1> 	; 8 bit colors (256 colors)
  8967 0000F269 AC                  <1> 	lodsb 
  8968 0000F26A 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  8969 0000F270 740C                <1> 	je	short m_pix_op_inc_8_1 ; exclude
  8970 0000F272 FE07                <1> 	inc	byte [edi]
  8971 0000F274 7502                <1> 	jnz	short m_pix_op_inc_8_0
  8972 0000F276 FE0F                <1> 	dec	byte [edi]
  8973                              <1> m_pix_op_inc_8_0:
  8974 0000F278 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  8975                              <1> m_pix_op_inc_8_1:
  8976 0000F27E 47                  <1> 	inc	edi
  8977 0000F27F E2E8                <1> 	loop	m_pix_op_inc_8
  8978 0000F281 C3                  <1> 	retn
  8979                              <1> m_pix_op_inc_1:
  8980 0000F282 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8981 0000F289 7752                <1> 	ja	short m_pix_op_inc_3 ; 32bpp	
  8982 0000F28B 7230                <1> 	jb	short m_pix_op_inc_2 ; 16bpp
  8983                              <1> 	; 24 bit true colors
  8984                              <1> 	;jmp	short m_pix_op_inc_24
  8985                              <1> m_pix_op_inc_24:
  8986                              <1> 	; 24 bit true colors
  8987 0000F28D 66AD                <1> 	lodsw
  8988 0000F28F C1E010              <1> 	shl	eax, 16
  8989 0000F292 AC                  <1> 	lodsb
  8990 0000F293 C1C010              <1> 	rol	eax, 16	
  8991 0000F296 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  8992 0000F29C 7419                <1> 	je	short m_pix_op_inc_24_1 ; exclude
  8993 0000F29E 40                  <1> 	inc	eax
  8994 0000F29F 3DFFFFFF00          <1> 	cmp	eax, 0FFFFFFh
  8995 0000F2A4 7601                <1> 	jna	short m_pix_op_inc_24_0
  8996 0000F2A6 48                  <1> 	dec	eax 
  8997                              <1> m_pix_op_inc_24_0:
  8998 0000F2A7 668907              <1> 	mov	[edi], ax
  8999 0000F2AA C1E810              <1> 	shr	eax, 16
  9000 0000F2AD 884702              <1> 	mov	[edi+2], al
  9001 0000F2B0 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
  9002                              <1> m_pix_op_inc_24_1:
  9003 0000F2B7 83C703              <1> 	add	edi, 3 ; +3
  9004 0000F2BA E2D1                <1> 	loop	m_pix_op_inc_24
  9005 0000F2BC C3                  <1> 	retn
  9006                              <1> 	; 65536 colors (16bpp)
  9007                              <1> m_pix_op_inc_2:
  9008                              <1> 	;jmp	short m_pix_op_inc_16
  9009                              <1> m_pix_op_inc_16:
  9010                              <1> 	; 16 bit colors (65536 colors)
  9011 0000F2BD 66AD                <1> 	lodsw
  9012 0000F2BF 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  9013 0000F2C6 740F                <1> 	je	short m_pix_op_inc_16_1 ; exclude
  9014 0000F2C8 66FF07              <1> 	inc	word [edi]
  9015 0000F2CB 7503                <1> 	jnz	short m_pix_op_inc_16_0
  9016 0000F2CD 66FF0F              <1> 	dec	word [edi]
  9017                              <1> m_pix_op_inc_16_0:
  9018 0000F2D0 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
  9019                              <1> m_pix_op_inc_16_1:
  9020 0000F2D7 83C702              <1> 	add	edi, 2 ; +2
  9021 0000F2DA E2E1                <1> 	loop	m_pix_op_inc_16
  9022 0000F2DC C3                  <1> 	retn
  9023                              <1> m_pix_op_inc_3:
  9024                              <1> 	; 32 bit true colors
  9025                              <1> 	;jmp	short m_pix_op_inc_32
  9026                              <1> m_pix_op_inc_32:
  9027                              <1> 	; 32 bit true colors
  9028 0000F2DD AD                  <1> 	lodsd 
  9029 0000F2DE 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  9030 0000F2E4 740D                <1> 	je	short m_pix_op_inc_32_1 ; exclude
  9031 0000F2E6 FF07                <1> 	inc	dword [edi]
  9032 0000F2E8 7502                <1> 	jnz	short m_pix_op_inc_32_0
  9033 0000F2EA FF0F                <1> 	dec	dword [edi]
  9034                              <1> m_pix_op_inc_32_0:	
  9035 0000F2EC 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
  9036                              <1> m_pix_op_inc_32_1:
  9037 0000F2F3 83C704              <1> 	add	edi, 4 ; +4
  9038 0000F2F6 E2E5                <1> 	loop	m_pix_op_inc_32
  9039 0000F2F8 C3                  <1> 	retn
  9040                              <1> 
  9041                              <1> m_pix_op_inc_w:
  9042                              <1> 	; 06/02/2021
  9043                              <1> 	; INCREASE COLOR (MASKED, window)
  9044                              <1> 	;
  9045                              <1> 	; jump from pix_op_inc_w
  9046                              <1> 	;
  9047                              <1> 	; INPUT:
  9048                              <1> 	;   ecx = bytes per row (to be applied)
  9049                              <1> 	;   edx = screen width in bytes
  9050                              <1> 	;   ebx = row count
  9051                              <1> 	;
  9052                              <1> 	;   [maskcolor] = mask color (to be excluded)
  9053                              <1> 	;
  9054                              <1> 	; OUTPUT:
  9055                              <1> 	; 	[u.r0] will be > 0 if succesful
  9056                              <1> 
  9057                              <1> 	; window
  9058                              <1> 	;mov	edi, [v_str] ; LFB start address
  9059                              <1> 	;mov	esi, edi 
  9060                              <1> 
  9061 0000F2F9 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  9062 0000F300 7707                <1> 	ja	short m_pix_op_inc_w_1
  9063                              <1> 
  9064                              <1> 	; 256 colors (8bpp)
  9065 0000F302 BD[69F20000]        <1> 	mov	ebp, m_pix_op_inc_8
  9066 0000F307 EB1E                <1> 	jmp	short m_pix_op_inc_w_4
  9067                              <1> 			
  9068                              <1> m_pix_op_inc_w_1:
  9069 0000F309 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  9070 0000F310 7710                <1> 	ja	short m_pix_op_inc_w_3 ; 32bpp
  9071 0000F312 7207                <1> 	jb	short m_pix_op_inc_w_2 ; 16bpp
  9072                              <1> 
  9073                              <1> 	; 24 bit true colors
  9074 0000F314 BD[8DF20000]        <1> 	mov	ebp, m_pix_op_inc_24
  9075 0000F319 EB0C                <1> 	jmp	short m_pix_op_inc_w_4
  9076                              <1> 
  9077                              <1> 	; 65536 colors (16bpp)
  9078                              <1> m_pix_op_inc_w_2:
  9079 0000F31B BD[BDF20000]        <1> 	mov	ebp, m_pix_op_inc_16
  9080 0000F320 EB05                <1> 	jmp	short m_pix_op_inc_w_4
  9081                              <1> 
  9082                              <1> 	; 32 bit true colors
  9083                              <1> m_pix_op_inc_w_3:
  9084 0000F322 BD[DDF20000]        <1> 	mov	ebp, m_pix_op_inc_32
  9085                              <1> m_pix_op_inc_w_4:
  9086 0000F327 E9DBF8FFFF          <1> 	jmp	m_pix_op_inc_w_x
  9087                              <1> 
  9088                              <1> m_pix_op_dec:
  9089                              <1> 	; 06/02/2021
  9090                              <1> 	; DECREASE COLOR (MASKED, full screen)
  9091                              <1> 	;
  9092                              <1> 	; jump from pix_op_dec
  9093                              <1> 	;
  9094                              <1> 	; INPUT:
  9095                              <1> 	;   ecx = [v_siz] ; display page pixel count
  9096                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  9097                              <1> 	;
  9098                              <1> 	;   [maskcolor] = mask color (to be excluded)
  9099                              <1> 	;
  9100                              <1> 	; OUTPUT:
  9101                              <1> 	; 	[u.r0] will be > 0 if succesful
  9102                              <1> 	
  9103                              <1> 	; Full screen
  9104                              <1> m_pix_op_dec_0:
  9105 0000F32C 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  9106 0000F333 7719                <1> 	ja	short m_pix_op_dec_1
  9107                              <1> 	; 256 colors (8bpp)
  9108                              <1> 	;jmp	short m_pix_op_dec_8
  9109                              <1> m_pix_op_dec_8:
  9110                              <1> 	; 8 bit colors (256 colors)
  9111 0000F335 AC                  <1> 	lodsb 
  9112 0000F336 3A05[4E100300]      <1> 	cmp	al, [maskcolor]
  9113 0000F33C 740C                <1> 	je	short m_pix_op_dec_8_1 ; exclude
  9114 0000F33E FE0F                <1> 	dec	byte [edi]
  9115 0000F340 7902                <1> 	jns	short m_pix_op_dec_8_0
  9116 0000F342 FE07                <1> 	inc	byte [edi]
  9117                              <1> m_pix_op_dec_8_0:
  9118 0000F344 FF05[1C010300]      <1> 	inc	dword [u.r0] ; +1
  9119                              <1> m_pix_op_dec_8_1:
  9120 0000F34A 47                  <1> 	inc	edi
  9121 0000F34B E2E8                <1> 	loop	m_pix_op_dec_8
  9122 0000F34D C3                  <1> 	retn
  9123                              <1> m_pix_op_dec_1:
  9124 0000F34E 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  9125 0000F355 774D                <1> 	ja	short m_pix_op_dec_3 ; 32bpp	
  9126 0000F357 722B                <1> 	jb	short m_pix_op_dec_2 ; 16bpp
  9127                              <1> 	; 24 bit true colors
  9128                              <1> 	;jmp	short m_pix_op_dec_24
  9129                              <1> m_pix_op_dec_24:
  9130                              <1> 	; 24 bit true colors
  9131 0000F359 66AD                <1> 	lodsw
  9132 0000F35B C1E010              <1> 	shl	eax, 16
  9133 0000F35E AC                  <1> 	lodsb
  9134 0000F35F C1C010              <1> 	rol	eax, 16	
  9135 0000F362 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  9136 0000F368 7414                <1> 	je	short m_pix_op_dec_24_1 ; exclude
  9137 0000F36A 48                  <1> 	dec	eax
  9138 0000F36B 7901                <1> 	jns	short m_pix_op_dec_24_0
  9139 0000F36D 40                  <1> 	inc	eax 
  9140                              <1> m_pix_op_dec_24_0:
  9141 0000F36E 668907              <1> 	mov	[edi], ax
  9142 0000F371 C1E810              <1> 	shr	eax, 16
  9143 0000F374 884702              <1> 	mov	[edi+2], al
  9144 0000F377 8305[1C010300]03    <1> 	add	dword [u.r0], 3 ; +3
  9145                              <1> m_pix_op_dec_24_1:
  9146 0000F37E 83C703              <1> 	add	edi, 3 ; +3
  9147 0000F381 E2D6                <1> 	loop	m_pix_op_dec_24
  9148 0000F383 C3                  <1> 	retn
  9149                              <1> 	; 65536 colors (16bpp)
  9150                              <1> m_pix_op_dec_2:
  9151                              <1> 	;jmp	short m_pix_op_dec_16
  9152                              <1> m_pix_op_dec_16:
  9153                              <1> 	; 16 bit colors (65536 colors)
  9154 0000F384 66AD                <1> 	lodsw
  9155 0000F386 663B05[4E100300]    <1> 	cmp	ax, [maskcolor]
  9156 0000F38D 740F                <1> 	je	short m_pix_op_dec_16_1 ; exclude
  9157 0000F38F 66FF0F              <1> 	dec	word [edi]
  9158 0000F392 7903                <1> 	jns	short m_pix_op_dec_16_0
  9159 0000F394 66FF07              <1> 	inc	word [edi]
  9160                              <1> m_pix_op_dec_16_0:
  9161 0000F397 8305[1C010300]02    <1> 	add	dword [u.r0], 2 ; +2
  9162                              <1> m_pix_op_dec_16_1:
  9163 0000F39E 83C702              <1> 	add	edi, 2 ; +2
  9164 0000F3A1 E2E1                <1> 	loop	m_pix_op_dec_16
  9165 0000F3A3 C3                  <1> 	retn
  9166                              <1> m_pix_op_dec_3:
  9167                              <1> 	; 32 bit true colors
  9168                              <1> 	;jmp	short m_pix_op_dec_32
  9169                              <1> m_pix_op_dec_32:
  9170                              <1> 	; 32 bit true colors
  9171 0000F3A4 AD                  <1> 	lodsd 
  9172 0000F3A5 3B05[4E100300]      <1> 	cmp	eax, [maskcolor]
  9173 0000F3AB 740D                <1> 	je	short m_pix_op_dec_32_1 ; exclude
  9174 0000F3AD FF0F                <1> 	dec	dword [edi]
  9175 0000F3AF 7902                <1> 	jns	short m_pix_op_dec_32_0
  9176 0000F3B1 FF07                <1> 	inc	dword [edi]
  9177                              <1> m_pix_op_dec_32_0:	
  9178 0000F3B3 8305[1C010300]04    <1> 	add	dword [u.r0], 4 ; +4
  9179                              <1> m_pix_op_dec_32_1:
  9180 0000F3BA 83C704              <1> 	add	edi, 4 ; +4
  9181 0000F3BD E2E5                <1> 	loop	m_pix_op_dec_32
  9182 0000F3BF C3                  <1> 	retn
  9183                              <1> 
  9184                              <1> m_pix_op_dec_w:
  9185                              <1> 	; 06/02/2021
  9186                              <1> 	; DECREASE COLOR (MASKED, window)
  9187                              <1> 	;
  9188                              <1> 	; jump from pix_op_dec_w
  9189                              <1> 	;
  9190                              <1> 	; INPUT:
  9191                              <1> 	;   ecx = bytes per row (to be applied)
  9192                              <1> 	;   edx = screen width in bytes
  9193                              <1> 	;   ebx = row count
  9194                              <1> 	;
  9195                              <1> 	;   [maskcolor] = mask color (to be excluded)
  9196                              <1> 	;
  9197                              <1> 	; OUTPUT:
  9198                              <1> 	; 	[u.r0] will be > 0 if succesful
  9199                              <1> 
  9200                              <1> 	; window
  9201                              <1> 	;mov	edi, [v_str] ; LFB start address
  9202                              <1> 	;mov	esi, edi 
  9203                              <1> 
  9204 0000F3C0 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  9205 0000F3C7 7707                <1> 	ja	short m_pix_op_dec_w_1
  9206                              <1> 
  9207                              <1> 	; 256 colors (8bpp)
  9208 0000F3C9 BD[35F30000]        <1> 	mov	ebp, m_pix_op_dec_8
  9209 0000F3CE EB1E                <1> 	jmp	short m_pix_op_dec_w_4
  9210                              <1> 			
  9211                              <1> m_pix_op_dec_w_1:
  9212 0000F3D0 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  9213 0000F3D7 7710                <1> 	ja	short m_pix_op_dec_w_3 ; 32bpp
  9214 0000F3D9 7207                <1> 	jb	short m_pix_op_dec_w_2 ; 16bpp
  9215                              <1> 
  9216                              <1> 	; 24 bit true colors
  9217 0000F3DB BD[59F30000]        <1> 	mov	ebp, m_pix_op_dec_24
  9218 0000F3E0 EB0C                <1> 	jmp	short m_pix_op_dec_w_4
  9219                              <1> 
  9220                              <1> 	; 65536 colors (16bpp)
  9221                              <1> m_pix_op_dec_w_2:
  9222 0000F3E2 BD[84F30000]        <1> 	mov	ebp, m_pix_op_dec_16
  9223 0000F3E7 EB05                <1> 	jmp	short m_pix_op_dec_w_4
  9224                              <1> 
  9225                              <1> 	; 32 bit true colors
  9226                              <1> m_pix_op_dec_w_3:
  9227 0000F3E9 BD[A4F30000]        <1> 	mov	ebp, m_pix_op_dec_32
  9228                              <1> m_pix_op_dec_w_4:
  9229 0000F3EE E914F8FFFF          <1> 	jmp	m_pix_op_dec_w_x
  9230                              <1> 
  9231                              <1> sysvideo_39:
  9232                              <1> 	; 15/02/2021
  9233                              <1> 	; 07/02/2021, 08/02/2021
  9234                              <1> 	; 03/01/2021, 04/01/2021
  9235                              <1> 	; 23/11/2020
  9236                              <1> 	; BH = 3
  9237                              <1> 	; PIXEL READ/WRITE
  9238                              <1> 	
  9239                              <1> 	; 07/02/2021
  9240                              <1> 	; 04/01/2021 (TRDOS 386 v2.0.3)
  9241 0000F3F3 80FB03              <1> 	cmp	bl, 3
  9242 0000F3F6 761A                <1> 	jna	short sysvideo_39_1
  9243                              <1> 	; 07/02/2021
  9244 0000F3F8 80FB06              <1> 	cmp	bl, 6
  9245 0000F3FB 7705                <1> 	ja	short sysvideo_39_0
  9246 0000F3FD E91A010000          <1> 	jmp	sysvideo_39_31
  9247                              <1> sysvideo_39_0:
  9248                              <1> 	; error
  9249 0000F402 B3FF                <1> 	mov	bl, 0FFh
  9250 0000F404 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
  9251 0000F40A 895D10              <1> 	mov	[ebp+16], ebx ; EBX
  9252 0000F40D E90DD9FFFF          <1> 	jmp	sysret
  9253                              <1> sysvideo_39_1:
  9254 0000F412 803D[CE660000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh
  9255 0000F419 7312                <1> 	jnb	short sysvideo_39_2 ; SVGA (VESA VBE) video mode
  9256                              <1> 
  9257                              <1> 	; Std VGA or CGA mode
  9258 0000F41B 81C200000A00        <1> 	add	edx, 0A0000h
  9259 0000F421 72DF                <1> 	jc	short sysvideo_39_0
  9260 0000F423 81FAFFFF0A00        <1> 	cmp	edx, 0AFFFFh
  9261 0000F429 77D7                <1> 	ja	short sysvideo_39_0
  9262 0000F42B EB1E                <1> 	jmp	short sysvideo_39_3 ; 8bpp
  9263                              <1> 
  9264                              <1> sysvideo_39_2:
  9265                              <1> 	; use current vbe (svga) video mode
  9266                              <1> 
  9267                              <1> 	; get LFB address
  9268 0000F42D A1[E00F0300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
  9269 0000F432 09C0                <1> 	or	eax, eax
  9270 0000F434 74CC                <1> 	jz	short sysvideo_39_0
  9271 0000F436 3B15[E40F0300]      <1> 	cmp	edx, [LFB_SIZE] 
  9272 0000F43C 73C4                <1> 	jnb	short sysvideo_39_0
  9273                              <1> 
  9274 0000F43E 01C2                <1> 	add	edx, eax
  9275                              <1> 	;jc	short sysvideo_39_0
  9276                              <1> 
  9277                              <1> 	; Pixel read/write in VESA VBE (2/3) video mode
  9278                              <1> 	; Video memory at Linear Frame Buffer base address
  9279                              <1> 
  9280 0000F440 8A3D[EC0F0300]      <1> 	mov	bh, [LFB_Info+LFBINFO.bpp]
  9281                              <1> 
  9282 0000F446 80FF08              <1> 	cmp	bh, 8 ; 8bpp
  9283 0000F449 775D                <1> 	ja	short sysvideo_39_17
  9284                              <1> 
  9285                              <1> 	; 8 bits per pixel
  9286                              <1> sysvideo_39_3:
  9287 0000F44B 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
  9288 0000F44E 7406                <1> 	je	short sysvideo_39_5
  9289 0000F450 7712                <1> 	ja	short sysvideo_39_8
  9290                              <1> sysvideo_39_4:
  9291                              <1> 	; read pixel (8bpp)
  9292 0000F452 8A02                <1> 	mov	al, [edx]
  9293                              <1> 	;mov	[u.r0], al
  9294                              <1> 	;jmp	sysret
  9295 0000F454 EB04                <1> 	jmp	short sysvideo_39_7
  9296                              <1> sysvideo_39_5:
  9297                              <1> 	; write pixel (8bpp)
  9298 0000F456 88C8                <1> 	mov	al, cl
  9299                              <1> sysvideo_39_6:
  9300 0000F458 8802                <1> 	mov	[edx], al
  9301                              <1> sysvideo_39_7:
  9302 0000F45A A2[1C010300]        <1> 	mov	[u.r0], al
  9303 0000F45F E9BBD8FFFF          <1> 	jmp	sysret
  9304                              <1> sysvideo_39_8:
  9305 0000F464 80FB03              <1> 	cmp	bl, 3 ; mix
  9306 0000F467 7208                <1> 	jb	short sysvideo_39_9
  9307                              <1> 	; mix  pixel colors (8bpp)
  9308 0000F469 8A02                <1> 	mov	al, [edx]
  9309 0000F46B 00C8                <1> 	add	al, cl
  9310 0000F46D D0D8                <1> 	rcr	al, 1
  9311 0000F46F EBE7                <1> 	jmp	short sysvideo_39_6
  9312                              <1> sysvideo_39_9:
  9313                              <1> 	 ; swap pixel colors (8bpp)
  9314 0000F471 88C8                <1> 	mov	al, cl
  9315 0000F473 8602                <1> 	xchg	[edx], al
  9316 0000F475 EBE3                <1> 	jmp	short sysvideo_39_7
  9317                              <1> 
  9318                              <1> 	; 16 bits per pixel
  9319                              <1> sysvideo_39_10:
  9320 0000F477 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
  9321 0000F47A 7406                <1> 	je	short sysvideo_39_12
  9322 0000F47C 7714                <1> 	ja	short sysvideo_39_15
  9323                              <1> sysvideo_39_11:
  9324                              <1> 	; read pixel (16bpp)
  9325 0000F47E 8B02                <1> 	mov	eax, [edx]
  9326                              <1> 	;mov	[u.r0], ax
  9327                              <1> 	;jmp	sysret
  9328 0000F480 EB05                <1> 	jmp	short sysvideo_39_14
  9329                              <1> sysvideo_39_12:
  9330                              <1> 	; write pixel (16bpp)
  9331 0000F482 89C8                <1> 	mov	eax, ecx
  9332                              <1> sysvideo_39_13:
  9333 0000F484 668902              <1> 	mov	[edx], ax
  9334                              <1> sysvideo_39_14:
  9335 0000F487 66A3[1C010300]      <1> 	mov	[u.r0], ax
  9336 0000F48D E98DD8FFFF          <1> 	jmp	sysret
  9337                              <1> sysvideo_39_15:
  9338 0000F492 80FB03              <1> 	cmp	bl, 3 ; mix
  9339 0000F495 720A                <1> 	jb	short sysvideo_39_16
  9340                              <1> 	; mix  pixel colors (16bpp)
  9341 0000F497 8B02                <1> 	mov	eax, [edx]
  9342 0000F499 6601C8              <1> 	add	ax, cx
  9343 0000F49C 66D1D8              <1> 	rcr	ax, 1
  9344 0000F49F EBE3                <1> 	jmp	short sysvideo_39_13
  9345                              <1> sysvideo_39_16:
  9346                              <1> 	 ; swap pixel colors (16bpp)
  9347 0000F4A1 89C8                <1> 	mov	eax, ecx
  9348 0000F4A3 668702              <1> 	xchg	[edx], ax
  9349 0000F4A6 EBDF                <1> 	jmp	short sysvideo_39_14
  9350                              <1> sysvideo_39_17:
  9351 0000F4A8 80FF18              <1> 	cmp	bh, 24
  9352 0000F4AB 7743                <1> 	ja	short sysvideo_39_24
  9353 0000F4AD 72C8                <1> 	jb	short sysvideo_39_10  
  9354                              <1> 	
  9355                              <1> 	; 24 bits per pixel
  9356 0000F4AF 81E1FFFFFF00        <1> 	and	ecx, 0FFFFFFh
  9357 0000F4B5 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
  9358 0000F4B8 7406                <1> 	je	short sysvideo_39_19
  9359 0000F4BA 7712                <1> 	ja	short sysvideo_39_22
  9360                              <1> sysvideo_39_18:
  9361                              <1> 	; read pixel (24bpp)
  9362 0000F4BC 8B02                <1> 	mov	eax, [edx]
  9363                              <1> 	;and	eax, 0FFFFFFh
  9364                              <1> 	;mov	[u.r0], eax
  9365                              <1> 	;jmp	sysret
  9366 0000F4BE EB04                <1> 	jmp	short sysvideo_39_21
  9367                              <1> sysvideo_39_19:
  9368                              <1> 	; write pixel (24bpp)
  9369 0000F4C0 89C8                <1> 	mov	eax, ecx
  9370                              <1> sysvideo_39_20:
  9371                              <1> 	;and	eax, 0FFFFFFh
  9372 0000F4C2 8902                <1> 	mov	[edx], eax
  9373                              <1> sysvideo_39_21:
  9374 0000F4C4 A3[1C010300]        <1> 	mov	[u.r0], eax
  9375 0000F4C9 E951D8FFFF          <1> 	jmp	sysret
  9376                              <1> sysvideo_39_22:
  9377 0000F4CE 80FB03              <1> 	cmp	bl, 3 ; mix
  9378 0000F4D1 720D                <1> 	jb	short sysvideo_39_23
  9379                              <1> 	; mix  pixel colors (24bpp)
  9380 0000F4D3 8B02                <1> 	mov	eax, [edx]
  9381 0000F4D5 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  9382                              <1> 	;and	ecx, 0FFFFFFh
  9383 0000F4DA 01C8                <1> 	add	eax, ecx
  9384 0000F4DC D1D8                <1> 	rcr	eax, 1
  9385 0000F4DE EBE2                <1> 	jmp	short sysvideo_39_20
  9386                              <1> sysvideo_39_23:
  9387                              <1> 	 ; swap pixel colors (24bpp)
  9388 0000F4E0 89C8                <1> 	mov	eax, ecx
  9389                              <1> 	;and	eax, 0FFFFFFh
  9390 0000F4E2 668702              <1> 	xchg	[edx], ax
  9391 0000F4E5 C1C810              <1> 	ror	eax, 16
  9392 0000F4E8 884202              <1> 	mov	[edx+2], al	
  9393 0000F4EB C1C010              <1> 	rol	eax, 16
  9394 0000F4EE EBD4                <1> 	jmp	short sysvideo_39_21
  9395                              <1> 
  9396                              <1> 	; 32 bits per pixel
  9397                              <1> sysvideo_39_24:
  9398 0000F4F0 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
  9399 0000F4F3 7406                <1> 	je	short sysvideo_39_26
  9400 0000F4F5 7712                <1> 	ja	short sysvideo_39_29
  9401                              <1> sysvideo_39_25:
  9402                              <1> 	; read pixel (32bpp)
  9403 0000F4F7 8B02                <1> 	mov	eax, [edx]
  9404                              <1> 	;mov	[u.r0], eax
  9405                              <1> 	;jmp	sysret
  9406 0000F4F9 EB04                <1> 	jmp	short sysvideo_39_28
  9407                              <1> sysvideo_39_26:
  9408                              <1> 	; write pixel (32bpp)
  9409 0000F4FB 89C8                <1> 	mov	eax, ecx
  9410                              <1> sysvideo_39_27:
  9411 0000F4FD 8902                <1> 	mov	[edx], eax
  9412                              <1> sysvideo_39_28:
  9413 0000F4FF A3[1C010300]        <1> 	mov	[u.r0], eax
  9414 0000F504 E916D8FFFF          <1> 	jmp	sysret
  9415                              <1> sysvideo_39_29:
  9416 0000F509 80FB03              <1> 	cmp	bl, 3 ; mix
  9417 0000F50C 7208                <1> 	jb	short sysvideo_39_30
  9418                              <1> 	; mix  pixel colors (32bpp)
  9419 0000F50E 8B02                <1> 	mov	eax, [edx]
  9420 0000F510 01C8                <1> 	add	eax, ecx
  9421 0000F512 D1D8                <1> 	rcr	eax, 1
  9422 0000F514 EBE7                <1> 	jmp	short sysvideo_39_27
  9423                              <1> sysvideo_39_30:
  9424                              <1> 	 ; swap pixel colors (32bpp)
  9425 0000F516 89C8                <1> 	mov	eax, ecx
  9426 0000F518 8702                <1> 	xchg	[edx], eax
  9427 0000F51A EBE3                <1> 	jmp	short sysvideo_39_28
  9428                              <1> 
  9429                              <1> sysvideo_39_31:
  9430                              <1> 	; 06/03/2021
  9431                              <1> 	; 08/02/2021
  9432                              <1> 	; 07/02/2021
  9433                              <1> 	; BL = 4 -> read pixels from user defined positions
  9434                              <1> 	; BL = 5 -> write single color pixels to user defined pos.
  9435                              <1> 	; BL = 6 -> write multi color pixels to user defined pos.
  9436                              <1> 	; ECX = color (CL, CX, ECX)
  9437                              <1> 	; EDX = number of pixels
  9438                              <1> 	; ESI = user buffer contains dword pixel positions
  9439                              <1> 	;	 (and dword colors for BL input = 6)
  9440                              <1> 	; EDI = user's pixel color buff (destination) for BL = 4
  9441                              <1> 
  9442 0000F51C 890D[4E100300]      <1> 	mov	[maskcolor], ecx
  9443 0000F522 89D5                <1> 	mov	ebp, edx ; number of pixels    
  9444 0000F524 803D[CE660000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; SVGA flag
  9445 0000F52B 7317                <1> 	jnb	short sysvideo_39_33 ; SVGA (VESA VBE mode)
  9446                              <1> 	; Standard VGA mode
  9447 0000F52D B900000100          <1> 	mov	ecx, 65536 ; Video page size (maximum)
  9448 0000F532 39CA                <1> 	cmp	edx, ecx
  9449 0000F534 7709                <1> 	ja	short sysvideo_39_32 ; abnormal value !
  9450 0000F536 B800000A00          <1> 	mov	eax, 0A0000h ; Video page start address
  9451 0000F53B B708                <1> 	mov	bh, 8  ; 8 bits per pixel (256 colors)
  9452 0000F53D EB35                <1> 	jmp	short sysvideo_39_34
  9453                              <1> sysvideo_39_32:
  9454                              <1> 	; nonsense! (edx has abnormal value)
  9455 0000F53F E9DBD7FFFF          <1> 	jmp	sysret	
  9456                              <1> sysvideo_39_33:
  9457                              <1> 	; 06/03/2021
  9458 0000F544 8A3D[EC0F0300]      <1> 	mov	bh, [LFB_Info+LFBINFO.bpp]
  9459 0000F54A 80FF08              <1> 	cmp	bh, 8
  9460 0000F54D 7412                <1> 	je	short sysvideo_39_81 ; 8bpp
  9461 0000F54F 89D0                <1> 	mov	eax, edx
  9462 0000F551 80FF10              <1> 	cmp	bh, 16
  9463 0000F554 7409                <1> 	je	short sysvideo_39_80 ; 16bpp
  9464 0000F556 D1E2                <1> 	shl	edx, 1
  9465 0000F558 80FF20              <1> 	cmp	bh, 32
  9466 0000F55B 7502                <1> 	jne	short sysvideo_39_80 ; 24bpp
  9467 0000F55D D1E0                <1> 	shl	eax, 1
  9468                              <1> sysvideo_39_80:	
  9469 0000F55F 01C2                <1> 	add	edx, eax
  9470                              <1> 	; edx = number of bytes
  9471                              <1> sysvideo_39_81:
  9472                              <1> 	; get LFB address
  9473 0000F561 A1[E00F0300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
  9474 0000F566 09C0                <1> 	or	eax, eax
  9475 0000F568 74D5                <1> 	jz	short sysvideo_39_32 ; LFB is not ready !
  9476 0000F56A 8B0D[E40F0300]      <1> 	mov	ecx, [LFB_SIZE]
  9477 0000F570 39CA                <1> 	cmp	edx, ecx 
  9478 0000F572 77CB                <1> 	ja	short sysvideo_39_32 ; abnormal value !
  9479                              <1> 
  9480                              <1> 	; 02/03/2021
  9481                              <1> 	; 08/02/2021
  9482                              <1> 	;mov	ebp, edx ; pixel count  
  9483                              <1> 	;shl	ebp, 2 ; byte count (pixel pos: 4 bytes)
  9484                              <1> 
  9485                              <1> 	; 06/03/2021
  9486                              <1> 	; bits per pixel (pixel color size)
  9487                              <1> 	;mov	bh, [LFB_Info+LFBINFO.bpp]	
  9488                              <1> sysvideo_39_34:
  9489 0000F574 C1E502              <1> 	shl	ebp, 2 ; 15/02/2021 (byte count)	
  9490 0000F577 A3[3E100300]        <1> 	mov	[v_mem], eax ; Save video page start address
  9491 0000F57C 88DE                <1> 	mov	dh, bl ; sub function
  9492                              <1> 	; 06/03/2021
  9493 0000F57E 883D[3D100300]      <1> 	mov	[v_bpp], bh ; bits per pixel (color size)
  9494                              <1> 	;mov	ebx, [LFB_SIZE]
  9495 0000F584 89CB                <1> 	mov	ebx, ecx ; [LFB_SIZE]
  9496                              <1> 
  9497 0000F586 B900080000          <1> 	mov	ecx, 2048
  9498 0000F58B 39CD                <1> 	cmp	ebp, ecx
  9499 0000F58D 7302                <1> 	jnb	short sysvideo_39_35 	
  9500 0000F58F 89E9                <1> 	mov	ecx, ebp ; fix to requested byte count	
  9501                              <1> sysvideo_39_35:
  9502 0000F591 80FE04              <1> 	cmp	dh, 4 ; 08/02/2021
  9503                              <1> 	;cmp	bl, 4 ; read pixels from user defined positions 
  9504 0000F594 7605                <1> 	jna	short sysvideo_39_36
  9505 0000F596 E9B2000000          <1> 	jmp	sysvideo_39_52
  9506                              <1> 	; 08/02/2021
  9507                              <1> 	;mov	[buffer8], edi  ; user's destination buff addr
  9508                              <1> sysvideo_39_36:
  9509                              <1> 	; 08/02/2021
  9510                              <1> 	; read pixel positions 
  9511                              <1> 	; as defined in user's source buffer 
  9512 0000F59B 893D[56100300]      <1> 	mov	[buffer8], edi  ; user's destination buff addr
  9513 0000F5A1 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
  9514                              <1> 					  ; 2028 byte data
  9515                              <1> 	; esi = user's source buffer for pixel positions
  9516                              <1> 	; ecx = byte count
  9517 0000F5A6 E8F8170000          <1> 	call	transfer_from_user_buffer
  9518 0000F5AB 7292                <1> 	jc	short sysvideo_39_32 ; error
  9519                              <1> 	; ecx  = transfer count (bytes)
  9520                              <1> 
  9521 0000F5AD 57                  <1> 	push	edi ; *
  9522 0000F5AE 56                  <1> 	push	esi ; **
  9523 0000F5AF 51                  <1> 	push	ecx ; ***
  9524                              <1> 
  9525 0000F5B0 89FE                <1> 	mov	esi, edi ; kernel buffer
  9526 0000F5B2 8B15[3E100300]      <1> 	mov	edx, [v_mem] ; video memory
  9527 0000F5B8 C1E902              <1> 	shr	ecx, 2 ; pixel count (within buffer capacity)
  9528                              <1> 
  9529 0000F5BB 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  9530 0000F5C2 7753                <1> 	ja	short sysvideo_39_49
  9531                              <1> sysvideo_39_37:
  9532                              <1> 	; 8bpp
  9533 0000F5C4 AD                  <1> 	lodsd
  9534 0000F5C5 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
  9535 0000F5C7 7309                <1> 	jnb	short sysvideo_39_39
  9536 0000F5C9 0FB60402            <1> 	movzx	eax, byte [edx+eax]
  9537                              <1> sysvideo_39_38:
  9538 0000F5CD AB                  <1> 	stosd
  9539 0000F5CE E2F4                <1> 	loop	sysvideo_39_37
  9540 0000F5D0 EB49                <1> 	jmp	short sysvideo_39_50
  9541                              <1> sysvideo_39_39:
  9542                              <1> 	; write black color for improper positions
  9543 0000F5D2 31C0                <1> 	xor	eax, eax
  9544 0000F5D4 EBF7                <1> 	jmp	short sysvideo_39_38
  9545                              <1> sysvideo_39_40:
  9546 0000F5D6 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  9547 0000F5DD 772A                <1> 	ja	short sysvideo_39_47 ; 32bpp
  9548 0000F5DF 7216                <1> 	jb	short sysvideo_39_44 ; 16bpp
  9549                              <1> sysvideo_39_41: 
  9550                              <1> 	; 24bpp
  9551 0000F5E1 AD                  <1> 	lodsd
  9552 0000F5E2 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
  9553 0000F5E4 730D                <1> 	jnb	short sysvideo_39_43
  9554 0000F5E6 8B0402              <1> 	mov	eax, [edx+eax]
  9555 0000F5E9 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  9556                              <1> sysvideo_39_42:
  9557 0000F5EE AB                  <1> 	stosd
  9558 0000F5EF E2F0                <1> 	loop	sysvideo_39_41
  9559 0000F5F1 EB28                <1> 	jmp	short sysvideo_39_50
  9560                              <1> sysvideo_39_43:
  9561                              <1> 	; write black color for improper positions
  9562 0000F5F3 31C0                <1> 	xor	eax, eax
  9563 0000F5F5 EBF7                <1> 	jmp	short sysvideo_39_42
  9564                              <1> sysvideo_39_44:
  9565                              <1> 	; 16bpp
  9566 0000F5F7 AD                  <1> 	lodsd
  9567 0000F5F8 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
  9568 0000F5FA 7309                <1> 	jnb	short sysvideo_39_46
  9569 0000F5FC 0FB70402            <1> 	movzx	eax, word [edx+eax]
  9570                              <1> sysvideo_39_45:
  9571 0000F600 AB                  <1> 	stosd
  9572 0000F601 E2F4                <1> 	loop	sysvideo_39_44
  9573 0000F603 EB16                <1> 	jmp	short sysvideo_39_50
  9574                              <1> sysvideo_39_46:
  9575                              <1> 	; write black color for improper positions
  9576 0000F605 31C0                <1> 	xor	eax, eax
  9577 0000F607 EBF7                <1> 	jmp	short sysvideo_39_45
  9578                              <1> sysvideo_39_47:
  9579                              <1> 	; 32bpp
  9580 0000F609 AD                  <1> 	lodsd
  9581 0000F60A 39D8                <1> 	cmp	eax, ebx ; < [LFB_SIZE]
  9582 0000F60C 7309                <1> 	jnb	short sysvideo_39_49
  9583 0000F60E 0FB70402            <1> 	movzx	eax, word [edx+eax]
  9584                              <1> sysvideo_39_48:
  9585 0000F612 AB                  <1> 	stosd
  9586 0000F613 E2F4                <1> 	loop	sysvideo_39_47
  9587 0000F615 EB04                <1> 	jmp	short sysvideo_39_50
  9588                              <1> sysvideo_39_49:
  9589                              <1> 	; write black color for improper positions
  9590 0000F617 31C0                <1> 	xor	eax, eax
  9591 0000F619 EBF7                <1> 	jmp	short sysvideo_39_48
  9592                              <1> sysvideo_39_50:
  9593 0000F61B 59                  <1> 	pop	ecx ; transfer count in bytes
  9594 0000F61C 5E                  <1> 	pop	esi ; ** ; kernel buffer
  9595                              <1>  	;mov	esi, VBE3SAVERESTOREBLOCK ; kernel buffer for
  9596                              <1> 					  ; 2048 byte data
  9597 0000F61D 8B3D[56100300]      <1> 	mov	edi, [buffer8]
  9598                              <1> 	; edi = user's destination buffer for pixel colors
  9599                              <1> 	; ecx = byte count
  9600 0000F623 E831170000          <1> 	call	transfer_to_user_buffer
  9601 0000F628 5E                  <1> 	pop	esi ; *
  9602 0000F629 7266                <1> 	jc	short sysvideo_39_56 ; error
  9603                              <1> 	; ecx  = transfer count (bytes)
  9604 0000F62B 89C8                <1> 	mov	eax, ecx
  9605 0000F62D C1E802              <1> 	shr	eax, 2
  9606 0000F630 0105[1C010300]      <1> 	add	[u.r0], eax ; transfer count (in pixels)
  9607                              <1> 		
  9608 0000F636 29CD                <1> 	sub	ebp, ecx
  9609 0000F638 7657                <1> 	jna	short sysvideo_39_56 ; completed/finished
  9610 0000F63A 01CE                <1> 	add	esi, ecx ; next position in source buffer
  9611                              <1> 	;add	[buffer8], ecx ; next pos in destination buff
  9612 0000F63C 01CF                <1> 	add	edi, ecx
  9613 0000F63E 66B90008            <1> 	mov	cx, 2048 ; new count, limit: kernel buff size
  9614 0000F642 39CD                <1> 	cmp	ebp, ecx ; remain >= limit ?
  9615 0000F644 7302                <1> 	jnb	short sysvideo_39_51 ; yes
  9616 0000F646 89E9                <1> 	mov	ecx, ebp ; fix byte count to remain bytes
  9617                              <1> sysvideo_39_51:
  9618 0000F648 E94EFFFFFF          <1> 	jmp	sysvideo_39_36 
  9619                              <1> 
  9620                              <1> sysvideo_39_52:
  9621 0000F64D 80FE05              <1> 	cmp	dh, 5 ; 08/02/2021
  9622                              <1> 	;cmp	bl, 5 ; write pixels to user defined positions 
  9623 0000F650 7605                <1> 	jna	short sysvideo_39_53
  9624 0000F652 E9A1000000          <1> 	jmp	sysvideo_39_66
  9625                              <1> sysvideo_39_53:
  9626                              <1> 	; single color pixel writing
  9627 0000F657 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
  9628                              <1> 					  ; 2028 byte data
  9629                              <1> 	; esi = user's source buffer for pixel positions
  9630                              <1> 	; ecx = byte count
  9631 0000F65C E842170000          <1> 	call	transfer_from_user_buffer
  9632 0000F661 722E                <1> 	jc	short sysvideo_39_56 ; error
  9633                              <1> 	; ecx = transfer count (bytes)
  9634                              <1> 
  9635                              <1> 	; write pixels by using (user) defined positions
  9636                              <1> 	; ecx = byte count (1,2,3,4 times pixel count)	
  9637                              <1> 	; edi = system buffer address
  9638                              <1> 
  9639 0000F663 56                  <1> 	push	esi ; *
  9640 0000F664 51                  <1> 	push	ecx ; **
  9641                              <1> 
  9642 0000F665 89FE                <1> 	mov	esi, edi
  9643 0000F667 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  9644                              <1> 
  9645                              <1> 	; 08/02/2021
  9646 0000F66D C1E902              <1> 	shr	ecx, 2 ; pixel count
  9647 0000F670 8B15[4E100300]      <1> 	mov	edx, [maskcolor]
  9648                              <1> 	;mov	ebx, [v_siz]
  9649                              <1> 
  9650 0000F676 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  9651 0000F67D 7717                <1> 	ja	short sysvideo_39_57
  9652                              <1> sysvideo_39_54:
  9653                              <1> 	; 8bpp
  9654 0000F67F AD                  <1> 	lodsd
  9655 0000F680 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9656 0000F682 7309                <1> 	jnb	short sysvideo_39_55
  9657 0000F684 881407              <1> 	mov	[edi+eax], dl
  9658                              <1> 	; 06/03/2021
  9659 0000F687 FF05[1C010300]      <1> 	inc	dword [u.r0]
  9660                              <1> sysvideo_39_55:
  9661 0000F68D E2F0                <1> 	loop	sysvideo_39_54
  9662 0000F68F EB50                <1> 	jmp	short sysvideo_39_64
  9663                              <1> sysvideo_39_56:
  9664 0000F691 E989D6FFFF          <1> 	jmp	sysret
  9665                              <1> sysvideo_39_57:
  9666 0000F696 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  9667 0000F69D 7732                <1> 	ja	short sysvideo_39_62 ; 32bpp
  9668 0000F69F 721D                <1> 	jb	short sysvideo_39_60 ; 16bpp
  9669                              <1> sysvideo_39_58: 
  9670                              <1> 	; 24bpp
  9671 0000F6A1 AD                  <1> 	lodsd
  9672 0000F6A2 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9673 0000F6A4 7314                <1> 	jnb	short sysvideo_39_59
  9674 0000F6A6 881407              <1> 	mov	[edi+eax], dl
  9675 0000F6A9 40                  <1> 	inc	eax
  9676 0000F6AA C1CA08              <1> 	ror	edx, 8
  9677 0000F6AD 66891407            <1> 	mov	[edi+eax], dx
  9678 0000F6B1 C1C208              <1> 	rol	edx, 8
  9679 0000F6B4 FF05[1C010300]      <1> 	inc	dword [u.r0]
  9680                              <1> sysvideo_39_59:
  9681 0000F6BA E2E5                <1> 	loop	sysvideo_39_58
  9682 0000F6BC EB23                <1> 	jmp	short sysvideo_39_64
  9683                              <1> sysvideo_39_60:
  9684                              <1> 	; 16bpp
  9685 0000F6BE AD                  <1> 	lodsd
  9686 0000F6BF 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9687 0000F6C1 730A                <1> 	jnb	short sysvideo_39_61
  9688 0000F6C3 66891407            <1> 	mov	[edi+eax], dx
  9689 0000F6C7 FF05[1C010300]      <1> 	inc	dword [u.r0]
  9690                              <1> sysvideo_39_61:	
  9691 0000F6CD E2EF                <1> 	loop	sysvideo_39_60
  9692 0000F6CF EB10                <1> 	jmp	short sysvideo_39_64	
  9693                              <1> sysvideo_39_62:
  9694                              <1> 	; 32bpp
  9695 0000F6D1 AD                  <1> 	lodsd
  9696 0000F6D2 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9697 0000F6D4 7309                <1> 	jnb	short sysvideo_39_63
  9698 0000F6D6 891407              <1> 	mov	[edi+eax], edx
  9699 0000F6D9 FF05[1C010300]      <1> 	inc	dword [u.r0]
  9700                              <1> sysvideo_39_63:	
  9701 0000F6DF E2F0                <1> 	loop	sysvideo_39_62
  9702                              <1> sysvideo_39_64:
  9703 0000F6E1 59                  <1> 	pop	ecx ; **
  9704 0000F6E2 5E                  <1> 	pop	esi ; *	
  9705 0000F6E3 29CD                <1> 	sub	ebp, ecx
  9706 0000F6E5 76AA                <1> 	jna	short sysvideo_39_56
  9707 0000F6E7 01CE                <1> 	add	esi, ecx
  9708 0000F6E9 66B90008            <1> 	mov	cx, 2048
  9709 0000F6ED 39CD                <1> 	cmp	ebp, ecx
  9710 0000F6EF 7302                <1> 	jnb	short sysvideo_39_65
  9711 0000F6F1 89E9                <1> 	mov	ecx, ebp
  9712                              <1> sysvideo_39_65:
  9713 0000F6F3 E95FFFFFFF          <1> 	jmp	sysvideo_39_53
  9714                              <1> 
  9715                              <1> sysvideo_39_66:
  9716                              <1> 	; 15/02/2021
  9717 0000F6F8 D1E5                <1> 	shl	ebp, 1 ; 8 bytes per pixel (position&color)
  9718                              <1> sysvideo_39_67: 	
  9719 0000F6FA 66B90008            <1> 	mov	cx, 2048
  9720 0000F6FE 39CD                <1> 	cmp	ebp, ecx
  9721 0000F700 7302                <1> 	jnb	short sysvideo_39_68
  9722 0000F702 89E9                <1> 	mov	ecx, ebp
  9723                              <1> sysvideo_39_68:
  9724                              <1> 	; multi colors pixel writing
  9725 0000F704 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
  9726                              <1> 					  ; 2048 byte data
  9727                              <1> 	; esi = user's source buffer for pixel positions
  9728                              <1> 	; ecx = byte count
  9729 0000F709 E895160000          <1> 	call	transfer_from_user_buffer
  9730 0000F70E 7281                <1> 	jc	short sysvideo_39_56 ; error
  9731                              <1> 	; ecx  = transfer count
  9732                              <1> 	
  9733                              <1> 	; write pixels & colors as defined in user buffer 
  9734                              <1> 	; ecx = byte count (2,4,6,8 times pixel count)	
  9735                              <1> 	; edi = system buffer address
  9736                              <1> 
  9737 0000F710 56                  <1> 	push	esi ; **
  9738 0000F711 51                  <1> 	push	ecx ; *
  9739                              <1> 
  9740 0000F712 89FE                <1> 	mov	esi, edi
  9741 0000F714 8B3D[3E100300]      <1> 	mov	edi, [v_mem]
  9742                              <1> 
  9743                              <1> 	; 08/02/2021
  9744 0000F71A C1E903              <1> 	shr	ecx, 3 ; pixel count
  9745                              <1> 
  9746                              <1> 	;mov	ebx, [v_siz]
  9747                              <1> 
  9748 0000F71D 803D[3D100300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  9749 0000F724 7715                <1> 	ja	short sysvideo_39_71
  9750                              <1> sysvideo_39_69:
  9751                              <1> 	; 8bpp
  9752 0000F726 AD                  <1> 	lodsd	; position
  9753 0000F727 89C2                <1> 	mov	edx, eax
  9754 0000F729 AD                  <1> 	lodsd	; color
  9755 0000F72A 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
  9756 0000F72C 7309                <1> 	jnb	short sysvideo_39_70
  9757 0000F72E 880417              <1> 	mov	[edi+edx], al
  9758                              <1> 	; 06/03/2021
  9759 0000F731 FF05[1C010300]      <1> 	inc	dword [u.r0]
  9760                              <1> sysvideo_39_70:
  9761 0000F737 E2ED                <1> 	loop	sysvideo_39_69
  9762 0000F739 EB51                <1> 	jmp	short sysvideo_39_78
  9763                              <1> sysvideo_39_71:
  9764 0000F73B 803D[3D100300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  9765 0000F742 7735                <1> 	ja	short sysvideo_39_76 ; 32bpp
  9766 0000F744 721D                <1> 	jb	short sysvideo_39_74 ; 16bpp
  9767                              <1> sysvideo_39_72:
  9768                              <1> 	; 24bpp 
  9769 0000F746 AD                  <1> 	lodsd	; position
  9770 0000F747 89C2                <1> 	mov	edx, eax
  9771 0000F749 AD                  <1> 	lodsd	; color
  9772 0000F74A 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
  9773 0000F74C 7311                <1> 	jnb	short sysvideo_39_73
  9774 0000F74E 880417              <1> 	mov	[edi+edx], al
  9775 0000F751 42                  <1> 	inc	edx
  9776 0000F752 C1E808              <1> 	shr	eax, 8
  9777 0000F755 66890417            <1> 	mov	[edi+edx], ax
  9778 0000F759 FF05[1C010300]      <1> 	inc	dword [u.r0]
  9779                              <1> sysvideo_39_73:	
  9780 0000F75F E2E5                <1> 	loop	sysvideo_39_72
  9781 0000F761 EB29                <1> 	jmp	short sysvideo_39_78
  9782                              <1> sysvideo_39_74:
  9783                              <1> 	; 16bpp
  9784 0000F763 AD                  <1> 	lodsd	; position
  9785 0000F764 89C2                <1> 	mov	edx, eax
  9786 0000F766 AD                  <1> 	lodsd	; color
  9787 0000F767 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
  9788 0000F769 730A                <1> 	jnb	short sysvideo_39_75
  9789 0000F76B 66890417            <1> 	mov	[edi+edx], ax
  9790 0000F76F FF05[1C010300]      <1> 	inc	dword [u.r0]
  9791                              <1> sysvideo_39_75:	
  9792 0000F775 E2EC                <1> 	loop	sysvideo_39_74
  9793 0000F777 EB13                <1> 	jmp	short sysvideo_39_78
  9794                              <1> sysvideo_39_76:
  9795                              <1> 	; 32bpp
  9796 0000F779 AD                  <1> 	lodsd	; position
  9797 0000F77A 89C2                <1> 	mov	edx, eax
  9798 0000F77C AD                  <1> 	lodsd	; color
  9799 0000F77D 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
  9800 0000F77F 7309                <1> 	jnb	short sysvideo_39_77
  9801 0000F781 890417              <1> 	mov	[edi+edx], eax
  9802 0000F784 FF05[1C010300]      <1> 	inc	dword [u.r0]
  9803                              <1> sysvideo_39_77:	
  9804 0000F78A E2ED                <1> 	loop	sysvideo_39_76
  9805                              <1> sysvideo_39_78:
  9806 0000F78C 59                  <1> 	pop	ecx ; *
  9807 0000F78D 5E                  <1> 	pop	esi ; **	
  9808                              <1> 
  9809 0000F78E 29CD                <1> 	sub	ebp, ecx
  9810 0000F790 762A                <1> 	jna	short sysvideo_39_79
  9811 0000F792 01CE                <1> 	add	esi, ecx
  9812 0000F794 E961FFFFFF          <1> 	jmp	sysvideo_39_67
  9813                              <1> ;sysvideo_39_79:
  9814                              <1> ;	jmp	sysret
  9815                              <1> 		
  9816                              <1> sysvideo_16:
  9817                              <1> 	; 11/08/2022
  9818                              <1> 	; 23/07/2022
  9819                              <1> 	; 06/03/2021
  9820                              <1> 	; 23/11/2020
  9821 0000F799 80FF04              <1> 	cmp	bh, 4
  9822                              <1> 	;jb	sysvideo_39 ; bh = 3, pixel r/w
  9823                              <1> 	;ja	short sysvideo_17
  9824                              <1> 	; 23/07/2022
  9825 0000F79C 7407                <1> 	je	short sysvideo_16_0
  9826 0000F79E 7721                <1> 	ja	short sysvideo_17
  9827 0000F7A0 E94EFCFFFF          <1> 	jmp	sysvideo_39
  9828                              <1> sysvideo_16_0:	
  9829                              <1> 	; BH = 4
  9830                              <1> 	; Direct User Access for CGA video memory.
  9831                              <1> 	; Setup user's page tables for direct access to 0B8000h.
  9832                              <1> 	;
  9833                              <1> 	; Permission checks are not implemented yet !
  9834                              <1> 	; (11/07/2016)
  9835                              <1> 
  9836 0000F7A5 B800800B00          <1> 	mov	eax, 0B8000h
  9837                              <1> 	;mov	ecx, 8 ; 8 pages (8*4K=32K)
  9838                              <1> 	; 11/08/2022
  9839 0000F7AA 31C9                <1> 	xor	ecx, ecx
  9840 0000F7AC B108                <1> 	mov	cl, 8
  9841 0000F7AE 89C3                <1> 	mov	ebx, eax ; 12/05/2017 ; virtual = physical
  9842 0000F7B0 E8C366FFFF          <1> 	call	direct_memory_access	
  9843                              <1> 	;jc	sysret
  9844 0000F7B5 7205                <1> 	jc	short sysvideo_39_79 ; 06/03/2021
  9845                              <1> 	; eax = 0B8000h if there is not an error
  9846 0000F7B7 A3[1C010300]        <1> 	mov	[u.r0], eax
  9847                              <1> sysvideo_39_79: ; 08/01/2021
  9848 0000F7BC E95ED5FFFF          <1> 	jmp	sysret
  9849                              <1> 
  9850                              <1> sysvideo_17:
  9851                              <1> 	; 23/07/2022
  9852                              <1> 	; 23/12/2020
  9853                              <1> 	; 11/12/2020
  9854                              <1> 	; 10/12/2020
  9855                              <1> 	; 23/11/2020
  9856 0000F7C1 80FF06              <1> 	cmp	bh, 6
  9857 0000F7C4 7424                <1> 	je	short sysvideo_17_0 ; 23/07/2022
  9858 0000F7C6 7205                <1> 	jb	short sysvideo_18 ; 23/07/2022
  9859 0000F7C8 E95E010000          <1> 	jmp	sysvideo_20 ; ja
  9860                              <1> 
  9861                              <1> 	; 23/07/2022
  9862                              <1> sysvideo_18:
  9863                              <1> 	; BH = 5
  9864                              <1> 	; Direct User Access for VGA video memory.
  9865                              <1> 	; Setup user's page tables for direct access to 0A0000h.
  9866                              <1> 	;
  9867                              <1> 	; Permission checks are not implemented yet !
  9868                              <1> 	; (11/07/2016)
  9869                              <1> 
  9870 0000F7CD B800000A00          <1> 	mov	eax, 0A0000h
  9871 0000F7D2 B910000000          <1> 	mov	ecx, 16 ; 16 pages (16*4K=64K)
  9872 0000F7D7 89C3                <1> 	mov	ebx, eax ; 12/05/2017 ; virtual = physical
  9873 0000F7D9 E89A66FFFF          <1> 	call	direct_memory_access	
  9874                              <1> 	;jc	sysret
  9875                              <1> 	; 23/07/2022
  9876 0000F7DE 7205                <1> 	jc	short sysvideo_18_0
  9877                              <1> 	; eax = 0A0000h if there is not an error
  9878 0000F7E0 A3[1C010300]        <1> 	mov	[u.r0], eax
  9879                              <1> sysvideo_18_0:
  9880 0000F7E5 E935D5FFFF          <1> 	jmp	sysret
  9881                              <1> 
  9882                              <1> sysvideo_17_0:
  9883                              <1> 	; BH = 6
  9884                              <1> 	; Direct User Access to Linear Frame Buffer.
  9885                              <1> 	; Setup user's page tables for direct access to LFB.
  9886                              <1> 	;
  9887                              <1> 	; Permission checks are not implemented yet !
  9888                              <1> 	; (10/12/2020)
  9889                              <1> 
  9890 0000F7EA 80FBFF              <1> 	cmp	bl, 0FFh ; current video mode
  9891 0000F7ED 722C                <1> 	jb	short sysvideo_17_2 ; for desired video mode
  9892                              <1> 
  9893 0000F7EF 381D[CE660000]      <1> 	cmp	[CRT_MODE], bl ; VESA VBE video mode ?
  9894 0000F7F5 750E                <1> 	jne	short sysvideo_17_1
  9895 0000F7F7 668B0D[D20F0300]    <1> 	mov	cx, [video_mode]
  9896 0000F7FE 6681E1FF01          <1> 	and	cx, 1FFh
  9897 0000F803 EB29                <1> 	jmp	short sysvideo_17_3
  9898                              <1> sysvideo_17_1:
  9899                              <1> 	; 11/12/2020
  9900 0000F805 88DF                <1> 	mov	bh, bl ; 0FFh
  9901 0000F807 8A1D[CE660000]      <1> 	mov	bl, [CRT_MODE] ; VGA/CGA video mode
  9902 0000F80D 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
  9903                              <1> 	; 23/12/2020
  9904 0000F813 895D10              <1> 	mov	[ebp+16], ebx ; return to user with EBX value 
  9905 0000F816 E904D5FFFF          <1> 	jmp	sysret ; return to user with EAX = 0
  9906                              <1> sysvideo_17_2:
  9907                              <1> 	; bl = VESA video mode - 100h
  9908 0000F81B B701                <1> 	mov	bh, 1 ; bx = 1XXh
  9909 0000F81D 53                  <1> 	push	ebx ; requested vesa video mode
  9910 0000F81E E80D42FFFF          <1> 	call	vbe_biosfn_return_current_mode
  9911 0000F823 59                  <1> 	pop	ecx ; requested vesa video mode
  9912 0000F824 6681E3FF01          <1> 	and	bx, 1FFh
  9913 0000F829 6639D9              <1> 	cmp	cx, bx
  9914 0000F82C 7564                <1> 	jne	short sysvideo_17_8
  9915                              <1> sysvideo_17_3:
  9916 0000F82E 663B0D[DE0F0300]    <1> 	cmp	cx, [LFB_Info+LFBINFO.mode]
  9917 0000F835 755B                <1> 	jne	short sysvideo_17_8
  9918                              <1> sysvideo_17_4:
  9919                              <1> 	; 11/12/2020
  9920 0000F837 A1[E00F0300]        <1> 	mov	eax, [LFB_Info+LFBINFO.LFB_addr]
  9921                              <1> 	; 21/12/2020
  9922 0000F83C 09C0                <1> 	or	eax, eax
  9923 0000F83E 744D                <1> 	jz	short sysvideo_17_7
  9924                              <1> 	;
  9925 0000F840 8B0D[E40F0300]      <1> 	mov	ecx, [LFB_Info+LFBINFO.LFB_size] ; buff size
  9926 0000F846 89C3                <1> 	mov 	ebx, eax ; user's address = physical address
  9927                              <1> 	;push	ebx
  9928 0000F848 51                  <1> 	push	ecx
  9929                              <1> 	; 21/12/2020
  9930 0000F849 81C1FF0F0000        <1> 	add	ecx, 4095  ; PAGESIZE - 1
  9931                              <1> 	; 14/12/2020
  9932 0000F84F C1E90C              <1> 	shr	ecx, 12  ; convert bytes to pages
  9933 0000F852 E82166FFFF          <1> 	call	direct_memory_access
  9934 0000F857 5A                  <1> 	pop	edx  ; linear frame buffer size in bytes
  9935                              <1> 	;pop	eax  ; linear frame buffer address (physical)
  9936 0000F858 7233                <1> 	jc	short sysvideo_17_7 ; [u.r0] = eax = 0
  9937                              <1> sysvideo_17_5:
  9938 0000F85A 668B0D[EA0F0300]    <1> 	mov	cx, [LFB_Info+LFBINFO.Y_res] ; screen height
  9939 0000F861 C1E110              <1> 	shl	ecx, 16
  9940 0000F864 668B0D[E80F0300]    <1> 	mov	cx,  [LFB_Info+LFBINFO.X_res] ; screen width
  9941 0000F86B 31DB                <1> 	xor	ebx, ebx
  9942 0000F86D 8A1D[EC0F0300]      <1> 	mov	bl, [LFB_Info+LFBINFO.bpp] ; bits per pixel
  9943 0000F873 8A3D[DE0F0300]      <1> 	mov	bh, [LFB_Info+LFBINFO.mode] ; XX part of 1XXh
  9944                              <1> sysvideo_26_4: ; 23/12/2020	
  9945 0000F879 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
  9946 0000F87F 895514              <1> 	mov	[ebp+20], edx ; return to user with EDX value 
  9947 0000F882 895D10              <1> 	mov	[ebp+16], ebx ; EBX
  9948 0000F885 894D18              <1> 	mov	[ebp+24], ecx ; ECX
  9949                              <1> sysvideo_17_6:
  9950 0000F888 A3[1C010300]        <1> 	mov	[u.r0], eax ; LFB address
  9951                              <1> sysvideo_17_7:
  9952 0000F88D E98DD4FFFF          <1> 	jmp	sysret 
  9953                              <1> sysvideo_17_8:
  9954                              <1> 	; cx = mode
  9955                              <1> 	; 21/12/2020
  9956 0000F892 80CD40              <1> 	or	ch, 40h  ; Linear frame buffer flag	
  9957 0000F895 E8B93FFFFF          <1> 	call	_vbe_biosfn_return_mode_info
  9958 0000F89A 72F1                <1> 	jc	short sysvideo_17_7
  9959 0000F89C EB99                <1> 	jmp	short sysvideo_17_4
  9960                              <1> 	
  9961                              <1> sysvideo_19:	
  9962                              <1> 	; 23/07/2022
  9963                              <1> 	; 22/01/2021
  9964                              <1> 	; 12/12/2020
  9965                              <1> 	; 11/12/2020
  9966                              <1> 	; 23/11/2020
  9967                              <1> 	; BH = 7
  9968                              <1> 	; Get (Super/Extended VGA) mode
  9969                              <1> 	; and Linear Frame Buffer info.
  9970                              <1> 	
  9971                              <1> 	; 22/01/2021
  9972 0000F89E B3FF                <1> 	mov	bl, 0FFh
  9973                              <1> 	; 11/12/2020
  9974                              <1> 	;cmp	byte [CRT_MODE], 0FFh ; (extended mode?)
  9975                              <1> 	; 22/01/2021
  9976 0000F8A0 381D[CE660000]      <1> 	cmp	[CRT_MODE], bl  ; 0FFh
  9977                              <1> 	;jb	short sysvideo_17_1 ; not a VESA VBE mode
  9978                              <1> 	; 23/07/2022
  9979                              <1> 	; 12/12/2020
  9980 0000F8A6 7305                <1> 	jnb	short sysvideo_19_0
  9981                              <1> 	; 23/07/2022
  9982 0000F8A8 E958FFFFFF          <1> 	jmp	sysvideo_17_1
  9983                              <1> 
  9984                              <1> sysvideo_19_0:
  9985 0000F8AD E87E41FFFF          <1> 	call	vbe_biosfn_return_current_mode
  9986 0000F8B2 6681E3FF01          <1> 	and	bx, 1FFh
  9987 0000F8B7 663B1D[DE0F0300]    <1> 	cmp	bx, [LFB_Info+LFBINFO.mode]
  9988 0000F8BE 750D                <1> 	jne	short sysvideo_19_2
  9989                              <1> sysvideo_19_1:
  9990 0000F8C0 A1[E00F0300]        <1> 	mov	eax, [LFB_Info+LFBINFO.LFB_addr]
  9991 0000F8C5 8B15[E40F0300]      <1> 	mov	edx, [LFB_Info+LFBINFO.LFB_size]
  9992 0000F8CB EB8D                <1> 	jmp	sysvideo_17_5
  9993                              <1> sysvideo_19_2:
  9994 0000F8CD E8813FFFFF          <1> 	call	_vbe_biosfn_return_mode_info
  9995 0000F8D2 73EC                <1> 	jnc	short sysvideo_19_1
  9996 0000F8D4 E946D4FFFF          <1> 	jmp	sysret
  9997                              <1> 
  9998                              <1> sysvideo_20_1:
  9999                              <1> 	; cx = vesa video mode
 10000 0000F8D9 6689C8              <1> 	mov	ax, cx
 10001 0000F8DC 663D0001            <1> 	cmp	ax, 100h
 10002 0000F8E0 725C                <1> 	jb	short sysvideo_20_0 ; VGA/CGA mode
 10003 0000F8E2 663DFF01            <1> 	cmp	ax, 1FFh
 10004                              <1> 	;ja	short sysvideo_20_4 ; not valid
 10005 0000F8E6 773E                <1> 	ja	short sysvideo_20_3
 10006 0000F8E8 50                  <1> 	push	eax
 10007 0000F8E9 6689C3              <1> 	mov	bx, ax
 10008 0000F8EC 66B8024F            <1> 	mov	ax, 4F02h
 10009                              <1> 
 10010                              <1> 	; simulate _int10h (int 31h) for func 4F02h
 10011                              <1> 	;pushfd
 10012                              <1> 	;push	cs
 10013                              <1> 	;push	sysvideo_20_1_retn 
 10014                              <1> 	;push	es ; *
 10015                              <1> 	;push	ds ; **	; SAVE WORK AND PARAMETER REGISTERS
 10016                              <1> 	;jmp	VBE_func
 10017                              <1> ;sysvideo_20_1_retn:	
 10018                              <1> 	
 10019 0000F8F0 E81B1EFFFF          <1> 	call	_int10h ; simulate int 10h (int 31h)
 10020                              <1> 
 10021 0000F8F5 6683F84F            <1> 	cmp	ax, 004Fh
 10022 0000F8F9 58                  <1> 	pop	eax
 10023 0000F8FA 752A                <1> 	jne	short sysvideo_20_3 ; error
 10024                              <1> 	;pop	eax
 10025 0000F8FC 40                  <1> 	inc	eax
 10026 0000F8FD A3[1C010300]        <1> 	mov	[u.r0], eax ; video mode + 1
 10027 0000F902 09D2                <1> 	or	edx, edx ; is LFBINFO requested by user ?	
 10028                              <1> 	;jz	short sysvideo_20_4
 10029 0000F904 7420                <1> 	jz	short sysvideo_20_3 ; no
 10030                              <1> 
 10031                              <1> 	; 11/12/2020
 10032                              <1> 	; Check LFBINFO table/structure
 10033                              <1> 	; (it is set by vbe2 'vbe_biosfn_set_mode'
 10034                              <1> 	; but if vbe3 vbios pmi is in use,
 10035                              <1> 	; it will not set LFBINFO table)
 10036                              <1> 
 10037 0000F906 52                  <1> 	push	edx
 10038 0000F907 48                  <1> 	dec	eax  ; video mode
 10039 0000F908 BE[DE0F0300]        <1> 	mov	esi, LFB_Info
 10040 0000F90D 663B06              <1> 	cmp	ax, [esi+LFBINFO.mode]
 10041 0000F910 7407                <1> 	je	short sysvideo_20_2
 10042                              <1> 
 10043 0000F912 E83C3FFFFF          <1> 	call	_vbe_biosfn_return_mode_info
 10044                              <1> 	;jnc	short sysvideo_20_2
 10045 0000F917 723B                <1> 	jc	short sysvideo_20_4 ; edx = 0	
 10046                              <1> 
 10047                              <1> 	;; clear LFBINFO table for invalidating	
 10048                              <1> 	;mov	ecx, LFBINFO.size ; 16
 10049                              <1> 	;mov	edi, esi ; LFB_Info table address
 10050                              <1> 	;xor	eax, eax
 10051                              <1> 	;rep	stosb
 10052                              <1> 
 10053                              <1> sysvideo_20_2:
 10054                              <1> 	;pop	ecx
 10055                              <1> 	;mov	edi, ecx ; user buffer
 10056 0000F919 5F                  <1> 	pop	edi
 10057 0000F91A B910000000          <1> 	mov	ecx, LFBINFO.size ; 16
 10058 0000F91F E835140000          <1> 	call	transfer_to_user_buffer ; fast transfer
 10059 0000F924 722F                <1> 	jc	short sysvideo_20_5
 10060                              <1> 	
 10061                              <1> 	;jmp	sysret
 10062                              <1> sysvideo_20_3:	
 10063                              <1> 	;pop	eax ; [u.r0] = 0		
 10064                              <1> ;sysvideo_20_4:
 10065 0000F926 E9F4D3FFFF          <1> 	jmp	sysret
 10066                              <1> 
 10067                              <1> 	; 23/07/2022
 10068                              <1> sysvideo_20:
 10069                              <1> 	; 11/12/2020
 10070                              <1> 	; 23/11/2020
 10071 0000F92B 80FF08              <1> 	cmp	bh, 8
 10072                              <1> 	; 08/08/2022
 10073                              <1> 	;jb	short sysvideo_19 ; video mode & lfb info
 10074 0000F92E 7407                <1> 	je	short sysvideo_20_6
 10075                              <1> 	; 23/07/2022
 10076 0000F930 7733                <1> 	ja	short sysvideo_21 ; 12/12/2020
 10077                              <1> 	; 08/08/2022 - jb
 10078 0000F932 E967FFFFFF          <1> 	jmp	sysvideo_19 
 10079                              <1> sysvideo_20_6:
 10080                              <1> 	; BH = 8
 10081                              <1> 	; Set (Super/Extended VGA) mode & return LFB info
 10082                              <1> 
 10083                              <1> 	; 11/12/2020
 10084 0000F937 80FBFF              <1> 	cmp	bl, 0FFh  ; CGA/VGA mode ?
 10085 0000F93A 739D                <1> 	jnb	short sysvideo_20_1
 10086                              <1> 
 10087                              <1> 	;xor	ah, ah
 10088 0000F93C 88D8                <1> 	mov	al, bl
 10089                              <1> sysvideo_20_0:
 10090 0000F93E E8CD1DFFFF          <1> 	call	_int10h  ; uses vbe3 pmi32 option
 10091 0000F943 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; -1
 10092 0000F946 74DE                <1> 	je	short sysvideo_20_3 ; error
 10093                              <1> 	
 10094                              <1> 	; 11/12/2020
 10095                              <1> 	; alternative (it does not use vbe3 pmi32)
 10096                              <1> 	;push	eax
 10097                              <1> 	;call	_set_mode
 10098                              <1> 	;pop	eax
 10099                              <1> 	;jc	short sysvideo_20_3
 10100                              <1> 	
 10101                              <1> 	;inc	eax
 10102 0000F948 FEC0                <1> 	inc	al
 10103                              <1> 	;mov	[u.r0], ax ; video mode + 1	
 10104 0000F94A A2[1C010300]        <1> 	mov	[u.r0], al
 10105 0000F94F E9CBD3FFFF          <1> 	jmp	sysret
 10106                              <1> 
 10107                              <1> sysvideo_20_4:
 10108 0000F954 5A                  <1> 	pop	edx
 10109                              <1> sysvideo_20_5:
 10110 0000F955 31D2                <1> 	xor	edx, edx ; 0
 10111                              <1> 	; edx = 0 -> invalid LFBINFO data
 10112 0000F957 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 10113 0000F95D 895514              <1> 	mov	[ebp+20], edx ; return to user with EDX value 
 10114 0000F960 E9BAD3FFFF          <1> 	jmp	sysret
 10115                              <1> 
 10116                              <1> sysvideo_21:
 10117                              <1> 	; 23/07/2022
 10118                              <1> 	; 04/01/2021
 10119                              <1> 	; 03/12/2020
 10120 0000F965 80FF0A              <1> 	cmp	bh, 10
 10121                              <1> 	;jb	sysvideo_22 ; VESA VBE3 pmi parms
 10122                              <1> 	; 23/07/2022
 10123 0000F968 723F                <1> 	jb	short sysvideo_21_19
 10124                              <1> 	; 23/12/2020
 10125                              <1> 	;je	sysvideo_26 ; Video memory mapping	
 10126                              <1> 	; 23/07/2022
 10127 0000F96A 7442                <1> 	je	short sysvideo_21_20
 10128                              <1> 	
 10129                              <1> 	; 04/01/2020
 10130 0000F96C 80FF0B              <1> 	cmp	bh, 11
 10131                              <1> 	;ja	sysvideo_27
 10132                              <1> 	; 23/07/2022
 10133 0000F96F 7742                <1> 	ja	short sysvideo_21_21
 10134                              <1> 		
 10135                              <1> 	; BH = 11
 10136                              <1> 	; set/read DAC color registers (for 8bpp)
 10137                              <1> 	
 10138 0000F971 80FB04              <1> 	cmp	bl, 4
 10139                              <1> 	;jnb	sysvideo_21_7	; BMP file type palette
 10140                              <1> 				; handling
 10141                              <1> 	; 23/07/2022
 10142                              <1> 	;jnb	short sysvideo_21_7
 10143                              <1> 	; 08/08/2022
 10144 0000F974 7205                <1> 	jb	short sysvideo_21_18
 10145 0000F976 E989000000          <1> 	jmp	sysvideo_21_7
 10146                              <1> sysvideo_21_18:	
 10147 0000F97B F6C301              <1> 	test	bl, 1
 10148 0000F97E 7563                <1> 	jnz	short sysvideo_21_4 ; set/write DAC colors
 10149                              <1> 		
 10150                              <1> 	; Read DAC color register or all DAC color registers
 10151 0000F980 F6C302              <1> 	test	bl, 2  ; read single DAC color register
 10152 0000F983 7433                <1> 	jz	short sysvideo_21_2 ; read all DAC color regs	
 10153                              <1> 
 10154                              <1> 	; read single DAC color register
 10155                              <1> 	; CL = DAC color register (index)
 10156                              <1>  	
 10157 0000F985 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 10158 0000F989 88C8                <1> 	mov	al, cl	; DAC color register
 10159 0000F98B 31C9                <1> 	xor	ecx, ecx ; (this may not be necessary)
 10160 0000F98D EE                  <1> 	out	dx, al
 10161                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 10162 0000F98E B2C9                <1> 	mov	dl, 0C9h
 10163 0000F990 EC                  <1> 	in	al, dx
 10164 0000F991 88C4                <1> 	mov	ah, al	; red
 10165 0000F993 EC                  <1> 	in	al, dx
 10166 0000F994 88C1                <1> 	mov	cl, al	; green
 10167 0000F996 EC                  <1> 	in	al, dx
 10168 0000F997 88C5                <1> 	mov	ch, al	; blue
 10169 0000F999 C1E108              <1> 	shl	ecx, 8
 10170 0000F99C 88E1                <1> 	mov	cl, ah	; red	
 10171                              <1> 	; CL = Red, CH = Green, byte 3 = Blue, byte 4 = 0
 10172                              <1> sysvideo_21_0:
 10173 0000F99E 890D[1C010300]      <1> 	mov	[u.r0], ecx
 10174                              <1> sysvideo_21_1:
 10175 0000F9A4 E976D3FFFF          <1> 	jmp	sysret
 10176                              <1> sysvideo_21_19:
 10177                              <1> 	; 23/07/2022
 10178 0000F9A9 E97A010000          <1> 	jmp	sysvideo_22
 10179                              <1> sysvideo_21_20:
 10180                              <1> 	; 23/07/2022
 10181 0000F9AE E930020000          <1> 	jmp	sysvideo_26
 10182                              <1> sysvideo_21_21:
 10183                              <1> 	; 23/07/2022
 10184 0000F9B3 E9B6020000          <1> 	jmp	sysvideo_27
 10185                              <1> sysvideo_21_2:
 10186                              <1> 	; read all DAC color registers
 10187 0000F9B8 89CB                <1> 	mov	ebx, ecx ; user's buffer address
 10188 0000F9BA BF00600900          <1> 	mov	edi, VBE3STACKADDR
 10189 0000F9BF 89FE                <1> 	mov	esi, edi
 10190                              <1> 	;mov	ecx, 768 ; 256*3
 10191                              <1> 	; 08/08/2022
 10192 0000F9C1 29C9                <1> 	sub	ecx, ecx
 10193 0000F9C3 B503                <1> 	mov	ch, 3
 10194                              <1> 	; ecx = 768 = 300h
 10195                              <1> 	;push	ecx
 10196 0000F9C5 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 10197 0000F9C9 28C0                <1> 	sub	al, al ; 0
 10198 0000F9CB EE                  <1> 	out	dx, al
 10199                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 10200 0000F9CC B2C9                <1> 	mov	dl, 0C9h
 10201                              <1> sysvideo_21_3:
 10202 0000F9CE EC                  <1> 	in	al, dx
 10203 0000F9CF AA                  <1> 	stosb
 10204 0000F9D0 EC                  <1> 	in	al, dx
 10205 0000F9D1 AA                  <1> 	stosb
 10206 0000F9D2 EC                  <1> 	in	al, dx
 10207 0000F9D3 AA                  <1> 	stosb
 10208 0000F9D4 E2F8                <1> 	loop	sysvideo_21_3
 10209                              <1> 	;pop	ecx
 10210                              <1> 	; 18/08/2022
 10211 0000F9D6 B503                <1> 	mov	ch, 3
 10212                              <1> 	; ecx = 768 = 300h
 10213                              <1> 
 10214 0000F9D8 89DF                <1> 	mov	edi, ebx ; user's buffer address
 10215                              <1> 	;mov	esi, VBE3STACKADDR
 10216                              <1> 	;mov	ecx, 256*3 = 768
 10217 0000F9DA E87A130000          <1> 	call	transfer_to_user_buffer
 10218 0000F9DF 72C3                <1> 	jc	short sysvideo_21_1
 10219                              <1> 	;mov	[u.r0], ecx ; actual transfer count
 10220 0000F9E1 EBBB                <1> 	jmp	short sysvideo_21_0
 10221                              <1> 
 10222                              <1> sysvideo_21_4:
 10223                              <1> 	; Set/Write DAC color register or all registers
 10224 0000F9E3 F6C302              <1> 	test	bl, 2 ; write/set single DAC color register
 10225 0000F9E6 7456                <1> 	jz	short sysvideo_21_5 ; set all DAC color regs
 10226                              <1> 
 10227                              <1> 	; set single DAC color register
 10228                              <1> 	; CL = DAC color register (index)
 10229                              <1> 	; (byte 1 = Red, byte 2 = Green, byte 3 = Blue) 
 10230                              <1> 
 10231 0000F9E8 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 10232 0000F9EC 89C8                <1> 	mov	eax, ecx ; DAC color register (index)
 10233 0000F9EE C1E910              <1> 	shr	ecx, 16  ; CL = green, AH = Red
 10234 0000F9F1 EE                  <1> 	out	dx, al
 10235                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 10236 0000F9F2 FEC2                <1> 	inc	dl
 10237 0000F9F4 88E0                <1> 	mov	al, ah	; Red
 10238 0000F9F6 EE                  <1> 	out	dx, al
 10239 0000F9F7 88C8                <1> 	mov	al, cl	; Green
 10240 0000F9F9 EE                  <1> 	out	dx, al
 10241 0000F9FA 88E8                <1> 	mov	al, ch	; Blue
 10242 0000F9FC EE                  <1> 	out	dx, al	
 10243                              <1> 	;rol	ecx, 8
 10244 0000F9FD C1E108              <1> 	shl	ecx, 8	; 21/02/2021
 10245 0000FA00 88E1                <1> 	mov	cl, ah	; Red
 10246                              <1> 		; ecx = 00BBGGRRh	
 10247 0000FA02 EB9A                <1> 	jmp	short sysvideo_21_0
 10248                              <1> 
 10249                              <1> 	; 23/07/2022
 10250                              <1> sysvideo_21_7:	
 10251                              <1> 	; BMP file type palette handling	
 10252                              <1> 	
 10253 0000FA04 F6C301              <1> 	test	bl, 1
 10254                              <1> 	;jnz	short sysvideo_21_12 ; set/write DAC colors
 10255                              <1> 	; 08/08/2022
 10256 0000FA07 7405                <1> 	jz	short sysvideo_21_16
 10257 0000FA09 E9A3000000          <1> 	jmp	sysvideo_21_12
 10258                              <1> 
 10259                              <1> sysvideo_21_16:		
 10260                              <1> 	; Read DAC color register or all DAC color registers
 10261 0000FA0E F6C302              <1> 	test	bl, 2  ; read single DAC color register
 10262 0000FA11 7460                <1> 	jz	short sysvideo_21_10 ; read all DAC color regs	
 10263                              <1> 
 10264                              <1> 	; read single DAC color register
 10265                              <1> 	; CL = DAC color register (index)
 10266                              <1>  	
 10267 0000FA13 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 10268 0000FA17 88C8                <1> 	mov	al, cl	; DAC color register
 10269 0000FA19 31C9                <1> 	xor	ecx, ecx
 10270 0000FA1B EE                  <1> 	out	dx, al
 10271                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 10272 0000FA1C B2C9                <1> 	mov	dl, 0C9h
 10273 0000FA1E EC                  <1> 	in	al, dx
 10274 0000FA1F C0E002              <1> 	shl	al, 2
 10275 0000FA22 88C5                <1> 	mov	ch, al	; red
 10276 0000FA24 EC                  <1> 	in	al, dx
 10277 0000FA25 C0E002              <1> 	shl	al, 2
 10278 0000FA28 88C1                <1> 	mov	cl, al	; green
 10279 0000FA2A EC                  <1> 	in	al, dx
 10280 0000FA2B C0E002              <1> 	shl	al, 2
 10281                              <1> 	; 21/02/2021
 10282 0000FA2E C1E108              <1> 	shl	ecx, 8
 10283 0000FA31 88C1                <1> 	mov	cl, al	; blue
 10284                              <1> 	; CL = Blue, CH = Green, byte 3 = Red, byte 4 = 0
 10285                              <1> sysvideo_21_8:
 10286 0000FA33 890D[1C010300]      <1> 	mov	[u.r0], ecx
 10287                              <1> sysvideo_21_9:
 10288 0000FA39 E9E1D2FFFF          <1> 	jmp	sysret
 10289                              <1> 
 10290                              <1> sysvideo_21_5:
 10291                              <1> 	; write/set all DAC color registers
 10292 0000FA3E 89CE                <1> 	mov	esi, ecx ; user's buffer address
 10293 0000FA40 BF00600900          <1> 	mov	edi, VBE3STACKADDR
 10294 0000FA45 89FB                <1> 	mov	ebx, edi
 10295 0000FA47 B900030000          <1> 	mov	ecx, 768 ; 256*3
 10296 0000FA4C E852130000          <1> 	call	transfer_from_user_buffer
 10297                              <1> 	;jc	short sysvideo_21_1
 10298                              <1> 	; 08/08/2022
 10299 0000FA51 7305                <1> 	jnc	short sysvideo_21_17
 10300 0000FA53 E94CFFFFFF          <1> 	jmp	sysvideo_21_1
 10301                              <1> sysvideo_21_17:
 10302 0000FA58 890D[1C010300]      <1> 	mov	[u.r0], ecx ; actual transfer count
 10303                              <1> 
 10304 0000FA5E 89DE                <1> 	mov	esi, ebx ; VBE3STACKADDR
 10305 0000FA60 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 10306 0000FA64 28C0                <1> 	sub	al, al ; 0
 10307 0000FA66 EE                  <1> 	out	dx, al
 10308                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 10309 0000FA67 FEC2                <1> 	inc	dl
 10310                              <1> sysvideo_21_6:
 10311 0000FA69 AC                  <1> 	lodsb
 10312 0000FA6A EE                  <1> 	out	dx, al
 10313 0000FA6B AC                  <1> 	lodsb
 10314 0000FA6C EE                  <1> 	out	dx, al
 10315 0000FA6D AC                  <1> 	lodsb
 10316 0000FA6E EE                  <1> 	out	dx, al
 10317 0000FA6F E2F8                <1> 	loop	sysvideo_21_6
 10318 0000FA71 EBC6                <1> 	jmp	short sysvideo_21_9
 10319                              <1> 
 10320                              <1> sysvideo_21_10:
 10321                              <1> 	; read all DAC color registers
 10322 0000FA73 89CD                <1> 	mov	ebp, ecx ; user's buffer address
 10323 0000FA75 BF00600900          <1> 	mov	edi, VBE3STACKADDR
 10324 0000FA7A 89FE                <1> 	mov	esi, edi
 10325 0000FA7C B900040000          <1> 	mov	ecx, 1024 ; 256*4
 10326 0000FA81 51                  <1> 	push	ecx
 10327 0000FA82 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
 10328 0000FA86 28C0                <1> 	sub	al, al ; 0
 10329 0000FA88 EE                  <1> 	out	dx, al
 10330                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 10331 0000FA89 B2C9                <1> 	mov	dl, 0C9h
 10332                              <1> sysvideo_21_11:
 10333 0000FA8B 31DB                <1> 	xor	ebx, ebx
 10334 0000FA8D EC                  <1> 	in	al, dx	; Red
 10335 0000FA8E C0E002              <1> 	shl	al, 2
 10336 0000FA91 88C7                <1> 	mov	bh, al
 10337 0000FA93 EC                  <1> 	in	al, dx	; Green
 10338 0000FA94 C0E002              <1> 	shl	al, 2
 10339 0000FA97 88C3                <1> 	mov	bl, al
 10340 0000FA99 EC                  <1> 	in	al, dx	; Blue
 10341 0000FA9A C0E002              <1> 	shl	al, 2
 10342 0000FA9D C1E308              <1> 	shl	ebx, 8
 10343 0000FAA0 89D8                <1> 	mov	eax, ebx ; 00RRGGBBh
 10344 0000FAA2 AB                  <1> 	stosd	
 10345 0000FAA3 E2E6                <1> 	loop	sysvideo_21_11
 10346 0000FAA5 59                  <1> 	pop	ecx
 10347                              <1> 
 10348 0000FAA6 89EF                <1> 	mov	edi, ebp ; user's buffer address
 10349                              <1> 	;mov	esi, VBE3STACKADDR
 10350                              <1> 	;mov	ecx, 1024 = 4*256
 10351 0000FAA8 E8AC120000          <1> 	call	transfer_to_user_buffer
 10352 0000FAAD 728A                <1> 	jc	short sysvideo_21_9
 10353                              <1> 	;mov	[u.r0], ecx ; actual transfer count
 10354 0000FAAF EB82                <1> 	jmp	short sysvideo_21_8
 10355                              <1> 
 10356                              <1> sysvideo_21_12:
 10357                              <1> 	; Set/Write DAC color register or all registers
 10358 0000FAB1 F6C302              <1> 	test	bl, 2 ; write/set single DAC color register
 10359 0000FAB4 742A                <1> 	jz	short sysvideo_21_13 ; set all DAC color regs
 10360                              <1> 
 10361                              <1> 	; set single DAC color register
 10362                              <1> 	; CL = DAC color register (index)
 10363                              <1> 	; (byte 1 = Blue, byte 2 = Green, byte 3 = Red) 
 10364                              <1> 
 10365 0000FAB6 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 10366 0000FABA 88C8                <1> 	mov	al, cl	; DAC color register (index)
 10367 0000FABC 88EC                <1> 	mov	ah, ch	; Blue 
 10368 0000FABE C1E910              <1> 	shr	ecx, 16
 10369 0000FAC1 EE                  <1> 	out	dx, al
 10370                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 10371 0000FAC2 FEC2                <1> 	inc	dl
 10372 0000FAC4 88E8                <1> 	mov	al, ch	; Red
 10373 0000FAC6 C0E802              <1> 	shr	al, 2
 10374 0000FAC9 EE                  <1> 	out	dx, al
 10375 0000FACA 88C8                <1> 	mov	al, cl	; Green
 10376 0000FACC C0E802              <1> 	shr	al, 2
 10377 0000FACF EE                  <1> 	out	dx, al
 10378 0000FAD0 88E0                <1> 	mov	al, ah	; Blue
 10379 0000FAD2 C0E802              <1> 	shr	al, 2
 10380 0000FAD5 EE                  <1> 	out	dx, al	
 10381                              <1> 	;rol	ecx, 8
 10382 0000FAD6 C1E108              <1> 	shl	ecx, 8 ; 21/02/2021 
 10383 0000FAD9 88E1                <1> 	mov	cl, ah
 10384 0000FADB E953FFFFFF          <1> 	jmp	sysvideo_21_8 ; 08/08/2022
 10385                              <1> 
 10386                              <1> sysvideo_21_13:
 10387                              <1> 	; write/set all DAC color registers
 10388 0000FAE0 89CE                <1> 	mov	esi, ecx ; user's buffer address
 10389 0000FAE2 BF00600900          <1> 	mov	edi, VBE3STACKADDR
 10390 0000FAE7 89FB                <1> 	mov	ebx, edi
 10391 0000FAE9 B900040000          <1> 	mov	ecx, 1024 ; 256*4
 10392 0000FAEE E8B0120000          <1> 	call	transfer_from_user_buffer
 10393 0000FAF3 722E                <1> 	jc	short sysvideo_21_15
 10394 0000FAF5 890D[1C010300]      <1> 	mov	[u.r0], ecx ; actual transfer count
 10395                              <1> 
 10396 0000FAFB 89DE                <1> 	mov	esi, ebx ; VBE3STACKADDR
 10397 0000FAFD 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 10398 0000FB01 28C0                <1> 	sub	al, al ; 0
 10399 0000FB03 EE                  <1> 	out	dx, al
 10400                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 10401 0000FB04 FEC2                <1> 	inc	dl
 10402                              <1> sysvideo_21_14:
 10403 0000FB06 AD                  <1> 	lodsd
 10404                              <1> 	; byte 0 = Blue, byte 1 = Green, byte 2 = Red
 10405                              <1> 	; 21/02/2021
 10406 0000FB07 89C3                <1> 	mov	ebx, eax ; BL = Blue, BH = Green
 10407 0000FB09 C1CB08              <1> 	ror	ebx, 8 ; BL = Green, BH = Red
 10408 0000FB0C 88F8                <1> 	mov	al, bh
 10409 0000FB0E C0E802              <1> 	shr	al, 2
 10410 0000FB11 EE                  <1> 	out	dx, al ; Red
 10411 0000FB12 88D8                <1> 	mov	al, bl
 10412 0000FB14 C0E802              <1> 	shr	al, 2	
 10413 0000FB17 EE                  <1> 	out	dx, al ; Green
 10414 0000FB18 C1C308              <1> 	rol	ebx, 8 ; BL = Blue
 10415 0000FB1B 88D8                <1> 	mov	al, bl
 10416 0000FB1D C0E802              <1> 	shr	al, 2
 10417 0000FB20 EE                  <1> 	out	dx, al ; Blue 
 10418 0000FB21 E2E3                <1> 	loop	sysvideo_21_14
 10419                              <1> sysvideo_21_15:
 10420 0000FB23 E9F7D1FFFF          <1> 	jmp	sysret
 10421                              <1> 
 10422                              <1> sysvideo_22:
 10423                              <1> 	; 28/02/2021
 10424                              <1> 	; 22/01/2021
 10425                              <1> 	; 17/01/2021
 10426                              <1> 	; 04/12/2020
 10427                              <1> 	; 03/12/2020
 10428                              <1> 	; BH = 9
 10429                              <1> 	; Set/Get VESA VBE3 protected mode interface params
 10430                              <1> 
 10431                              <1> 	; 22/01/2021
 10432                              <1> 	;cmp	byte [vbe3], 3
 10433                              <1> 	;jne	short sysvideo_25 ; not applicable if
 10434                              <1> 				; vbe3 compatible video bios
 10435                              <1> 				; is not detected by kernel	
 10436 0000FB28 80FB02              <1> 	cmp	bl, 2
 10437                              <1> 	;ja	short sysvideo_25 ; bl > 2 not implemented
 10438                              <1> 	; 17/01/2021
 10439 0000FB2B 7716                <1> 	ja	short sysvideo_22_0 ; srvs flag sub function
 10440                              <1> 	;jb	short sysvideo_23
 10441                              <1> 
 10442                              <1> 	; 21/01/2021
 10443 0000FB2D 803D[79090000]03    <1> 	cmp	byte [vbe3], 3
 10444                              <1> 	;jne	short sysvideo_25 ; not applicable if
 10445                              <1> 				; vbe3 compatible video bios
 10446                              <1> 				; is not detected by kernel
 10447 0000FB34 75ED                <1> 	jne	short sysvideo_21_15 ; 28/02/2021
 10448                              <1> 	
 10449 0000FB36 80FB01              <1> 	cmp	bl, 1
 10450 0000FB39 7673                <1> 	jna	short sysvideo_23
 10451                              <1> 
 10452 0000FB3B 8A1D[D00F0300]      <1> 	mov	bl, [pmi32] ; Video bios 32 bit PMI functions
 10453 0000FB41 EB78                <1> 	jmp	short sysvideo_24
 10454                              <1> 
 10455                              <1> sysvideo_22_0:
 10456                              <1> 	; 17/01/2021
 10457                              <1> 	; save/restore video state user permission
 10458 0000FB43 80FB05              <1> 	cmp	bl, 5
 10459 0000FB46 771E                <1> 	ja	short sysvideo_22_2
 10460 0000FB48 7208                <1> 	jb	short sysvideo_22_1
 10461                              <1> 	; get srvs flag value/status
 10462 0000FB4A 8A1D[34100300]      <1> 	mov	bl, [srvsf] ; 0 = disabled, 1 = enabled
 10463 0000FB50 EB2C                <1> 	jmp	short sysvideo_22_3
 10464                              <1> 
 10465                              <1> sysvideo_22_1:
 10466                              <1> 	; permission (root and multi tasking) check
 10467 0000FB52 E836000000          <1> 	call	sysvideo_22_4
 10468 0000FB57 736A                <1> 	jnc	short sysvideo_25 ; not permitted !
 10469                              <1> 	; cf = 1
 10470 0000FB59 80EB03              <1> 	sub	bl, 3 ; disable = 0, enable = 1
 10471                              <1> 	; 22/01/2021
 10472 0000FB5C 881D[34100300]      <1> 	mov	[srvsf], bl
 10473 0000FB62 FEC3                <1> 	inc	bl ; 1 = disabled, 2 = enabled
 10474 0000FB64 EB18                <1> 	jmp	short sysvideo_22_3
 10475                              <1> 
 10476                              <1> sysvideo_22_2:
 10477 0000FB66 80FB06              <1> 	cmp	bl, 6
 10478                              <1> 	;ja	short sysvideo_25 ; invalid/unimplemented
 10479                              <1> 	; 28/02/2021
 10480 0000FB69 7733                <1> 	ja	short sysvideo_22_6
 10481                              <1> 	; get VESA VBE number/status
 10482 0000FB6B 8A25[79090000]      <1> 	mov	ah, [vbe3] ; vbe3 = 3, vbe2 = 2, others = 0
 10483 0000FB71 A0[7A090000]        <1> 	mov	al, [vbe2bios] ; bochs/qemu/vbox emulator status
 10484 0000FB76 66A3[1C010300]      <1> 	mov	[u.r0], ax
 10485 0000FB7C EB45                <1> 	jmp	short sysvideo_25
 10486                              <1> 
 10487                              <1> sysvideo_22_3:
 10488                              <1> 	; 22/01/2021
 10489 0000FB7E 8A3D[35100300]      <1> 	mov	bh, [srvso] ; state options (> 80h -> svga)
 10490 0000FB84 66891D[1C010300]    <1> 	mov	[u.r0], bx ; function result is return value 
 10491 0000FB8B EB36                <1> 	jmp	short sysvideo_25 
 10492                              <1> 
 10493                              <1> sysvideo_22_4:
 10494                              <1> 	; 17/01/2021 - permission will be given by root only
 10495 0000FB8D 803D[16840100]00    <1> 	cmp	byte [multi_tasking], 0 ; in single user mode
 10496 0000FB94 7707                <1> 	ja	short sysvideo_22_5
 10497                              <1> 	; 19/01/2021
 10498 0000FB96 803D[6E010300]01    <1>  	cmp	byte [u.uid], 1 ; ([u.uid] = 0 -> root)
 10499                              <1> sysvideo_22_5:
 10500                              <1> 	; [multi_tasking] = 0 & [u.uid] = 0 -> CF = 1
 10501                              <1> 	; otherwise -> CF = 0 
 10502 0000FB9D C3                  <1> 	retn
 10503                              <1> 
 10504                              <1> sysvideo_22_6:
 10505                              <1> 	; 28/02/2021
 10506 0000FB9E 80FB09              <1> 	cmp	bl, 9
 10507 0000FBA1 7720                <1> 	ja	short sysvideo_25 ; invalid/unimplemented
 10508 0000FBA3 7436                <1> 	je	short sysvideo_22_9
 10509 0000FBA5 80FB08              <1> 	cmp	bl, 8
 10510 0000FBA8 721E                <1> 	jb	short sysvideo_22_7
 10511                              <1> 
 10512                              <1> 	; BL = 8
 10513                              <1> 	; Set default true color bpp to 24
 10514                              <1> 
 10515 0000FBAA B318                <1> 	mov	bl, 24
 10516                              <1> 	;mov	[truecolor], al	; 24bpp (RRGGBBh)
 10517                              <1> 	;mov	[u.r0], al
 10518                              <1> 	;jmp	short sysvideo_25
 10519 0000FBAC EB25                <1> 	jmp	short sysvideo_22_8
 10520                              <1> 
 10521                              <1> sysvideo_23:
 10522                              <1> 	; 17/01/2021
 10523                              <1> 	; permission (root and multi tasking) check
 10524 0000FBAE E8DAFFFFFF          <1> 	call	sysvideo_22_4
 10525 0000FBB3 730E                <1> 	jnc	short sysvideo_25 ; not permitted !
 10526                              <1> 
 10527 0000FBB5 881D[D00F0300]      <1> 	mov	[pmi32], bl ; 1 = enabled, 0 = disabled 
 10528                              <1> sysvideo_24:
 10529 0000FBBB FEC3                <1> 	inc	bl
 10530                              <1> sysvideo_22_10:	; 28/02/2021
 10531 0000FBBD 881D[1C010300]      <1> 	mov	[u.r0], bl ; function result is return value 
 10532                              <1> sysvideo_25:
 10533 0000FBC3 E957D1FFFF          <1> 	jmp	sysret
 10534                              <1> 
 10535                              <1> sysvideo_22_7:
 10536                              <1> 	; BL = 7
 10537                              <1> 	; Set default true color bpp to 32
 10538                              <1> 	; (it will set if [VBE3]=3)
 10539                              <1> 
 10540                              <1> 	; Note: This sub function is used to set 24bpp
 10541                              <1> 	; VESA VBE video modes to 32bpp.. because,
 10542                              <1> 	; old hardware uses 24 bpp but new video hardware
 10543                              <1> 	; uses 32bpp for same VESA VBE truecolor modes.
 10544                              <1> 	; (For example: VBE mode 112h is 640*480, 24bpp but
 10545                              <1> 	; new hardware uses/apply it as 640*480, 32bpp.)  	
 10546                              <1> 	; So, TRDOS 386 v2.0.3 kernel will check [truecolor]
 10547                              <1> 	; status is 32 bpp or not and it will change 24bpp
 10548                              <1> 	; to 32bpp if default [truecolor] value is 32, for
 10549                              <1> 	; same video mode number.
 10550                              <1> 
 10551 0000FBC8 803D[79090000]03    <1> 	cmp	byte [vbe3], 3
 10552 0000FBCF 75F2                <1> 	jne	short sysvideo_25 ; Only applicable 
 10553                              <1> 				  ; for VBE3 video hardware!
 10554 0000FBD1 B320                <1> 	mov	bl, 32
 10555                              <1> sysvideo_22_8:
 10556 0000FBD3 881D[4F740100]      <1> 	mov	[truecolor], bl	; 32bpp (00RRGGBBh)
 10557                              <1> 	;mov	[u.r0], bl
 10558                              <1> 	;jmp	short sysvideo_25
 10559 0000FBD9 EBE2                <1> 	jmp	short sysvideo_22_10
 10560                              <1> 
 10561                              <1> sysvideo_22_9:
 10562                              <1> 	; BL = 9
 10563                              <1> 	; Return default true color bpp
 10564 0000FBDB 8A1D[4F740100]      <1> 	mov	bl, [truecolor]
 10565 0000FBE1 EBDA                <1> 	jmp	short sysvideo_22_10
 10566                              <1> ;sysvideo_22_10:
 10567                              <1> 	;mov	[u.r0], bl
 10568                              <1> 	;jmp	sysret
 10569                              <1> 
 10570                              <1> sysvideo_26:
 10571                              <1> 	; 23/12/2020
 10572                              <1> 	; BH = 10
 10573                              <1> 	; Map video memory to user's buffer
 10574                              <1> 	; (multiuser/owner r/w permisions are ignored
 10575                              <1> 	;  for current TRDOS 386 version !)
 10576                              <1> 
 10577 0000FBE3 6681E100F0          <1> 	and	cx, ~4095  ; clear low 12 bits
 10578 0000FBE8 09C9                <1> 	or	ecx, ecx ; start address of user's buffer
 10579 0000FBEA 74D7                <1> 	jz	short sysvideo_25 ; error !
 10580                              <1> 	
 10581 0000FBEC 80FB01              <1> 	cmp	bl, 1  ; VGA memory mapping ?
 10582 0000FBEF 740E                <1> 	je	short sysvideo_26_1
 10583 0000FBF1 7718                <1> 	ja	short sysvideo_26_2
 10584                              <1> sysvideo_26_0:
 10585                              <1> 	; BL = 0 : CGA memory (0B8000h) map (32K)
 10586 0000FBF3 B800800B00          <1> 	mov	eax, 0B8000h	
 10587 0000FBF8 BB00800000          <1> 	mov	ebx, 32768
 10588 0000FBFD EB37                <1> 	jmp	short sysvideo_26_3
 10589                              <1> sysvideo_26_1:
 10590                              <1> 	; BL = 1 : VGA memory (0A0000h) map (64K)
 10591 0000FBFF B800000A00          <1> 	mov	eax, 0A0000h	
 10592 0000FC04 BB00000100          <1> 	mov	ebx, 65536
 10593 0000FC09 EB2B                <1> 	jmp	short sysvideo_26_3
 10594                              <1> sysvideo_26_2:
 10595                              <1> 	; BL = 2 : SVGA memory (LFB) map to user's buffer
 10596 0000FC0B 803D[79090000]02    <1> 	cmp	byte [vbe3], 2  ; VESA VBE 2/3 vbios ready ?
 10597 0000FC12 72AF                <1> 	jb	short sysvideo_25  ; no, error !
 10598 0000FC14 6681E200F0          <1> 	and	dx, ~4095 ; clear low 12 bits
 10599 0000FC19 09D2                <1> 	or	edx, edx  ; buffer size in bytes	
 10600 0000FC1B 74A6                <1> 	jz	short sysvideo_25  ; error
 10601 0000FC1D 89D3                <1> 	mov	ebx, edx
 10602 0000FC1F A1[E00F0300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
 10603 0000FC24 21C0                <1> 	and	eax, eax
 10604 0000FC26 7425                <1> 	jz	short sysvideo_26_5
 10605                              <1> 				; (LFB parms are not set yet)
 10606 0000FC28 3B1D[E40F0300]      <1> 	cmp	ebx, [LFB_SIZE] ; [LFB_Info+LFBINFO.LFB_size]
 10607 0000FC2E 7606                <1> 	jna	short sysvideo_26_3
 10608 0000FC30 8B1D[E40F0300]      <1> 	mov	ebx, [LFB_SIZE]
 10609                              <1> sysvideo_26_3: 
 10610 0000FC36 52                  <1> 	push	edx
 10611 0000FC37 53                  <1> 	push	ebx	; buffer size in bytes
 10612 0000FC38 51                  <1> 	push	ecx	; user's buffer address
 10613 0000FC39 87D9                <1> 	xchg	ebx, ecx
 10614 0000FC3B C1E90C              <1> 	shr	ecx, 12 ; convert buffer size to page count
 10615 0000FC3E E83562FFFF          <1> 	call	direct_memory_access
 10616 0000FC43 59                  <1> 	pop	ecx	; user's buffer address
 10617 0000FC44 5B                  <1> 	pop	ebx	; buffer size
 10618 0000FC45 5A                  <1> 	pop	edx
 10619                              <1> 	;jc	short sysvideo_25 ; error !
 10620                              <1> 				  ; [u.r0] = 0
 10621                              <1> 	; 28/02/2021
 10622 0000FC46 7235                <1> 	jc	short sysvideo_27_0 ; error !	
 10623                              <1> 
 10624                              <1> ;sysvideo_26_4:
 10625                              <1> 	;mov	ebp, [u.usp] ; ebp points to user's registers
 10626                              <1> 	;mov	[ebp+20], edx ; return to user with EDX value 
 10627                              <1> 	;mov	[ebp+16], ebx ; EBX
 10628                              <1> 	;mov	[ebp+24], ecx ; ECX
 10629                              <1> 	; eax = physical address of video memory (LFB)
 10630                              <1> 	;mov	[u.r0], eax
 10631                              <1> 	;jmp	sysret
 10632 0000FC48 E92CFCFFFF          <1> 	jmp	sysvideo_26_4
 10633                              <1> 
 10634                              <1> sysvideo_26_5:
 10635 0000FC4D 66A1[060F0000]      <1> 	mov	ax, [def_LFB_addr] ; default LFB for mode 118h
 10636                              <1> 	; ah must be 0C0h or 0D0h or E0h
 10637                              <1> 	; others are nonsence !?
 10638 0000FC53 08E4                <1>  	or	ah, ah
 10639                              <1> 	;jz	short sysvideo_25 ; invalid lfb addr or
 10640                              <1> 			  	; it is not a vbe2 -bochs emu- 
 10641                              <1> 			  	; or vbe3 -real- video bios
 10642                              <1> 	; 28/02/2021
 10643 0000FC55 7426                <1> 	jz	short sysvideo_27_0 ; invalid LFB address
 10644                              <1>  
 10645 0000FC57 80FCF0              <1> 	cmp	ah, 0F0h  
 10646                              <1> 	;jnb	short sysvideo_25 ; nonsence !?
 10647                              <1> 	; 28/02/2021
 10648 0000FC5A 7321                <1> 	jnb	short sysvideo_27_0 ; nonsence !?
 10649                              <1> 
 10650 0000FC5C C1E010              <1> 	shl	eax, 16
 10651                              <1> 	;jz	short sysvideo_25 ; eax = 0 
 10652                              <1> 
 10653 0000FC5F 81FB00907E00        <1> 	cmp	ebx, 1920*1080*4 ; maximum value of possible
 10654                              <1> 				 ; buffer sizes
 10655 0000FC65 76CF                <1> 	jna	short sysvideo_26_3  ; buffer size is proper
 10656                              <1> 	; resize buffer to fit 4GB limit
 10657 0000FC67 BB00907E00          <1> 	mov	ebx, 1920*1080*4
 10658 0000FC6C EBC8                <1> 	jmp	short sysvideo_26_3
 10659                              <1> 
 10660                              <1> sysvideo_27:
 10661                              <1> 	; 23/07/2022
 10662                              <1> 	; 16/02/2021
 10663                              <1> 	; 18/01/2021
 10664 0000FC6E 80FF0C              <1> 	cmp	bh, 12
 10665                              <1> 	;ja	sysvideo_28 ; 19/01/2021
 10666                              <1> 	; 23/07/2022
 10667 0000FC71 7605                <1> 	jna	short sysvideo_27_24
 10668 0000FC73 E970010000          <1> 	jmp	sysvideo_28
 10669                              <1> 
 10670                              <1> sysvideo_27_24:	; 23/07/2022
 10671                              <1> 	; BH = 12
 10672                              <1> 	; Font sub functions.
 10673                              <1> 	; 12/02/2021
 10674                              <1> 	; 11/01/2021
 10675                              <1> 	; 10/01/2021
 10676                              <1> 	;   BL = 0 : Disable system font overwrite
 10677                              <1> 	;   BL = 1 : Enable system font overwrite
 10678                              <1> 	;   BL = 2 : Read system font 8x8
 10679                              <1> 	;   BL = 3 : Read system font 8x14
 10680                              <1> 	;   BL = 4 : Read system font 8x16
 10681                              <1> 	;   BL = 5 : Read user defined font 8x8
 10682                              <1> 	;   BL = 6 : Read user defined font 8x16
 10683                              <1> 	;   BL = 7 : Write system font 8x8
 10684                              <1> 	;   BL = 8 : Write system font 8x14
 10685                              <1> 	;   BL = 9 : Write system font 8x16
 10686                              <1> 	;   BL = 10 : Write user defined font 8x8
 10687                              <1> 	;   BL = 11 : Write user defined font 8x16
 10688                              <1> 	;
 10689                              <1> 	;  BL > 11 : invalid (not implemented)
 10690                              <1> 	;
 10691                              <1> 	; For BL = 1 to 11
 10692                              <1> 	;   ECX = number of characters (<= 256)
 10693                              <1> 	;   EDX = first character (ascii code in DL)
 10694                              <1> 	;   ESI = user's buffer address
 10695                              <1> 	;
 10696                              <1> 	; Return: EAX = character count 
 10697                              <1> 
 10698 0000FC78 80FB0B              <1> 	cmp	bl, 11
 10699 0000FC7B 7605                <1> 	jna	short sysvideo_27_1
 10700                              <1> sysvideo_27_0:
 10701 0000FC7D E99DD0FFFF          <1> 	jmp	sysret ; not implemented yet !		
 10702                              <1> sysvideo_27_1:
 10703 0000FC82 66B80001            <1> 	mov	ax, 256
 10704 0000FC86 08DB                <1> 	or	bl, bl
 10705 0000FC88 750E                <1>  	jnz	short sysvideo_27_3
 10706                              <1> 	
 10707                              <1> 	; bl = 0
 10708                              <1> 	; disable system font overwrite 
 10709                              <1> 
 10710 0000FC8A 8025[32100300]7F    <1> 	and	byte [ufont], 7Fh ; clear bit 7
 10711                              <1> sysvideo_27_2:
 10712                              <1> 	;mov	word [u.r0], 256  ; > 0 -> successful
 10713 0000FC91 A3[1C010300]        <1> 	mov	[u.r0], eax ; 256
 10714 0000FC96 EBE5                <1> 	jmp	short sysvideo_27_0
 10715                              <1> sysvideo_27_3:
 10716 0000FC98 80FB01              <1> 	cmp	bl, 1
 10717 0000FC9B 7710                <1> 	ja	short sysvideo_27_4
 10718                              <1> 
 10719                              <1> 	; bl = 1
 10720                              <1> 	; enable system font overwrite 
 10721                              <1> 	;	if [multi_tasking]= 0 and [u.uid] = 0
 10722                              <1> 
 10723                              <1> 	;cmp	byte [multi_tasking], 0 
 10724                              <1> 	;			; multi tasking enabled ?
 10725                              <1> 	;ja	short sysvideo_27_0 ; yes
 10726                              <1> 	;; 19/01/2021 
 10727                              <1> 	;; system maintenance or single user mode
 10728                              <1> 	;cmp	byte [u.uid], 0  ; root ?
 10729                              <1> 	;ja	short sysvideo_27_0 ; no
 10730                              <1> 
 10731                              <1> 	; 19/01/2021
 10732                              <1> 	; multi tasking & root check
 10733 0000FC9D E8EBFEFFFF          <1> 	call	sysvideo_22_4
 10734 0000FCA2 73D9                <1> 	jnc	short sysvideo_27_0 ; not permitted
 10735                              <1> 
 10736                              <1> 	; [multi_tasking]= 0 and [u.uid] = 0
 10737                              <1> 
 10738 0000FCA4 800D[32100300]80    <1> 	or	byte [ufont], 80h ; set bit 7
 10739                              <1> 		
 10740 0000FCAB EBE4                <1>  	jmp	short sysvideo_27_2
 10741                              <1> 
 10742                              <1> sysvideo_27_4:
 10743 0000FCAD 09C9                <1> 	or	ecx, ecx
 10744 0000FCAF 74CC                <1> 	jz	short sysvideo_27_0
 10745 0000FCB1 21D2                <1> 	and	edx, edx
 10746 0000FCB3 7410                <1> 	jz	short sysvideo_27_4_0
 10747                              <1> 	;mov	ax, 256
 10748 0000FCB5 39C1                <1> 	cmp	ecx, eax ; 256
 10749 0000FCB7 77C4                <1> 	ja	short sysvideo_27_0
 10750 0000FCB9 48                  <1> 	dec	eax
 10751 0000FCBA 39C2                <1> 	cmp	edx, eax ; 255
 10752 0000FCBC 77BF                <1> 	ja	short sysvideo_27_0
 10753 0000FCBE 40                  <1> 	inc	eax
 10754 0000FCBF 29D0                <1> 	sub	eax, edx ; 256 - DX
 10755 0000FCC1 39C8                <1> 	cmp	eax, ecx
 10756 0000FCC3 72B8                <1> 	jb	short sysvideo_27_0
 10757                              <1> 
 10758                              <1> sysvideo_27_4_0:
 10759 0000FCC5 89F5                <1> 	mov	ebp, esi
 10760                              <1> 
 10761 0000FCC7 80FB06              <1> 	cmp	bl, 6
 10762 0000FCCA 7768                <1> 	ja	short sysvideo_27_13
 10763 0000FCCC 7210                <1> 	jb	short sysvideo_27_5
 10764                              <1> 	; bl = 6
 10765 0000FCCE F605[32100300]10    <1> 	test	byte [ufont], 16 ; 8x16 user font loaded ?
 10766 0000FCD5 74A6                <1> 	jz	short sysvideo_27_0
 10767                              <1> 	; read 8x16 user defined font
 10768 0000FCD7 BE00400900          <1> 	mov	esi, VGAFONT16USER
 10769 0000FCDC EB0C                <1> 	jmp	short sysvideo_27_6
 10770                              <1> sysvideo_27_5:
 10771 0000FCDE 80FB04              <1> 	cmp	bl, 4
 10772 0000FCE1 7239                <1> 	jb	short sysvideo_27_11
 10773 0000FCE3 7721                <1> 	ja	short sysvideo_27_9
 10774                              <1> 	; bl = 4
 10775                              <1> 	; read 8x16 system font
 10776 0000FCE5 BE[1C640100]        <1> 	mov	esi, vgafont16
 10777                              <1> sysvideo_27_6:
 10778                              <1> 	; read 8x16 font
 10779                              <1> 	;shl	dx, 4 ; * 16
 10780                              <1> 	;shl	cx, 4 ; * 16 ; 16 bytes per char
 10781                              <1> 	; 23/07/2022
 10782 0000FCEA C1E204              <1> 	shl	edx, 4 ; * 16
 10783 0000FCED C1E104              <1> 	shl	ecx, 4 ; * 16
 10784                              <1> sysvideo_27_7:
 10785 0000FCF0 89EF                <1> 	mov	edi, ebp
 10786                              <1> 	;add	edi, edx ; 16/02/2021
 10787 0000FCF2 01D6                <1> 	add	esi, edx
 10788                              <1> 	; ecx = byte count
 10789                              <1> 	; esi = source (in system memory)
 10790                              <1> 	; edi = destination (in user memory)
 10791 0000FCF4 E860100000          <1> 	call	transfer_to_user_buffer
 10792 0000FCF9 7206                <1> 	jc	short sysvideo_27_8
 10793 0000FCFB 890D[1C010300]      <1> 	mov	[u.r0], ecx	
 10794                              <1> sysvideo_27_8:
 10795 0000FD01 E919D0FFFF          <1> 	jmp	sysret
 10796                              <1> sysvideo_27_9:
 10797                              <1> 	; bl = 5
 10798 0000FD06 F605[32100300]08    <1> 	test	byte [ufont], 8 ; 8x8 user font loaded ?
 10799 0000FD0D 74F2                <1> 	jz	short sysvideo_27_8
 10800                              <1> 	; read 8x8 user defined font
 10801 0000FD0F BE00500900          <1> 	mov	esi, VGAFONT8USER
 10802                              <1> sysvideo_27_10:
 10803                              <1> 	; read 8x8 font
 10804                              <1> 	;shl	dx, 3 ; * 8
 10805                              <1> 	;shl	cx, 3 ; * 8 ; 8 bytes per char
 10806                              <1> 	; 23/07/2022
 10807 0000FD14 C1E203              <1> 	shl	edx, 3 ; * 8
 10808 0000FD17 C1E103              <1> 	shl	ecx, 3 ; * 8
 10809 0000FD1A EBD4                <1> 	jmp	short sysvideo_27_7
 10810                              <1> 
 10811                              <1> sysvideo_27_11:
 10812 0000FD1C 80FB03              <1> 	cmp	bl, 3  ; 8x14 system font
 10813 0000FD1F 720C                <1> 	jb	short sysvideo_27_12 ; 8x8 system font
 10814                              <1> 	; bl = 3
 10815                              <1> 	; read 8x14 system font 
 10816                              <1> 	;mov	al, 14
 10817                              <1> 	;mul	dl
 10818                              <1> 	;mov	dx, ax
 10819                              <1> 	;push	edx
 10820                              <1> 	;mov	ax, 14
 10821                              <1> 	;mul	cx
 10822                              <1> 	;mov	cx, ax
 10823                              <1> 	;pop	edx
 10824 0000FD21 E8A5000000          <1> 	call	sysvideo_27_14
 10825 0000FD26 BE[1C560100]        <1> 	mov	esi, vgafont14
 10826 0000FD2B EBC3                <1> 	jmp	short sysvideo_27_7	
 10827                              <1> 	
 10828                              <1> sysvideo_27_12:
 10829                              <1> 	; bl = 2
 10830                              <1> 	; read 8x8 system font 
 10831 0000FD2D BE[1C4E0100]        <1> 	mov	esi, vgafont8
 10832 0000FD32 EBE0                <1> 	jmp	short sysvideo_27_10
 10833                              <1> 
 10834                              <1> sysvideo_27_13:
 10835                              <1> 	; overwrite font
 10836 0000FD34 80FB0A              <1> 	cmp	bl, 10
 10837 0000FD37 776E                <1> 	ja	short sysvideo_27_22 ; 8x16 user font
 10838 0000FD39 7224                <1> 	jb	short sysvideo_27_15
 10839                              <1> 	; bl = 10
 10840 0000FD3B BF00500900          <1> 	mov	edi, VGAFONT8USER
 10841 0000FD40 F605[32100300]08    <1> 	test	byte [ufont], 8 ; 8x8 user font loaded ?
 10842 0000FD47 7556                <1> 	jnz	short sysvideo_27_21 ; yes
 10843 0000FD49 08ED                <1> 	or	ch, ch ; cx = 256
 10844                              <1> 	;jnz	short sysvideo_27_21 ; 256 chars
 10845 0000FD4B 7406                <1> 	jz	short sysvideo_27_13_0
 10846 0000FD4D 66B90008            <1> 	mov	cx, 8*256
 10847 0000FD51 EB35                <1> 	jmp	short sysvideo_27_18_0
 10848                              <1> sysvideo_27_13_0:
 10849                              <1> 	; copy system font to user font before overwrite
 10850 0000FD53 BE[1C4E0100]        <1> 	mov	esi, vgafont8
 10851                              <1> 	;push	edi
 10852                              <1> 	;push	ecx
 10853                              <1> 	;mov	cl, 64
 10854                              <1> 	;rep	movsd
 10855                              <1> 	;pop	ecx
 10856                              <1> 	;pop	edi
 10857                              <1> 	;mov	esi, ebp ; user's font buffer
 10858 0000FD58 E880000000          <1> 	call	sysvideo_27_23
 10859 0000FD5D EB40                <1> 	jmp	short sysvideo_27_21
 10860                              <1> 
 10861                              <1> sysvideo_27_15:
 10862                              <1> 	; check system font overwrite permission
 10863 0000FD5F F605[32100300]80    <1> 	test	byte [ufont], 80h
 10864 0000FD66 7499                <1> 	jz	short sysvideo_27_8
 10865                              <1> 
 10866 0000FD68 80FB08              <1> 	cmp	bl, 8
 10867 0000FD6B 773A                <1> 	ja	short sysvideo_27_22 ; 8x16 system font
 10868 0000FD6D 722B                <1> 	jb	short sysvideo_27_20 ; 8x8 system font
 10869                              <1> 	; bl = 8
 10870                              <1> 	; overwrite 8x14 system font 
 10871                              <1> 	;mov	al, 14
 10872                              <1> 	;mul	dl
 10873                              <1> 	;mov	dx, ax
 10874                              <1> 	;push	edx
 10875                              <1> 	;mov	ax, 14
 10876                              <1> 	;mul	cx
 10877                              <1> 	;mov	cx, ax
 10878                              <1> 	;pop	edx
 10879 0000FD6F E857000000          <1> 	call	sysvideo_27_14
 10880 0000FD74 BF[1C560100]        <1> 	mov	edi, vgafont14
 10881 0000FD79 EB0B                <1> 	jmp	short sysvideo_27_18
 10882                              <1> sysvideo_27_16:
 10883                              <1> 	; bl = 9
 10884                              <1> 	; overwrite 8x16 system font
 10885 0000FD7B BF[1C640100]        <1> 	mov	edi, vgafont16
 10886                              <1> sysvideo_27_17:
 10887                              <1> 	; overwrite 8x16 font
 10888                              <1> 	;shl	dx, 4 ; * 16
 10889                              <1> 	;shl	cx, 4 ; * 16 ; 16 bytes per char
 10890                              <1> 	; 23/07/2022
 10891 0000FD80 C1E204              <1> 	shl	edx, 4 ; * 16
 10892 0000FD83 C1E104              <1> 	shl	ecx, 4 ; * 16
 10893                              <1> sysvideo_27_18:
 10894 0000FD86 01D7                <1> 	add	edi, edx
 10895                              <1> 	;add	esi, edx ; 16/02/2021
 10896                              <1> sysvideo_27_18_0:
 10897                              <1> 	; ecx = byte count
 10898                              <1> 	; esi = source (in user memory)
 10899                              <1> 	; edi = destination (in system memory)
 10900 0000FD88 E816100000          <1> 	call	transfer_from_user_buffer
 10901 0000FD8D 7206                <1> 	jc	short sysvideo_27_19
 10902 0000FD8F 890D[1C010300]      <1> 	mov	[u.r0], ecx	
 10903                              <1> sysvideo_27_19:
 10904 0000FD95 E985CFFFFF          <1> 	jmp	sysret
 10905                              <1> sysvideo_27_20:
 10906                              <1> 	; bl = 7
 10907                              <1> 	; overwrite 8x8 system font
 10908 0000FD9A BF[1C4E0100]        <1> 	mov	edi, vgafont8
 10909                              <1> sysvideo_27_21:
 10910                              <1> 	; overwrite 8x8 font
 10911                              <1> 	;shl	dx, 3 ; * 8
 10912                              <1> 	;shl	cx, 3 ; * 8 ; 8 bytes per char
 10913                              <1> 	; 23/07/2022
 10914 0000FD9F C1E203              <1> 	shl	edx, 3 ; * 8
 10915 0000FDA2 C1E103              <1> 	shl	ecx, 3 ; * 8
 10916 0000FDA5 EBDF                <1> 	jmp	short sysvideo_27_18
 10917                              <1> sysvideo_27_22:
 10918                              <1> 	; bl = 11
 10919                              <1> 	; overwrite 8x16 user defined font
 10920 0000FDA7 BF00400900          <1> 	mov	edi, VGAFONT16USER
 10921 0000FDAC F605[32100300]10    <1> 	test	byte [ufont], 16 ; 8x16 user font loaded ?
 10922 0000FDB3 75CB                <1> 	jnz	short sysvideo_27_17 ; yes
 10923 0000FDB5 08ED                <1> 	or	ch, ch ; cx = 256
 10924                              <1> 	;jnz	short sysvideo_27_17 ; 256 chars
 10925 0000FDB7 7406                <1> 	jz	short sysvideo_27_22_0
 10926 0000FDB9 66B90010            <1> 	mov	cx, 16*256
 10927 0000FDBD EBC9                <1> 	jmp	short sysvideo_27_18_0
 10928                              <1> sysvideo_27_22_0:
 10929                              <1> 	; copy system font to user font before overwrite
 10930 0000FDBF BE[1C640100]        <1> 	mov	esi, vgafont16
 10931                              <1> 	;push	edi
 10932                              <1> 	;push	ecx
 10933                              <1> 	;mov	cl, 64
 10934                              <1> 	;rep	movsd
 10935                              <1> 	;pop	ecx
 10936                              <1> 	;pop	edi
 10937                              <1> 	;mov	esi, ebp ; user's font buffer
 10938 0000FDC4 E814000000          <1> 	call	sysvideo_27_23
 10939 0000FDC9 EBB5                <1> 	jmp	short sysvideo_27_17
 10940                              <1> 
 10941                              <1> sysvideo_27_14:
 10942                              <1> 	; 16/02/2021
 10943 0000FDCB 52                  <1> 	push	edx
 10944 0000FDCC 66B80E00            <1> 	mov	ax, 14	
 10945 0000FDD0 66F7E1              <1> 	mul	cx
 10946 0000FDD3 89C1                <1> 	mov	ecx, eax
 10947 0000FDD5 5A                  <1> 	pop	edx
 10948 0000FDD6 B00E                <1> 	mov	al, 14
 10949 0000FDD8 F6E2                <1> 	mul	dl
 10950 0000FDDA 89C2                <1> 	mov	edx, eax
 10951 0000FDDC C3                  <1> 	retn
 10952                              <1> 
 10953                              <1> 	;mov	al, 14
 10954                              <1> 	;mul	dl
 10955                              <1> 	;mov	dx, ax
 10956                              <1> 	;push	edx
 10957                              <1> 	;; 12/02/2021
 10958                              <1> 	;mov	ax, 14
 10959                              <1> 	;;mov	eax, 14
 10960                              <1> 	;;mul	cx
 10961                              <1> 	;mul	ecx
 10962                              <1> 	;;mov	cx, ax
 10963                              <1> 	;mov	ecx, eax
 10964                              <1> 	;pop	edx
 10965                              <1> 	;retn	
 10966                              <1> 
 10967                              <1> sysvideo_27_23:
 10968 0000FDDD 57                  <1> 	push	edi
 10969 0000FDDE 51                  <1> 	push	ecx
 10970 0000FDDF B140                <1> 	mov	cl, 64
 10971 0000FDE1 F3A5                <1> 	rep	movsd
 10972 0000FDE3 59                  <1> 	pop	ecx
 10973 0000FDE4 5F                  <1> 	pop	edi
 10974 0000FDE5 89EE                <1> 	mov	esi, ebp ; user's font buffer
 10975 0000FDE7 C3                  <1> 	retn
 10976                              <1> 
 10977                              <1> sysvideo_28:
 10978                              <1> 	; 23/07/2022
 10979                              <1> 	; 24/01/2021
 10980                              <1> 	; 23/01/2021
 10981                              <1> 	; 18/01/2021
 10982 0000FDE8 80FF0E              <1> 	cmp	bh, 14
 10983                              <1> 	;jb	sysvideo_29
 10984                              <1> 	; 23/07/2022
 10985 0000FDEB 7222                <1> 	jb	short sysvideo_28_29
 10986                              <1> 	;ja	sysvideo_30
 10987                              <1> 	; 23/07/2022
 10988 0000FDED 7725                <1> 	ja	short sysvideo_28_30
 10989                              <1> 
 10990                              <1> 	; BH = 14
 10991                              <1> 	; Save/Restore Super VGA video state
 10992                              <1> 	
 10993                              <1> 	; BL = options
 10994                              <1> 	;	bit 0 - Save (0) or Restore (1)	
 10995                              <1> 	;	bit 1 - controller hardware state
 10996                              <1> 	;	bit 2 - BIOS data state
 10997                              <1> 	;	bit 3 - DAC state
 10998                              <1> 	;	bit 4 - (extended) Register state
 10999                              <1> 	;	bit 5 - system (0) or user (1) memory
 11000                              <1> 	;	bit 6 - verify without transfer
 11001                              <1> 	;	bit 7 - not used (must be 0)
 11002                              <1> 
 11003                              <1> 	; ECX = Buffer address or VideoStateID
 11004                              <1> 
 11005 0000FDEF 803D[79090000]02    <1> 	cmp	byte [vbe3], 2 ;  VESA VBE2 or VBE3 ?
 11006 0000FDF6 7721                <1> 	ja	short sysvideo_28_0 ; yes
 11007 0000FDF8 7210                <1> 	jb	short sysvideo_28_16 ; not a SVGA sys !
 11008                              <1> 
 11009                              <1> 	; == VBE2 ==
 11010                              <1> 	; Check Bochs/Qemu/VirtualBox PC emulator
 11011                              <1> 	; (vbe2 is usable only for emulator's vbios)
 11012 0000FDFA 8A25[7A090000]      <1> 	mov	ah, [vbe2bios]
 11013 0000FE00 80FCC0              <1> 	cmp	ah, 0C0h	
 11014 0000FE03 7205                <1> 	jb	short sysvideo_28_16 ; unknown vbios !
 11015 0000FE05 80FCC5              <1> 	cmp	ah, 0C5h
 11016 0000FE08 760F                <1> 	jna	short sysvideo_28_0
 11017                              <1> 		; Use kernel's vbios functions (video.s)
 11018                              <1> sysvideo_28_16:
 11019                              <1> 	; unknown vbios !
 11020 0000FE0A E910CFFFFF          <1> 	jmp	sysret
 11021                              <1> 
 11022                              <1> sysvideo_28_29:
 11023                              <1> 	; 23/07/2022
 11024 0000FE0F E955010000          <1> 	jmp	sysvideo_29
 11025                              <1> sysvideo_28_30:
 11026                              <1> 	; 23/07/2022
 11027 0000FE14 E935020000          <1> 	jmp	sysvideo_30	
 11028                              <1> 
 11029                              <1> sysvideo_28_0:
 11030 0000FE19 80FB7F              <1> 	cmp	bl, 7Fh
 11031 0000FE1C 77EC                <1> 	ja	short sysvideo_28_16 ; unknown options
 11032                              <1> 
 11033 0000FE1E 88DA                <1> 	mov	dl, bl
 11034 0000FE20 80E21F              <1> 	and	dl, 1Fh 
 11035 0000FE23 D0EA                <1> 	shr	dl, 1
 11036 0000FE25 74E3                <1> 	jz	short sysvideo_28_16 ; invalid !
 11037                              <1> 	; DL = VBE Function 4F04h Save/Restore options 	
 11038                              <1> 	;  bit 0 : controller hardware state
 11039                              <1> 	;  bit 1 : BIOS data state
 11040                              <1> 	;  bit 2 : DAC state
 11041                              <1> 	;  bit 3 : (extended) Register state
 11042                              <1> 	
 11043 0000FE27 F6C320              <1> 	test	bl, 32 ; bit 5
 11044                              <1> 	;jnz	sysvideo_28_7 ; user buffer
 11045                              <1> 	; 23/07/2022
 11046 0000FE2A 7405                <1> 	jz	short sysvideo_28_17
 11047 0000FE2C E9B1000000          <1> 	jmp	sysvideo_28_7
 11048                              <1> 
 11049                              <1> sysvideo_28_17:	 ; 23/07/2022
 11050                              <1> 	; source or destination is kernel/system buffer
 11051                              <1> 
 11052 0000FE31 803D[34100300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 11053 0000FE38 76D0                <1> 	jna	short sysvideo_28_16 ; not permitted
 11054                              <1> 
 11055 0000FE3A F6C301              <1> 	test	bl, 1
 11056 0000FE3D 743A                <1> 	jz	short sysvideo_28_4 ; Save
 11057                              <1> 
 11058                              <1> 	; Restore
 11059 0000FE3F 3B0D[36100300]      <1> 	cmp	ecx, [VideoStateID]
 11060 0000FE45 75C3                <1> 	jne	short sysvideo_28_16 ; not correct ID !
 11061                              <1> 		
 11062 0000FE47 0FB6CA              <1> 	movzx	ecx, dl
 11063 0000FE4A 80CA80              <1> 	or	dl, 80h
 11064 0000FE4D 3A15[35100300]      <1> 	cmp	dl, [srvso]
 11065 0000FE53 75B5                <1> 	jne	short sysvideo_28_16 ; not correct !
 11066                              <1> 
 11067 0000FE55 88DA                <1> 	mov	dl, bl
 11068                              <1> 
 11069                              <1> 	; ecx = cl = options
 11070 0000FE57 E8983CFFFF          <1> 	call	vbe_srs_gbs
 11071                              <1> 	; ebx = state buffer size (data size)
 11072                              <1> 
 11073 0000FE5C 891D[1C010300]      <1> 	mov	[u.r0], ebx
 11074                              <1> 
 11075 0000FE62 F6C240              <1> 	test	dl, 64 ; verify without transfer
 11076 0000FE65 75A3                <1> 	jnz	short sysvideo_28_16 ; yes
 11077                              <1> 
 11078 0000FE67 BE00580900          <1> 	mov	esi, VBE3VIDEOSTATE	
 11079 0000FE6C BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 11080 0000FE71 87CB                <1> 	xchg	ecx, ebx
 11081 0000FE73 F3A4                <1> 	rep	movsb
 11082                              <1> 	
 11083 0000FE75 88D9                <1> 	mov	cl, bl
 11084                              <1> 
 11085                              <1> 	; 23/01/2021
 11086 0000FE77 EB44                <1> 	jmp	short sysvideo_28_10
 11087                              <1> 
 11088                              <1> sysvideo_28_4:
 11089 0000FE79 53                  <1> 	push	ebx	
 11090                              <1> 	; 24/01/2021
 11091 0000FE7A 31DB                <1> 	xor	ebx, ebx ; 0 ; use kernel's buffer
 11092 0000FE7C 881D[35100300]      <1> 	mov	[srvso], bl ; 0 ; invalidate
 11093 0000FE82 891D[36100300]      <1> 	mov	[VideoStateID], ebx ; 0 ; invalidate
 11094 0000FE88 0FB6CA              <1> 	movzx	ecx, dl ; options
 11095 0000FE8B B201                <1> 	mov	dl, 1 ; save state		
 11096 0000FE8D E890000000          <1> 	call	sysvideo_28_11 ; 23/01/2021
 11097                              <1> 	; Note: VBE3 BIOS data save option will be
 11098                              <1> 	;	disabled.. ; 24/01/2021
 11099 0000FE92 89CA                <1> 	mov	edx, ecx ; state (save) options
 11100 0000FE94 5B                  <1> 	pop	ebx
 11101                              <1> 	
 11102 0000FE95 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 11103 0000FE99 7536                <1> 	jne	short sysvideo_28_3 ; no !
 11104                              <1> 
 11105 0000FE9B F6C340              <1> 	test	bl, 64 ; verify without transfer
 11106 0000FE9E 7536                <1> 	jnz	short sysvideo_28_6 ; yes
 11107                              <1> 
 11108                              <1> 	; ecx = cl = options
 11109 0000FEA0 E84F3CFFFF          <1> 	call	vbe_srs_gbs
 11110                              <1> 	; ebx = state buffer size (data size)
 11111                              <1> 
 11112 0000FEA5 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 11113 0000FEAA BF00580900          <1> 	mov	edi, VBE3VIDEOSTATE	
 11114 0000FEAF 89D9                <1> 	mov	ecx, ebx
 11115 0000FEB1 F3A4                <1> 	rep	movsb
 11116                              <1> 
 11117 0000FEB3 88D1                <1> 	mov	cl, dl
 11118 0000FEB5 80C980              <1> 	or	cl, 80h ; SVGA (VESA VBE) flag
 11119                              <1> 	;mov	[srvso], dl
 11120                              <1> 
 11121 0000FEB8 E908010000          <1> 	jmp	sysvideo_28_15
 11122                              <1> 
 11123                              <1> 	; 23/01/2021
 11124                              <1> sysvideo_28_10:
 11125                              <1> 	; CL = VESA VBE3 Save/Restore options
 11126                              <1> 
 11127 0000FEBD B202                <1> 	mov	dl, 2 ; restore state
 11128                              <1> 
 11129 0000FEBF E85C000000          <1> 	call	sysvideo_28_1
 11130                              <1> 
 11131 0000FEC4 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 11132 0000FEC8 7407                <1> 	je	short sysvideo_28_3
 11133                              <1> 	;jmp	short sysvideo_28_9 
 11134                              <1> 
 11135                              <1> sysvideo_28_9:
 11136                              <1> 	; return zero size (error) to user
 11137 0000FECA 29C0                <1> 	sub	eax, eax
 11138                              <1> sysvideo_28_5:
 11139 0000FECC A3[1C010300]        <1> 	mov	[u.r0], eax
 11140                              <1> sysvideo_28_3:
 11141 0000FED1 E949CEFFFF          <1> 	jmp	sysret
 11142                              <1> 
 11143                              <1> sysvideo_28_6:
 11144                              <1> 	; use timer ticks as VideoStateID
 11145 0000FED6 A1[08780100]        <1> 	mov	eax, [TIMER_LH]
 11146 0000FEDB 09C0                <1> 	or 	eax, eax
 11147 0000FEDD 75ED                <1> 	jnz	short sysvideo_28_5
 11148 0000FEDF 40                  <1> 	inc	eax
 11149 0000FEE0 EBEA                <1> 	jmp	short sysvideo_28_5
 11150                              <1> 
 11151                              <1> sysvideo_28_7:
 11152                              <1> 	; save/restore to/from user buffer
 11153                              <1> 
 11154                              <1> 	; 23/01/2021
 11155 0000FEE2 89CE                <1> 	mov	esi, ecx ; user's vstate buffer
 11156 0000FEE4 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 11157                              <1> 
 11158 0000FEE9 0FB6CA              <1> 	movzx	ecx, dl ; VESA VBE func 4F04h options
 11159                              <1> 
 11160                              <1> 	; source or destination is user buffer
 11161 0000FEEC F6C301              <1> 	test	bl, 1
 11162 0000FEEF 7444                <1> 	jz	short sysvideo_28_12  ; Save
 11163                              <1> 
 11164                              <1> 	; Restore
 11165 0000FEF1 803D[34100300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 11166 0000FEF8 766A                <1> 	jna	short sysvideo_28_14 ; not permitted
 11167                              <1> 
 11168 0000FEFA 88DA                <1> 	mov	dl, bl ; 'sysvideo' options
 11169                              <1> 
 11170                              <1> 	; ecx = cl = options
 11171 0000FEFC E8F33BFFFF          <1> 	call	vbe_srs_gbs
 11172                              <1> 	; ebx = state buffer size (data size)
 11173                              <1> 
 11174 0000FF01 891D[1C010300]      <1> 	mov	[u.r0], ebx ; transfer count
 11175                              <1> 
 11176 0000FF07 F6C240              <1> 	test	dl, 64 ; verify without transfer
 11177 0000FF0A 7558                <1> 	jnz	short sysvideo_28_14 ; yes
 11178                              <1>  
 11179 0000FF0C 6681FB0008          <1> 	cmp	bx, 2048
 11180 0000FF11 73B7                <1> 	jnb	short sysvideo_28_9 ; invalid
 11181                              <1> 
 11182 0000FF13 87CB                <1> 	xchg	ecx, ebx
 11183                              <1> 	; esi = user buffer
 11184                              <1> 	; edi = VBE3SAVERESTOREBLOCK
 11185                              <1> 
 11186 0000FF15 E8890E0000          <1> 	call	transfer_from_user_buffer
 11187 0000FF1A 72AE                <1> 	jc	short sysvideo_28_9 ; error 
 11188                              <1> 
 11189 0000FF1C 89D9                <1> 	mov	ecx, ebx ; Function 4F04h options
 11190 0000FF1E EB9D                <1> 	jmp	short sysvideo_28_10 ; 23/01/2021
 11191                              <1> 
 11192                              <1> sysvideo_28_1:
 11193 0000FF20 31DB                <1> 	xor	ebx, ebx ; 0 ; use kernel's buffer
 11194                              <1> sysvideo_28_11:
 11195                              <1> 	; 24/01/2021
 11196 0000FF22 803D[79090000]03    <1> 	cmp	byte [vbe3], 3
 11197 0000FF29 7405                <1> 	je	short sysvideo_28_2
 11198                              <1> 
 11199                              <1> 	; VESA VBE2 (BOCHS/QEMU/VBOX) video bios
 11200 0000FF2B E92D3BFFFF          <1> 	jmp	_vbe_biosfn_save_restore_state
 11201                              <1> sysvideo_28_2:
 11202                              <1> 	;24/01/2021
 11203                              <1> 	;mov	eax, 4F04h  ; Save/Restore vstate
 11204                              <1> 	; VESA VBE3 video bios
 11205 0000FF30 E9A31AFFFF          <1> 	jmp	_vbe3_pmfn_save_restore_state
 11206                              <1> 	
 11207                              <1> sysvideo_28_12:
 11208                              <1> 	; Save
 11209                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 11210                              <1> 
 11211                              <1> 	;movzx	ecx, dl ; options
 11212 0000FF35 56                  <1> 	push	esi
 11213 0000FF36 53                  <1> 	push	ebx
 11214                              <1> 	; 23/01/2021
 11215 0000FF37 B201                <1> 	mov	dl, 1 ; save state
 11216 0000FF39 E8E2FFFFFF          <1> 	call	sysvideo_28_1
 11217 0000FF3E 5A                  <1> 	pop	edx ; 'sysvideo' options
 11218 0000FF3F 5F                  <1> 	pop	edi ; user's video state buffer
 11219                              <1> 
 11220 0000FF40 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 11221 0000FF44 751E                <1> 	jne	short sysvideo_28_14 ; no !
 11222                              <1> 
 11223                              <1> 	; ecx = cl = options
 11224 0000FF46 E8A93BFFFF          <1> 	call	vbe_srs_gbs
 11225                              <1> 	; ebx = state buffer size (data size)
 11226                              <1> 
 11227 0000FF4B 89D9                <1> 	mov	ecx, ebx ; transfer count
 11228                              <1> 
 11229 0000FF4D F6C240              <1> 	test	dl, 64 ; verify without transfer
 11230 0000FF50 750C                <1> 	jnz	short sysvideo_28_13 ; yes
 11231                              <1> 		
 11232                              <1> 	;mov	edi, esi
 11233 0000FF52 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 11234 0000FF57 E8FD0D0000          <1> 	call	transfer_to_user_buffer
 11235 0000FF5C 7206                <1> 	jc	short sysvideo_28_14
 11236                              <1> sysvideo_28_13:
 11237 0000FF5E 890D[1C010300]      <1> 	mov	[u.r0], ecx
 11238                              <1> sysvideo_28_14:
 11239 0000FF64 E9B6CDFFFF          <1> 	jmp	sysret
 11240                              <1> 
 11241                              <1> sysvideo_29:
 11242                              <1> 	; 18/01/2021
 11243                              <1> 	; BH = 13
 11244                              <1> 	; Save/Restore std VGA video state
 11245                              <1> 
 11246                              <1> 	; bl = 0..3
 11247                              <1> 	;	save to or restore from
 11248                              <1> 	;	system buffer, VBE3VIDEOSTATE
 11249                              <1> 	;	ECX = VideoStateID for restoring	
 11250                              <1> 	; bl = 4..7
 11251                              <1> 	;	save to or restore from
 11252                              <1> 	;	user buffer pointed by ECX
 11253                              <1> 		   	
 11254 0000FF69 80FB03              <1> 	cmp	bl, 3
 11255 0000FF6C 7776                <1> 	ja	short sysvideo_29_6
 11256                              <1> 
 11257                              <1> 	; source or destination is kernel/system buffer
 11258                              <1> 
 11259 0000FF6E 803D[34100300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 11260 0000FF75 7668                <1> 	jna	short sysvideo_29_5 ; not permitted
 11261                              <1> 
 11262 0000FF77 F6C301              <1> 	test	bl, 1
 11263 0000FF7A 7437                <1> 	jz	short sysvideo_29_2  ; Save
 11264                              <1> 
 11265                              <1> 	; Restore
 11266 0000FF7C 3B0D[36100300]      <1> 	cmp	ecx, [VideoStateID]
 11267 0000FF82 755B                <1> 	jne	short sysvideo_29_5 ; not correct ID !
 11268 0000FF84 80FB01              <1> 	cmp	bl, 1
 11269 0000FF87 7709                <1> 	ja	short sysvideo_29_0
 11270                              <1> 	; bl = 1
 11271 0000FF89 BB6E000000          <1> 	mov	ebx, 110 
 11272 0000FF8E B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 11273 0000FF90 EB07                <1> 	jmp	short sysvideo_29_1
 11274                              <1> sysvideo_29_0:
 11275                              <1>  	; bl  = 3
 11276 0000FF92 BB72030000          <1> 	mov	ebx, 882 
 11277 0000FF97 B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 11278                              <1> sysvideo_29_1:
 11279 0000FF99 3A0D[35100300]      <1> 	cmp	cl, [srvso]
 11280 0000FF9F 753E                <1> 	jne	short sysvideo_29_5 ; not correct !
 11281                              <1> 
 11282 0000FFA1 BE00580900          <1> 	mov	esi, VBE3VIDEOSTATE ; 22/01/2021
 11283 0000FFA6 E8DD3CFFFF          <1> 	call	biosfn_restore_video_state
 11284 0000FFAB 891D[1C010300]      <1> 	mov	[u.r0], ebx ; video state size (bytes)
 11285                              <1> 	;jmp	sysret
 11286 0000FFB1 EB2C                <1> 	jmp	short sysvideo_29_5	
 11287                              <1> sysvideo_29_2:
 11288                              <1> 	;mov	esi, ecx
 11289 0000FFB3 BF00580900          <1> 	mov	edi, VBE3VIDEOSTATE
 11290                              <1> 	
 11291 0000FFB8 B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 11292 0000FFBA 08DB                <1> 	or	bl, bl
 11293 0000FFBC 7502                <1> 	jnz	short sysvideo_29_3 ; bl = 2
 11294                              <1> 	; bl = 0 
 11295 0000FFBE B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 11296                              <1> sysvideo_29_3:
 11297 0000FFC0 E85B3BFFFF          <1> 	call	biosfn_save_video_state
 11298                              <1> sysvideo_28_15:
 11299                              <1> 	; use timer ticks as VideoStateID
 11300 0000FFC5 A1[08780100]        <1> 	mov	eax, [TIMER_LH]
 11301 0000FFCA 21C0                <1> 	and 	eax, eax
 11302 0000FFCC 7501                <1> 	jnz	short sysvideo_29_4
 11303 0000FFCE 40                  <1> 	inc	eax
 11304                              <1> sysvideo_29_4:
 11305 0000FFCF 880D[35100300]      <1> 	mov	[srvso], cl
 11306 0000FFD5 A3[36100300]        <1> 	mov	[VideoStateID], eax
 11307 0000FFDA A3[1C010300]        <1> 	mov	[u.r0], eax
 11308                              <1> sysvideo_29_5:
 11309 0000FFDF E93BCDFFFF          <1> 	jmp	sysret
 11310                              <1> 
 11311                              <1> sysvideo_29_6:
 11312 0000FFE4 80FB07              <1> 	cmp	bl, 7
 11313 0000FFE7 77F6                <1> 	ja	short sysvideo_29_5 ; invalid sub function 
 11314                              <1> 
 11315 0000FFE9 89CE                <1> 	mov	esi, ecx
 11316 0000FFEB BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 11317                              <1> 
 11318                              <1> 	; source or destination is user buffer
 11319 0000FFF0 F6C301              <1> 	test	bl, 1
 11320 0000FFF3 7434                <1> 	jz	short sysvideo_29_9  ; Save
 11321                              <1> 
 11322                              <1> 	; Restore
 11323 0000FFF5 803D[34100300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 11324 0000FFFC 76E1                <1> 	jna	short sysvideo_29_5 ; not permitted
 11325                              <1> 	
 11326                              <1> 	;mov	esi, ecx
 11327                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 11328                              <1> 	
 11329 0000FFFE 80FB07              <1> 	cmp	bl, 7
 11330 00010001 7409                <1> 	je	short sysvideo_29_7
 11331                              <1> 	; bl = 5 
 11332 00010003 B303                <1> 	mov	bl, 3
 11333 00010005 B96E000000          <1> 	mov	ecx, 110
 11334 0001000A EB05                <1> 	jmp	short sysvideo_29_8
 11335                              <1> sysvideo_29_7:
 11336                              <1> 	; bl = 7
 11337 0001000C B972030000          <1> 	mov	ecx, 882
 11338                              <1> sysvideo_29_8:
 11339 00010011 E88D0D0000          <1> 	call	transfer_from_user_buffer
 11340 00010016 72C7                <1> 	jc	short sysvideo_29_5
 11341 00010018 890D[1C010300]      <1> 	mov	[u.r0], ecx
 11342 0001001E 88D9                <1> 	mov	cl, bl ; mov cl,7 (mov cl,3)
 11343 00010020 89FE                <1> 	mov	esi, edi ; VBE3SAVERESTOREBLOCK
 11344                              <1> 	; cl = 3 or 7  	
 11345 00010022 E8613CFFFF          <1> 	call	biosfn_restore_video_state
 11346 00010027 EBB6                <1> 	jmp	sysvideo_29_5
 11347                              <1> 	;jmp	sysret
 11348                              <1> sysvideo_29_9:
 11349                              <1> 	; Save
 11350                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 11351                              <1> 
 11352 00010029 80FB06              <1> 	cmp	bl, 6
 11353 0001002C 7409                <1> 	je	short sysvideo_29_10
 11354                              <1> 	; bl = 4
 11355 0001002E BB6E000000          <1> 	mov	ebx, 110
 11356 00010033 B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 11357 00010035 EB07                <1> 	jmp	short sysvideo_29_11
 11358                              <1> sysvideo_29_10:
 11359                              <1> 	; bl = 6
 11360 00010037 BB72030000          <1> 	mov	ebx, 882
 11361 0001003C B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 11362                              <1> sysvideo_29_11:
 11363 0001003E E8DD3AFFFF          <1> 	call	biosfn_save_video_state
 11364                              <1> 
 11365 00010043 89D9                <1> 	mov	ecx, ebx ; transfer count
 11366 00010045 89F7                <1> 	mov	edi, esi
 11367 00010047 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 11368                              <1> 
 11369                              <1> 	;call	transfer_to_user_buffer
 11370                              <1> 	;jc	short sysvideo_29_5
 11371                              <1> 	;mov	[u.r0], ecx ; transfer count
 11372                              <1> 	;;jmp	sysret
 11373                              <1> 	;jmp	short sysvideo_29_5
 11374                              <1>  
 11375 0001004C EB1A                <1> 	jmp	short sysvideo_29_12
 11376                              <1> 
 11377                              <1> sysvideo_30:	 
 11378 0001004E 80FF0F              <1> 	cmp	bh, 15
 11379 00010051 7722                <1> 	ja	short sysvideo_31 ; invalid function
 11380                              <1> 	
 11381                              <1> 	; BH = 15
 11382                              <1> 	; Copy VESA EDID to user's buffer
 11383                              <1> 	
 11384 00010053 803D[91410000]4F    <1> 	cmp	byte [edid], 4Fh
 11385 0001005A 7519                <1> 	jne	short sysvideo_31 ; not ready ! 
 11386                              <1> 
 11387                              <1> 	;and	ecx, ecx
 11388                              <1> 	;jz	short sysvideo_31
 11389                              <1> 
 11390                              <1> 	; ecx = user's buffer address
 11391 0001005C 89CF                <1> 	mov	edi, ecx
 11392 0001005E BE[500F0300]        <1> 	mov	esi, edid_info
 11393 00010063 B980000000          <1> 	mov	ecx, 128 ; 128 bytes
 11394                              <1> sysvideo_29_12:
 11395 00010068 E8EC0C0000          <1> 	call	transfer_to_user_buffer
 11396 0001006D 7206                <1> 	jc	short sysvideo_31
 11397                              <1> 
 11398 0001006F 890D[1C010300]      <1> 	mov	[u.r0], ecx ; EDID size, 128 bytes
 11399                              <1> sysvideo_31:
 11400 00010075 E9A5CCFFFF          <1> 	jmp	sysret
 11401                              <1> 
 11402                              <1> mkdir:
 11403                              <1> 	; 04/12/2015 (14 byte directory names)
 11404                              <1> 	; 12/10/2015
 11405                              <1> 	; 17/06/2015 (Retro UNIX 386 v1 - Beginning)
 11406                              <1> 	; 29/04/2013 - 01/08/2013 (Retro UNIX 8086 v1)
 11407                              <1> 	;
 11408                              <1> 	; 'mkdir' makes a directory entry from the name pointed to
 11409                              <1> 	; by u.namep into the current directory.
 11410                              <1> 	;
 11411                              <1> 	; INPUTS ->
 11412                              <1> 	;    u.namep - points to a file name 
 11413                              <1> 	;	           that is about to be a directory entry.
 11414                              <1> 	;    ii - current directory's i-number.	
 11415                              <1> 	; OUTPUTS ->
 11416                              <1> 	;    u.dirbuf+2 - u.dirbuf+10 - contains file name. 
 11417                              <1> 	;    u.off - points to entry to be filled 
 11418                              <1> 	;	     in the current directory		
 11419                              <1> 	;    u.base - points to start of u.dirbuf.
 11420                              <1> 	;    r1 - contains i-number of current directory 
 11421                              <1> 	;	
 11422                              <1> 	; ((AX = R1)) output
 11423                              <1> 	;
 11424                              <1> 	;    (Retro UNIX Prototype : 11/11/2012, UNIXCOPY.ASM)
 11425                              <1>         ;    ((Modified registers: EAX, EDX, EBX, ECX, ESI, EDI, EBP))  
 11426                              <1> 	;
 11427                              <1> 
 11428                              <1> 	; 17/06/2015 - 32 bit modifications (Retro UNIX 386 v1)
 11429 0001007A 31C0                <1> 	xor 	eax, eax
 11430 0001007C BF[56010300]        <1> 	mov     edi, u.dirbuf+2
 11431 00010081 89FE                <1> 	mov	esi, edi
 11432 00010083 AB                  <1> 	stosd
 11433 00010084 AB                  <1> 	stosd
 11434                              <1> 	; 04/12/2015 (14 byte directory names)
 11435 00010085 AB                  <1> 	stosd
 11436 00010086 66AB                <1> 	stosw
 11437                              <1> 		; jsr r0,copyz; u.dirbuf+2; u.dirbuf+10. / clear this
 11438 00010088 89F7                <1> 	mov	edi, esi ; offset to u.dirbuf
 11439                              <1> 	; 12/10/2015 ([u.namep] -> ebp)
 11440                              <1> 	;mov 	ebp, [u.namep]
 11441 0001008A E8CE040000          <1> 	call	trans_addr_nmbp ; convert virtual address to physical
 11442                              <1> 		; esi = physical address (page start + offset)
 11443                              <1> 		; ecx = byte count in the page (1 - 4096)
 11444                              <1> 	; edi = offset to u.dirbuf (edi is not modified in trans_addr_nm)
 11445                              <1> 		; mov u.namep,r2 / r2 points to name of directory entry
 11446                              <1> 		; mov $u.dirbuf+2,r3 / r3 points to u.dirbuf+2
 11447                              <1> mkdir_1: ; 1: 
 11448 0001008F 45                  <1> 	inc	ebp ; 12/10/2015
 11449                              <1> 	;
 11450                              <1> 	; / put characters in the directory name in u.dirbuf+2 - u.dirbuf+10
 11451                              <1> 	 ; 01/08/2013
 11452 00010090 AC                  <1> 	lodsb
 11453                              <1> 		; movb (r2)+,r1 / move character in name to r1
 11454 00010091 20C0                <1> 	and 	al, al
 11455 00010093 7427                <1> 	jz 	short mkdir_3 	  
 11456                              <1> 		; beq 1f / if null, done
 11457 00010095 3C2F                <1> 	cmp	al, '/'
 11458                              <1> 		; cmp r1,$'/ / is it a "/"?
 11459 00010097 7414                <1> 	je	short mkdir_err
 11460                              <1> 	;je	error
 11461                              <1> 		; beq error9 / yes, error
 11462                              <1> 	; 12/10/2015
 11463 00010099 6649                <1> 	dec	cx
 11464 0001009B 7505                <1> 	jnz	short mkdir_2
 11465                              <1> 	; 12/10/2015 ([u.namep] -> ebp)
 11466 0001009D E8C1040000          <1> 	call	trans_addr_nm ; convert virtual address to physical
 11467                              <1> 		; esi = physical address (page start + offset)
 11468                              <1> 		; ecx = byte count in the page
 11469                              <1> 	; edi = offset to u.dirbuf (edi is not modified in trans_addr_nm)
 11470                              <1> mkdir_2:
 11471 000100A2 81FF[64010300]      <1> 	cmp     edi, u.dirbuf+16 ; ; 04/12/2015 (10 -> 16) 
 11472                              <1> 		; cmp r3,$u.dirbuf+10. / have we reached the last slot for
 11473                              <1> 				     ; / a char?
 11474 000100A8 74E5                <1> 	je	short mkdir_1
 11475                              <1> 		; beq 1b / yes, go back
 11476 000100AA AA                  <1> 	stosb
 11477                              <1> 		; movb r1,(r3)+ / no, put the char in the u.dirbuf
 11478 000100AB EBE2                <1> 	jmp 	short mkdir_1
 11479                              <1> 		; br 1b / get next char
 11480                              <1> mkdir_err:
 11481                              <1> 	; 17/06/2015
 11482 000100AD C705[84010300]1300- <1> 	mov	dword [u.error], ERR_NOT_DIR ; 'not a valid directory !'
 11482 000100B5 0000                <1>
 11483 000100B7 E943CCFFFF          <1> 	jmp	error
 11484                              <1> 
 11485                              <1> mkdir_3: ; 1:
 11486 000100BC A1[34010300]        <1> 	mov	eax, [u.dirp]
 11487 000100C1 A3[3C010300]        <1> 	mov	[u.off], eax
 11488                              <1> 		; mov u.dirp,u.off / pointer to empty current directory
 11489                              <1> 				 ; / slot to u.off
 11490                              <1> wdir: ; 29/04/2013
 11491 000100C6 C705[40010300]-     <1>         mov     dword [u.base], u.dirbuf
 11491 000100CC [54010300]          <1>
 11492                              <1> 		; mov $u.dirbuf,u.base / u.base points to created file name
 11493 000100D0 C705[44010300]1000- <1>         mov     dword [u.count], 16 ; 04/12/2015 (10 -> 16) 
 11493 000100D8 0000                <1>
 11494                              <1> 		; mov $10.,u.count / u.count = 10
 11495 000100DA 66A1[20020300]      <1> 	mov	ax, [ii] 
 11496                              <1> 		; mov ii,r1 / r1 has i-number of current directory
 11497 000100E0 B201                <1> 	mov	dl, 1 ; owner flag mask ; RETRO UNIX 8086 v1 modification !
 11498 000100E2 E85E1C0000          <1> 	call 	access
 11499                              <1> 		; jsr r0,access; 1 / get i-node and set its file up 
 11500                              <1> 				 ; / for writing
 11501                              <1> 	; AX = i-number of current directory
 11502                              <1> 	; 01/08/2013
 11503 000100E7 FE05[82010300]      <1> 	inc     byte [u.kcall] ; the caller is 'mkdir' sign	
 11504 000100ED E8C60E0000          <1> 	call	writei
 11505                              <1> 		; jsr r0,writei / write into directory
 11506 000100F2 C3                  <1> 	retn	
 11507                              <1> 		; rts r0
 11508                              <1> 
 11509                              <1> sysexec:
 11510                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 11511                              <1> 	; 06/02/2022 - Retro UNIX 386 v1.2
 11512                              <1> 	; 18/11/2017
 11513                              <1> 	; 14/11/2017
 11514                              <1> 	; 13/11/2017
 11515                              <1> 	; 24/10/2016 - 04/01/2017
 11516                              <1> 	; 24/04/2016 - TRDOS 386 (TRDOS v2.0)
 11517                              <1> 	; 23/06/2015 - 23/10/2015 (Retro UNIX 386 v1)
 11518                              <1> 	; 03/06/2013 - 06/12/2013 (Retro UNIX 8086 v1)
 11519                              <1> 	;
 11520                              <1> 	; 'sysexec' initiates execution of a file whose path name if
 11521                              <1> 	; pointed to by 'name' in the sysexec call. 
 11522                              <1> 	; 'sysexec' performs the following operations:
 11523                              <1> 	;    1. obtains i-number of file to be executed via 'namei'.
 11524                              <1> 	;    2. obtains i-node of file to be exceuted via 'iget'.
 11525                              <1> 	;    3. sets trap vectors to system routines.
 11526                              <1> 	;    4. loads arguments to be passed to executing file into
 11527                              <1> 	;	highest locations of user's core
 11528                              <1> 	;    5. puts pointers to arguments in locations immediately
 11529                              <1> 	;	following arguments.
 11530                              <1> 	;    6.	saves number of arguments in next location.
 11531                              <1> 	;    7. initializes user's stack area so that all registers
 11532                              <1> 	;	will be zeroed and the PS is cleared and the PC set
 11533                              <1> 	;	to core when 'sysret' restores registers 
 11534                              <1> 	;	and does an rti.
 11535                              <1> 	;    8. initializes u.r0 and u.sp
 11536                              <1> 	;    9. zeros user's core down to u.r0
 11537                              <1> 	;   10.	reads executable file from storage device into core
 11538                              <1> 	;	starting at location 'core'.
 11539                              <1> 	;   11.	sets u.break to point to end of user's code with
 11540                              <1> 	;	data area appended.
 11541                              <1> 	;   12.	calls 'sysret' which returns control at location
 11542                              <1> 	;	'core' via 'rti' instruction.
 11543                              <1> 	;
 11544                              <1> 	; Calling sequence:
 11545                              <1> 	;	sysexec; namep; argp
 11546                              <1> 	; Arguments:
 11547                              <1> 	;	namep - points to pathname of file to be executed
 11548                              <1> 	;	argp  - address of table of argument pointers
 11549                              <1> 	;	argp1... argpn - table of argument pointers
 11550                              <1> 	;	argp1:<...0> ... argpn:<...0> - argument strings
 11551                              <1> 	; Inputs: (arguments)
 11552                              <1> 	; Outputs: -	
 11553                              <1> 	; ...............................................................
 11554                              <1> 	;
 11555                              <1> 	; Retro UNIX 386 v1 modification: 
 11556                              <1> 	;	User application runs in it's own virtual space 
 11557                              <1> 	;	which is izolated from kernel memory (and other
 11558                              <1> 	;	memory pages) via 80386	paging in ring 3 
 11559                              <1> 	;	privilige mode. Virtual start address is always 0.
 11560                              <1> 	;	User's core memory starts at linear address 400000h
 11561                              <1> 	;	(the end of the 1st 4MB).
 11562                              <1> 	;
 11563                              <1> 	; Retro UNIX 8086 v1 modification: 
 11564                              <1> 	;	user/application segment and system/kernel segment
 11565                              <1> 	;	are different and sysenter/sysret/sysrele routines
 11566                              <1> 	;	are different (user's registers are saved to 
 11567                              <1> 	;	and then restored from system's stack.)
 11568                              <1> 	;
 11569                              <1> 	;	NOTE: Retro UNIX 8086 v1 'arg2' routine gets these
 11570                              <1> 	;	      arguments which were in these registers;
 11571                              <1> 	;	      but, it returns by putting the 1st argument
 11572                              <1> 	;	      in 'u.namep' and the 2nd argument
 11573                              <1> 	;	      on top of stack. (1st argument is offset of the
 11574                              <1> 	;	      file/path name in the user's program segment.)
 11575                              <1> 	
 11576                              <1> 	;call	arg2
 11577                              <1> 	; * name - 'u.namep' points to address of file/path name
 11578                              <1> 	;          in the user's program segment ('u.segmnt')
 11579                              <1> 	;          with offset in BX register (as sysopen argument 1).
 11580                              <1> 	; * argp - sysexec argument 2 is in CX register 
 11581                              <1> 	;          which is on top of stack.
 11582                              <1> 	;
 11583                              <1> 		; jsr r0,arg2 / arg0 in u.namep,arg1 on top of stack
 11584                              <1> 
 11585                              <1> 	; 23/06/2015 (32 bit modifications)
 11586                              <1> 
 11587                              <1> 	;; 13/11/2017
 11588                              <1> 	;;mov	[u.namep], ebx ; argument 1
 11589                              <1>         ; 18/10/2015
 11590 000100F3 890D[18020300]      <1> 	mov     [argv], ecx  ; * ; argument 2
 11591                              <1> 
 11592                              <1> 	; 13/11/2017
 11593 000100F9 89DE                <1> 	mov	esi, ebx
 11594 000100FB E869200000          <1> 	call	set_working_path_x
 11595 00010100 7319                <1> 	jnc	short sysexec_0
 11596                              <1> 
 11597                              <1> 	;; 'bad command or file name'
 11598                              <1> 	;mov	eax, ERR_BAD_CMD_ARG ; 01h ; TRDOS 8086
 11599                              <1> 	
 11600                              <1> 	; 'file not found !' error
 11601 00010102 B802000000          <1> 	mov	eax, ERR_NOT_FOUND ; 02h ; TRDOS 8086
 11602                              <1> sysexec_not_found_err:
 11603                              <1> sysexec_access_error:
 11604                              <1> sysexec_ext_error:
 11605 00010107 A3[1C010300]        <1> 	mov	[u.r0], eax
 11606 0001010C A3[84010300]        <1> 	mov	[u.error], eax
 11607 00010111 E828210000          <1> 	call 	reset_working_path
 11608 00010116 E9E4CBFFFF          <1> 	jmp	error
 11609                              <1> 
 11610                              <1> sysexec_0:
 11611                              <1> 	; 13/11/2017
 11612                              <1> 	;mov	esi, FindFile_Name
 11613 0001011B 66B80018            <1>         mov	ax, 1800h ; Only files 
 11614 0001011F E81C89FFFF          <1> 	call	find_first_file
 11615 00010124 72E1                <1> 	jc	short sysexec_not_found_err ; eax = 2
 11616                              <1> 
 11617                              <1> 	; check_ file attributes
 11618                              <1> 	; (attribute bits = 00ADVSHR) ; 18h = Directory+Volume
 11619                              <1> 	; BL = Attributes byte
 11620                              <1> 	
 11621 00010126 F6C306              <1>         test	bl, 6  ; system file or hidden file (S+H) 
 11622                              <1> 	;jz	short sysexec_0ext
 11623 00010129 7417                <1> 	jz	short sysexec_1 ; yes
 11624                              <1> 
 11625                              <1> 	; 13/11/2017 
 11626                              <1> 	; /// TRDOS386 permission check for multiuser mode ///
 11627                              <1> 	; SYSTEM file or HIDDEN file !!
 11628                              <1> 	; (Only super user has permission to run this file.)
 11629                              <1> 	
 11630                              <1> 	; ([u.uid]=0 for super user or root in multiuser mode)
 11631                              <1> 	; ([u.uid]=0 for any users in singleuser mode) 
 11632 0001012B 803D[6E010300]00    <1> 	cmp 	byte [u.uid], 0 ; Super User ([u.uid]=0) ?
 11633                              <1> 	;jna	short sysexec_0ext
 11634 00010132 760E                <1> 	jna	short sysexec_1 ; yes 
 11635                              <1> 
 11636                              <1> 	; 'permission denied !' error  
 11637 00010134 B80B000000          <1>         mov	eax, ERR_FILE_ACCESS  ; 11 = ERR_PERM_DENIED
 11638 00010139 EBCC                <1>         jmp	short sysexec_access_error
 11639                              <1> 
 11640                              <1> sysexec_not_exf:
 11641                              <1> 	; 'not executable file !' error
 11642 0001013B B816000000          <1> 	mov	eax, ERR_NOT_EXECUTABLE
 11643 00010140 EBC5                <1> 	jmp	sysexec_ext_error
 11644                              <1> 
 11645                              <1> ;sysexec_0ext:
 11646                              <1> sysexec_1:
 11647                              <1> 	; 18/11/2017
 11648 00010142 BE[2C810100]        <1> 	mov	esi, FindFile_Name
 11649                              <1> 	; 13/11/2017
 11650                              <1> 	; check program file name extension
 11651                              <1> 	; ('.PRG' for current TRDOS version)
 11652 00010147 E8BFA2FFFF          <1> 	call	check_prg_filename_ext
 11653 0001014C 72ED                <1> 	jc	short sysexec_not_exf
 11654                              <1> 	
 11655                              <1> 	; 18/11/2017
 11656 0001014E 3C50                <1> 	cmp	al, 'P'
 11657 00010150 75E9                <1> 	jne	short sysexec_not_exf	
 11658                              <1> 
 11659                              <1> 	; '.PRG' extension is OK.
 11660                              <1> 	; Only '.PRG' files are valid program files
 11661                              <1> 	; for current TRDOS 386 version.
 11662                              <1> 
 11663 00010152 8B15[58810100]      <1> 	mov	edx, [FindFile_DirEntry+DirEntry_FileSize]
 11664 00010158 66A1[50810100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusHI]
 11665 0001015E C1E010              <1> 	shl	eax, 16
 11666 00010161 66A1[56810100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusLO]
 11667                              <1> 	; EAX = First Cluster number
 11668                              <1> 	; EDX = File Size
 11669                              <1> 
 11670 00010167 A3[20020300]        <1> 	mov	[ii], eax
 11671 0001016C 8915[24020300]      <1> 	mov	[i.size], edx
 11672                              <1> 
 11673                              <1> ;sysexec_1:
 11674                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 11675                              <1> 	; 06/02/2022 - Retro UNIX 386 v1.2
 11676                              <1> 	; 13/11/2017 - TRDOS 386 (TRDOS v2.0)
 11677                              <1> 	; 24/06/2015 - 23/10/2015 (Retro UNIX 386 v1)
 11678                              <1>         ; Moving arguments to the end of [u.upage]
 11679                              <1> 	; (by regarding page borders in user's memory space)
 11680                              <1> 	;
 11681                              <1> 	; 10/10/2015
 11682                              <1> 	; 21/07/2015
 11683                              <1> 	;mov	ebp, esp ; (**)
 11684                              <1> 	; 18/10/2015
 11685                              <1> 	;mov 	edi, ebp
 11686                              <1> 	; 23/07/2022
 11687 00010172 89E7                <1> 	mov	edi, esp ; (**)
 11688 00010174 B900010000          <1> 	mov 	ecx, MAX_ARG_LEN ; 256
 11689                              <1> 	;sub	edi, MAX_ARG_LEN ; 256
 11690 00010179 29CF                <1> 	sub	edi, ecx
 11691 0001017B 89FC                <1> 	mov	esp, edi ; *!*
 11692 0001017D 31C0                <1> 	xor	eax, eax
 11693 0001017F A3[48010300]        <1> 	mov 	[u.nread], eax ; 0
 11694                              <1> 	; ([argc] must be cleared because previous 'sysexec'
 11695                              <1> 	; may leave it with any value after an error))
 11696                              <1> 	;mov	[argc], ax ; 0 ; 13/11/2017
 11697                              <1> 	; 23/07/2022
 11698 00010184 A3[14020300]        <1> 	mov	[argc], eax ; 0
 11699 00010189 49                  <1> 	dec	ecx ; 256 - 1
 11700 0001018A 890D[44010300]      <1> 	mov 	[u.count], ecx ; MAX_ARG_LEN - 1 ; 255
 11701                              <1> 	;mov 	dword [u.count], MAX_ARG_LEN - 1 ; 255
 11702                              <1> sysexec_2:
 11703 00010190 8B35[18020300]      <1> 	mov	esi, [argv] ; 18/10/2015 
 11704 00010196 E87A020000          <1> 	call	get_argp
 11705                              <1> 	;mov	ecx, 4 
 11706                              <1> 	; 23/07/2022
 11707 0001019B 31C9                <1> 	xor	ecx, ecx
 11708 0001019D B104                <1> 	mov	cl, 4
 11709                              <1> sysexec_3:
 11710 0001019F 21C0                <1> 	and	eax, eax
 11711 000101A1 7453                <1>         jz	short sysexec_6 ; 23/07/2022
 11712                              <1> 	; 18/10/2015
 11713 000101A3 010D[18020300]      <1> 	add	[argv], ecx ; 4
 11714                              <1> 	;;inc	word [argc]
 11715                              <1> 	; 23/07/2022
 11716                              <1> 	;inc	dword [argc]
 11717 000101A9 FE05[14020300]      <1> 	inc	byte [argc]
 11718                              <1> 	;
 11719 000101AF A3[40010300]        <1> 	mov	[u.base], eax
 11720                              <1>  	; 23/10/2015
 11721 000101B4 66C705[80010300]00- <1> 	mov	word [u.pcount], 0
 11721 000101BC 00                  <1>
 11722                              <1> sysexec_4:
 11723 000101BD E8380B0000          <1> 	call	cpass ; get a character from user's core memory
 11724 000101C2 750B                <1>         jnz	short sysexec_5
 11725                              <1> 		; (max. 255 chars + null)
 11726                              <1> 	; 18/10/2015
 11727 000101C4 28C0                <1> 	sub 	al, al
 11728 000101C6 AA                  <1> 	stosb
 11729 000101C7 FF05[48010300]      <1> 	inc	dword [u.nread]
 11730                              <1> 	; 23/07/2022
 11731 000101CD EB27                <1> 	jmp	short sysexec_6 ; 24/04/2016
 11732                              <1> sysexec_5:
 11733 000101CF AA                  <1> 	stosb
 11734 000101D0 20C0                <1> 	and 	al, al
 11735 000101D2 75E9                <1> 	jnz	short sysexec_4
 11736                              <1> 	;mov	ecx, 4
 11737                              <1> 	; 23/07/2022
 11738 000101D4 31C9                <1> 	xor	ecx, ecx
 11739 000101D6 B104                <1> 	mov	cl, 4
 11740 000101D8 390D[10020300]      <1> 	cmp	[ncount], ecx ; 4
 11741 000101DE 72B0                <1> 	jb	short sysexec_2
 11742 000101E0 8B35[0C020300]      <1> 	mov	esi, [nbase]
 11743 000101E6 010D[0C020300]      <1> 	add	[nbase], ecx ; 4	
 11744                              <1> 	;sub	[ncount], cx 
 11745                              <1> 	; 23/07/2022
 11746 000101EC 290D[10020300]      <1> 	sub	[ncount], ecx
 11747 000101F2 8B06                <1> 	mov	eax, [esi]
 11748 000101F4 EBA9                <1> 	jmp	short sysexec_3
 11749                              <1> 
 11750                              <1> sysexec_6:
 11751                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 11752                              <1> 	; 19/11/2017
 11753                              <1> 	; 18/11/2017
 11754                              <1> 	; 14/11/2017
 11755                              <1> 	; 13/11/2017
 11756 000101F6 8925[18020300]      <1> 	mov	[argv], esp ; *!* ; start address of argument list 
 11757                              <1> 
 11758                              <1> 	; 04/01/2017
 11759                              <1> 	; 24/10/2016
 11760                              <1> 	;;02/05/2016
 11761                              <1> 	; 23/04/2016 (TRDOS 386)
 11762                              <1> 	; 18/10/2015 ('sysexec_6')
 11763                              <1> 	; 23/06/2015
 11764 000101FC A1[74010300]        <1> 	mov	eax, [u.pgdir] ; physical address of page directory
 11765                              <1> 	;cmp 	eax, [k_page_dir] ; TRDOS MainProg ? 
 11766                              <1> 	;je	short sysexec_7
 11767                              <1> 	; 19/11/2017
 11768 00010201 8B1D[78010300]      <1> 	mov	ebx, [u.ppgdir] ; phy addr of the parent's page dir
 11769 00010207 E8F955FFFF          <1> 	call	deallocate_page_dir
 11770                              <1> sysexec_7:
 11771 0001020C E82955FFFF          <1> 	call	make_page_dir
 11772                              <1> 	;jc	panic  ; allocation error 
 11773                              <1> 	;	       ; after a deallocation would be nonsence !?
 11774                              <1> 	; 23/07/2022
 11775 00010211 7243                <1> 	jc	short sysexec_panic
 11776                              <1> 
 11777                              <1> 	; 24/07/2015
 11778                              <1> 	; map kernel pages (1st 4MB) to PDE 0
 11779                              <1> 	;     of the user's page directory
 11780                              <1> 	;     (It is needed for interrupts!)
 11781                              <1> 	; 18/10/2015
 11782 00010213 8B15[88770100]      <1> 	mov	edx, [k_page_dir] ; Kernel's page directory
 11783 00010219 8B02                <1> 	mov	eax, [edx] ; physical address of
 11784                              <1> 			   ; kernel's first page table (1st 4 MB)
 11785                              <1> 			   ; (PDE 0 of kernel's page directory)
 11786 0001021B 8B15[74010300]      <1> 	mov 	edx, [u.pgdir]
 11787 00010221 8902                <1> 	mov	[edx], eax ; PDE 0 (1st 4MB)
 11788                              <1> 	;
 11789                              <1> 	; 20/07/2015
 11790 00010223 BB00004000          <1> 	mov	ebx, CORE ; start address = 0 (virtual) + CORE
 11791                              <1> 	; 18/10/2015
 11792 00010228 BE[04020300]        <1> 	mov	esi, pcore ; physical start address
 11793                              <1> sysexec_8:	
 11794 0001022D B907000000          <1> 	mov	ecx, PDE_A_USER + PDE_A_WRITE + PDE_A_PRESENT
 11795 00010232 E82155FFFF          <1> 	call	make_page_table
 11796                              <1> 	;jc	panic
 11797                              <1> 	; 23/07/2022
 11798 00010237 721D                <1> 	jc	short sysexec_panic
 11799                              <1> 	;
 11800                              <1> 	;mov	ecx, PTE_A_USER + PTE_A_WRITE + PTE_A_PRESENT
 11801 00010239 E82855FFFF          <1> 	call	make_page ; make new page, clear and set the pte 
 11802                              <1> 	;jc	panic
 11803                              <1> 	; 23/07/2022
 11804 0001023E 7216                <1> 	jc	short sysexec_panic
 11805                              <1> 	;
 11806 00010240 8906                <1> 	mov	[esi], eax ; 24/06/2015
 11807                              <1> 	; ebx = virtual address (24/07/2015)
 11808                              <1> 	; 23/07/2022
 11809                              <1> 	;call 	add_to_swap_queue
 11810                              <1> 	; 18/10/2015
 11811 00010242 81FE[08020300]      <1> 	cmp	esi, ecore ; user's stack (last) page ?
 11812 00010248 7411                <1> 	je	short sysexec_9 ; yes
 11813 0001024A BE[08020300]        <1> 	mov	esi, ecore  ; physical address of the last page 
 11814                              <1> 	; 20/07/2015
 11815 0001024F BB00F0FFFF          <1> 	mov	ebx, (ECORE - PAGE_SIZE) + CORE
 11816                              <1> 	; ebx = virtual end address + segment base address - 4K
 11817 00010254 EBD7                <1>         jmp     short sysexec_8
 11818                              <1> sysexec_panic:
 11819                              <1> 	; 23/07/2022
 11820 00010256 E95E6AFFFF          <1> 	jmp	panic
 11821                              <1> 
 11822                              <1> sysexec_9:
 11823                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 11824                              <1> 	; 19/11/2017 
 11825                              <1> 	; 24/04/2016 (TRDOS 386 = TRDOS v2.0)
 11826                              <1> 	; 25/06/2015 - 26/08/2015 - 18/10/2015
 11827                              <1> 	; move arguments from kernel stack to [ecore]
 11828                              <1> 	; (argument list/line will be copied from kernel stack
 11829                              <1> 	; frame to the last (stack) page of user's core memory)
 11830                              <1> 	; 18/10/2015
 11831 0001025B 8B3D[08020300]      <1> 	mov	edi, [ecore]
 11832 00010261 81C700100000        <1> 	add	edi, PAGE_SIZE
 11833                              <1> 	; 19/11/2017
 11834                              <1> 	;sub	edi, 4
 11835                              <1> 	;mov	dword [edi], 0 
 11836                              <1> 	;mov	ebx, edi
 11837                              <1> 	;
 11838                              <1> 	;movzx	eax, word [argc]
 11839                              <1> 	;or	eax, eax
 11840                              <1> 	;jz	short sysexec_13 ; 19/11/2017
 11841                              <1> 	;;jnz	short sysexec_10
 11842                              <1> 	;;mov 	ebx, edi
 11843                              <1> 	;;sub	ebx, 4 
 11844                              <1> 	;;mov	[ebx], eax ; 0
 11845                              <1> 	;;jmp 	short sysexec_13
 11846                              <1> 	; 23/07/2022
 11847                              <1> 	; [argc] < 32
 11848 00010267 A1[14020300]        <1> 	mov	eax, [argc]
 11849 0001026C 09C0                <1> 	or	eax, eax
 11850 0001026E 7509                <1> 	jnz	short sysexec_10
 11851 00010270 89FB                <1> 	mov 	ebx, edi
 11852 00010272 83EB04              <1> 	sub	ebx, 4 
 11853 00010275 8903                <1> 	mov	[ebx], eax ; 0
 11854 00010277 EB47                <1> 	jmp 	short sysexec_13
 11855                              <1> 
 11856                              <1> sysexec_10:
 11857 00010279 8B0D[48010300]      <1> 	mov	ecx, [u.nread]
 11858                              <1> 	; 13/11/2017
 11859                              <1> 	;;mov	esi, TextBuffer ; 'load_and_execute_file'
 11860                              <1> 	;mov	esi, esp  	; 'sysexec'
 11861 0001027F 8B35[18020300]      <1> 	mov	esi, [argv] ; 24/04/2016 (TRDOS 386  = TRDOS v2.0)
 11862                              <1> 	; 23/07/2022
 11863 00010285 29CF                <1> 	sub	edi, ecx ; page end address - argument list length
 11864                              <1> 	;sub	ebx, ecx ; 19/11/2017
 11865                              <1> 
 11866                              <1> 	;;;;
 11867                              <1> 	; 23/07/2022
 11868                              <1> 	; (move edi -backward- to dword boundary)
 11869                              <1> 	; ((this will prevent 'general protection fault' error
 11870                              <1> 	;  as result of a lodsd or dword move instruction
 11871                              <1> 	;  at the end of argument list))
 11872 00010287 83EF03              <1> 	sub	edi, 3
 11873 0001028A 83E7FC              <1> 	and	edi, ~3 ; (*)
 11874                              <1> 	;;;
 11875                              <1> 
 11876 0001028D 89C2                <1> 	mov	edx, eax
 11877 0001028F FEC2                <1> 	inc	dl ; argument count + 1 for argc value  
 11878 00010291 C0E202              <1> 	shl 	dl, 2  ; 4 * (argument count + 1)
 11879                              <1> 	; edx <= 128
 11880 00010294 89FB                <1> 	mov	ebx, edi
 11881                              <1> 	;mov	edi, ebx ; 19//11/2017
 11882                              <1> 	; 23/07/2022 (*) - edi is already dword aligned -
 11883                              <1> 	;and	bl, 0FCh ; 32 bit (dword) alignment
 11884 00010296 29D3                <1> 	sub 	ebx, edx
 11885 00010298 89FA                <1> 	mov	edx, edi
 11886 0001029A F3A4                <1> 	rep	movsb
 11887 0001029C 89D6                <1> 	mov 	esi, edx
 11888 0001029E 89DF                <1> 	mov 	edi, ebx
 11889 000102A0 BA00F0BFFF          <1> 	mov	edx, ECORE - PAGE_SIZE ; virtual addr. of the last page
 11890 000102A5 2B15[08020300]      <1> 	sub 	edx, [ecore] ; difference (virtual - physical) 
 11891 000102AB AB                  <1> 	stosd	; eax = argument count	
 11892                              <1> sysexec_11:
 11893 000102AC 89F0                <1> 	mov	eax, esi
 11894 000102AE 01D0                <1> 	add	eax, edx
 11895 000102B0 AB                  <1> 	stosd  ; eax = virtual address
 11896                              <1> 	; 23/07/2022
 11897 000102B1 FE0D[14020300]      <1> 	dec	byte [argc]
 11898                              <1> 	;dec	dword [argc]
 11899                              <1> 	;;dec	word [argc] ; 14/11/2017
 11900 000102B7 7407                <1> 	jz	short sysexec_13
 11901                              <1> sysexec_12:
 11902 000102B9 AC                  <1> 	lodsb
 11903 000102BA 20C0                <1> 	and	al, al
 11904 000102BC 75FB                <1> 	jnz	short sysexec_12
 11905 000102BE EBEC                <1> 	jmp	short sysexec_11
 11906                              <1> sysexec_13:
 11907                              <1> 	; 24/10/2016
 11908                              <1> 	; 24/04/2016 - TRDOS 386 (TRDOS v2.0)
 11909                              <1> 	; 23/06/2015 - 19/10/2015 (Retro UNIX 386 v1, 'sysexec_13')
 11910                              <1> 	;
 11911                              <1> 	; moving arguments to [ecore] is OK here..
 11912                              <1> 	;
 11913                              <1> 	; ebx = beginning addres of argument list pointers
 11914                              <1> 		;	in user's stack
 11915 000102C0 2B1D[08020300]      <1> 	sub 	ebx, [ecore]
 11916 000102C6 81C300F0BFFF        <1> 	add     ebx, (ECORE - PAGE_SIZE)
 11917                              <1> 			; end of core - 4096 (last page)
 11918                              <1> 			; (virtual address)
 11919 000102CC 891D[18020300]      <1> 	mov	[argv], ebx
 11920 000102D2 891D[4C010300]      <1> 	mov	[u.break], ebx ; available user memory
 11921                              <1> 	;
 11922 000102D8 29C0                <1> 	sub	eax, eax
 11923 000102DA C705[44010300]2000- <1> 	mov	dword [u.count], 32 ; Executable file header size
 11923 000102E2 0000                <1>
 11924 000102E4 C705[30010300]-     <1> 	mov	dword [u.fofp], u.off
 11924 000102EA [3C010300]          <1>
 11925 000102EE A3[3C010300]        <1> 	mov	[u.off], eax ; 0
 11926 000102F3 A3[40010300]        <1> 	mov	[u.base], eax ; 0, start of user's core (virtual)
 11927                              <1> 	; 24/10/2016
 11928 000102F8 A0[4A780100]        <1> 	mov	al, [Current_Drv]
 11929 000102FD A2[01010300]        <1> 	mov	[cdev], al
 11930                              <1> 	;
 11931 00010302 A1[20020300]        <1> 	mov	eax, [ii] ; Fist Cluster of the Program (PRG) file
 11932                              <1> 	; EAX = First cluster of the executable file
 11933 00010307 E893050000          <1> 	call	readi
 11934                              <1> 
 11935 0001030C 8B0D[4C010300]      <1> 	mov	ecx, [u.break] ; top of user's stack (physical addr.)
 11936 00010312 890D[44010300]      <1> 	mov	[u.count], ecx ; save for overrun check
 11937                              <1> 	;
 11938 00010318 8B0D[48010300]      <1> 	mov	ecx, [u.nread]
 11939 0001031E 890D[4C010300]      <1> 	mov	[u.break], ecx ; virtual address (offset from start)
 11940 00010324 80F920              <1> 	cmp	cl, 32
 11941 00010327 7540                <1>         jne     short sysexec_15
 11942                              <1> 	;:
 11943                              <1> 	; Retro UNIX 386 v1 (32 bit) executable file header format
 11944 00010329 8B35[04020300]      <1> 	mov	esi, [pcore] ; start address of user's core memory 
 11945                              <1> 		             ; (phys. start addr. of the exec. file)
 11946 0001032F AD                  <1> 	lodsd
 11947 00010330 663DEB1E            <1> 	cmp	ax, 1EEBh ; EBH, 1Eh -> jump to +32
 11948 00010334 7533                <1> 	jne	short sysexec_15
 11949 00010336 AD                  <1> 	lodsd
 11950 00010337 89C1                <1> 	mov	ecx, eax ; text (code) section size
 11951 00010339 AD                  <1> 	lodsd
 11952 0001033A 01C1                <1> 	add	ecx, eax ; + data section size (initialized data)
 11953 0001033C 89CB                <1> 	mov	ebx, ecx
 11954 0001033E AD                  <1> 	lodsd	
 11955 0001033F 01C3                <1> 	add	ebx, eax ; + bss section size (for overrun checking)
 11956 00010341 3B1D[44010300]      <1> 	cmp	ebx, [u.count]
 11957 00010347 7711                <1> 	ja	short sysexec_14  ; program overruns stack !
 11958                              <1> 	;
 11959                              <1> 	; add bss section size to [u.break]
 11960 00010349 0105[4C010300]      <1> 	add 	[u.break], eax
 11961                              <1> 	;
 11962 0001034F 83E920              <1> 	sub	ecx, 32  ; header size (already loaded)
 11963                              <1> 	;cmp	ecx, [u.count]
 11964                              <1> 	;jnb	short sysexec_16
 11965 00010352 890D[44010300]      <1> 	mov	[u.count], ecx ; required read count
 11966 00010358 EB29                <1> 	jmp	short sysexec_16
 11967                              <1> sysexec_14:
 11968                              <1> 	; insufficient (out of) memory
 11969 0001035A C705[84010300]0400- <1> 	mov	dword [u.error], ERR_MINOR_IM ; 1
 11969 00010362 0000                <1>
 11970 00010364 E996C9FFFF          <1> 	jmp	error
 11971                              <1> sysexec_15:
 11972 00010369 8B15[24020300]      <1>         mov	edx, [i.size] ; file size
 11973 0001036F 29CA                <1> 	sub	edx, ecx ; file size - loaded bytes
 11974 00010371 7626                <1> 	jna	short sysexec_17 ; no need to next read
 11975 00010373 01D1                <1> 	add	ecx, edx ; [i.size]
 11976 00010375 3B0D[44010300]      <1> 	cmp	ecx, [u.count] ; overrun check (!)
 11977 0001037B 77DD                <1> 	ja	short sysexec_14
 11978 0001037D 8915[44010300]      <1> 	mov	[u.count], edx
 11979                              <1> sysexec_16:
 11980 00010383 A1[20020300]        <1> 	mov	eax, [ii] ; first cluster
 11981 00010388 E812050000          <1> 	call	readi
 11982 0001038D 8B0D[48010300]      <1> 	mov	ecx, [u.nread]
 11983 00010393 010D[4C010300]      <1> 	add	[u.break], ecx
 11984                              <1> sysexec_17:
 11985 00010399 A1[20020300]        <1> 	mov	eax, [ii] ; first cluster
 11986 0001039E E8A2190000          <1> 	call	iclose
 11987 000103A3 31C0                <1> 	xor     eax, eax
 11988 000103A5 FEC0                <1> 	inc	al
 11989 000103A7 66A3[68010300]      <1> 	mov	[u.intr], ax ; 1 (interrupt/time-out is enabled)
 11990 000103AD 66A3[6A010300]      <1> 	mov	[u.quit], ax ; 1 ('crtl+brk' signal is enabled) 
 11991                              <1> 	; 23/07/2022
 11992 000103B3 FEC8                <1> 	dec	al
 11993                              <1> 	;cmp	dword [u.ppgdir], 0  ; is the caller MainProg (kernel) ?
 11994 000103B5 3905[78010300]      <1> 	cmp	[u.ppgdir], eax ; 0 ; 23/07/2022
 11995 000103BB 770C                <1> 	ja	short sysexec_18 ; no, the caller is user process
 11996                              <1> 	; If the caller is kernel (MainProg), 'sysexec' will come here
 11997 000103BD 8B15[88770100]      <1> 	mov	edx, [k_page_dir] ; kernel's page directory
 11998 000103C3 8915[78010300]      <1> 	mov	[u.ppgdir], edx ; next time 'sysexec' must not come here 
 11999                              <1> sysexec_18:
 12000                              <1> 	; 02/05/2016
 12001                              <1> 	; 24/04/2016 (TRDOS 386 = TRDOS v2.0)
 12002                              <1> 	; 18/10/2015 (Retro UNIX 386 v1)
 12003                              <1> 	; 05/08/2015
 12004                              <1> 	; 29/07/2015
 12005                              <1> 
 12006                              <1> ;	; **** arguments list test start - 19/11/2017
 12007                              <1> ;	mov	ebp, [argv]
 12008                              <1> ;	sub	ebp, ECORE - 4096
 12009                              <1> ;	add	ebp, [ecore]
 12010                              <1> ;
 12011                              <1> ;	mov	ebx, [ebp]
 12012                              <1> ;	mov	[argc], bx
 12013                              <1> ;	add	ebp, 4
 12014                              <1> ;	mov	byte [ccolor], 1Fh
 12015                              <1> ;_zx0:
 12016                              <1> ;	cmp	word [argc], 0
 12017                              <1> ;	jna	short _zx2
 12018                              <1> ;_zx1:
 12019                              <1> ;	push	ebp
 12020                              <1> ;	mov	esi, [ebp]
 12021                              <1> ;
 12022                              <1> ;	sub	esi, ECORE - 4096
 12023                              <1> ;	add	esi, [ecore]
 12024                              <1> ;
 12025                              <1> ;	call	print_cmsg
 12026                              <1> ;
 12027                              <1> ;	dec	word [argc]
 12028                              <1> ;	jz	short _zx2
 12029                              <1> ;
 12030                              <1> ;	mov	al, '.'
 12031                              <1> ;	mov	bl, 07h
 12032                              <1> ;	mov	bh, [u.ttyn]
 12033                              <1> ;	call 	_write_tty 
 12034                              <1> ;
 12035                              <1> ;	pop	ebp
 12036                              <1> ;	add	ebp, 4
 12037                              <1> ;	jmp	short _zx1
 12038                              <1> ;_zx2:
 12039                              <1> ;	pop	ebp
 12040                              <1> ;	mov	byte [ccolor], 07h
 12041                              <1> ;	mov	eax, 1
 12042                              <1> ;	; **** arguments list test stop
 12043                              <1> ;	Test result is OK! (there is not a wrong thing) - 19/11/2017
 12044                              <1> 
 12045 000103C9 8B2D[18020300]      <1> 	mov	ebp, [argv] ; user's stack pointer must point to argument
 12046                              <1> 			    ; list pointers (argument count)
 12047 000103CF FA                  <1> 	cli
 12048 000103D0 8B25[24770100]      <1>         mov     esp, [tss.esp0] ; ring 0 (kernel) stack pointer
 12049                              <1> 	;mov   	esp, [u.sp] ; Restore Kernel stack
 12050                              <1> 			    ; for this process	 
 12051                              <1> 	;add	esp, 20 ; --> EIP, CS, EFLAGS, ESP, SS
 12052                              <1> 	;;xor	eax, eax ; 0
 12053                              <1> 	; 23/07/2022
 12054                              <1> 	;dec	al ; eax = 0
 12055                              <1> 	; eax = 0
 12056                              <1> 
 12057                              <1> 	;mov	edx, UDATA
 12058                              <1> 	; 18/11/2017
 12059 000103D6 6A23                <1> 	push	UDATA ; user's stack segment
 12060                              <1> 	;push	edx
 12061 000103D8 55                  <1> 	push	ebp ; user's stack pointer
 12062                              <1> 		    ; (points to number of arguments)
 12063                              <1> 	
 12064                              <1> 	; 04/01/2017
 12065                              <1> 	; MainProg comes here while [sysflg]= 0FFh
 12066                              <1> 	; (but sysexec comes here while [sysflg]= 0)
 12067 000103D9 C605[10010300]00    <1> 	mov	byte [sysflg], 0 ; 04/01/2017
 12068                              <1> 				 ; (timer_int sysflg control)
 12069 000103E0 FB                  <1> 	sti
 12070 000103E1 9C                  <1> 	pushfd	; EFLAGS
 12071                              <1> 		; Set IF for enabling interrupts in user mode
 12072                              <1> 	;or	dword [esp], 200h 
 12073                              <1> 	;
 12074                              <1> 	;mov	bx, UCODE
 12075                              <1> 	;push	bx ; user's code segment
 12076 000103E2 6A1B                <1> 	push	UCODE
 12077                              <1> 	;push	0
 12078 000103E4 50                  <1> 	push	eax ; EIP (=0) - start address -
 12079 000103E5 8925[14010300]      <1> 	mov	[u.sp], esp ; 29/07/2015
 12080                              <1> 	; 05/08/2015
 12081                              <1> 	; Remedy of a General Protection Fault during 'iretd' is here !
 12082                              <1> 	; ('push dx' would cause to general protection fault, 
 12083                              <1> 	; after 'pop ds' etc.)
 12084                              <1> 	;
 12085                              <1> 	;; push dx ; ds (UDATA)
 12086                              <1> 	;; push dx ; es (UDATA)
 12087                              <1> 	;; push dx ; fs (UDATA)
 12088                              <1> 	;; push dx ; gs (UDATA)
 12089                              <1> 	;
 12090                              <1> 	; This is a trick to prevent general protection fault
 12091                              <1> 	; during 'iretd' intruction at the end of 'sysrele' (in u1.s):
 12092 000103EB 66BA2300            <1> 	mov	dx, UDATA ; 19/11/2017
 12093 000103EF 8EC2                <1> 	mov 	es, dx ; UDATA
 12094 000103F1 06                  <1> 	push 	es ; ds (UDATA)
 12095 000103F2 06                  <1> 	push 	es ; es (UDATA)
 12096 000103F3 06                  <1> 	push 	es ; fs (UDATA)
 12097 000103F4 06                  <1> 	push	es ; gs (UDATA)
 12098 000103F5 66BA1000            <1> 	mov	dx, KDATA
 12099 000103F9 8EC2                <1> 	mov	es, dx
 12100                              <1> 	;
 12101                              <1> 	;; pushad simulation
 12102 000103FB 89E5                <1> 	mov	ebp, esp ; esp before pushad
 12103 000103FD 50                  <1> 	push	eax ; eax (0)
 12104 000103FE 50                  <1> 	push	eax ; ecx (0)
 12105 000103FF 50                  <1> 	push	eax ; edx (0)
 12106 00010400 50                  <1> 	push	eax ; ebx (0)
 12107 00010401 55                  <1> 	push	ebp ; esp before pushad
 12108 00010402 50                  <1> 	push	eax ; ebp (0)
 12109 00010403 50                  <1> 	push	eax ; esi (0)		
 12110 00010404 50                  <1> 	push	eax ; edi (0)	
 12111                              <1> 	;
 12112 00010405 A3[1C010300]        <1> 	mov	[u.r0], eax ; eax = 0
 12113 0001040A 8925[18010300]      <1> 	mov	[u.usp], esp
 12114                              <1> 
 12115                              <1> 	; 14/11/2017
 12116 00010410 E90CC9FFFF          <1> 	jmp	sysret0
 12117                              <1> 
 12118                              <1> get_argp:
 12119                              <1> 	; 08/08/2022
 12120                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 12121                              <1> 	; 11/12/2021 - Retro UNIX 386 v1.2 
 12122                              <1> 	; 14/11/2017 - TRDOS 386 (TRDOS v2.0)
 12123                              <1> 	; 18/10/2015 (nbase, ncount)
 12124                              <1> 	; 21/07/2015
 12125                              <1> 	; 24/06/2015 (Retro UNIX 386 v1)
 12126                              <1> 	; Get (virtual) address of argument from user's core memory
 12127                              <1> 	;
 12128                              <1> 	; INPUT:
 12129                              <1> 	;	esi = virtual address of argument pointer
 12130                              <1> 	; OUTPUT:
 12131                              <1> 	;	eax = virtual address of argument
 12132                              <1> 	;
 12133                              <1> 	; Modified registers: EAX, EBX, ECX, EDX, ESI 
 12134                              <1> 	;
 12135 00010415 833D[78010300]00    <1>  	cmp     dword [u.ppgdir], 0 ; /etc/init ?
 12136                              <1> 				    ; (the caller is kernel)
 12137                              <1> 	;jna	short get_argpk
 12138                              <1> 	; 08/08/2022
 12139 0001041C 7705                <1> 	ja	short get_argp5
 12140 0001041E E985000000          <1> 	jmp	get_argpk
 12141                              <1> get_argp5:
 12142 00010423 89F3                <1>      	mov	ebx, esi
 12143 00010425 E88D56FFFF          <1> 	call	get_physical_addr ; get physical address
 12144 0001042A 7253                <1>         jc      short get_argp_err ; 23/07/2022
 12145 0001042C A3[0C020300]        <1> 	mov 	[nbase], eax ; physical address	
 12146                              <1> 	;mov	[ncount], cx ; remain byte count in page (1-4096)
 12147                              <1> 	; 23/07/2022
 12148 00010431 890D[10020300]      <1> 	mov	[ncount], ecx
 12149                              <1> 	;mov	eax, 4 ; 21/07/2015
 12150 00010437 31C0                <1> 	xor	eax, eax
 12151 00010439 B004                <1> 	mov	al, 4
 12152                              <1> 	;cmp	cx, ax ; 4
 12153                              <1> 	; 23/07/2022
 12154 0001043B 39C1                <1> 	cmp	ecx, eax ; 4
 12155 0001043D 7354                <1> 	jnb	short get_argp2
 12156 0001043F 89F3                <1> 	mov	ebx, esi
 12157 00010441 01CB                <1> 	add	ebx, ecx
 12158 00010443 E86F56FFFF          <1> 	call	get_physical_addr ; get physical address
 12159 00010448 7235                <1> 	jc	short get_argp_err
 12160                              <1> 	;push	esi
 12161 0001044A 89C6                <1> 	mov	esi, eax
 12162                              <1> 	;xchg	cx, [ncount]
 12163                              <1> 	; 23/07/2022
 12164 0001044C 870D[10020300]      <1> 	xchg	ecx, [ncount]
 12165 00010452 8735[0C020300]      <1> 	xchg	esi, [nbase]
 12166 00010458 B504                <1> 	mov	ch, 4
 12167 0001045A 28CD                <1> 	sub	ch, cl
 12168                              <1> get_argp0:
 12169 0001045C AC                  <1> 	lodsb
 12170                              <1> 	;push	ax
 12171                              <1> 	; 23/07/2022
 12172 0001045D 50                  <1> 	push	eax
 12173 0001045E FEC9                <1> 	dec	cl
 12174 00010460 75FA                <1>         jnz     short get_argp0
 12175 00010462 8B35[0C020300]      <1> 	mov	esi, [nbase]
 12176                              <1> 	; 21/07/2015
 12177 00010468 0FB6C5              <1> 	movzx	eax, ch
 12178 0001046B 0105[0C020300]      <1> 	add	[nbase], eax
 12179                              <1> 	;sub	[ncount], ax
 12180                              <1> 	; 23/07/2022
 12181 00010471 2905[10020300]      <1> 	sub	[ncount], eax
 12182                              <1> get_argp1:
 12183 00010477 AC                  <1> 	lodsb
 12184 00010478 FECD                <1> 	dec	ch
 12185 0001047A 7445                <1>         jz      short get_argp3
 12186                              <1>         ;push	ax
 12187                              <1> 	; 23/07/2022
 12188 0001047C 50                  <1> 	push	eax
 12189 0001047D EBF8                <1> 	jmp     short get_argp1
 12190                              <1> get_argp_err:
 12191 0001047F A3[84010300]        <1> 	mov	[u.error], eax
 12192                              <1> 	; 14/11/2017
 12193 00010484 B801000000          <1> 	mov	eax, ERR_BAD_CMD_ARG ; 01h ; TRDOS 8086
 12194 00010489 A3[1C010300]        <1> 	mov	[u.r0], eax
 12195 0001048E E96CC8FFFF          <1> 	jmp	error
 12196                              <1> get_argp2:
 12197                              <1> 	; 21/07/2015
 12198                              <1> 	;mov	eax, 4
 12199 00010493 8B15[0C020300]      <1> 	mov 	edx, [nbase] ; 18/10/2015
 12200 00010499 0105[0C020300]      <1> 	add	[nbase], eax
 12201                              <1> 	;sub	[ncount], ax
 12202                              <1> 	; 23/07/2022
 12203 0001049F 2905[10020300]      <1> 	sub	[ncount], eax
 12204                              <1> 	;
 12205 000104A5 8B02                <1> 	mov	eax, [edx]
 12206 000104A7 C3                  <1> 	retn
 12207                              <1> get_argpk:
 12208                              <1> 	; Argument is in kernel's memory space
 12209 000104A8 66C705[10020300]00- <1> 	mov	word [ncount], PAGE_SIZE ; 4096
 12209 000104B0 10                  <1>
 12210 000104B1 8935[0C020300]      <1> 	mov	[nbase], esi
 12211 000104B7 8305[0C020300]04    <1> 	add	dword [nbase], 4
 12212 000104BE 8B06                <1> 	mov	eax, [esi] ; virtual addr. = physical addr.
 12213 000104C0 C3                  <1> 	retn
 12214                              <1> get_argp3:
 12215 000104C1 B103                <1> 	mov	cl, 3
 12216                              <1> get_argp4:
 12217 000104C3 C1E008              <1> 	shl	eax, 8
 12218                              <1> 	;pop	dx
 12219                              <1> 	; 23/07/2022
 12220 000104C6 5A                  <1> 	pop	edx
 12221 000104C7 88D0                <1> 	mov 	al, dl
 12222 000104C9 E2F8                <1>         loop    get_argp4
 12223                              <1> 	;pop	esi
 12224 000104CB C3                  <1> 	retn
 12225                              <1> 
 12226                              <1> 	; 23/07/2022
 12227                              <1> %if 0	
 12228                              <1> 
 12229                              <1> sysstat: 
 12230                              <1> 	; 13/01/2017 - TRDOS 386 (TRDOS v2.0)
 12231                              <1> 	; temporary !
 12232                              <1> 	mov	eax, ERR_INV_FNUMBER ; 'invalid function number !'
 12233                              <1>         mov     [u.error], eax
 12234                              <1>         mov     [u.r0], eax 
 12235                              <1> 	jmp	error
 12236                              <1> 
 12237                              <1> sysfstat: 
 12238                              <1> 	; 13/01/2017 - TRDOS 386 (TRDOS v2.0)
 12239                              <1> 	; temporary !
 12240                              <1> 	mov	eax, ERR_INV_FNUMBER ; 'invalid function number !'
 12241                              <1>         mov     [u.error], eax
 12242                              <1>         mov     [u.r0], eax 
 12243                              <1> 	jmp	error
 12244                              <1> 
 12245                              <1> %endif
 12246                              <1> 
 12247                              <1> fclose:
 12248                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 12249                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 12250                              <1> 	;
 12251                              <1> 	; 18/06/2015 (Retro UNIX 386 v1 - Beginning)
 12252                              <1> 	;            (32 bit offset pointer modification)
 12253                              <1> 	; 19/04/2013 - 12/01/2014 (Retro UNIX 8086 v1)
 12254                              <1> 	;
 12255                              <1> 	; Given the file descriptor (index to the u.fp list)
 12256                              <1> 	; 'fclose' first gets the i-number of the file via 'getf'.
 12257                              <1> 	; If i-node is active (i-number > 0) the entry in 
 12258                              <1> 	; u.fp list is cleared. If all the processes that opened
 12259                              <1> 	; that file close it, then fsp etry is freed and the file
 12260                              <1> 	; is closed. If not a return is taken. 
 12261                              <1> 	; If the file has been deleted while open, 'anyi' is called
 12262                              <1> 	; to see anyone else has it open, i.e., see if it is appears
 12263                              <1> 	; in another entry in the fsp table. Upon return from 'anyi'
 12264                              <1> 	; a check is made to see if the file is special.
 12265                              <1> 	;
 12266                              <1> 	; INPUTS ->
 12267                              <1> 	;    r1 - contains the file descriptor (value=0,1,2...)
 12268                              <1> 	;    u.fp - list of entries in the fsp table
 12269                              <1> 	;    fsp - table of entries (4 words/entry) of open files. 
 12270                              <1> 	; OUTPUTS ->
 12271                              <1> 	;    r1 - contains the same file descriptor
 12272                              <1> 	;    r2 - contains i-number
 12273                              <1> 	;
 12274                              <1> 	; ((AX = R1))
 12275                              <1> 	; ((Modified registers: EDX, EBX, ECX, ESI, EDI, EBP))
 12276                              <1> 	;
 12277                              <1> 	; Retro UNIX 8086 v1 modification : CF = 1
 12278                              <1> 	;              if i-number of the file is 0. (error)
 12279                              <1> 	;
 12280                              <1> 	; TRDOS 386 (06/10/2016)
 12281                              <1> 	; 
 12282                              <1> 	; INPUT:
 12283                              <1> 	;	EAX = File Handle (File Descriptor, File Index)
 12284                              <1> 	;
 12285                              <1> 	; OUTPUT:
 12286                              <1> 	;	CF = 1 -> File not open !
 12287                              <1> 	;	CF = 0 -> OK!
 12288                              <1> 	;	     EBX = File Number (System)
 12289                              <1> 	;	     [cdev] = Logical DOS Drive Number
 12290                              <1> 	;	     EAX = File Handle/Number (user)
 12291                              <1> 	;
 12292                              <1> 	; Modified Registers: EBX
 12293                              <1> 
 12294 000104CC 50                  <1> 	push	eax ; File handle
 12295                              <1> 	
 12296 000104CD E846000000          <1> 	call	getf
 12297                              <1> 	;jc	device_close ; eax = device number
 12298                              <1> 	; 17/04/2021 (temporary)
 12299 000104D2 7306                <1> 	jnc	short _fclose_0
 12300 000104D4 58                  <1> 	pop	eax
 12301 000104D5 E943CFFFFF          <1> 	jmp	rw2 ; file not open !
 12302                              <1> _fclose_0:
 12303 000104DA 80BB[E4840100]01    <1> 	cmp	byte [ebx+OF_MODE], 1 ; open mode ; 0 = empty entry
 12304 000104E1 722C                <1> 	jb	short fclose_1	      ; 1 = read, 2 = write
 12305                              <1> 	
 12306 000104E3 83F801              <1> 	cmp	eax, 1 ; is the first cluster number > 0
 12307 000104E6 7227                <1> 	jb	short fclose_1 ; no, this is empty entry
 12308                              <1> 
 12309                              <1> fclose_0:
 12310 000104E8 FE8B[24850100]      <1> 	dec	byte [ebx+OF_OPENCOUNT] ; decrement the number of processes 
 12311                              <1> 			                ; that have opened the file
 12312 000104EE 791F                <1> 	jns	short fclose_1 ; jump if not negative (jump if bit 7 is 0)	 
 12313                              <1> 			; if all processes haven't closed the file, return
 12314                              <1> 	;
 12315                              <1> 	; eax ; First cluster
 12316 000104F0 31C0                <1> 	xor	eax, eax ; 0
 12317 000104F2 8883[E4840100]      <1> 	mov	[ebx+OF_MODE], al ; 0 = empty entry
 12318                              <1> 	;mov	[ebx+OF_STATUS], al ; 0 = empty entry
 12319                              <1> 	;shl	bx, 2 
 12320                              <1> 	; 23/07/2022
 12321                              <1> 	;shl	bl, 2
 12322 000104F8 C1E302              <1> 	shl	ebx, 2
 12323 000104FB 8983[44840100]      <1> 	mov	[ebx+OF_FCLUSTER], eax ; 0
 12324 00010501 8983[C4870100]      <1> 	mov	[ebx+OF_CCLUSTER], eax ; 0
 12325                              <1> 	;mov	[ebx+OF_CCINDEX], eax ; 0
 12326                              <1> 	; 23/07/2022
 12327                              <1> 	;mov	[ebx+OF_OPENCOUNT], al ; 0
 12328 00010507 A3[30010300]        <1> 	mov	[u.fofp], eax ; 0
 12329                              <1> 	;shr	bx, 2
 12330                              <1> 	; 23/07/2022
 12331                              <1> 	;shr	bl, 2
 12332 0001050C C1EB02              <1> 	shr	ebx, 2
 12333                              <1> fclose_1: ; 1:
 12334 0001050F 58                  <1> 	pop	eax ; File handle (File Descriptor, File Index)
 12335 00010510 C680[26010300]00    <1> 	mov	byte [eax+u.fp], 0 ; clear that entry in the u.fp list
 12336 00010517 C3                  <1> 	retn
 12337                              <1> 
 12338                              <1> getf:
 12339                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 12340                              <1> 	; 17/04/2021 - TRDOS 386 v2.0.4
 12341                              <1> 	;	(temporary modifications)
 12342                              <1> 	; 12/10/2016
 12343                              <1> 	; 11/10/2016
 12344                              <1> 	; 08/10/2016
 12345                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 12346                              <1> 	; / get the device number and the i-number of an open file
 12347                              <1> 	; 13/05/2015
 12348                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
 12349                              <1> 	; 19/04/2013 - 18/11/2013 (Retro UNIX 8086 v1)
 12350                              <1> 	;
 12351 00010518 89C3                <1> 	mov	ebx, eax
 12352                              <1> getf1: 
 12353 0001051A 83FB0A              <1> 	cmp	ebx, 10
 12354 0001051D 730A                <1>         jnb	short getf2
 12355 0001051F 8A9B[26010300]      <1> 	mov	bl, [ebx+u.fp]
 12356 00010525 08DB                <1> 	or	bl, bl
 12357 00010527 7503                <1> 	jnz	short getf3
 12358                              <1> getf2:
 12359                              <1> 	; 'File not open !' error (ax=0)
 12360 00010529 29C0                <1> 	sub	eax, eax
 12361 0001052B C3                  <1> 	retn
 12362                              <1> getf3:	
 12363                              <1> 	; 23/07/2022
 12364                              <1> 	;test	bl, 80h
 12365                              <1> 	;jnz	short getf5 ; device
 12366 0001052C FECB                <1> 	dec	bl ; 0 based
 12367 0001052E 8A83[C4840100]      <1> 	mov	al, [ebx+OF_DRIVE]
 12368 00010534 A2[01010300]        <1> 	mov	[cdev], al
 12369 00010539 C0E302              <1> 	shl	bl, 2 ; *4 (dword offset)
 12370                              <1> 	; 23/07/2022
 12371                              <1> 	;shl	ebx, 2
 12372 0001053C 8B83[C4850100]      <1> 	mov	eax, [ebx+OF_SIZE]
 12373 00010542 A3[24020300]        <1> 	mov	[i.size], eax ; file size
 12374 00010547 8D83[44850100]      <1> 	lea	eax, [ebx+OF_POINTER] ; 12/10/2016
 12375 0001054D A3[30010300]        <1> 	mov	[u.fofp], eax
 12376 00010552 8B83[44840100]      <1> 	mov	eax, [ebx+OF_FCLUSTER]
 12377 00010558 C0EB02              <1> 	shr	bl, 2 ; /4 (byte offset)
 12378                              <1> 	; 23/07/2022
 12379                              <1> 	;shr	ebx, 2
 12380                              <1> 	; 17/04/2021
 12381 0001055B F8                  <1> 	clc 
 12382                              <1> getf4:
 12383 0001055C C3                  <1> 	retn
 12384                              <1> ;getf5: 
 12385                              <1> 	; 17/04/2021
 12386                              <1> 	; (following code is disabled as temporary)
 12387                              <1> 	;
 12388                              <1> 	;; get device number
 12389                              <1> 	;and	bl, 7Fh ; 1 to 7Fh
 12390                              <1> 	;dec	bl ; 0 based (0 to 7Eh)
 12391                              <1> 	;mov	al, [ebx+DEV_DRIVER]
 12392                              <1> 	;mov	ch, [ebx+DEV_ACCESS]
 12393                              <1> 	;mov	cl, [ebx+DEV_OPENMODE]
 12394                              <1> 	;and	ch, 0FEh ; reset bit 0 ; dev_close
 12395                              <1> 	;
 12396                              <1> 	; 23/07/2022
 12397                              <1> 	;stc ; cf = 1 
 12398                              <1> 	;retn
 12399                              <1> 
 12400                              <1> trans_addr_nmbp:
 12401                              <1> 	; 18/10/2015
 12402                              <1> 	; 12/10/2015
 12403 0001055D 8B2D[38010300]      <1> 	mov 	ebp, [u.namep]
 12404                              <1> trans_addr_nm: 
 12405                              <1> 	; Convert virtual (pathname) address to physical address
 12406                              <1> 	; (Retro UNIX 386 v1 feature only !)
 12407                              <1> 	; 18/10/2015
 12408                              <1> 	; 12/10/2015 (u.pnbase & u.pncount has been removed from code)
 12409                              <1> 	; 02/07/2015
 12410                              <1> 	; 17/06/2015
 12411                              <1> 	; 16/06/2015
 12412                              <1> 	;
 12413                              <1> 	; INPUTS: 
 12414                              <1> 	;	ebp = pathname address (virtual) ; [u.namep]
 12415                              <1> 	;	[u.pgdir] = user's page directory
 12416                              <1> 	; OUTPUT:
 12417                              <1> 	;       esi = physical address of the pathname
 12418                              <1> 	;	ecx = remain byte count in the page
 12419                              <1> 	;
 12420                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI)
 12421                              <1> 	;
 12422 00010563 833D[78010300]00    <1>         cmp     dword [u.ppgdir], 0  ; /etc/init ? (sysexec)
 12423 0001056A 7618                <1> 	jna	short trans_addr_nmk ; the caller is os kernel;
 12424                              <1> 				     ; it is already physical address
 12425 0001056C 50                  <1>    	push	eax	
 12426 0001056D 89EB                <1> 	mov	ebx, ebp ; [u.namep] ; pathname address (virtual)
 12427 0001056F E84355FFFF          <1>        	call	get_physical_addr ; get physical address
 12428 00010574 7204                <1> 	jc	short tr_addr_nm_err
 12429                              <1> 	; 18/10/2015
 12430                              <1> 	; eax = physical address 
 12431                              <1> 	; cx = remain byte count in page (1-4096) 
 12432                              <1> 		; 12/10/2015 (cx = [u.pncount])
 12433 00010576 89C6                <1> 	mov	esi, eax ; 12/10/2015 (esi=[u.pnbase])
 12434 00010578 58                  <1> 	pop	eax 
 12435 00010579 C3                  <1> 	retn
 12436                              <1> 
 12437                              <1> tr_addr_nm_err:
 12438 0001057A A3[84010300]        <1> 	mov	[u.error], eax
 12439                              <1> 	;pop 	eax
 12440 0001057F E97BC7FFFF          <1> 	jmp	error
 12441                              <1> 
 12442                              <1> trans_addr_nmk:
 12443                              <1> 	; 12/10/2015
 12444                              <1> 	; 02/07/2015
 12445 00010584 8B35[38010300]      <1> 	mov	esi, [u.namep]  ; [u.pnbase]
 12446 0001058A 66B90010            <1> 	mov	cx, PAGE_SIZE ; 4096 ; [u.pncount]
 12447 0001058E C3                  <1> 	retn
 12448                              <1> 
 12449                              <1> sysbreak:
 12450                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 12451                              <1> 	; 18/10/2015
 12452                              <1> 	; 07/10/2015
 12453                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
 12454                              <1> 	; 20/06/2013 - 24/03/2014 (Retro UNIX 8086 v1)
 12455                              <1> 	;
 12456                              <1> 	; 'sysbreak' sets the programs break points. 
 12457                              <1> 	; It checks the current break point (u.break) to see if it is
 12458                              <1> 	; between "core" and the stack (sp). If it is, it is made an
 12459                              <1> 	; even address (if it was odd) and the area between u.break
 12460                              <1> 	; and the stack is cleared. The new breakpoint is then put
 12461                              <1> 	; in u.break and control is passed to 'sysret'.
 12462                              <1> 	;
 12463                              <1> 	; Calling sequence:
 12464                              <1> 	;	sysbreak; addr
 12465                              <1> 	; Arguments: -
 12466                              <1> 	;	
 12467                              <1> 	; Inputs: u.break - current breakpoint
 12468                              <1> 	; Outputs: u.break - new breakpoint 
 12469                              <1> 	;	area between old u.break and the stack (sp) is cleared.
 12470                              <1> 	; ...............................................................
 12471                              <1> 	;	
 12472                              <1> 	; Retro UNIX 8086 v1 modification:
 12473                              <1> 	;	The user/application program puts breakpoint address
 12474                              <1> 	;       in BX register as 'sysbreak' system call argument.
 12475                              <1> 	; 	(argument transfer method 1)
 12476                              <1> 	;
 12477                              <1> 	;  NOTE: Beginning of core is 0 in Retro UNIX 8086 v1 !
 12478                              <1> 	; 	((!'sysbreak' is not needed in Retro UNIX 8086 v1!))
 12479                              <1> 	;  NOTE:
 12480                              <1> 	; 	'sysbreak' clears extended part (beyond of previous
 12481                              <1> 	;	'u.break' address) of user's memory for original unix's
 12482                              <1> 	;	'bss' compatibility with Retro UNIX 8086 v1 (19/11/2013)
 12483                              <1> 
 12484                              <1> 		; mov u.break,r1 / move users break point to r1
 12485                              <1> 		; cmp r1,$core / is it the same or lower than core?
 12486                              <1> 		; blos 1f / yes, 1f
 12487                              <1> 	; 23/06/2015
 12488 0001058F 8B2D[4C010300]      <1> 	mov	ebp, [u.break] ; virtual address (offset)
 12489                              <1> 	;and	ebp, ebp
 12490                              <1> 	;jz	short sysbreak_3 
 12491                              <1> 	; Retro UNIX 386 v1 NOTE: u.break points to virtual address !!!
 12492                              <1> 	; (Even break point address is not needed for Retro UNIX 386 v1)
 12493 00010595 8B15[14010300]      <1> 	mov	edx, [u.sp] ; kernel stack at the beginning of sys call
 12494 0001059B 83C20C              <1> 	add	edx, 12 ; EIP -4-> CS -4-> EFLAGS -4-> ESP (user) 
 12495                              <1> 	; 07/10/2015
 12496 0001059E 891D[4C010300]      <1> 	mov	[u.break], ebx ; virtual address !!!
 12497                              <1> 	;
 12498 000105A4 3B1A                <1> 	cmp	ebx, [edx] ; compare new break point with 
 12499                              <1> 			   ; with top of user's stack (virtual!)
 12500 000105A6 7323                <1> 	jnb	short sysbreak_3
 12501                              <1> 		; cmp r1,sp / is it the same or higher 
 12502                              <1> 			  ; / than the stack?
 12503                              <1> 		; bhis 1f / yes, 1f
 12504 000105A8 89DE                <1> 	mov	esi, ebx
 12505 000105AA 29EE                <1> 	sub	esi, ebp ; new break point - old break point
 12506 000105AC 761D                <1> 	jna	short sysbreak_3 
 12507                              <1> 	;push	ebx
 12508                              <1> sysbreak_1:
 12509 000105AE 89EB                <1> 	mov	ebx, ebp  
 12510 000105B0 E80255FFFF          <1> 	call	get_physical_addr ; get physical address
 12511 000105B5 72C3                <1> 	jc	short tr_addr_nm_err ; 23/07/2022
 12512                              <1> 	; 18/10/2015
 12513 000105B7 89C7                <1> 	mov	edi, eax 
 12514 000105B9 29C0                <1> 	sub	eax, eax ; 0
 12515                              <1> 		 ; ECX = remain byte count in page (1-4096)
 12516 000105BB 39CE                <1> 	cmp	esi, ecx
 12517 000105BD 7302                <1> 	jnb	short sysbreak_2
 12518 000105BF 89F1                <1> 	mov	ecx, esi
 12519                              <1> sysbreak_2:
 12520 000105C1 29CE                <1> 	sub	esi, ecx
 12521 000105C3 01CD                <1> 	add	ebp, ecx
 12522 000105C5 F3AA                <1> 	rep 	stosb
 12523 000105C7 09F6                <1> 	or	esi, esi
 12524 000105C9 75E3                <1> 	jnz	short sysbreak_1
 12525                              <1> 	;
 12526                              <1> 		; bit $1,r1 / is it an odd address
 12527                              <1> 		; beq 2f / no, its even
 12528                              <1> 		; clrb (r1)+ / yes, make it even
 12529                              <1> 	; 2: / clear area between the break point and the stack
 12530                              <1> 		; cmp r1,sp / is it higher or same than the stack
 12531                              <1> 		; bhis 1f / yes, quit
 12532                              <1> 		; clr (r1)+ / clear word
 12533                              <1> 		; br 2b / go back
 12534                              <1> 	;pop	ebx
 12535                              <1> sysbreak_3: ; 1:
 12536                              <1> 	;mov	[u.break], ebx ; virtual address !!!
 12537                              <1> 		; jsr r0,arg; u.break / put the "address" 
 12538                              <1> 			; / in u.break (set new break point)
 12539                              <1> 		; br sysret4 / br sysret
 12540 000105CB E94FC7FFFF          <1> 	jmp	sysret
 12541                              <1> 
 12542                              <1> sysseek: ; / moves read write pointer in an fsp entry
 12543                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0)
 12544                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 12545                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 12546                              <1> 	;
 12547                              <1> 	; 'sysseek' changes the r/w pointer of (3rd word of in an
 12548                              <1> 	; fsp entry) of an open file whose file descriptor is in u.r0.
 12549                              <1> 	; The file descriptor refers to a file open for reading or
 12550                              <1> 	; writing. The read (or write) pointer is set as follows:
 12551                              <1> 	;	* if 'ptrname' is 0, the pointer is set to offset.
 12552                              <1> 	;	* if 'ptrname' is 1, the pointer is set to its
 12553                              <1> 	;	  current location plus offset.
 12554                              <1> 	;	* if 'ptrname' is 2, the pointer is set to the
 12555                              <1> 	;	  size of file plus offset.
 12556                              <1> 	; The error bit (e-bit) is set for an undefined descriptor.
 12557                              <1> 	;
 12558                              <1> 	; Calling sequence:
 12559                              <1> 	;	sysseek; offset; ptrname
 12560                              <1> 	; Arguments:
 12561                              <1> 	;	offset - number of bytes desired to move 
 12562                              <1> 	;		 the r/w pointer
 12563                              <1> 	;	ptrname - a switch indicated above
 12564                              <1> 	;
 12565                              <1> 	; Inputs: r0 - file descriptor 
 12566                              <1> 	; Outputs: -
 12567                              <1> 	; ...............................................................
 12568                              <1> 	;	
 12569                              <1> 	; Retro UNIX 8086 v1 modification: 
 12570                              <1> 	;       'sysseek' system call has three arguments; so,
 12571                              <1> 	;	* 1st argument, file descriptor is in BX (BL) register
 12572                              <1> 	;	* 2nd argument, offset is in CX register
 12573                              <1> 	;	* 3rd argument, ptrname/switch is in DX (DL) register
 12574                              <1> 
 12575 000105D0 E821000000          <1> 	call	seektell
 12576                              <1> 	; EAX = Current R/W pointer of the file
 12577                              <1> 	; EBX = [u.fofp]
 12578                              <1> 	; [u.base] = offset (ECX input)
 12579                              <1> 
 12580 000105D5 0305[40010300]      <1> 	add	eax, [u.base]
 12581 000105DB 8903                <1> 	mov	[ebx], eax
 12582 000105DD E93DC7FFFF          <1> 	jmp	sysret
 12583                              <1> 
 12584                              <1> systell: ; / get the r/w pointer
 12585                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0) - temporary !-
 12586                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 12587                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 12588                              <1> 	;
 12589                              <1> 	; Retro UNIX 8086 v1 modification:
 12590                              <1> 	; ! 'systell' does not work in original UNIX v1,
 12591                              <1> 	; 	    it returns with error !
 12592                              <1> 	; Inputs: r0 - file descriptor 
 12593                              <1> 	; Outputs: r0 - file r/w pointer
 12594                              <1> 
 12595                              <1> 	;xor	ecx, ecx ; 0
 12596 000105E2 BA01000000          <1> 	mov	edx, 1 ; 05/08/2013
 12597                              <1> 	;call 	seektell
 12598 000105E7 E810000000          <1> 	call 	seektell0 ; 05/08/2013
 12599                              <1> 	;; 06/11/2016
 12600                              <1> 	;; mov	eax, [ebx]
 12601 000105EC A3[1C010300]        <1> 	mov	[u.r0], eax
 12602 000105F1 E929C7FFFF          <1> 	jmp	sysret
 12603                              <1> 
 12604                              <1> ; Original unix v1 'systell' system call:
 12605                              <1> 		; jsr r0,seektell
 12606                              <1> 		; br error4
 12607                              <1> 
 12608                              <1> seektell:
 12609                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0)
 12610                              <1> 	; 03/01/2016
 12611                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 12612                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 12613                              <1> 	;
 12614                              <1> 	; 'seektell' puts the arguments from sysseek and systell
 12615                              <1> 	; call in u.base and u.count. It then gets the i-number of
 12616                              <1> 	; the file from the file descriptor in u.r0 and by calling
 12617                              <1> 	; getf. The i-node is brought into core and then u.count
 12618                              <1> 	; is checked to see it is a 0, 1, or 2.
 12619                              <1> 	; If it is 0 - u.count stays the same
 12620                              <1> 	;          1 - u.count = offset (u.fofp)
 12621                              <1> 	;	   2 - u.count = i.size (size of file)
 12622                              <1> 	; 	 		
 12623                              <1> 	; !! Retro UNIX 8086 v1 modification:
 12624                              <1> 	;	Argument 1, file descriptor is in BX;
 12625                              <1> 	;	Argument 2, offset is in CX;
 12626                              <1> 	;	Argument 3, ptrname/switch is in DX register.	
 12627                              <1> 	;
 12628                              <1> 	; ((Return -> eax = base for offset (position= base+offset))
 12629                              <1> 	;
 12630 000105F6 890D[40010300]      <1> 	mov 	[u.base], ecx ; offset
 12631                              <1> seektell0:
 12632 000105FC 8915[44010300]      <1> 	mov 	[u.count], edx
 12633                              <1> 	; EBX = file descriptor (file number)
 12634 00010602 E813FFFFFF          <1> 	call	getf1
 12635                              <1> 	; EAX = First cluster of the file
 12636                              <1> 	; EBX = File number (Open file number)
 12637                              <1> 	; [u.fofp] = Pointer to File pointer
 12638                              <1> 	; [i.size] = File size
 12639                              <1> 
 12640 00010607 09C0                <1> 	or	eax, eax
 12641 00010609 7514                <1> 	jnz	short seektell1
 12642                              <1> 
 12643 0001060B B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN
 12644 00010610 A3[1C010300]        <1> 	mov	[u.r0], eax 
 12645 00010615 A3[84010300]        <1> 	mov	dword [u.error], eax ; 'file not open !'
 12646 0001061A E9E0C6FFFF          <1> 	jmp	error
 12647                              <1> 
 12648                              <1> seektell1:
 12649 0001061F 8B1D[30010300]      <1>         mov     ebx, [u.fofp]
 12650 00010625 803D[44010300]01    <1> 	cmp	byte [u.count], 1
 12651 0001062C 7705                <1> 	ja	short seektell2
 12652 0001062E 7409                <1> 	je	short seektell3
 12653 00010630 31C0                <1> 	xor	eax, eax
 12654 00010632 C3                  <1> 	retn
 12655                              <1> 
 12656                              <1> seektell2:
 12657 00010633 A1[24020300]        <1>         mov   	eax, [i.size]
 12658 00010638 C3                  <1> 	retn
 12659                              <1> 
 12660                              <1> seektell3:
 12661 00010639 8B03                <1> 	mov	eax, [ebx]
 12662 0001063B C3                  <1> 	retn
 12663                              <1> 
 12664                              <1> sysintr: ; / set interrupt handling
 12665                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 12666                              <1> 	; 07/07/2013 (Retro UNIX 8086 v1)
 12667                              <1> 	;
 12668                              <1> 	; 'sysintr' sets the interrupt handling value. It puts
 12669                              <1> 	; argument of its call in u.intr then branches into 'sysquit'
 12670                              <1> 	; routine. u.tty is checked if to see if a control tty exists.
 12671                              <1> 	; If one does the interrupt character in the tty buffer is
 12672                              <1> 	; cleared and 'sysret'is called. If one does not exits
 12673                              <1> 	; 'sysret' is just called.
 12674                              <1> 	;
 12675                              <1> 	; Calling sequence:
 12676                              <1> 	;	sysintr; arg
 12677                              <1> 	; Argument:
 12678                              <1> 	;	arg - if 0, interrupts (ASCII DELETE) are ignored.
 12679                              <1> 	;	    - if 1, intterupts cause their normal result
 12680                              <1> 	;		 i.e force an exit.
 12681                              <1> 	;	    - if arg is a location within the program,
 12682                              <1> 	;		control is passed to that location when
 12683                              <1> 	;		an interrupt occurs.
 12684                              <1> 	; Inputs: -
 12685                              <1> 	; Outputs: -
 12686                              <1> 	; ...............................................................
 12687                              <1> 	;	
 12688                              <1> 	; Retro UNIX 8086 v1 modification: 
 12689                              <1> 	;       'sysintr' system call sets u.intr to value of BX
 12690                              <1> 	;	then branches into sysquit.
 12691                              <1> 	;
 12692 0001063C 66891D[68010300]    <1> 	mov	[u.intr], bx
 12693                              <1> 		; jsr r0,arg; u.intr / put the argument in u.intr
 12694                              <1> 		; br 1f / go into quit routine
 12695 00010643 E9D7C6FFFF          <1> 	jmp	sysret
 12696                              <1> 
 12697                              <1> sysquit:
 12698                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 12699                              <1> 	; 07/07/2013 (Retro UNIX 8086 v1)
 12700                              <1> 	;
 12701                              <1> 	; 'sysquit' turns off the quit signal. it puts the argument of
 12702                              <1> 	; the call in u.quit. u.tty is checked if to see if a control 
 12703                              <1> 	; tty exists. If one does the interrupt character in the tty
 12704                              <1> 	; buffer is cleared and 'sysret'is called. If one does not exits
 12705                              <1> 	; 'sysret' is just called.
 12706                              <1> 	;
 12707                              <1> 	; Calling sequence:
 12708                              <1> 	;	sysquit; arg
 12709                              <1> 	; Argument:
 12710                              <1> 	;	arg - if 0, this call diables quit signals from the
 12711                              <1> 	;		typewriter (ASCII FS)
 12712                              <1> 	;	    - if 1, quits are re-enabled and cause execution to
 12713                              <1> 	;		cease and a core image to be produced.
 12714                              <1> 	;		 i.e force an exit.
 12715                              <1> 	;	    - if arg is an addres in the program,
 12716                              <1> 	;		a quit causes control to sent to that
 12717                              <1> 	;		location.
 12718                              <1> 	; Inputs: -
 12719                              <1> 	; Outputs: -
 12720                              <1> 	; ...............................................................
 12721                              <1> 	;	
 12722                              <1> 	; Retro UNIX 8086 v1 modification: 
 12723                              <1> 	;       'sysquit' system call sets u.quit to value of BX
 12724                              <1> 	;	then branches into 'sysret'.
 12725                              <1> 	;
 12726 00010648 66891D[6A010300]    <1> 	mov	[u.quit], bx
 12727 0001064F E9CBC6FFFF          <1> 	jmp	sysret
 12728                              <1> 		; jsr r0,arg; u.quit / put argument in u.quit
 12729                              <1> 	;1:
 12730                              <1> 		; mov u.ttyp,r1 / move pointer to control tty buffer
 12731                              <1> 			      ; / to r1
 12732                              <1> 		; beq sysret4 / return to user
 12733                              <1> 		; clrb 6(r1) / clear the interrupt character 
 12734                              <1> 			   ; / in the tty buffer
 12735                              <1> 		; br sysret4 / return to user
 12736                              <1> 
 12737                              <1> %if 0
 12738                              <1> 
 12739                              <1> anyi: 
 12740                              <1> 	; 23/07/2022
 12741                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 12742                              <1> 	; Major Modification!
 12743                              <1> 	; TRDOS 386 does not permit to delete a file while it is open 
 12744                              <1> 	; The role of 'anyi' procedure has beeen changed to ensure that.
 12745                              <1> 	; 	
 12746                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 12747                              <1> 	; 25/04/2013 (Retro UNIX 8086 v1)
 12748                              <1> 	;
 12749                              <1> 	; 'anyi' is called if a file deleted while open.
 12750                              <1> 	; "anyi" checks to see if someone else has opened this file.
 12751                              <1> 	;
 12752                              <1> 	; INPUTS ->
 12753                              <1> 	;    r1 - contains an i-number
 12754                              <1> 	;    fsp - start of table containing open files
 12755                              <1> 	;
 12756                              <1> 	; OUTPUTS ->
 12757                              <1> 	;    "deleted" flag set in fsp entry of another occurrence of
 12758                              <1> 	;	   this file and r2 points 1st word of this fsp entry.
 12759                              <1> 	;    if file not found - bit in i-node map is cleared
 12760                              <1> 	;    			 (i-node is freed)
 12761                              <1> 	;               all blocks related to i-node are freed
 12762                              <1> 	;	        all flags in i-node are cleared
 12763                              <1> 	; ((AX = R1)) input
 12764                              <1> 	;
 12765                              <1> 	;    (Retro UNIX Prototype : 02/12/2012, UNIXCOPY.ASM)
 12766                              <1>         ;    ((Modified registers: EDX, ECX, EBX, ESI, EDI, EBP))
 12767                              <1> 	;
 12768                              <1> 	; / r1 contains an i-number
 12769                              <1> 
 12770                              <1> 	; TRDOS 386 (06/10/2016)
 12771                              <1> 	; 
 12772                              <1> 	; INPUT:
 12773                              <1> 	;	EAX = First Cluster
 12774                              <1> 	;	 DL = Logical DOS Drive Number
 12775                              <1> 	;
 12776                              <1> 	; OUTPUT:
 12777                              <1> 	;	CF = 1 -> EBX = File Handle/Number/Index
 12778                              <1> 	;	CF = 0 -> EBX = 0
 12779                              <1> 	;
 12780                              <1> 	; Modified Registers: EBX
 12781                              <1> 
 12782                              <1> 	xor	ebx, ebx
 12783                              <1> anyi_0: 
 12784                              <1> 	cmp	byte [ebx+OF_MODE], 0 ; 0 = empty entry
 12785                              <1> 	ja	short anyi_2 ; 1 (r), 2 (w) or 3 (r&w)
 12786                              <1> anyi_1:
 12787                              <1> 	inc	bl
 12788                              <1> 	cmp	bl, OPENFILES ; max. count of open files
 12789                              <1> 	jb	short anyi_0
 12790                              <1> 	xor	eax, eax
 12791                              <1> 	retn 
 12792                              <1> anyi_2:
 12793                              <1> 	cmp	dl, [ebx+OF_DRIVE]
 12794                              <1> 	jne	short anyi_1
 12795                              <1> 	;shl	bx, 2 ; *4 (dword offset)
 12796                              <1> 	shl	ebx, 2 ; 23/07/2022
 12797                              <1> 	cmp	eax, [ebx+OF_FCLUSTER]
 12798                              <1> 	je	short anyi_3
 12799                              <1> 	;shr	bx, 2 ; /4 (byte offset)
 12800                              <1> 	shr	ebx, 2 ; 23/07/2022
 12801                              <1> 	jmp	short anyi_1 	
 12802                              <1> anyi_3:
 12803                              <1> 	;shr	bx, 2 ; /4 (bytes offset) (index)
 12804                              <1> 	shr	ebx, 2 ; 23/07/2022
 12805                              <1> 	stc
 12806                              <1> 	retn
 12807                              <1> 
 12808                              <1> %endif
 12809                              <1> 
 12810                              <1> ; Retro UNIX 386 v1 Kernel (v0.2) - SYS9.INC
 12811                              <1> ; Last Modification: 09/12/2015
 12812                              <1> 
 12813                              <1> syssleep:
 12814                              <1> 	; 24/07/2022 - TRDOS 386 v2.0.5
 12815                              <1> 	; 29/06/2015 - (Retro UNIX 386 v1)
 12816                              <1> 	; 11/06/2014 - (Retro UNIX 8086 v1)
 12817                              <1> 	;
 12818                              <1> 	; Retro UNIX 8086 v1 feature only
 12819                              <1> 	; (INPUT -> none)
 12820                              <1> 	
 12821                              <1> 	; Temporary - 24/07/2022
 12822 00010654 891D[1C010300]      <1> 	mov	[u.r0], ebx
 12823                              <1> 	;
 12824 0001065A 0FB61D[6D010300]    <1> 	movzx	ebx, byte [u.uno] ; process number
 12825 00010661 8AA3[3F000300]      <1> 	mov	ah, [ebx+p.ttyc-1] ; current/console tty
 12826 00010667 E8D9160000          <1> 	call	sleep
 12827                              <1> 	; 24/07/2022
 12828 0001066C FF05[1C010300]      <1> 	inc	dword [u.r0] ; Temporary ! 
 12829 00010672 E9A8C6FFFF          <1> 	jmp	sysret
 12830                              <1> 
 12831                              <1> _vp_clr:
 12832                              <1> 	; Reset/Clear Video Page
 12833                              <1> 	;
 12834                              <1> 	; 24/07/2022 - TRDOS 386 v2.0.5
 12835                              <1> 	; 30/06/2015 - (Retro UNIX 386 v1)
 12836                              <1> 	; 21/05/2013 - 30/10/2013(Retro UNIX 8086 v1) (U0.ASM)
 12837                              <1> 	;
 12838                              <1> 	; Retro UNIX 8086 v1 feature only !
 12839                              <1> 	;
 12840                              <1> 	; INPUTS -> 
 12841                              <1> 	;   BH = video page number	 
 12842                              <1> 	;
 12843                              <1> 	; OUTPUT ->
 12844                              <1> 	;   none
 12845                              <1> 	; ((Modified registers: EAX, BH, ECX, EDX, ESI, EDI))
 12846                              <1> 	;
 12847                              <1> 	; 04/12/2013
 12848 00010677 28C0                <1> 	sub	al, al
 12849                              <1> 	; al = 0 (clear video page)
 12850                              <1> 	; bh = video page ; 13/05/2016
 12851 00010679 B407                <1> 	mov	ah, 07h
 12852                              <1> 	; ah = 7 (attribute/color)
 12853                              <1> 	;xor 	cx, cx ; 0, left upper column (cl) & row (cl)
 12854                              <1> 	;mov	dx, 184Fh ; right lower column & row (dl=24, dh=79)
 12855                              <1> 	; 24/07/2022
 12856 0001067B 31C9                <1> 	xor	ecx, ecx
 12857 0001067D BA4F180000          <1> 	mov	edx, 184Fh
 12858 00010682 E82319FFFF          <1> 	call	_scroll_up
 12859                              <1> 	; bh = video page
 12860                              <1> 	;xor	dx, dx ; 0 (cursor position) 
 12861                              <1> 	; 24/07/2022
 12862 00010687 31D2                <1> 	xor	edx, edx
 12863 00010689 E9621CFFFF          <1> 	jmp 	_set_cpos
 12864                              <1> 
 12865                              <1> sysmsg:
 12866                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 12867                              <1> 	; 07/12/2020
 12868                              <1> 	; 05/12/2020
 12869                              <1> 	; 13/05/2016
 12870                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 12871                              <1> 	; 01/07/2015 - 11/11/2015 (Retro UNIX 386 v1)
 12872                              <1> 	; Print user-application message on user's console tty
 12873                              <1> 	;
 12874                              <1> 	; Input -> EBX = Message address
 12875                              <1> 	;	   ECX = Message length (max. 255)
 12876                              <1> 	;	   DL = Color (IBM PC Rombios color attributes)
 12877                              <1> 	;
 12878 0001068E 81F9FF000000        <1> 	cmp	ecx, MAX_MSG_LEN ; 255
 12879                              <1> 	;ja	sysret ; nothing to do with big message size
 12880                              <1> 	; 23/07/2022
 12881 00010694 7605                <1> 	jna	short sysmsg8
 12882                              <1> sysmsg7:
 12883 00010696 E984C6FFFF          <1> 	jmp	sysret
 12884                              <1> sysmsg8:	; 23/07/2022
 12885 0001069B 08C9                <1> 	or	cl, cl
 12886                              <1> 	;jz	sysret
 12887                              <1> 	; 23/07/2022
 12888 0001069D 74F7                <1> 	jz	short sysmsg7
 12889 0001069F 20D2                <1> 	and	dl, dl
 12890 000106A1 7502                <1> 	jnz	short sysmsg0
 12891 000106A3 B207                <1> 	mov	dl, 07h ; default color
 12892                              <1> 		; (black background, light gray character) 
 12893                              <1> sysmsg0:
 12894 000106A5 891D[40010300]      <1> 	mov	[u.base], ebx
 12895 000106AB 8815[B7770100]      <1> 	mov	[ccolor], dl ; color attributes
 12896 000106B1 89E5                <1> 	mov	ebp, esp
 12897 000106B3 31DB                <1> 	xor	ebx, ebx ; 0
 12898 000106B5 891D[48010300]      <1> 	mov	[u.nread], ebx ; 0
 12899                              <1> 	;
 12900 000106BB 381D[82010300]      <1> 	cmp	[u.kcall], bl ; 0
 12901 000106C1 776F                <1> 	ja	short sysmsgk ; Temporary (01/07/2015)
 12902                              <1> 	;
 12903 000106C3 890D[44010300]      <1> 	mov	[u.count], ecx
 12904                              <1> 	;inc	ecx ; + 00h ; ASCIIZ
 12905                              <1> 	;
 12906                              <1> 	; 07/12/2020
 12907                              <1> 	;add	ecx, 3
 12908 000106C9 6683C103            <1> 	add	cx, 3
 12909 000106CD 80E1FC              <1> 	and	cl, ~3  ; not 3
 12910                              <1> 	;
 12911 000106D0 29CC                <1> 	sub	esp, ecx
 12912 000106D2 89E7                <1> 	mov	edi, esp
 12913 000106D4 89E6                <1> 	mov	esi, esp
 12914 000106D6 66891D[80010300]    <1> 	mov	[u.pcount], bx ; reset page (phy. addr.) counter
 12915                              <1> 	; 11/11/2015
 12916 000106DD 8A25[50010300]      <1> 	mov 	ah, [u.ttyp] ; recent open tty
 12917                              <1> 	; 0 = none
 12918 000106E3 FECC                <1> 	dec	ah
 12919 000106E5 790C                <1> 	jns	short sysmsg1 
 12920 000106E7 8A1D[6D010300]      <1> 	mov	bl, [u.uno] ; process number	
 12921 000106ED 8AA3[3F000300]      <1> 	mov	ah, [ebx+p.ttyc-1] ; user's (process's) console tty
 12922                              <1> sysmsg1:
 12923 000106F3 8825[52010300]      <1> 	mov	[u.ttyn], ah
 12924                              <1> sysmsg2:
 12925 000106F9 E8FC050000          <1> 	call	cpass
 12926 000106FE 7416                <1> 	jz	short sysmsg5
 12927 00010700 AA                  <1> 	stosb
 12928 00010701 20C0                <1> 	and	al, al
 12929 00010703 75F4                <1> 	jnz	short sysmsg2
 12930                              <1> sysmsg3:
 12931 00010705 80FC07              <1> 	cmp	ah, 7 ; tty number
 12932 00010708 7711                <1> 	ja	short sysmsg6 ; serial port
 12933 0001070A E83E000000          <1> 	call	print_cmsg ; 05/12/2020
 12934                              <1> sysmsg4:
 12935 0001070F 89EC                <1> 	mov	esp, ebp	
 12936 00010711 E909C6FFFF          <1> 	jmp	sysret
 12937                              <1> sysmsg5:
 12938 00010716 C60700              <1> 	mov	byte [edi], 0
 12939 00010719 EBEA                <1> 	jmp	short sysmsg3
 12940                              <1> sysmsg6:
 12941 0001071B 8A06                <1> 	mov	al, [esi]
 12942 0001071D E823160000          <1> 	call	sndc
 12943 00010722 72EB                <1> 	jc	short sysmsg4
 12944 00010724 803E00              <1> 	cmp	byte [esi], 0  ; 0 is stop character
 12945 00010727 76E6                <1> 	jna	short sysmsg4
 12946 00010729 46                  <1> 	inc 	esi
 12947 0001072A 8A25[52010300]      <1> 	mov	ah, [u.ttyn]
 12948 00010730 EBE9                <1> 	jmp	short sysmsg6
 12949                              <1> 
 12950                              <1> sysmsgk: ; Temporary (01/07/2015)
 12951                              <1> 	; The message has been sent by Kernel (ASCIIZ string)
 12952                              <1> 	; (ECX -character count- will not be considered)
 12953 00010732 8B35[40010300]      <1> 	mov	esi, [u.base]
 12954 00010738 8A25[B6770100]      <1> 	mov	ah, [ptty] ; present/current screen (video page)
 12955 0001073E 8825[52010300]      <1> 	mov	[u.ttyn], ah
 12956 00010744 C605[82010300]00    <1> 	mov	byte [u.kcall], 0
 12957 0001074B EBB8                <1> 	jmp	short sysmsg3
 12958                              <1> 	
 12959                              <1> print_cmsg: 
 12960                              <1> 	; 08/12/2020
 12961                              <1> 	; 07/12/2020
 12962                              <1> 	; 05/12/2020
 12963                              <1> 	; 18/11/2017
 12964                              <1> 	; 13/05/2016 - TRDOS 386 (TRDOS v2.0)
 12965                              <1> 	; 01/07/2015 (Retro UNIX 386 v1)
 12966                              <1> 	;
 12967                              <1> 	; print message (on user's console tty) 
 12968                              <1> 	;	with requested color
 12969                              <1> 	;
 12970                              <1> 	; INPUTS:
 12971                              <1> 	;	esi = message address
 12972                              <1> 	;	[u.ttyn] = tty number (0 to 7)
 12973                              <1> 	;	[ccolor] = color attributes (IBM PC BIOS colors)
 12974                              <1> 	;
 12975                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi
 12976                              <1> 	; (ebp must be preserved)
 12977                              <1> 
 12978                              <1> 	;mov	bh, ah
 12979 0001074D 8A3D[52010300]      <1> 	mov	bh, [u.ttyn]
 12980 00010753 8A1D[B7770100]      <1> 	mov	bl, [ccolor] ; * ; 05/12/2020
 12981                              <1> 
 12982                              <1> 	; 05/12/2020
 12983 00010759 803D[D00F0300]00    <1> 	cmp	byte [pmi32], 0 ; is vbios's 32 bit pmi enabled ?
 12984 00010760 772E                <1> 	ja	short pcmsg5 ; yes
 12985                              <1> pcmsg1:
 12986                              <1> 	; 08/12/2020
 12987 00010762 8A1D[B7770100]      <1> 	mov	bl, [ccolor] ; * (video.s 'u11'&'beep' change BL)
 12988                              <1> 	
 12989 00010768 AC                  <1> 	lodsb
 12990 00010769 20C0                <1> 	and 	al, al  ; 0
 12991 0001076B 743A                <1> 	jz 	short pcmsg2
 12992                              <1> pcmsg7:
 12993 0001076D 56                  <1> 	push 	esi
 12994                              <1> 	;mov	bl, [ccolor] ; * (video.s 'u11'&'beep' change BL)
 12995                              <1> 	; 05/12/2020
 12996                              <1> 	;;mov	bh, [u.ttyn]
 12997                              <1> 	;call 	_write_tty
 12998                              <1> 	;pop	esi
 12999                              <1> 	;jmp	short pcmsg1
 13000                              <1> ;pcmsg2:
 13001                              <1> 	;retn
 13002                              <1> 
 13003                              <1> 	; 07/12/2020
 13004 0001076E 803D[CE660000]03    <1> 	cmp     byte [CRT_MODE], 3
 13005 00010775 7708                <1> 	ja 	short pcmsg4
 13006                              <1> pcmsg3:
 13007 00010777 E8EF1AFFFF          <1> 	call	_write_tty_m3
 13008 0001077C 5E                  <1> 	pop	esi
 13009 0001077D EBE3                <1> 	jmp	short pcmsg1
 13010                              <1> pcmsg4:
 13011 0001077F 803D[CE660000]07    <1>         cmp     byte [CRT_MODE], 7
 13012 00010786 76EF                <1> 	jna 	short pcmsg3
 13013 00010788 E8A727FFFF          <1> 	call	vga_write_teletype
 13014 0001078D 5E                  <1> 	pop	esi
 13015 0001078E EBD2                <1> 	jmp	short pcmsg1
 13016                              <1> pcmsg5:
 13017                              <1> 	; 07/12/2020
 13018 00010790 803D[CE660000]07    <1>         cmp     byte [CRT_MODE], 7
 13019 00010797 76C9                <1> 	jna 	short pcmsg1
 13020                              <1> 
 13021                              <1> 	; 05/12/2020
 13022                              <1> 	; writing message by using
 13023                              <1> 	; VESA VBE3 video bios protected mode interface
 13024                              <1> 	
 13025 00010799 B40E                <1> 	mov	ah, 0Eh
 13026                              <1> pcmsg6:
 13027 0001079B AC                  <1> 	lodsb
 13028 0001079C 20C0                <1> 	and 	al, al  ; 0
 13029 0001079E 7407                <1> 	jz 	short pcmsg2
 13030                              <1> 	; bh = video page
 13031                              <1> 	; ah = 0Eh 
 13032                              <1> 	; al = character
 13033                              <1> 	; bl = color
 13034 000107A0 E80712FFFF          <1> 	call	int10h_32bit_pmi
 13035 000107A5 EBF4                <1> 	jmp	short pcmsg6
 13036                              <1> pcmsg2:
 13037 000107A7 C3                  <1> 	retn
 13038                              <1> 
 13039                              <1> sysgeterr:
 13040                              <1> 	; 09/12/2015
 13041                              <1> 	; 21/09/2015 - (Retro UNIX 386 v1 feature only!)
 13042                              <1> 	; Get last error number or page fault count
 13043                              <1> 	; (for debugging)
 13044                              <1> 	;
 13045                              <1> 	; Input -> EBX = return type
 13046                              <1> 	;	   0 = last error code (which is in 'u.error')	
 13047                              <1> 	;	   FFFFFFFFh = page fault count for running process
 13048                              <1> 	;	   FFFFFFFEh = total page fault count
 13049                              <1> 	;	   1 .. FFFFFFFDh = undefined 
 13050                              <1> 	;
 13051                              <1> 	; Output -> EAX = last error number or page fault count
 13052                              <1> 	;	   (depending on EBX input)
 13053                              <1> 	; 	
 13054 000107A8 21DB                <1> 	and 	ebx, ebx
 13055 000107AA 750B                <1> 	jnz	short glerr_2
 13056                              <1> glerr_0:
 13057 000107AC A1[84010300]        <1> 	mov	eax, [u.error]
 13058                              <1> glerr_1:
 13059 000107B1 A3[1C010300]        <1> 	mov	[u.r0], eax
 13060 000107B6 C3                  <1>  	retn
 13061                              <1> glerr_2:
 13062 000107B7 43                  <1> 	inc	ebx ; FFFFFFFFh -> 0, FFFFFFFEh -> FFFFFFFFh
 13063 000107B8 74FD                <1> 	jz	short glerr_2 ; page fault count for process
 13064 000107BA 43                  <1> 	inc	ebx ; FFFFFFFFh -> 0	
 13065 000107BB 75EF                <1> 	jnz	short glerr_0
 13066 000107BD A1[34030300]        <1> 	mov	eax, [PF_Count] ; total page fault count
 13067 000107C2 EBED                <1>         jmp     short glerr_1
 13068                              <1> glerr_3:
 13069 000107C4 A1[88010300]        <1> 	mov 	eax, [u.pfcount]
 13070 000107C9 EBE6                <1> 	jmp	short glerr_1
 13071                              <1> 
 13072                              <1> load_and_run_file:
 13073                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 13074                              <1> 	; 18/11/2017
 13075                              <1> 	; 22/01/2017
 13076                              <1> 	; 04/01/2017 - 07/01/2017
 13077                              <1> 	; 24/10/2016
 13078                              <1> 	; 24/04/2016 - 02/05/2016 - 03/05/2016 - 06/05/2016
 13079                              <1> 	; 23/04/2016 (TRDOS 386 = TRDOS v2.0)
 13080                              <1> 	; 23/10/2015 (Retro UNIX 386 v1, 'sysexec')
 13081                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
 13082                              <1> 	; 03/06/2013 - 06/12/2013 (Retro UNIX 8086 v1)
 13083                              <1> 	; EAX = First Cluster number
 13084                              <1> 	; EDX = File Size
 13085                              <1> 	; ESI = Argument list address
 13086                              <1> 	; [argc] = argument count
 13087                              <1> 	; [u.nread] = argument list length
 13088                              <1> 	; [esp] = return address to the caller (*)
 13089                              <1> 	;
 13090 000107CB 8935[18020300]      <1> 	mov	[argv], esi
 13091 000107D1 8915[24020300]      <1> 	mov	[i.size], edx
 13092 000107D7 A3[20020300]        <1> 	mov	[ii], eax
 13093                              <1> 
 13094                              <1> 	;sti	; 07/01/2017
 13095                              <1> 	;mov	eax, [k_page_dir]
 13096                              <1> 	;mov	[u.pgdir], eax
 13097 000107DC 31C0                <1> 	xor 	eax, eax ; clc ; *** ; 04/01/2017
 13098                              <1> 	;mov	[u.r0], eax ; 0 ; 07/01/2017
 13099                              <1> 
 13100                              <1> 	; 06/05/2016
 13101                              <1> 	; Set 'sysexit' return order to MainProg
 13102                              <1> 	;
 13103 000107DE 58                  <1> 	pop	eax ; * 'loc_load_and_run_file_8:' address
 13104                              <1> 	;; 22/01/2017
 13105                              <1> 	;;cli ; 07/01/2017
 13106 000107DF 8B25[24770100]      <1> 	mov	esp, [tss.esp0]
 13107                              <1> 	;
 13108                              <1> 	; 'loc_load_run_file_8' address has 
 13109                              <1> 	; 'jmp loc_file_rw_restore_retn' instruction
 13110                              <1> 	; 'loc_file_rw_restore_retn:' will return to
 13111                              <1> 	; [mainprog_return_addr] 
 13112                              <1> 	; just after 'call command_interpreter'
 13113                              <1> 	;
 13114 000107E5 68[386C0000]        <1> 	push	_end_of_mainprog ; we must not return to here !
 13115 000107EA FF35[04840100]      <1> 	push	dword [mainprog_return_addr]
 13116 000107F0 89E5                <1> 	mov	ebp, esp ; **
 13117                              <1> 	;	
 13118 000107F2 9C                  <1> 	pushfd  ; EFLAGS      ; IRETD ; ***
 13119 000107F3 6A08                <1> 	push	KCODE ; cs    ; IRETD
 13120 000107F5 50                  <1> 	push	eax ; * (eip) ; IRETD
 13121 000107F6 8925[14010300]      <1> 	mov	[u.sp], esp
 13122                              <1> 	;mov	byte [u.quant], time_count
 13123 000107FC 1E                  <1> 	push	ds
 13124 000107FD 06                  <1> 	push	es
 13125 000107FE 0FA0                <1> 	push	fs
 13126 00010800 0FA8                <1> 	push	gs	
 13127                              <1> 	;mov	eax, [u.r0]
 13128 00010802 29C0                <1> 	sub	eax, eax
 13129 00010804 60                  <1> 	pushad
 13130 00010805 68[1FCD0000]        <1> 	push	sysret
 13131                              <1> 	;push	sysrel1 ; 07/01/2017
 13132 0001080A 8925[18010300]      <1> 	mov	[u.usp], esp
 13133                              <1> 	;
 13134 00010810 E800040000          <1> 	call	wswap ; Save MainProg (process 1) 'u' structure
 13135                              <1> 		      ; and registers for return (from program)	
 13136 00010815 89EC                <1> 	mov	esp, ebp ; **
 13137                              <1> 	;;22/01/2017
 13138                              <1> 	;;sti ; 07/01/2017
 13139                              <1> 	; 23/07/2022
 13140                              <1> 	;push	eax  ; * 'loc_load_and_run_file_8:' address
 13141                              <1> 	;
 13142                              <1> 	;;; 02/05/2016
 13143                              <1> 	;;; Create a new process (parent: MainProg)	
 13144 00010817 31F6                <1> 	xor 	esi, esi
 13145                              <1> cnpm_1: ; search p.stat table for unused process number
 13146 00010819 46                  <1> 	inc	esi
 13147 0001081A 80BE[5F000300]00    <1> 	cmp	byte [esi+p.stat-1], 0 ; SFREE
 13148                              <1> 				; is process active, unused, dead
 13149 00010821 760B                <1> 	jna	short cnpm_2	; it's unused so branch
 13150 00010823 6683FE10            <1> 	cmp	si, nproc 	; all processes checked
 13151 00010827 72F0                <1> 	jb	short cnpm_1    ; no, branch back
 13152                              <1> cnpm_panic:
 13153 00010829 E98B64FFFF          <1> 	jmp	panic 
 13154                              <1> cnpm_2:
 13155 0001082E A1[74010300]        <1> 	mov	eax, [u.pgdir] ; page directory of MainProg
 13156 00010833 A3[78010300]        <1> 	mov	[u.ppgdir], eax ; parent's page directory
 13157 00010838 E8984EFFFF          <1> 	call	allocate_page
 13158                              <1> 	;jc	panic
 13159                              <1> 	; 23/07/2022
 13160 0001083D 72EA                <1> 	jc	short cnpm_panic
 13161                              <1> 	
 13162                              <1> 	; EAX = UPAGE (user structure page) address
 13163 0001083F A3[70010300]        <1> 	mov	[u.upage], eax ; memory page for 'user' struct (child)
 13164 00010844 89F7                <1> 	mov	edi, esi
 13165                              <1> 	;shl	di, 2
 13166                              <1> 	; 23/07/2022
 13167 00010846 C1E702              <1> 	shl	edi, 2
 13168 00010849 8987[6C000300]      <1> 	mov	[edi+p.upage-4], eax ; memory page for 'user' struct
 13169 0001084F E8F24EFFFF          <1> 	call	clear_page ; 03/05/2016
 13170                              <1> 	;;movzx	eax, byte [p.ttyc] ; console tty (for MainProg)
 13171                              <1> 	;sub	ax, ax ; 0
 13172                              <1> 	; 23/07/2022
 13173 00010854 29C0                <1> 	sub	eax, eax
 13174 00010856 668986[3F000300]    <1> 	mov     [esi+p.ttyc-1], ax ; al - set child's console tty
 13175                              <1> 				   ; ah - reset child's wait channel	
 13176 0001085D 66A3[50010300]      <1> 	mov 	[u.ttyp], ax ; 0
 13177                              <1> 	
 13178 00010863 89F2                <1> 	mov	edx, esi
 13179 00010865 8815[6D010300]      <1> 	mov	[u.uno], dl ; child process number
 13180 0001086B FE86[5F000300]      <1>         inc     byte [esi+p.stat-1] ; 1, SRUN
 13181                              <1> 	;shl	si, 1 ; multiply si by 2 to get index into p.pid table
 13182                              <1> 	; 23/07/2022
 13183 00010871 D1E6                <1> 	shl	esi, 1
 13184 00010873 66FF05[04010300]    <1> 	inc	word [mpid] ; increment m.pid; get a new process name
 13185                              <1> 
 13186                              <1> 	; 23/07/2022	
 13187                              <1> 	;mov	ax, [p.pid]  ; get process name of MainProg
 13188                              <1> 	;mov	ax, 1
 13189 0001087A FEC0                <1> 	inc	al ; eax = 1
 13190 0001087C 668986[1E000300]    <1> 	mov	[esi+p.ppid-2], ax ; put parent process name 
 13191                              <1> 			           ; in parent process slot for child
 13192 00010883 A2[66010300]        <1> 	mov	[u.pri], al ; 1	; normal priority
 13193                              <1> 	
 13194                              <1> 	;dec	ax ; 0
 13195                              <1> 	;mov 	[u.ttyp], ax ; 0
 13196                              <1> 
 13197 00010888 66A1[04010300]      <1> 	mov	ax, [mpid]
 13198 0001088E 668986[FEFF0200]    <1> 	mov	[esi+p.pid-2], ax ; put new process name 
 13199                              <1> 				  ; in child process' name slot
 13200                              <1> 	;;;
 13201 00010895 A1[20020300]        <1> 	mov 	eax, [ii]
 13202                              <1> 	; 23/07/2022
 13203                              <1> 	; Retro UNIX 386 v1, 'sysexec' (u2.s)
 13204                              <1> 	;call	iopen
 13205                              <1> 	; 06/06/2016
 13206                              <1> 	;mov	byte [u.pri], 1 ; normal priority
 13207                              <1> 	;
 13208                              <1> 	;jmp	short sysexec_7 ; 02/05/2016
 13209                              <1> 	; 23/07/2022
 13210 0001089A E96DF9FFFF          <1> 	jmp	sysexec_7
 13211                              <1> 
 13212                              <1> ;	; 02/05/2016
 13213                              <1> ;	;inc	byte [sysflg] ; 0FFh -> 0
 13214                              <1> ;	;mov	byte [sysflg], 0 ; 04/01/2017
 13215                              <1> ;	movzx	ebx, byte [u.uno]
 13216                              <1> ;	shl	bl, 1 ; 13/11/2017 	
 13217                              <1> ;	cmp	word [ebx+p.ppid-2], 1 ; MainProg
 13218                              <1> ;	ja	sysret0 ; 03/05/2016
 13219                              <1> ;	push	sysret ; * 
 13220                              <1> ;	mov	[u.usp], esp
 13221                              <1> ;	call	wswap ; save child process 'u' structure and
 13222                              <1> ;		      ; registers
 13223                              <1> ;	add	dword [u.usp], 4 ; 03/05/2016 
 13224                              <1> ;sysexec_19: ; 02/05/2016
 13225                              <1> ;	retn ; * 'sysret' ; byte [sysflg] -> 0FFh
 13226                              <1> 
 13227                              <1> readi:
 13228                              <1> 	; 09/08/2022
 13229                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 13230                              <1> 	; 01/05/2016
 13231                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 13232                              <1> 	; 20/05/2015 - Retro UNIX 386 v1
 13233                              <1> 	; 11/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 13234                              <1> 	;
 13235                              <1> 	; Reads from a file whose the first cluster number in EAX
 13236                              <1> 	; 
 13237                              <1> 	; INPUTS ->
 13238                              <1> 	;    EAX - First cluster number of the file
 13239                              <1> 	;    u.count - byte count user desires
 13240                              <1> 	;    u.base - points to user buffer
 13241                              <1> 	;    u.fofp - points to dword with current file offset
 13242                              <1> 	;    i.size - file size
 13243                              <1> 	;    cdev - logical dos drive number of the file
 13244                              <1> 	; OUTPUTS ->
 13245                              <1> 	;    u.count - cleared
 13246                              <1> 	;    u.nread - accumulates total bytes passed back
 13247                              <1> 	;
 13248                              <1> 	; ((EAX)) input/output
 13249                              <1> 	; (Retro UNIX Prototype : 14/12/2012 - 01/03/2013, UNIXCOPY.ASM)
 13250                              <1>         ; ((Modified registers: edx, ebx, ecx, esi, edi))  
 13251                              <1> 
 13252 0001089F 31D2                <1> 	xor	edx, edx ; 0
 13253 000108A1 8915[48010300]      <1> 	mov 	[u.nread], edx ; 0
 13254 000108A7 668915[80010300]    <1> 	mov	[u.pcount], dx ; 19/05/2015
 13255 000108AE 3915[44010300]      <1> 	cmp 	[u.count], edx ; 0
 13256                              <1> 	;ja 	short readi_1
 13257                              <1> 	;retn
 13258                              <1> 	; 09/08/2022
 13259 000108B4 765E                <1> 	jna	short dskr_5 ; retn
 13260                              <1> ;readi_1:
 13261                              <1> dskr:
 13262                              <1> 	; 01/05/2016
 13263                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 13264                              <1> 	; 24/05/2015 - 12/10/2015 (Retro UNIX 386 v1)
 13265                              <1> 	; 26/04/2013 - 03/08/2013 (Retro UNIX 8086 v1)
 13266                              <1> dskr_0:
 13267 000108B6 8B15[24020300]      <1>         mov	edx, [i.size]
 13268 000108BC 8B1D[30010300]      <1> 	mov	ebx, [u.fofp]
 13269 000108C2 2B13                <1> 	sub	edx, [ebx]
 13270 000108C4 7647                <1> 	jna	short dskr_4
 13271                              <1> 	;
 13272 000108C6 50                  <1> 	push	eax ; 01/05/2016
 13273 000108C7 3B15[44010300]      <1> 	cmp     edx, [u.count] 
 13274 000108CD 7306                <1> 	jnb	short dskr_1
 13275 000108CF 8915[44010300]      <1> 	mov	[u.count], edx
 13276                              <1> dskr_1:
 13277                              <1> 	; EAX = First Cluster
 13278                              <1> 	; [Current_Drv] = Physical drive number 
 13279 000108D5 E83B000000          <1> 	call	mget_r
 13280                              <1> 	; NOTE: in 'mget_r', relevant sector will be read in buffer
 13281                              <1> 	; if it is not already in buffer !
 13282 000108DA BB[40030300]        <1> 	mov	ebx, readi_buffer
 13283 000108DF 803D[82010300]00    <1> 	cmp	byte [u.kcall], 0 ; the caller is 'namei' sign (=1)
 13284 000108E6 770F                <1> 	ja	short dskr_3	  ; zf=0 -> the caller is 'namei'
 13285 000108E8 66833D[80010300]00  <1> 	cmp	word [u.pcount], 0
 13286 000108F0 7705                <1> 	ja	short dskr_3
 13287                              <1> dskr_2:
 13288                              <1> 	; [u.base] = virtual address to transfer (as destination address)
 13289 000108F2 E88D010000          <1> 	call	trans_addr_w ; translate virtual address to physical (w)
 13290                              <1> dskr_3:
 13291                              <1> 	; EBX (r5) = system (I/O) buffer address -physical-
 13292 000108F7 E8F0010000          <1> 	call	sioreg
 13293 000108FC 87F7                <1> 	xchg	esi, edi
 13294                              <1> 	; EDI = file (user data) offset
 13295                              <1> 	; ESI = sector (I/O) buffer offset
 13296                              <1> 	; ECX = byte count
 13297 000108FE F3A4                <1> 	rep	movsb
 13298                              <1> 	; eax = remain bytes in buffer
 13299                              <1>         ;       (check if remain bytes in the buffer > [u.pcount])
 13300 00010900 09C0                <1> 	or	eax, eax
 13301 00010902 75EE                <1> 	jnz	short dskr_2 ; (page end before system buffer end!)
 13302 00010904 58                  <1> 	pop	eax  ; (first cluster number)
 13303 00010905 390D[44010300]      <1> 	cmp	[u.count], ecx ; 0
 13304 0001090B 77A9                <1> 	ja	short dskr_0
 13305                              <1> dskr_4:
 13306 0001090D C605[82010300]00    <1> 	mov	byte [u.kcall], 0
 13307                              <1> dskr_5:		; 23/07/2022
 13308 00010914 C3                  <1> 	retn
 13309                              <1> 
 13310                              <1> mget_r:
 13311                              <1> 	; 29/08/2023
 13312                              <1> 	; 30/07/2022
 13313                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 13314                              <1> 	; 24/10/2016
 13315                              <1> 	; 22/10/2016
 13316                              <1> 	; 12/10/2016
 13317                              <1> 	; 29/04/2016
 13318                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 13319                              <1> 	; 03/06/2015 (Retro UNIX 386 v1, 'mget', u.5s)
 13320                              <1> 	; 22/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 13321                              <1> 	;
 13322                              <1> 	; Get existing or (allocate) a new disk block for file
 13323                              <1> 	; 
 13324                              <1> 	; INPUTS ->
 13325                              <1> 	;    [u.fofp] = file offset pointer
 13326                              <1> 	;    EAX = First Cluster
 13327                              <1> 	;    [cdev] = Logical dos drive number 	  
 13328                              <1> 	;    ([u.off] = file offset)
 13329                              <1> 	; OUTPUTS ->
 13330                              <1> 	;    EAX = logical sector number
 13331                              <1> 	;    ESI = Logical Dos Drive Description Table address	
 13332                              <1> 	;
 13333                              <1> 	; Modified registers: EDX, EBX, ECX, ESI, EDI
 13334                              <1> 
 13335 00010915 8B35[30010300]      <1> 	mov     esi, [u.fofp]
 13336 0001091B 8B1E                <1> 	mov	ebx, [esi] ; (u.off)
 13337                              <1> 
 13338 0001091D 29C9                <1> 	sub	ecx, ecx
 13339 0001091F 8A2D[01010300]      <1> 	mov	ch, [cdev]
 13340                              <1> 
 13341 00010925 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 13342 0001092A 01CE                <1> 	add	esi, ecx
 13343                              <1> 
 13344 0001092C 380D[B8830100]      <1> 	cmp	[readi.valid], cl ; 0
 13345 00010932 7648                <1> 	jna	short mget_r_0
 13346                              <1> 	
 13347 00010934 3A2D[B9830100]      <1> 	cmp	ch, [readi.drv]
 13348 0001093A 7540                <1> 	jne	short mget_r_0
 13349                              <1> 
 13350 0001093C 3B05[CC830100]      <1> 	cmp	eax, [readi.fclust]
 13351 00010942 7561                <1> 	jne	short mget_r_3
 13352                              <1> 	
 13353 00010944 89D8                <1> 	mov	eax, ebx ; file offset
 13354 00010946 668B0D[C0830100]    <1> 	mov	cx, [readi.bpc]
 13355 0001094D 41                  <1> 	inc	ecx ; <= 65536
 13356 0001094E 29D2                <1> 	sub	edx, edx
 13357 00010950 F7F1                <1> 	div	ecx
 13358                              <1> 
 13359 00010952 8B3D[C8830100]      <1> 	mov	edi, [readi.c_index] ; cluster index
 13360                              <1> 
 13361 00010958 39F8                <1> 	cmp	eax, edi
 13362 0001095A 7576                <1>         jne     short mget_r_4  ; (*)
 13363                              <1> 
 13364                              <1> 	; edx = byte offset in cluster (<= 65535)
 13365 0001095C 668915[C2830100]    <1> 	mov	[readi.offset], dx
 13366                              <1> 	; 23/07/2022
 13367                              <1> 	;shr	dx, 9 ; / 512
 13368 00010963 C1EA09              <1> 	shr	edx, 9
 13369 00010966 8815[BB830100]      <1> 	mov	[readi.s_index], dl ; sector index in cluster (0 to spc -1)
 13370                              <1> 	
 13371 0001096C A1[C4830100]        <1> 	mov	eax, [readi.cluster]  ; > 0 if [readi.valid] = 1
 13372 00010971 8B15[D0830100]      <1> 	mov	edx, [readi.fs_index]
 13373 00010977 E996000000          <1>         jmp     mget_r_7
 13374                              <1> 	
 13375                              <1> mget_r_0:
 13376 0001097C 882D[B9830100]      <1> 	mov	[readi.drv], ch ; physical drive number
 13377 00010982 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 13378 00010986 7707                <1> 	ja	short mget_r_1
 13379 00010988 8A4E12              <1> 	mov	cl, [esi+LD_FS_BytesPerSec+1]
 13380 0001098B D0E9                <1> 	shr	cl, 1 ;  ; 1 for 512 bytes, 4 for 2048 bytes
 13381 0001098D EB03                <1> 	jmp	short mget_r_2	
 13382                              <1> mget_r_1:
 13383 0001098F 8A4E13              <1> 	mov	cl, [esi+LD_BPB+BPB_SecPerClust]
 13384                              <1> mget_r_2:
 13385 00010992 880D[BA830100]      <1> 	mov	[readi.spc], cl  ; sectors per cluster
 13386                              <1> 	; NOTE: readi bytes per sector value is always 512 !
 13387                              <1> 	; 23/07/2022
 13388                              <1> 	;xor	ch, ch
 13389                              <1> 	; 29/08/2023
 13390 00010998 C1E109              <1> 	shl	ecx, 9 
 13391                              <1> 	;shl	cx, 9 ; * 512
 13392                              <1> 	;dec	cx ; bytes per cluster - 1
 13393                              <1> 	; 23/07/2022
 13394 0001099B 49                  <1> 	dec	ecx
 13395 0001099C 66890D[C0830100]    <1> 	mov	[readi.bpc], cx
 13396                              <1> 	;sub	cx, cx
 13397                              <1> 	; 23/07/2022
 13398 000109A3 29C9                <1> 	sub	ecx, ecx
 13399                              <1> mget_r_3:
 13400 000109A5 A3[CC830100]        <1> 	mov	[readi.fclust], eax ; first cluster (or FDT address)
 13401 000109AA 880D[B8830100]      <1> 	mov	[readi.valid], cl ; 0 
 13402                              <1> 	;mov	[readi.s_index], cl ; 0
 13403                              <1> 	;mov	[readi.offset], cx ; 0
 13404 000109B0 890D[C8830100]      <1> 	mov	[readi.c_index], ecx ; 0
 13405 000109B6 890D[C4830100]      <1> 	mov	[readi.cluster], ecx ; 0
 13406 000109BC 890D[BC830100]      <1> 	mov	[readi.sector], ecx ; 0
 13407                              <1> 	
 13408 000109C2 89D8                <1> 	mov	eax, ebx ; file offset
 13409 000109C4 668B0D[C0830100]    <1> 	mov	cx, [readi.bpc]
 13410 000109CB 41                  <1> 	inc	ecx ; <= 65536
 13411 000109CC 29D2                <1> 	sub	edx, edx
 13412 000109CE F7F1                <1> 	div	ecx
 13413                              <1> 	;mov	edi, [readi.c_index] ; previous cluster index
 13414 000109D0 29FF                <1> 	sub	edi, edi
 13415                              <1> mget_r_4:
 13416 000109D2 A3[C8830100]        <1> 	mov	[readi.c_index], eax ; cluster index
 13417                              <1> 	; edx = byte offset in cluster (<= 65535)
 13418 000109D7 668915[C2830100]    <1> 	mov	[readi.offset], dx
 13419                              <1> 	; 23/07/2022
 13420                              <1> 	;shr	dx, 9 ; / 512
 13421 000109DE C1EA09              <1> 	shr	edx, 9
 13422 000109E1 8815[BB830100]      <1> 	mov	[readi.s_index], dl ; sector index in cluster (0 to spc -1)
 13423                              <1> 
 13424 000109E7 89C1                <1> 	mov	ecx, eax ; current cluster index
 13425 000109E9 A1[CC830100]        <1> 	mov	eax, [readi.fclust]
 13426 000109EE 09C9                <1> 	or	ecx, ecx ; cluster index
 13427 000109F0 741B                <1> 	jz	short mget_r_6
 13428                              <1> 
 13429 000109F2 39CF                <1> 	cmp	edi, ecx
 13430 000109F4 7710                <1> 	ja	short mget_r_5 ; old cluster index is higher
 13431 000109F6 8B15[C4830100]      <1> 	mov	edx, [readi.cluster]
 13432 000109FC 21D2                <1> 	and	edx, edx
 13433 000109FE 7406                <1> 	jz	short mget_r_5
 13434                              <1> 	; valid 'readi' parameters (*)
 13435 00010A00 89D0                <1> 	mov	eax, edx
 13436 00010A02 29F9                <1> 	sub	ecx, edi
 13437 00010A04 740C                <1> 	jz	short mget_r_7
 13438                              <1> mget_r_5:
 13439                              <1> 	; EAX = Beginning cluster
 13440                              <1> 	; EDX = Sector index in disk/file section
 13441                              <1> 	;	(Only for SINGLIX file system!)
 13442                              <1> 	; ECX = Cluster sequence number after the beginning cluster
 13443                              <1> 	; ESI = Logical DOS Drive Description Table address
 13444 00010A06 E82CC1FFFF          <1> 	call	get_cluster_by_index
 13445 00010A0B 724C                <1> 	jc	short mget_r_err
 13446                              <1> 	; EAX = Cluster number		
 13447                              <1> mget_r_6:
 13448 00010A0D A3[C4830100]        <1> 	mov	[readi.cluster], eax ; FDT number for Singlix File System
 13449                              <1> mget_r_7:
 13450 00010A12 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 13451 00010A16 765D                <1> 	jna	short mget_r_12
 13452                              <1> 
 13453                              <1> 	;sub	eax, 2
 13454                              <1> 	; 30/07/2022
 13455 00010A18 48                  <1> 	dec	eax
 13456 00010A19 48                  <1> 	dec	eax
 13457 00010A1A 0FB615[BA830100]    <1> 	movzx	edx, byte [readi.spc]
 13458 00010A21 F7E2                <1> 	mul	edx
 13459                              <1> 
 13460 00010A23 034668              <1> 	add	eax, [esi+LD_DATABegin]
 13461 00010A26 8A15[BB830100]      <1> 	mov	dl, [readi.s_index]
 13462 00010A2C 01D0                <1> 	add	eax, edx
 13463                              <1> mget_r_8:
 13464                              <1> 	; eax = logical sector number
 13465 00010A2E 803D[B8830100]00    <1> 	cmp	byte [readi.valid], 0
 13466 00010A35 7608                <1> 	jna	short mget_r_9
 13467 00010A37 3B05[BC830100]      <1> 	cmp	eax, [readi.sector]
 13468 00010A3D 7435                <1> 	je	short mget_r_11 ; sector is already in 'readi' buffer
 13469                              <1> mget_r_9:
 13470 00010A3F A3[BC830100]        <1> 	mov	[readi.sector], eax
 13471 00010A44 BB[40030300]        <1> 	mov	ebx, readi_buffer ; buffer address
 13472                              <1> 	;mov	ecx, 1
 13473                              <1> 	; 30/07/2022
 13474 00010A49 31C9                <1> 	xor	ecx, ecx
 13475 00010A4B FEC1                <1> 	inc	cl
 13476                              <1> 	; ecx = 1	
 13477                              <1> 
 13478                              <1> 	; 29/04/2016
 13479                              <1> 	;xor	dl, dl
 13480                              <1> 
 13481                              <1> 	; EAX = Logical sector number
 13482                              <1> 	; ECX = Sector count
 13483                              <1> 	; EBX = Buffer address
 13484                              <1> 	; (EDX = 0)
 13485                              <1> 	; ESI = Logical DOS drive description table address	
 13486                              <1> 
 13487 00010A4D E803130000          <1> 	call	disk_read
 13488 00010A52 7314                <1> 	jnc	short mget_r_10
 13489                              <1> 
 13490                              <1> 	; 22/10/2016 (15h -> 17)
 13491 00010A54 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
 13492                              <1> mget_r_err:
 13493 00010A59 A3[84010300]        <1> 	mov	[u.error], eax
 13494                              <1> 	; 12/10/2016
 13495 00010A5E A3[1C010300]        <1> 	mov	[u.r0], eax
 13496 00010A63 E997C2FFFF          <1> 	jmp	error
 13497                              <1> mget_r_10:
 13498 00010A68 C605[B8830100]01    <1> 	mov	byte [readi.valid], 1 ; 24/10/2016
 13499 00010A6F A1[BC830100]        <1> 	mov	eax, [readi.sector]
 13500                              <1> mget_r_11:
 13501 00010A74 C3                  <1> 	retn
 13502                              <1> mget_r_12:
 13503                              <1> 	; EAX = FDT number
 13504                              <1> 	; EDX = Sector index from FDT sector (0,1,2,3,4...)
 13505 00010A75 40                  <1> 	inc	eax ; the first data sector in FS disk section	
 13506 00010A76 8915[D0830100]      <1> 	mov	[readi.fs_index], edx
 13507 00010A7C 01D0                <1> 	add	eax, edx
 13508 00010A7E EBAE                <1> 	jmp	short mget_r_8
 13509                              <1> 
 13510                              <1> trans_addr_r:
 13511                              <1> 	; 12/10/2016
 13512                              <1> 	; 02/05/2016 - TRDOS 386 (TRDOS v2.0)
 13513                              <1> 	; Translate virtual address to physical address 
 13514                              <1> 	; for reading from user's memory space
 13515                              <1> 	; 04/06/2015 - 18/10/2015 (Retro UNIX 386 v1)
 13516                              <1> 
 13517 00010A80 31D2                <1> 	xor	edx, edx ; 0 (read access sign)
 13518 00010A82 EB04                <1> 	jmp 	short trans_addr_rw
 13519                              <1> 
 13520                              <1> trans_addr_w:
 13521                              <1> 	; 12/10/2016
 13522                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 13523                              <1> 	; Translate virtual address to physical address 
 13524                              <1> 	; for writing to user's memory space
 13525                              <1> 	; 04/06/2015 - 18/10/2015 (Retro UNIX 386 v1)
 13526                              <1> 	
 13527 00010A84 29D2                <1> 	sub	edx, edx
 13528 00010A86 FEC2                <1> 	inc	dl ; 1 (write access sign)
 13529                              <1> trans_addr_rw:
 13530 00010A88 50                  <1> 	push	eax
 13531 00010A89 53                  <1> 	push	ebx
 13532 00010A8A 52                  <1> 	push 	edx ; r/w sign (in DL)
 13533                              <1> 	;
 13534 00010A8B 8B1D[40010300]      <1> 	mov	ebx, [u.base]
 13535 00010A91 E82150FFFF          <1> 	call	get_physical_addr ; get physical address
 13536 00010A96 730F                <1> 	jnc	short passc_0
 13537 00010A98 A3[84010300]        <1> 	mov	[u.error], eax
 13538 00010A9D A3[1C010300]        <1> 	mov	[u.r0], eax ; 12/10/2016
 13539                              <1> 	;pop	edx
 13540                              <1> 	;pop 	ebx
 13541                              <1> 	;pop	eax
 13542 00010AA2 E958C2FFFF          <1> 	jmp	error
 13543                              <1> passc_0:
 13544 00010AA7 F6C202              <1> 	test	dl, PTE_A_WRITE ; writable page
 13545 00010AAA 5A                  <1> 	pop	edx
 13546 00010AAB 751C                <1> 	jnz	short passc_1
 13547                              <1> 	
 13548 00010AAD 20D2                <1> 	and 	dl, dl
 13549 00010AAF 7418                <1> 	jz	short passc_1
 13550                              <1> 	; read only (duplicated) page -must be copied to a new page-
 13551                              <1> 	; EBX = linear address
 13552 00010AB1 51                  <1> 	push 	ecx
 13553 00010AB2 E8714FFFFF          <1> 	call 	copy_page
 13554 00010AB7 59                  <1> 	pop	ecx
 13555 00010AB8 721E                <1> 	jc	short passc_2
 13556 00010ABA 50                  <1> 	push	eax ; physical address of the new/allocated page
 13557 00010ABB E8F74FFFFF          <1> 	call	add_to_swap_queue	
 13558 00010AC0 58                  <1> 	pop	eax
 13559 00010AC1 81E3FF0F0000        <1> 	and 	ebx, PAGE_OFF ; 0FFFh
 13560                              <1> 	;mov 	ecx, PAGE_SIZE
 13561                              <1> 	;sub	ecx, ebx 
 13562 00010AC7 01D8                <1> 	add	eax, ebx  
 13563                              <1> passc_1: 
 13564 00010AC9 A3[7C010300]        <1> 	mov 	[u.pbase], eax ; physical address	
 13565 00010ACE 66890D[80010300]    <1> 	mov	[u.pcount], cx ; remain byte count in page (1-4096)
 13566 00010AD5 5B                  <1> 	pop	ebx
 13567 00010AD6 58                  <1> 	pop	eax
 13568 00010AD7 C3                  <1> 	retn
 13569                              <1> passc_2:
 13570 00010AD8 B804000000          <1> 	mov	eax, ERR_MINOR_IM ; "Insufficient memory !" error
 13571 00010ADD A3[1C010300]        <1> 	mov	[u.r0], eax ; 12/10/2016
 13572 00010AE2 A3[84010300]        <1> 	mov	[u.error], eax
 13573                              <1> 	;pop 	ebx
 13574                              <1> 	;pop	eax
 13575 00010AE7 E913C2FFFF          <1> 	jmp	error
 13576                              <1> 
 13577                              <1> sioreg: 
 13578                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 13579                              <1> 	; 19/05/2015 - 25/07/2015 (Retro UNIX 386 v1)
 13580                              <1> 	; 12/03/2013 - 22/07/2013 (Retro UNIX 8086 v1)
 13581                              <1> 	; INPUTS -> 
 13582                              <1> 	;     EBX = system buffer (data) address (r5)
 13583                              <1> 	;     [u.fofp] = pointer to file offset pointer
 13584                              <1> 	;     [u.base] = virtual address of the user buffer
 13585                              <1> 	;     [u.pbase] = physical address of the user buffer
 13586                              <1> 	;     [u.count] = byte count
 13587                              <1> 	;     [u.pcount] = byte count within page frame
 13588                              <1> 	; OUTPUTS -> 
 13589                              <1> 	;     ESI = user data offset (r1)
 13590                              <1> 	;     EDI = system (I/O) buffer offset (r2)
 13591                              <1> 	;     ECX = byte count (r3)
 13592                              <1> 	;     EAX = remain bytes after byte count within page frame
 13593                              <1> 	;	(If EAX > 0, transfer will continue from the next page)
 13594                              <1>         ;
 13595                              <1> 	; ((Modified registers:  EDX))
 13596                              <1>  
 13597 00010AEC 8B35[30010300]      <1>         mov     esi, [u.fofp]
 13598 00010AF2 8B3E                <1>         mov     edi, [esi]
 13599 00010AF4 89F9                <1> 	mov	ecx, edi
 13600 00010AF6 81C900FEFFFF        <1> 	or	ecx, 0FFFFFE00h
 13601 00010AFC 81E7FF010000        <1> 	and	edi, 1FFh
 13602 00010B02 01DF                <1> 	add	edi, ebx ; EBX = system buffer (data) address
 13603 00010B04 F7D9                <1> 	neg	ecx
 13604 00010B06 3B0D[44010300]      <1> 	cmp	ecx, [u.count]
 13605 00010B0C 7606                <1> 	jna	short sioreg_0
 13606 00010B0E 8B0D[44010300]      <1> 	mov	ecx, [u.count]
 13607                              <1> sioreg_0:
 13608 00010B14 803D[82010300]00    <1> 	cmp	byte [u.kcall], 0 
 13609 00010B1B 7613                <1> 	jna	short sioreg_1
 13610                              <1> 	 ; the caller is 'mkdir' or 'namei'
 13611 00010B1D A1[40010300]        <1> 	mov	eax, [u.base]
 13612 00010B22 A3[7C010300]        <1> 	mov 	[u.pbase], eax ; physical address = virtual address
 13613 00010B27 66890D[80010300]    <1> 	mov	word [u.pcount], cx ; remain bytes in buffer (1 sector)
 13614 00010B2E EB0B                <1> 	jmp	short sioreg_2
 13615                              <1> sioreg_1:
 13616 00010B30 0FB715[80010300]    <1> 	movzx	edx, word [u.pcount]
 13617 00010B37 39D1                <1> 	cmp	ecx, edx	
 13618 00010B39 772A                <1> 	ja	short sioreg_4 ; transfer count > [u.pcount]
 13619                              <1> sioreg_2: ; 2:
 13620 00010B3B 31C0                <1> 	xor 	eax, eax
 13621                              <1> sioreg_3:
 13622 00010B3D 010D[48010300]      <1> 	add 	[u.nread], ecx
 13623 00010B43 290D[44010300]      <1> 	sub 	[u.count], ecx
 13624 00010B49 010D[40010300]      <1> 	add 	[u.base], ecx
 13625 00010B4F 010E                <1>         add 	[esi], ecx 
 13626 00010B51 8B35[7C010300]      <1> 	mov	esi, [u.pbase]
 13627 00010B57 66290D[80010300]    <1> 	sub	[u.pcount], cx
 13628 00010B5E 010D[7C010300]      <1> 	add	[u.pbase], ecx
 13629 00010B64 C3                  <1>         retn
 13630                              <1> sioreg_4:
 13631                              <1> 	; transfer count > [u.pcount] 
 13632                              <1> 	; (ecx > edx)
 13633 00010B65 89C8                <1> 	mov	eax, ecx
 13634 00010B67 29D0                <1> 	sub	eax, edx ; remain bytes for 1 sector (block) transfer 
 13635 00010B69 89D1                <1> 	mov	ecx, edx ; current transfer count = [u.pcount]
 13636 00010B6B EBD0                <1> 	jmp	short sioreg_3
 13637                              <1> 
 13638                              <1> tswitch: ; Retro UNIX 386 v1
 13639                              <1> tswap:
 13640                              <1> 	; 16/01/2017
 13641                              <1> 	; 21/05/2016 - TRDOS 386 (TRDOS v2.0)
 13642                              <1> 	; 10/05/2015 - 01/09/2015 (Retro UNIX 386 v1)
 13643                              <1> 	; 14/04/2013 - 14/02/2014 (Retro UNIX 8086 v1)
 13644                              <1> 	; time out swap, called when a user times out.
 13645                              <1> 	; the user is put on the low priority queue.
 13646                              <1> 	; This is done by making a link from the last user
 13647                              <1> 	; on the low priority queue to him via a call to 'putlu'.
 13648                              <1> 	; then he is swapped out.
 13649                              <1> 
 13650                              <1> 	; TRDOS 386 (TRDOS v2.0) modification ->  ** 21/05/2016 **
 13651                              <1> 	;     * when a high priority (event) process will be stopped
 13652                              <1> 	;	(swapped out, swithched out/off), 'tswap/tswitch' will
 13653                              <1> 	;	not add it to a run queue. 
 13654                              <1> 	;	/// What for: Process may be already in a run queue, 
 13655                              <1> 	;	it is unspeficied state because process might be started
 13656                              <1> 	;	by a timer event which does not regard previous priority
 13657                              <1> 	;	level and run queue of the process (for fast executing!).
 13658                              <1> 	;	After the 'run for event', process will be sequenced
 13659                              <1> 	;	to run by it's actual run queue. ///
 13660                              <1> 	;
 13661                              <1> 	; Retro UNIX 386 v1 modification ->
 13662                              <1> 	;       swap (software task switch) is performed by changing
 13663                              <1> 	;	user's page directory (u.pgdir) instead of segment change
 13664                              <1> 	;	as in Retro UNIX 8086 v1.
 13665                              <1> 	;
 13666                              <1> 	; RETRO UNIX 8086 v1 modification ->
 13667                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 13668                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 13669                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 13670                              <1> 	;	compatibles was using 1MB segmented memory
 13671                              <1> 	;	in 8086/8088 times.
 13672                              <1> 	;
 13673                              <1> 	; INPUTS ->
 13674                              <1> 	;    u.uno - users process number
 13675                              <1> 	;    runq+4 - lowest priority queue
 13676                              <1> 	; OUTPUTS ->
 13677                              <1> 	;    r0 - users process number
 13678                              <1> 	;    r2 - lowest priority queue address
 13679                              <1> 	;
 13680                              <1> 	; ((AX = R0, BX = R2)) output
 13681                              <1> 	; ((Modified registers: EDX, EBX, ECX, ESI, EDI))
 13682                              <1> 	;
 13683                              <1> 
 13684                              <1> 	NOTE:
 13685                              <1> 	;* [u.pri] priority level is specified by run queue which is process 
 13686                              <1> 	;  comes to run from.
 13687                              <1> 	;* Initial [u.pri] is 1 ('normal/regular') for programs 
 13688                              <1> 	;  (which are launched by MainProg or 'sysexec'), it is changed
 13689                              <1> 	;  to 2 ('high') by timer event, if program uses 'systimer' system call.
 13690                              <1> 	;* Program (Process) also can change it's running priority 
 13691                              <1> 	;  from 1 to 0 or up to 2 by using 'syspri' system call; but,
 13692                              <1> 	;  if program selects priority level 2 (high) for running, next time 
 13693                              <1> 	;  it is reduced to 1 (normal/regular) because 'syspri' adds this
 13694                              <1> 	;  program to 'run for normal' queue while running duration is a bit
 13695                              <1> 	;  protected from swap/switch out immediate, behalf of other high 
 13696                              <1> 	;  priority process in sequence. Program (with high priority) will not 
 13697                              <1> 	;  be swapped/switched out (by timer event) before it's time quantum 
 13698                              <1> 	;  will be elapsed, but, this will be temporary if program is not using 
 13699                              <1> 	;  timer event function.
 13700                              <1> 
 13701                              <1> 	;For example:
 13702                              <1> 	;If a process frequently gets a timer event, it runs at high priority
 13703                              <1> 	;level but when it returns from running it returns to actual run queue,
 13704                              <1> 	;not to 'run for event' queue again.
 13705                              <1> 	;'tswap' will not change the sequence at return/stop(swap out) stage.
 13706                              <1> 	;But if priority level not high (=2, 'run for event'), 'tswap/tswitch'
 13707                              <1> 	;will add the stopping process to relevant run queue according to
 13708                              <1> 	;[u.pri] priority level.
 13709                              <1> 
 13710                              <1> 	; 16/01/2017
 13711 00010B6D BB[0C010300]        <1> 	mov	ebx, runq+2 	; 'runq_normal' ; normal/regular priority
 13712                              <1> 	; 21/05/2016
 13713                              <1> 	;cmp	byte [u.pri], 2	; high priority (run for event) ?
 13714                              <1> 	;jnb	short swap
 13715                              <1> 	; 16/01/2017
 13716                              <1> 	; (Normal and also high/event priority processes will be added to
 13717                              <1> 	; normal priority run queue for ensuring circular running sequence!)
 13718                              <1> 	; (Timer interrupt or 'syspri' system call may change priority and run
 13719                              <1> 	; queue to high/event level.)
 13720 00010B72 803D[66010300]00    <1> 	cmp	byte [u.pri], 0
 13721 00010B79 7702                <1> 	ja	short tswap_1	; normal priority run queue
 13722                              <1> 	;
 13723 00010B7B 43                  <1> 	inc	ebx
 13724 00010B7C 43                  <1> 	inc	ebx		; runq+4, 'runq_background', low priority
 13725                              <1> tswap_1:
 13726 00010B7D A0[6D010300]        <1> 	mov 	al, [u.uno]
 13727                              <1> 	       	; movb u.uno,r1 / move users process number to r1
 13728                              <1> 		; mov  $runq+4,r2 
 13729                              <1> 			; / move lowest priority queue address to r2
 13730                              <1>       	; ebx = run queue
 13731 00010B82 E8FE000000          <1> 	call 	putlu
 13732                              <1> 		; jsr r0,putlu / create link from last user on Q to 
 13733                              <1> 		             ; / u.uno's user
 13734                              <1> 
 13735                              <1> switch: ; Retro UNIX 386 v1
 13736                              <1> swap:
 13737                              <1> 	; 02/01/2017
 13738                              <1> 	; 21/05/2016
 13739                              <1> 	; 20/05/2016
 13740                              <1> 	; 02/05/2016
 13741                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 13742                              <1> 	; 10/05/2015 - 02/09/2015 (Retro UNIX 386 v1)
 13743                              <1> 	; 14/04/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 13744                              <1> 	;
 13745                              <1> 	; 'swap' is routine that controls the swapping of processes
 13746                              <1> 	; in and out of core.
 13747                              <1> 	;
 13748                              <1> 	; TRDOS 386 (TRDOS v2.0) modification ->  ** 20/05/2016 **
 13749                              <1> 	;     * 3 different priority level is applied 
 13750                              <1> 	;	(just as original unix v1)
 13751                              <1> 	;	1) high priority (event) run queue, 'runq_event'
 13752                              <1> 	;	2) normal priority (regular) run queue, 'runq_normal'
 13753                              <1> 	;	3) low priority (background) run queue, 'runq_backgroud'
 13754                              <1> 	;	'swap' code will run a process which has max. priority
 13755                              <1>         ;       (for earliest event at first)
 13756                              <1> 	;
 13757                              <1> 	; Retro UNIX 386 v1 modification ->
 13758                              <1> 	;       swap (software task switch) is performed by changing
 13759                              <1> 	;	user's page directory (u.pgdir) instead of segment change
 13760                              <1> 	;	as in Retro UNIX 8086 v1.
 13761                              <1> 	;
 13762                              <1> 	; RETRO UNIX 8086 v1 modification ->
 13763                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 13764                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 13765                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 13766                              <1> 	;	compatibles was using 1MB segmented memory
 13767                              <1> 	;	in 8086/8088 times.
 13768                              <1> 	;
 13769                              <1> 	; INPUTS ->
 13770                              <1> 	;    runq table - contains processes to run.
 13771                              <1> 	;    p.link - contains next process in line to be run.
 13772                              <1> 	;    u.uno - process number of process in core	
 13773                              <1> 	;    s.stack - swap stack used as an internal stack for swapping.
 13774                              <1> 	; OUTPUTS ->
 13775                              <1> 	;    (original unix v1 -> present process to its disk block)
 13776                              <1> 	;    (original unix v1 -> new process into core -> 
 13777                              <1> 	;	   Retro Unix 8086 v1 -> segment registers changed 
 13778                              <1> 	;	   for new process)
 13779                              <1> 	;    u.quant = 3 (Time quantum for a process)
 13780                              <1> 	; 	((INT 1Ch count down speed -> 18.2 times per second)
 13781                              <1> 	;    RETRO UNIX 8086 v1 will use INT 1Ch (18.2 times per second)
 13782                              <1> 	;	 for now, it will swap the process if there is not
 13783                              <1> 	;	 a keyboard event (keystroke) (Int 15h, function 4Fh)
 13784                              <1> 	;	 or will count down from 3 to 0 even if there is a
 13785                              <1> 	;        keyboard event locking due to repetitive key strokes.
 13786                              <1> 	;	 u.quant will be reset to 3 for RETRO UNIX 8086 v1.
 13787                              <1> 	;
 13788                              <1> 	; ((Modified registers: EAX, EDX, EBX, ECX, ESI, EDI))
 13789                              <1> 
 13790                              <1> 	;NOTE:
 13791                              <1> 	;High priority queue is the first for selecting a process to run.
 13792                              <1> 	;If there is not a process in high priority level run queue,
 13793                              <1> 	;a process in normal priority run queue will be selected
 13794                              <1> 	;or a proces in low priority run queue will be selected if normal
 13795                              <1> 	;priority level run queue is empty.
 13796                              <1> 	
 13797                              <1> 	; 21/05/2016 -(3 priority levels, 3 run queues)
 13798 00010B87 BE[0A010300]        <1> 	mov	esi, runq ; 'runq_event' ; high priority, 'run for event'
 13799 00010B8C C605[14840100]03    <1> 	mov	byte [priority], 3 ; high priority + 1
 13800 00010B93 31DB                <1> 	xor	ebx, ebx ; 02/01/2017
 13801                              <1> swap_0: ; 1: / search runq table for highest priority process
 13802 00010B95 66AD                <1> 	lodsw  ; mov ax, [esi], add esi+2
 13803                              <1> 	;xor	ebx, ebx ; 02/05/2016
 13804 00010B97 6621C0              <1> 	and 	ax, ax ; are there any processes to run in this Q entry
 13805 00010B9A 750E                <1> 	jnz	short swap_2 
 13806                              <1> 	; 21/05/2026
 13807                              <1> 	; runq_normal = runq+2, runq_background = runq+4
 13808 00010B9C FE0D[14840100]      <1> 	dec	byte [priority] ; 3 -> 3, 2 -> 1, 1-> 0
 13809 00010BA2 75F1                <1> 	jnz	short swap_0	
 13810                              <1> 	;cmp	esi, runq+6  ; if zero compare address to end of table
 13811                              <1> 	;jb	short swap_0 ; if not at end, go back
 13812                              <1> swap_1:
 13813                              <1> 	; 02/05/2016
 13814                              <1> 	; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
 13815                              <1> 	; No user process to run...
 13816                              <1> 	; Run the kernel process... MainProg: Internal Command Interpreter
 13817 00010BA4 FEC0                <1> 	inc	al ; mov al, 1  ; process number of MainProg
 13818 00010BA6 FEC3                <1> 	inc	bl ; mov bl, al ; 1
 13819 00010BA8 EB1E                <1> 	jmp	short swap_4
 13820                              <1> swap_2:
 13821                              <1> 	; 21/05/2016
 13822 00010BAA FE0D[14840100]      <1> 	dec	byte [priority] ; priority level of present user/process
 13823                              <1> 			        ; 0, 1, 2
 13824 00010BB0 4E                  <1> 	dec	esi
 13825 00010BB1 4E                  <1>         dec     esi
 13826                              <1> 	;
 13827 00010BB2 88C3                <1> 	mov	bl, al
 13828 00010BB4 38E0                <1> 	cmp	al, ah ; is there only 1 process in the queue to be run
 13829 00010BB6 740A                <1> 	je	short swap_3 ; yes
 13830 00010BB8 8AA3[4F000300]      <1> 	mov	ah, [ebx+p.link-1] 
 13831 00010BBE 8826                <1>        	mov	[esi], ah ; move next process in line into run queue
 13832 00010BC0 EB06                <1> 	jmp	short swap_4
 13833                              <1> swap_3: 
 13834 00010BC2 6631D2              <1> 	xor	dx, dx
 13835 00010BC5 668916              <1> 	mov	[esi], dx ; zero the entry; no processes on the Q
 13836                              <1> swap_4: 
 13837 00010BC8 8A25[6D010300]      <1> 	mov 	ah, [u.uno]
 13838 00010BCE 38C4                <1> 	cmp	ah, al ; is this process the same as the process in core?
 13839 00010BD0 743B                <1>        	je	short swap_8 ; yes, don't have to swap
 13840 00010BD2 08E4                <1> 	or	ah, ah  ; is the process # = 0
 13841 00010BD4 740D                <1>        	jz	short swap_6 ; 'sysexit'
 13842                              <1> 	;cmp	ah, al ;is this process the same as the process in core?
 13843                              <1>        	;je	short swap_8 ; yes, don't have to swap
 13844 00010BD6 8925[18010300]      <1> 	mov	[u.usp], esp ; return  address for 'syswait' & 'sleep'
 13845 00010BDC E834000000          <1> 	call	wswap   ; write out core to disk
 13846 00010BE1 EB1C                <1> 	jmp 	short swap_7
 13847                              <1> swap_6:
 13848                              <1> 	; Deallocate memory pages belong to the process
 13849                              <1> 	; which is being terminated.
 13850                              <1> 	; (Retro UNIX 386 v1 modification !)
 13851                              <1> 	;
 13852 00010BE3 53                  <1> 	push	ebx
 13853 00010BE4 A1[74010300]        <1> 	mov 	eax, [u.pgdir]  ; page directory of the process
 13854 00010BE9 8B1D[78010300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
 13855 00010BEF E8114CFFFF          <1> 	call	deallocate_page_dir
 13856 00010BF4 A1[70010300]        <1> 	mov	eax, [u.upage] ; 'user' structure page of the process
 13857 00010BF9 E8964CFFFF          <1> 	call	deallocate_page
 13858 00010BFE 5B                  <1> 	pop	ebx
 13859                              <1> swap_7: 
 13860 00010BFF C0E302              <1> 	shl	bl, 2 ; * 4 
 13861 00010C02 8B83[6C000300]      <1> 	mov	eax, [ebx+p.upage-4] ; the 'u' page of the new process
 13862 00010C08 E840000000          <1> 	call	rswap ; read new process into core
 13863                              <1> swap_8: 
 13864                              <1> 	; Retro UNIX  8086 v1 modification !
 13865 00010C0D C605[64010300]04    <1> 	mov	byte [u.quant], time_count 
 13866 00010C14 C3                  <1> 	retn
 13867                              <1> 
 13868                              <1> wswap:  ; < swap out, swap to disk >
 13869                              <1> 	; 28/02/2017 (fnsave)
 13870                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 13871                              <1> 	; 09/05/2015 (Retro UNIX 386 v1)
 13872                              <1> 	; 26/05/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 13873                              <1> 	; 'wswap' writes out the process that is in core onto its
 13874                              <1> 	; appropriate disk area.
 13875                              <1> 	;
 13876                              <1> 	; Retro UNIX 386 v1 modification ->
 13877                              <1> 	;       User (u) structure content and the user's register content
 13878                              <1> 	;	will be copied to the process's/user's UPAGE (a page for
 13879                              <1> 	;	saving 'u' structure and user registers for task switching).
 13880                              <1> 	;	u.usp - points to kernel stack address which contains
 13881                              <1> 	;		user's registers while entering system call.
 13882                              <1> 	;	u.sp  - points to kernel stack address 
 13883                              <1> 	;		to return from system call -for IRET-.
 13884                              <1> 	;	[u.usp]+32+16 = [u.sp] 
 13885                              <1> 	;	[u.usp] -> edi, esi, ebp, esp (= [u.usp]+32), ebx, 
 13886                              <1> 	;		edx, ecx, eax, gs, fs, es, ds, -> [u.sp].
 13887                              <1> 	;
 13888                              <1> 	; Retro UNIX 8086 v1 modification ->
 13889                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 13890                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 13891                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 13892                              <1> 	;	compatibles was using 1MB segmented memory 
 13893                              <1> 	;	in 8086/8088 times.
 13894                              <1> 	;
 13895                              <1> 	; INPUTS ->
 13896                              <1> 	;    u.break - points to end of program
 13897                              <1> 	;    u.usp - stack pointer at the moment of swap
 13898                              <1> 	;    core - beginning of process program
 13899                              <1> 	;    ecore - end of core 	
 13900                              <1> 	;    user - start of user parameter area
 13901                              <1> 	;    u.uno - user process number
 13902                              <1> 	;    p.dska - holds block number of process
 13903                              <1> 	; OUTPUTS ->
 13904                              <1> 	;    swp I/O queue
 13905                              <1> 	;    p.break - negative word count of process 
 13906                              <1> 	;    r1 - process disk address	
 13907                              <1> 	;    r2 - negative word count
 13908                              <1> 	;
 13909                              <1> 	; RETRO UNIX 8086 v1 input/output:
 13910                              <1> 	;
 13911                              <1> 	; INPUTS ->
 13912                              <1> 	;    u.uno - process number (to be swapped out)
 13913                              <1> 	; OUTPUTS ->
 13914                              <1> 	;    none
 13915                              <1> 	;
 13916                              <1> 	;   ((Modified registers: ECX, ESI, EDI))  
 13917                              <1> 	;
 13918                              <1> 
 13919                              <1> 	; 28/02/2017
 13920                              <1> 	;cmp	byte [multi_tasking], 0  ; Musti tasking mode ?
 13921                              <1> 	;jna	short wswp
 13922 00010C15 803D[97010300]00    <1> 	cmp	byte [u.fpsave], 0 ; 28/02/2017
 13923 00010C1C 7606                <1> 	jna	short wswp
 13924 00010C1E DD35[98010300]      <1> 	fnsave	[u.fpregs] ; save floating point registers (94 bytes)
 13925                              <1> wswp:
 13926 00010C24 8B3D[70010300]      <1> 	mov	edi, [u.upage] ; process's user (u) structure page addr
 13927 00010C2A B93C000000          <1> 	mov	ecx, (U_SIZE + 3) / 4
 13928 00010C2F BE[14010300]        <1> 	mov	esi, user ; active user (u) structure
 13929 00010C34 F3A5                <1> 	rep	movsd
 13930                              <1> 	;
 13931 00010C36 8B35[18010300]      <1> 	mov	esi, [u.usp] ; esp (system stack pointer, 
 13932                              <1> 			     ;      points to user registers)
 13933 00010C3C 8B0D[14010300]      <1> 	mov	ecx, [u.sp]  ; return address from the system call
 13934                              <1> 			     ; (for IRET)
 13935                              <1> 			     ; [u.sp] -> EIP (user)
 13936                              <1> 			     ; [u.sp+4]-> CS (user)
 13937                              <1> 			     ; [u.sp+8] -> EFLAGS (user)
 13938                              <1> 			     ; [u.sp+12] -> ESP (user)
 13939                              <1> 			     ; [u.sp+16] -> SS (user)
 13940 00010C42 29F1                <1> 	sub	ecx, esi     ; required space for user registers
 13941 00010C44 83C114              <1> 	add	ecx, 20	     ; +5 dwords to return from system call
 13942                              <1> 			     ; (for IRET)
 13943 00010C47 C1E902              <1> 	shr	ecx, 2
 13944 00010C4A F3A5                <1> 	rep	movsd
 13945 00010C4C C3                  <1> 	retn
 13946                              <1> 
 13947                              <1> rswap:  ; < swap in, swap from disk >
 13948                              <1> 	; 28/02/2017 (frstor)
 13949                              <1> 	; 15/01/2017
 13950                              <1> 	; 14/01/2017
 13951                              <1> 	; 21/05/2016
 13952                              <1> 	; 03/05/2016
 13953                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 13954                              <1> 	; 09/05/2015 - 15/09/2015 (Retro UNIX 386 v1)
 13955                              <1> 	; 26/05/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 13956                              <1> 	; 'rswap' reads a process whose number is in r1,
 13957                              <1> 	; from disk into core.
 13958                              <1> 	;
 13959                              <1> 	; Retro UNIX 386 v1 modification ->
 13960                              <1> 	;       User (u) structure content and the user's register content
 13961                              <1> 	;	will be restored from process's/user's UPAGE (a page for
 13962                              <1> 	;	saving 'u' structure and user registers for task switching).
 13963                              <1> 	;	u.usp - points to kernel stack address which contains
 13964                              <1> 	;		user's registers while entering system call.
 13965                              <1> 	;	u.sp  - points to kernel stack address 
 13966                              <1> 	;		to return from system call -for IRET-.
 13967                              <1> 	;	[u.usp]+32+16 = [u.sp] 
 13968                              <1> 	;	[u.usp] -> edi, esi, ebp, esp (= [u.usp]+32), ebx, 
 13969                              <1> 	;		edx, ecx, eax, gs, fs, es, ds, -> [u.sp].
 13970                              <1> 	;
 13971                              <1> 	; RETRO UNIX 8086 v1 modification ->
 13972                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 13973                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 13974                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 13975                              <1> 	;	compatibles was using 1MB segmented memory 
 13976                              <1> 	;	in 8086/8088 times.
 13977                              <1> 	;
 13978                              <1> 	; INPUTS ->
 13979                              <1> 	;    r1 - process number of process to be read in
 13980                              <1> 	;    p.break - negative of word count of process 
 13981                              <1> 	;    p.dska - disk address of the process
 13982                              <1> 	;    u.emt - determines handling of emt's
 13983                              <1> 	;    u.ilgins - determines handling of illegal instructions
 13984                              <1> 	; OUTPUTS ->
 13985                              <1> 	;    8 = (u.ilgins)
 13986                              <1> 	;    24 = (u.emt)
 13987                              <1> 	;    swp - bit 10 is set to indicate read 
 13988                              <1> 	;		(bit 15=0 when reading is done)	
 13989                              <1> 	;    swp+2 - disk block address
 13990                              <1> 	;    swp+4 - negative word count 	
 13991                              <1> 	;      ((swp+6 - address of user structure)) 
 13992                              <1> 	;
 13993                              <1> 	; RETRO UNIX 8086 v1 input/output:
 13994                              <1> 	;
 13995                              <1> 	; INPUTS ->
 13996                              <1> 	;    AL	- new process number (to be swapped in)	 
 13997                              <1> 	; OUTPUTS ->
 13998                              <1> 	;    none
 13999                              <1> 	;
 14000                              <1> 	;   ((Modified registers: EAX, ECX, ESI, EDI, ESP))
 14001                              <1> 	;
 14002                              <1> 	; Retro UNIX 386 v1 - modification ! 14/05/2015
 14003 00010C4D 89C6                <1> 	mov	esi, eax  ; process's user (u) structure page addr
 14004 00010C4F B93C000000          <1> 	mov	ecx, (U_SIZE + 3) / 4
 14005 00010C54 BF[14010300]        <1> 	mov	edi, user ; active user (u) structure	
 14006 00010C59 F3A5                <1> 	rep	movsd
 14007 00010C5B 58                  <1> 	pop	eax	; 'rswap' return address
 14008                              <1> 	; 
 14009                              <1> 	;cli
 14010 00010C5C 8B3D[18010300]      <1> 	mov	edi, [u.usp] ; esp (system stack pointer,
 14011                              <1> 			     ;     points to user registers)
 14012 00010C62 89FC                <1> 	mov	esp, edi     ; 14/01/2017
 14013 00010C64 8B0D[14010300]      <1> 	mov	ecx, [u.sp]  ; return address from the system call
 14014                              <1> 			     ; (for IRET)
 14015                              <1> 			     ; [u.sp] -> EIP (user)
 14016                              <1> 			     ; [u.sp+4]-> CS (user)
 14017                              <1> 			     ; [u.sp+8] -> EFLAGS (user)
 14018                              <1> 			     ; [u.sp+12] -> ESP (user)
 14019                              <1> 			     ; [u.sp+16] -> SS (user)
 14020 00010C6A 29F9                <1> 	sub	ecx, edi     ; required space for user registers
 14021 00010C6C 83C114              <1> 	add	ecx, 20	     ; +5 dwords to return from system call
 14022                              <1> 			     ; (for IRET)
 14023 00010C6F C1E902              <1> 	shr	ecx, 2
 14024 00010C72 F3A5                <1> 	rep	movsd
 14025                              <1> 	;mov	esp, [u.usp] ; 15/09/2015
 14026                              <1> 	;sti
 14027                              <1> 	; 28/02/2017
 14028                              <1> 	;cmp	byte [multi_tasking], 0  ; Musti tasking mode ?
 14029                              <1> 	;jna	short rswp_retn
 14030 00010C74 803D[97010300]00    <1> 	cmp	byte [u.fpsave], 0
 14031 00010C7B 7606                <1> 	jna	short rswp_retn
 14032 00010C7D DD25[98010300]      <1> 	frstor	[u.fpregs] ; restore floating point regs (94 bytes)
 14033                              <1> rswp_retn:
 14034 00010C83 50                  <1> 	push	eax	; 'rswap' return address
 14035 00010C84 C3                  <1> 	retn
 14036                              <1> 
 14037                              <1> putlu: 
 14038                              <1> 	; 20/05/2016
 14039                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 14040                              <1> 	; 10/05/2015 - 12/09/2015 (Retro UNIX 386 v1)
 14041                              <1> 	; 15/04/2013 - 23/02/2014 (Retro UNIX 8086 v1)
 14042                              <1> 	; 'putlu' is called with a process number in r1 and a pointer
 14043                              <1> 	; to lowest priority Q (runq+4) in r2. A link is created from
 14044                              <1> 	; the last process on the queue to process in r1 by putting
 14045                              <1> 	; the process number in r1 into the last process's link.
 14046                              <1> 	;
 14047                              <1> 	; INPUTS ->
 14048                              <1> 	;    r1 - user process number
 14049                              <1> 	;    r2 - points to lowest priority queue
 14050                              <1> 	;    p.dska - disk address of the process	
 14051                              <1> 	;    u.emt - determines handling of emt's
 14052                              <1> 	;    u.ilgins - determines handling of illegal instructions
 14053                              <1> 	; OUTPUTS ->
 14054                              <1> 	;    r3 - process number of last process on the queue upon
 14055                              <1> 	;	  entering putlu
 14056                              <1> 	;    p.link-1 + r3 - process number in r1
 14057                              <1> 	;    r2 - points to lowest priority queue
 14058                              <1> 	;
 14059                              <1> 	; ((Modified registers: EDX, EBX)) 
 14060                              <1> 	;
 14061                              <1> 	; / r1 = user process no.; r2 points to lowest priority queue
 14062                              <1> 
 14063                              <1> 	; EBX = r2
 14064                              <1> 	; EAX = r1 (AL=r1b)
 14065                              <1> 
 14066                              <1> 	; 20/05/2016
 14067                              <1> 	; AL = process number (1 to 16) // Retro UNIX 8086, 386 v1 //
 14068                              <1> 	;     (max. 16 processes available for current kernel version)
 14069                              <1> 	; EBX = run queue address ; 20/05/2016 (TRDOS 386)
 14070                              <1> 		; which is one of following addresses:
 14071                              <1> 		;  1) 'runq_event' high priority run queue
 14072                              <1> 		;  2) 'runq_normal' normal/regular priority run queue
 14073                              <1> 		;  3) 'runq_background' low priority run queue
 14074                              <1> 
 14075                              <1> 	;mov	ebx, runq
 14076 00010C85 0FB613              <1> 	movzx  	edx, byte [ebx]
 14077 00010C88 43                  <1> 	inc	ebx
 14078 00010C89 20D2                <1> 	and	dl, dl
 14079                              <1> 		; tstb (r2)+ / is queue empty?
 14080 00010C8B 740A                <1>        	jz	short putlu_1
 14081                              <1> 		; beq 1f / yes, branch
 14082 00010C8D 8A13                <1> 	mov 	dl, [ebx] ; 12/09/2015
 14083                              <1> 		; movb (r2),r3 / no, save the "last user" process number
 14084                              <1> 			     ; / in r3
 14085 00010C8F 8882[4F000300]      <1>        	mov	[edx+p.link-1], al
 14086                              <1> 		; movb r1,p.link-1(r3) / put pointer to user on 
 14087                              <1> 			     ; / "last users" link
 14088 00010C95 EB03                <1> 	jmp	short putlu_2
 14089                              <1> 		; br 2f /
 14090                              <1> putlu_1: ; 1:
 14091 00010C97 8843FF              <1> 	mov	[ebx-1], al
 14092                              <1>        		; movb r1,-1(r2) / user is only user; 
 14093                              <1> 			    ; / put process no. at beginning and at end
 14094                              <1> putlu_2: ; 2: 
 14095 00010C9A 8803                <1> 	mov	[ebx], al
 14096                              <1>        		; movb r1,(r2) / user process in r1 is now the last entry
 14097                              <1> 			     ; / on the queue
 14098 00010C9C 88C2                <1> 	mov	dl, al
 14099 00010C9E 88B2[4F000300]      <1>         mov     [edx+p.link-1], dh ; 0
 14100                              <1> 		; dec r2 / restore r2
 14101 00010CA4 C3                  <1>         retn
 14102                              <1> 		; rts r0
 14103                              <1> 
 14104                              <1> sysver:
 14105                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 14106 00010CA5 C705[1C010300]0002- <1> 	mov	dword [u.r0], 200h ; AH = major version, AL = minor version 
 14106 00010CAD 0000                <1>
 14107 00010CAF E96BC0FFFF          <1> 	jmp	sysret
 14108                              <1> 
 14109                              <1> syspri: ; change running priority (of the process)
 14110                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 14111                              <1> 	; 21/05/2016
 14112                              <1> 	; 20/05/2026 - TRDOS 386 (TRDOS v2.0)
 14113                              <1> 	; INPUT ->
 14114                              <1> 	;	BL = priority level
 14115                              <1> 	;	   0 = low running priority (running on background)
 14116                              <1> 	;	   1 = normal/regular priority (running as regular)
 14117                              <1> 	;	   2 = high/event priority (running for event)
 14118                              <1> 	;	   >2 = invalid, it will accepted as 2 (event)
 14119                              <1> 	;	   0FFh = get/return current running priority only
 14120                              <1> 	; OUTPUT -> 	
 14121                              <1> 	;	* if current [u.pri] < 2
 14122                              <1> 	;	  if BL input < 0FFh ->
 14123                              <1> 	;	     [u.pri] is updated as in BL input (0,1,2)
 14124                              <1> 	;	  if BL input = 0FFh -> AL = [u.pri] (current)
 14125                              <1> 	;	      
 14126                              <1> 	;	* if current [u.pri] = 2
 14127                              <1> 	;	  if BL input < 0FFh -> cf = 1 & AL = 2
 14128                              <1> 	;	  if BL input = 0FFh -> cf = 0 & AL = 2
 14129                              <1> 	;	
 14130                              <1> 	;	NOTE: 	
 14131                              <1> 	;	If [u.pri] = 2, it can not be changed to 1 or 0;
 14132                              <1> 	;	because, run queue of the running process is unspecified
 14133                              <1> 	;	at this	stage. Process might be started by a timer event
 14134                              <1> 	;	or priority might be changed to high by previous
 14135                              <1> 	;	'syspri' system	call. In both cases, the process is in
 14136                              <1> 	;	'runq_normal' or 'runq_background' queue.
 14137                              <1> 	;	As result of this fact, when the [u.quant] time quantum
 14138                              <1> 	;	of the process is elapsed or 'sysrele' system call is
 14139                              <1> 	;	instructed by the process, 'tswap' ('tswitch') procedure
 14140                              <1> 	;	will be called (to 'swap' or 'switch' out the procedure)
 14141                              <1> 	;	and it will not call 'putlu' to add the (stopping)
 14142                              <1> 	;	process to relevant run queue when [u.pri] = 2.
 14143                              <1> 	;	(Otherwise, it would be possible to add process to
 14144                              <1> 	;	a run queue while it is already in a run queue, wrongly.)
 14145                              <1>   	;
 14146                              <1> 	;	If [u.pri]< 2, 'tswap/tswitch' procedure will call
 14147                              <1> 	;	'putlu' to add process to relevant run queue
 14148                              <1> 	;	according to [u.pri] value. ('runq_normal' for 1,
 14149                              <1> 	;	'runq_background' for 0).
 14150                              <1> 	;
 14151                              <1> 	;	If BL input >= 2 and < 0FFh while [u.pri] < 2,
 14152                              <1> 	;	process will be added to 'runq_normal' queue and
 14153                              <1> 	;	[u.pri] will be set to 2. (in 'syspri' system call)
 14154                              <1> 	;
 14155                              <1> 
 14156 00010CB4 29C0                <1> 	sub	eax, eax ; 0
 14157 00010CB6 A3[84010300]        <1> 	mov	[u.error], eax
 14158                              <1> 
 14159 00010CBB A0[66010300]        <1> 	mov	al, [u.pri]
 14160 00010CC0 A3[1C010300]        <1> 	mov	[u.r0], eax
 14161                              <1> 
 14162 00010CC5 FEC3                <1> 	inc	bl
 14163                              <1> 	;jz	sysret ; 0FFh -> 0, get priority level
 14164                              <1> 	; 23/07/2022	
 14165 00010CC7 742C                <1> 	jz	short syspri_2	; jmp sysret
 14166                              <1> 
 14167 00010CC9 3C02                <1> 	cmp	al, 2
 14168                              <1> 	;jnb	error ; CF = 1 & AL = 2 (& last error = 0)
 14169                              <1> 	; 23/07/2022
 14170 00010CCB 7205                <1> 	jb	short syspri_0
 14171 00010CCD E92DC0FFFF          <1> 	jmp	error
 14172                              <1> syspri_0:
 14173 00010CD2 FECB                <1> 	dec	bl
 14174 00010CD4 80FB02              <1> 	cmp	bl, 2
 14175 00010CD7 7602                <1> 	jna	short syspri_1
 14176 00010CD9 B302                <1> 	mov	bl, 2
 14177                              <1> syspri_1:
 14178 00010CDB 881D[66010300]      <1> 	mov	[u.pri], bl
 14179 00010CE1 80FB02              <1> 	cmp	bl, 2
 14180                              <1> 	;jb	sysret
 14181                              <1> 	; 23/07/2022
 14182 00010CE4 720F                <1> 	jb	short syspri_2	; jmp sysret
 14183                              <1> 
 14184                              <1> 	; here...
 14185                              <1> 	; Priority of current process has been changed to high
 14186                              <1> 	; ('run for event') but current process will be added to
 14187                              <1> 	; 'run as normal' queue. ('run for event' high priority
 14188                              <1> 	; queue is under control of timer -& RTC- interrupt only!) 
 14189                              <1> 	;
 14190                              <1> 	; (Otherwise, process can fall into black hole!
 14191                              <1> 	; e.g. if it is not in waiting list and it has not got 
 14192                              <1> 	; a timer event and it is not in a run queue!
 14193                              <1> 	; Because, when [u.pri] is 2, 'tswap/tswitch' will not 
 14194                              <1> 	; add the stopping process to a run queue.)
 14195                              <1> 
 14196 00010CE6 A0[6D010300]        <1> 	mov	al, [u.uno]
 14197 00010CEB BB[0C010300]        <1> 	mov	ebx, runq_normal ; normal priority !
 14198                              <1> 				 ; [u.pri] is set to high
 14199                              <1> 				 ; but 'runq_event' queue is set
 14200                              <1> 				 ; only by the kernel's timer
 14201                              <1> 				 ; event function (timer interrupt). 
 14202 00010CF0 E890FFFFFF          <1> 	call	putlu
 14203                              <1> syspri_2:
 14204 00010CF5 E925C0FFFF          <1> 	jmp	sysret
 14205                              <1> 
 14206                              <1> cpass: ; / get next character from user area of core and put it in AL (r1)
 14207                              <1> 	; 30/07/2022 - TRDOS 386 Kernel v2.0.5
 14208                              <1> 	; 02/05/2016 - TRDOS 386 (TRDOS v2.0)
 14209                              <1> 	; 19/05/2015 - 18/10/2015 (Retro UNIX 386 v1)
 14210                              <1> 	; 14/08/2013 - 20/09/2013 (Retro UNIX 8086 v1)
 14211                              <1> 	; INPUTS -> 
 14212                              <1> 	;     [u.base] = virtual address in user area
 14213                              <1> 	;     [u.count] = byte count (max.)
 14214                              <1> 	;     [u.pcount] = byte count in page (0 = reset)
 14215                              <1> 	; OUTPUTS -> 
 14216                              <1> 	;     AL = the character which is pointed by [u.base]
 14217                              <1> 	;     zf = 1 -> transfer count has been completed
 14218                              <1>         ;
 14219                              <1> 	; ((Modified registers: EAX, EDX, ECX))
 14220                              <1> 	
 14221                              <1> 	; 30/07/2022
 14222 00010CFA 29C0                <1> 	sub	eax, eax
 14223                              <1> 	
 14224 00010CFC 3905[44010300]      <1> 	cmp	[u.count], eax ; 0
 14225                              <1> 	;cmp 	dword [u.count], 0  ; have all the characters been transferred
 14226                              <1> 			    	    ; i.e., u.count, # of chars. left
 14227 00010D02 763D                <1> 	jna	short cpass_3	    ; to be transferred = 0?) yes, branch
 14228 00010D04 FF0D[44010300]      <1> 	dec	dword [u.count]	    ; no, decrement u.count
 14229                              <1>         ; 19/05/2015 
 14230                              <1> 	;(Retro UNIX 386 v1 - translation from user's virtual address
 14231                              <1> 	;		      to physical address
 14232                              <1> 	; 30/07/2022
 14233 00010D0A 663905[80010300]    <1> 	cmp	[u.pcount], ax ; 0
 14234                              <1> 	;cmp	word [u.pcount], 0 ; byte count in page = 0 (initial value)
 14235                              <1> 			     ; 1-4095 --> use previous physical base address
 14236                              <1> 			     ; in [u.pbase]
 14237 00010D11 770D                <1> 	ja	short cpass_1
 14238                              <1> 	; 30/07/2022
 14239 00010D13 3905[78010300]      <1> 	cmp	[u.ppgdir], eax ; 0
 14240                              <1> 	;cmp	dword [u.ppgdir], 0 ; is the caller os kernel
 14241 00010D19 7427                <1>         je      short cpass_k       ; (sysexec, '/etc/init') ?  (MainProg)
 14242 00010D1B E860FDFFFF          <1> 	call	trans_addr_r
 14243                              <1> cpass_1:
 14244 00010D20 66FF0D[80010300]    <1> 	dec	word [u.pcount]
 14245                              <1> cpass_2: 
 14246 00010D27 8B15[7C010300]      <1> 	mov	edx, [u.pbase]
 14247 00010D2D 8A02                <1> 	mov	al, [edx]	; take the character pointed to 
 14248                              <1> 				; by u.base and put it in r1
 14249 00010D2F FF05[48010300]      <1> 	inc	dword [u.nread] ; increment no. of bytes transferred
 14250 00010D35 FF05[40010300]      <1> 	inc	dword [u.base]  ; increment the buffer address to point to the
 14251                              <1> 			        ; next byte
 14252 00010D3B FF05[7C010300]      <1> 	inc	dword [u.pbase]
 14253                              <1> cpass_3:
 14254 00010D41 C3                  <1> 	retn
 14255                              <1> cpass_k:
 14256                              <1> 	; 02/07/2015
 14257                              <1> 	; The caller is os kernel 
 14258                              <1> 	; (get sysexec arguments from kernel's memory space)
 14259 00010D42 8B1D[40010300]      <1> 	mov	ebx, [u.base]
 14260 00010D48 66C705[80010300]00- <1>         mov     word [u.pcount], PAGE_SIZE ; 4096
 14260 00010D50 10                  <1>
 14261 00010D51 891D[7C010300]      <1> 	mov	[u.pbase], ebx
 14262 00010D57 EBCE                <1> 	jmp	short cpass_2
 14263                              <1> 
 14264                              <1> transfer_to_user_buffer: ; fast transfer
 14265                              <1> 	; 27/05/2016
 14266                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
 14267                              <1> 	;
 14268                              <1> 	; INPUT ->
 14269                              <1> 	;	ESI = source address in system space
 14270                              <1> 	;	EDI = user's buffer address
 14271                              <1> 	;	ECX = transfer (byte) count
 14272                              <1> 	;	[u.pgdir] = user's page directory
 14273                              <1> 	; OUTPUT ->
 14274                              <1> 	;	ECX = actual transfer count
 14275                              <1> 	;	cf = 1 -> error
 14276                              <1> 	;	[u.count] = remain byte count
 14277                              <1> 	;
 14278                              <1> 	; Modified registers: eax, ecx
 14279                              <1> 	;
 14280                              <1> 
 14281 00010D59 21C9                <1> 	and	ecx, ecx
 14282 00010D5B 743B                <1> 	jz	short ttub_4
 14283                              <1> 
 14284 00010D5D 890D[44010300]      <1> 	mov	[u.count], ecx
 14285                              <1> 	
 14286 00010D63 57                  <1> 	push	edi
 14287 00010D64 56                  <1> 	push	esi
 14288 00010D65 53                  <1> 	push	ebx
 14289 00010D66 52                  <1> 	push	edx
 14290 00010D67 51                  <1> 	push	ecx
 14291                              <1> 
 14292 00010D68 89FB                <1> 	mov	ebx, edi
 14293 00010D6A 81C300004000        <1> 	add	ebx, CORE ; 27/05/2016
 14294                              <1> ttub_1:
 14295                              <1> 	; ebx = virtual (linear) address
 14296                              <1> 	; [u.pgdir] = user's page directory
 14297 00010D70 E8484DFFFF          <1>        	call	get_physical_addr_x ; get physical address
 14298 00010D75 7222                <1> 	jc	short ttub_5
 14299                              <1> 	; eax = physical address 
 14300                              <1> 	; ecx = remain byte count in page (1-4096)
 14301 00010D77 89C7                <1> 	mov	edi, eax
 14302 00010D79 A1[44010300]        <1> 	mov	eax, [u.count]
 14303 00010D7E 39C1                <1> 	cmp	ecx, eax
 14304 00010D80 7602                <1> 	jna	short ttub_2
 14305 00010D82 89C1                <1> 	mov	ecx, eax
 14306                              <1> ttub_2:	
 14307 00010D84 29C8                <1> 	sub	eax, ecx
 14308 00010D86 01CB                <1> 	add	ebx, ecx
 14309 00010D88 F3A4                <1> 	rep	movsb
 14310 00010D8A A3[44010300]        <1> 	mov	[u.count], eax
 14311 00010D8F 09C0                <1> 	or	eax, eax
 14312 00010D91 75DD                <1> 	jnz	short ttub_1
 14313                              <1> ttub_retn:
 14314                              <1> tfub_retn:
 14315 00010D93 59                  <1> 	pop	ecx ; transfer count = actual transfer count
 14316                              <1> ttub_3:
 14317 00010D94 5A                  <1> 	pop	edx
 14318 00010D95 5B                  <1> 	pop	ebx
 14319 00010D96 5E                  <1> 	pop	esi
 14320 00010D97 5F                  <1> 	pop	edi
 14321                              <1> ttub_4:
 14322 00010D98 C3                  <1> 	retn
 14323                              <1> ttub_5:
 14324 00010D99 59                  <1> 	pop	ecx
 14325 00010D9A 2B0D[44010300]      <1> 	sub	ecx, [u.count] ; actual transfer count
 14326 00010DA0 F9                  <1> 	stc
 14327 00010DA1 EBF1                <1> 	jmp	short ttub_3
 14328                              <1> 
 14329                              <1> transfer_from_user_buffer: ; fast transfer
 14330                              <1> 	; 27/05/2016
 14331                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
 14332                              <1> 	;
 14333                              <1> 	; INPUT ->
 14334                              <1> 	;	ESI = user's buffer address
 14335                              <1> 	;	EDI = destination address in system space
 14336                              <1> 	;	ECX = transfer (byte) count
 14337                              <1> 	;	[u.pgdir] = user's page directory
 14338                              <1> 	; OUTPUT ->
 14339                              <1> 	;	ecx = actual transfer count
 14340                              <1> 	;	cf = 1 -> error
 14341                              <1> 	;	[u.count] = remain byte count
 14342                              <1> 	;
 14343                              <1> 	; Modified registers: eax, ecx
 14344                              <1> 	;
 14345                              <1> 
 14346 00010DA3 21C9                <1> 	and	ecx, ecx
 14347                              <1> 	;jz	short tfub_4
 14348 00010DA5 74F1                <1> 	jz	short ttub_4
 14349                              <1> 
 14350 00010DA7 890D[44010300]      <1> 	mov	[u.count], ecx
 14351                              <1> 	
 14352 00010DAD 57                  <1> 	push	edi
 14353 00010DAE 56                  <1> 	push	esi
 14354 00010DAF 53                  <1> 	push	ebx
 14355 00010DB0 52                  <1> 	push	edx
 14356 00010DB1 51                  <1> 	push	ecx
 14357                              <1> 
 14358 00010DB2 89F3                <1> 	mov	ebx, esi
 14359 00010DB4 81C300004000        <1> 	add	ebx, CORE ; 27/05/2016
 14360                              <1> tfub_1:
 14361                              <1> 	; ebx = virtual (linear) address
 14362                              <1> 	; [u.pgdir] = user's page directory
 14363 00010DBA E8FE4CFFFF          <1>        	call	get_physical_addr_x ; get physical address
 14364                              <1> 	;jc	short tfub_5
 14365 00010DBF 72D8                <1> 	jc	short ttub_5
 14366                              <1> 	; eax = physical address 
 14367                              <1> 	; ecx = remain byte count in page (1-4096)
 14368 00010DC1 89C6                <1> 	mov	esi, eax
 14369 00010DC3 A1[44010300]        <1> 	mov	eax, [u.count]
 14370 00010DC8 39C1                <1> 	cmp	ecx, eax
 14371 00010DCA 7602                <1> 	jna	short tfub_2
 14372 00010DCC 89C1                <1> 	mov	ecx, eax
 14373                              <1> tfub_2:	
 14374 00010DCE 29C8                <1> 	sub	eax, ecx
 14375 00010DD0 01CB                <1> 	add	ebx, ecx
 14376 00010DD2 F3A4                <1> 	rep	movsb
 14377 00010DD4 A3[44010300]        <1> 	mov	[u.count], eax
 14378 00010DD9 09C0                <1> 	or	eax, eax
 14379 00010DDB 75DD                <1> 	jnz	short tfub_1
 14380                              <1> 
 14381 00010DDD EBB4                <1> 	jmp	short tfub_retn
 14382                              <1> 
 14383                              <1> ;tfub_retn:
 14384                              <1> ;	pop	ecx ; transfer count = actual transfer count
 14385                              <1> ;tfub_3:
 14386                              <1> ;	pop	edx
 14387                              <1> ;	pop	ebx
 14388                              <1> ;	pop	esi
 14389                              <1> ;	pop	edi
 14390                              <1> ;tfub_4:
 14391                              <1> ;	retn
 14392                              <1> ;tfub_5:
 14393                              <1> ;	pop	ecx
 14394                              <1> ;	sub	ecx, [u.count] ; actual transfer count
 14395                              <1> ;	stc
 14396                              <1> ;	jmp	short tfub_3
 14397                              <1> 
 14398                              <1> sysfff: ; <Find First File>
 14399                              <1> 	; 08/08/2022
 14400                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
 14401                              <1> 	; 17/10/2016
 14402                              <1> 	; 16/10/2016
 14403                              <1> 	; 15/10/2016 TRDOS 386 (TRDOS v2.0) feature only !
 14404                              <1> 	;           -derived from TRDOS v1.0, INT_21H.ASM-
 14405                              <1> 	;            ("loc_INT21h_find_first_file")
 14406                              <1> 	; TRDOS 8086 (v1.0)
 14407                              <1>         ; 	07/08/2011 
 14408                              <1>         ;	Find First File
 14409                              <1> 	;	INPUT:
 14410                              <1>         ;	    CX= Attributes
 14411                              <1>         ;	    DS:DX= Pointer to filename
 14412                              <1> 	;	MSDOS OUTPUT:
 14413                              <1> 	;	    DTA: (Default address: PSP offset 80h)
 14414                              <1> 	;	    Offset  Descrription
 14415                              <1> 	;	    0	    Reserved for use find next file
 14416                              <1> 	;	    21	    Attribute of file found
 14417                              <1> 	;	    22	    Time stamp of file
 14418                              <1> 	;	    24	    Date stamp of file
 14419                              <1> 	;	    26	    File size in bytes
 14420                              <1> 	;	    30	    Filename and extension (zero terminated)
 14421                              <1> 	;	If cf = 1:
 14422                              <1> 	;	    Error Codes: (in AX)
 14423                              <1> 	;	    	2 - File not found
 14424                              <1> 	;	       18 - No more files
 14425                              <1>         ;
 14426                              <1> 	; TRDOS 386 (v2.0) 
 14427                              <1> 	; 15/10/2016
 14428                              <1> 	;	
 14429                              <1>         ; INPUT ->
 14430                              <1>         ;	   CL = File attributes
 14431                              <1> 	;     	      bit 0 (1) - Read only file (R)
 14432                              <1> 	;             bit 1 (1) - Hidden file (H)
 14433                              <1>         ;             bit 2 (1) - System file (R)
 14434                              <1> 	;             bit 3 (1) - Volume label/name (V)
 14435                              <1>         ;             bit 4 (1) - Subdirectory (D)
 14436                              <1> 	;	      bit 5 (1) - File has been archived (A)
 14437                              <1> 	;	   CH = 0 -> Return basic parameters (24 bytes)
 14438                              <1> 	;	   CH > 0 -> Return FindFile structure/table (128 bytes)
 14439                              <1>         ;          EBX = Pointer to filename (ASCIIZ) -path-
 14440                              <1> 	;	   EDX = File parameters buffer address
 14441                              <1> 	;		(buffer size = 24 bytes if CH input = 0)
 14442                              <1> 	;		(buffer size = 128 bytes if CH input > 0)
 14443                              <1> 	;		 
 14444                              <1> 	; OUTPUT ->
 14445                              <1> 	;	   EAX = 0 if CH input > 0
 14446                              <1> 	;	   EAX = First cluster number of file if CH input = 0
 14447                              <1> 	;	   EDX = File parameters table/structure address
 14448                              <1> 	;	   Basic Parameters:
 14449                              <1> 	;		Offset  Description
 14450                              <1> 	;		------	---------------
 14451                              <1> 	;		0	File Attributes
 14452                              <1> 	;		1	Ambiguous filename chars are used sign
 14453                              <1> 	;			(0 = filename fits exactly with request)
 14454                              <1> 	;			(>0 = ambiguous filename chars are used)
 14455                              <1> 	;	      	2	Time stamp of file
 14456                              <1> 	;		4	Date stamp of file
 14457                              <1> 	;		6	File size in bytes
 14458                              <1> 	;		10	Short Filename (ASCIIZ, max. 13 bytes)
 14459                              <1> 	;		23	Longname Length (1-255) if existing 
 14460                              <1> 	;  
 14461                              <1> 	;          cf = 1 -> Error code in AL
 14462                              <1> 	;
 14463                              <1> 	; Modified Registers: EAX (at the return of system call)
 14464                              <1> 	;  
 14465                              <1> 	; TR-DOS FindFile (FFF) Structure (128 bytes):
 14466                              <1> 	; 09/10/2011 (DIR.ASM) - 10/02/2016 (trdoskx.s)
 14467                              <1> 	;	
 14468                              <1> 	; Offset	Parameter		Size
 14469                              <1> 	; ------	------------------	-------- 
 14470                              <1> 	; 0		FindFile_Drv		1 byte
 14471                              <1> 	; 1		FindFile_Directory	65 bytes
 14472                              <1> 	; 66		FindFile_Name		13 bytes
 14473                              <1> 	; 79		FindFile_LongNameEntryLength 1 byte
 14474                              <1> 	;Above 80 bytes form
 14475                              <1> 	;TR-DOS Source/Destination File FullName Format/Structure
 14476                              <1> 	; 80		FindFile_AttributesMask 1 word
 14477                              <1> 	; 82		FindFile_DirEntry	32 bytes (*)
 14478                              <1> 	; 114		FindFile_DirFirstCluster 1 double word
 14479                              <1> 	; 118		FindFile_DirCluster	1 double word
 14480                              <1> 	; 122		FindFile_DirEntryNumber 1 word
 14481                              <1> 	; 124		FindFile_MatchCounter	1 word
 14482                              <1> 	; 126		FindFile_Reserved	1 word
 14483                              <1>    	; (*) MS-DOS, FAT 12-16-32 classic directory entry (32 bytes)
 14484                              <1> 
 14485                              <1> 	;mov	[u.namep], ebx
 14486                              <1> 	; 16/10/2016
 14487 00010DDF 8915[34840100]      <1> 	mov	[FFF_UBuffer], edx
 14488 00010DE5 66890D[39840100]    <1> 	mov	[FFF_Attrib], cx ; [FFF_RType] = ch
 14489                              <1> 		    ; Attributes in CL, return data type in CH
 14490 00010DEC 89DE                <1> 	mov	esi, ebx
 14491                              <1> 	; file name is forced, change directory as temporary
 14492                              <1> 	;mov	ax, 1
 14493                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
 14494                              <1> 	;call	set_working_path 
 14495 00010DEE E876130000          <1> 	call	set_working_path_x ; 17/10/2016	
 14496 00010DF3 731D                <1> 	jnc	short sysfff_0
 14497                              <1>  
 14498 00010DF5 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 14499 00010DF7 7505                <1> 	jnz	short sysfff_err
 14500                              <1> 
 14501                              <1> 	; eax = 0
 14502 00010DF9 B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 14503                              <1> sysfff_err:
 14504 00010DFE A3[1C010300]        <1> 	mov	[u.r0], eax
 14505 00010E03 A3[84010300]        <1> 	mov	[u.error], eax
 14506 00010E08 E831140000          <1>         call 	reset_working_path
 14507 00010E0D E9EDBEFFFF          <1> 	jmp	error
 14508                              <1> 
 14509                              <1> sysfff_0:
 14510                              <1> 	;sub	ah, ah ; ah = 0
 14511 00010E12 8A0424              <1> 	mov	al, [esp]
 14512 00010E15 08C0                <1> 	or	al, al
 14513 00010E17 7412                <1> 	jz	short sysfff_2
 14514 00010E19 B410                <1> 	mov	ah, 10h
 14515 00010E1B A808                <1> 	test	al, 08h
 14516 00010E1D 7503                <1> 	jnz	short sysfff_1
 14517 00010E1F 80CC08              <1> 	or	ah, 08h
 14518                              <1> sysfff_1:
 14519 00010E22 2410                <1> 	and	al, 10h ; Directory
 14520 00010E24 7405                <1> 	jz	short sysfff_2
 14521 00010E26 80E408              <1> 	and	ah, 08h
 14522 00010E29 30C0                <1> 	xor	al, al ; When a directory is searched,
 14523                              <1> 		       ; filename will be returned even if
 14524                              <1> 		       ; it is not a directory!
 14525                              <1> 		       ; Because: (in order to prevent
 14526                              <1> 		       ; creating a dir with existing file name)
 14527                              <1> 		       ; Dir and file names must not be same!
 14528                              <1> 		       ; (return attribute must be checked)	
 14529                              <1> sysfff_2:
 14530                              <1> 	; AX = Attributes mask 
 14531                              <1> 		; AL = AND mask (result must be equal to AL)
 14532                              <1> 		; AH = Negative AND mask (result must be ZERO)
 14533                              <1>  	; ESI = FindFile_Name address
 14534                              <1> 
 14535 00010E2B E8107CFFFF          <1> 	call	find_first_file
 14536 00010E30 72CC                <1> 	jc	short sysfff_err ; eax = 2 (File not found !)
 14537                              <1> 
 14538                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
 14539                              <1> 	; EDI = Directory Buffer Directory Entry Location
 14540                              <1> 	; EAX = File Size
 14541                              <1> 	;  BL = Attributes of The File/Directory
 14542                              <1> 	;  BH = Long Name Yes/No Status (>0 is YES)
 14543                              <1> 	;  DX > 0 : Ambiguous filename chars are used
 14544                              <1> 
 14545                              <1> sysfff_3:
 14546                              <1> 	; 16/10/2016
 14547 00010E32 668B0D[39840100]    <1> 	mov	cx, [FFF_Attrib]
 14548                              <1> 	; Attribs in CL, return data type in CH
 14549                              <1> 
 14550                              <1> 	;or	cl, cl
 14551                              <1> 	;jz	short sysfff_4 ; 0 = No filter
 14552 00010E39 80F1FF              <1> 	xor	cl, 0FFh
 14553 00010E3C 20D9                <1> 	and	cl, bl
 14554 00010E3E 7409                <1> 	jz	short sysfff_4
 14555                              <1> 
 14556                              <1> 	;mov	eax, 2 ; 'file not found !' error
 14557                              <1> 	;jmp	short sysfff_err_1
 14558                              <1> 
 14559                              <1> 	; 16/10/2016
 14560 00010E40 E8A87CFFFF          <1> 	call	find_next_file
 14561 00010E45 72B7                <1> 	jc	short sysfff_err ; eax = 12 (no more files !)
 14562 00010E47 EBE9                <1> 	jmp	short sysfff_3
 14563                              <1> 
 14564                              <1> sysfff_4:
 14565 00010E49 20ED                <1> 	and	ch, ch ; [FFF_RType]
 14566 00010E4B 740C                <1> 	jz	short sysfff_5
 14567                              <1> 	;mov	ecx, 128 ; ; transfer length
 14568                              <1> 	; 30/07/2022
 14569 00010E4D 29C9                <1> 	sub	ecx, ecx
 14570 00010E4F B180                <1> 	mov	cl, 128
 14571 00010E51 880D[38840100]      <1> 	mov	[FFF_Valid], cl
 14572                              <1> sysfnf_11:
 14573                              <1> 	; ecx = 128
 14574                              <1> 	; 08/08/2022
 14575                              <1> 	;mov	esi, FindFile_Drv
 14576 00010E57 EB3F                <1> 	jmp	short sysfff_6	
 14577                              <1> sysfff_5:
 14578                              <1> 	;;mov	esi, FindFile_DirEntry
 14579                              <1> 	;mov	ecx, 24  ; transfer length
 14580                              <1> 	; 30/07/2022
 14581                              <1> 	;sub	ecx, ecx
 14582                              <1> 	;mov	cl, 24
 14583                              <1> 	;mov	[FFF_Valid], cl
 14584 00010E59 C605[38840100]18    <1> 	mov	byte [FFF_Valid], 24
 14585                              <1> sysfnf_12:
 14586 00010E60 BF[04890100]        <1> 	mov	edi, DTA ; FFF data transfer address
 14587                              <1> 	;mov	al, [esi+DirEntry_Attr] ; 11
 14588 00010E65 88D8                <1> 	mov	al, bl ; File/Dir Attributes
 14589 00010E67 887F17              <1> 	mov	[edi+23], bh ; Longname length (0= none)
 14590 00010E6A AA                  <1> 	stosb
 14591 00010E6B 88D0                <1> 	mov	al, dl ; DL is for '?'
 14592 00010E6D 00F0                <1> 	add	al, dh ; DH is for '*'
 14593                              <1> 	; AL > 0 if ambiguous file name wildcards are used
 14594 00010E6F AA                  <1> 	stosb
 14595 00010E70 8B4616              <1> 	mov	eax, [esi+DirEntry_WrtTime] ; 22
 14596 00010E73 AB                  <1>         stosd	; DirEntry_WrtTime & DirEntry_WrtDate
 14597 00010E74 8B461C              <1>         mov	eax, [esi+DirEntry_FileSize] ; 28
 14598 00010E77 AB                  <1>         stosd
 14599 00010E78 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI] ; 20
 14600                              <1> 	;shl	ax, 16
 14601                              <1> 	; 23/07/2022 (BugFix)
 14602 00010E7C C1E010              <1> 	shl	eax, 16 
 14603 00010E7F 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO] ; 26 
 14604 00010E83 A3[1C010300]        <1> 	mov	[u.r0], eax ; First Cluster
 14605                              <1> 
 14606                              <1>         ;mov	esi, FindFile_DirEntry
 14607 00010E88 E8EE130000          <1> 	call	get_file_name
 14608                              <1> 
 14609 00010E8D 8A0D[38840100]      <1> 	mov	cl, [FFF_Valid]
 14610 00010E93 BE[04890100]        <1>        	mov	esi, DTA ; FFF data transfer address
 14611                              <1> sysfff_6:
 14612 00010E98 8B3D[34840100]      <1> 	mov	edi, [FFF_UBuffer] ; user's buffer address (edx)
 14613 00010E9E E8B6FEFFFF          <1> 	call	transfer_to_user_buffer
 14614                              <1> 
 14615 00010EA3 890D[1C010300]      <1> 	mov	[u.r0], ecx ; actual transfer count
 14616 00010EA9 E890130000          <1>         call 	reset_working_path
 14617 00010EAE E96CBEFFFF          <1> 	jmp	sysret
 14618                              <1> 
 14619                              <1> sysfnf: ; <Find Next File>
 14620                              <1> 	; 29/08/2023 (TRDOS 386 Kernel v2.0.6)
 14621                              <1> 	; 08/08/2022
 14622                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
 14623                              <1> 	; 16/10/2016 TRDOS 386 (TRDOS v2.0) feature only !
 14624                              <1> 	;           -derived from TRDOS v1.0, INT_21H.ASM-
 14625                              <1> 	;            ("loc_INT21h_find_next_file")
 14626                              <1> 	; TRDOS 8086 (v1.0)
 14627                              <1>         ; 	07/08/2011 
 14628                              <1>         ;	Find First File
 14629                              <1> 	;	INPUT:
 14630                              <1>         ;	    none
 14631                              <1> 	;	MSDOS OUTPUT:
 14632                              <1> 	;	    DTA: (Default address: PSP offset 80h)
 14633                              <1> 	;	    Offset  Descrription
 14634                              <1> 	;	    0	    Reserved for use find next file
 14635                              <1> 	;	    21	    Attribute of file found
 14636                              <1> 	;	    22	    Time stamp of file
 14637                              <1> 	;	    24	    Date stamp of file
 14638                              <1> 	;	    26	    File size in bytes
 14639                              <1> 	;	    30	    Filename and extension (zero terminated)
 14640                              <1> 	;	If cf = 1:
 14641                              <1> 	;	    Error Codes: (in AX)
 14642                              <1> 	;	       18 - No more files
 14643                              <1>         ;
 14644                              <1> 	; TRDOS 386 (v2.0) 
 14645                              <1> 	; 16/10/2016
 14646                              <1> 	;	
 14647                              <1>         ; INPUT ->
 14648                              <1>        	; 	   none
 14649                              <1> 	; OUTPUT ->
 14650                              <1> 	;	   EAX = 0 if CH input of 'Find First File' > 0
 14651                              <1> 	;	   EAX = First cluster number of file
 14652                              <1> 	;		 if CH input of 'Find First File' = 0	
 14653                              <1> 	;	   EDX = File parameters table/structure address
 14654                              <1> 	;
 14655                              <1> 	;          cf = 1 -> Error code in AL
 14656                              <1> 	;
 14657                              <1>  	; Modified Registers: EAX (at the return of system call)
 14658                              <1> 
 14659                              <1> 	;	
 14660                              <1> 	; Note: If byte [FFF_Valid] = 0
 14661                              <1> 	;	'sysfnf' will return with 'no more files' error.
 14662                              <1> 	;	If byte [FFF_Valid] = 24
 14663                              <1> 	;	'sysfnf' will return with 32 bytes basic parameters
 14664                              <1> 	;	at the address which is in EDX.
 14665                              <1> 	;	If byte [FFF_Valid] = 128
 14666                              <1> 	;	'sysfnf' will return with 128 bytes Find File 
 14667                              <1> 	;	Structure/Table at the address which is in EDX.
 14668                              <1> 	
 14669 00010EB3 803D[38840100]00    <1> 	cmp	byte [FFF_Valid], 0
 14670 00010EBA 7713                <1> 	ja	short stsfnf_0
 14671                              <1>  	; 'no more files !' error 
 14672                              <1> 	;mov	eax, ERR_NO_MORE_FILES ; 12
 14673                              <1> 	; 30/07/2022
 14674 00010EBC 29C0                <1> 	sub	eax, eax
 14675 00010EBE B00C                <1> 	mov	al, ERR_NO_MORE_FILES ; 12
 14676 00010EC0 A3[1C010300]        <1> 	mov	[u.r0], eax
 14677 00010EC5 A3[84010300]        <1> 	mov	[u.error], eax
 14678 00010ECA E930BEFFFF          <1> 	jmp	error
 14679                              <1> stsfnf_0:
 14680                              <1> 	;cmp	byte [FFF_Valid], 128
 14681                              <1> 	;je	short stsfnf_1
 14682                              <1> 	;cmp	byte [FFF_Valid], 24
 14683                              <1> 	;je	short stsfnf_1
 14684                              <1> 	;mov	[FFF_Valid], 24 ; Default
 14685                              <1> stsfnf_1:
 14686 00010ECF 0FB61D[4A780100]    <1> 	movzx	ebx, byte [Current_Drv]
 14687 00010ED6 66891D[3E840100]    <1> 	mov	[SWP_DRV], bx
 14688 00010EDD 8A15[EA800100]      <1> 	mov	dl, [FindFile_Drv]
 14689 00010EE3 38DA                <1> 	cmp	dl, bl
 14690 00010EE5 7535                <1> 	jne	short stsfnf_2
 14691 00010EE7 86FB                <1> 	xchg	bh, bl
 14692 00010EE9 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 14693 00010EEE 01DE                <1> 	add	esi, ebx
 14694 00010EF0 EB37                <1> 	jmp	short sysfnf_3
 14695                              <1> 
 14696                              <1> sysfnf_8:
 14697 00010EF2 E87CB4FFFF          <1> 	call	load_FAT_sub_directory	 
 14698 00010EF7 7275                <1> 	jc	short sysfnf_err_1 ; read error (no FNF stop)
 14699                              <1> 
 14700                              <1> sysfnf_9:
 14701 00010EF9 E8EF7BFFFF          <1> 	call	find_next_file
 14702 00010EFE 7263                <1> 	jc	short sysfnf_5
 14703                              <1> 	; 08/08/2022
 14704                              <1> 	; esi = FindFile_Drv
 14705                              <1> 
 14706 00010F00 A0[39840100]        <1> 	mov	al, [FFF_Attrib]
 14707                              <1> 	;or	al, al
 14708                              <1> 	;jz	short sysfnf_10 ; 0 = No filter
 14709 00010F05 34FF                <1> 	xor	al, 0FFh
 14710 00010F07 20D8                <1> 	and	al, bl
 14711 00010F09 75EE                <1> 	jnz	short sysfnf_9 ; search for next file until
 14712                              <1> 			       ; an error return from
 14713                              <1> 			       ; find_next_file procedure
 14714                              <1> sysfnf_10:
 14715                              <1>         ;movzx	ecx, byte [FFF_Valid]
 14716                              <1> 	;cmp	cl, 128 ; complete FindFile structure/table 
 14717                              <1> 	;je	sysfnf_11
 14718                              <1> 	;;cmp	cl, 24  ; basic parameters
 14719                              <1> 	;;je	sysfnf_12       
 14720                              <1> 	;jmp	sysfnf_12
 14721                              <1> 	; 30/07/2022
 14722 00010F0B 0FB60D[38840100]    <1> 	movzx	ecx, byte [FFF_Valid]
 14723 00010F12 80F980              <1> 	cmp	cl, 128
 14724                              <1> 	;jne	short sysfnf_12
 14725                              <1> 	;jmp	short sysfnf_11	
 14726                              <1> 	; 08/08/2022
 14727                              <1> 	;je	short sysfnf_6 ; esi = FindFile_Drv
 14728                              <1> 	; 29/08/2023 (BugFix)
 14729 00010F15 7481                <1> 	je	short sysfff_6 ; esi = FindFile_Drv
 14730                              <1> 	
 14731 00010F17 E944FFFFFF          <1> 	jmp	sysfnf_12
 14732                              <1> 
 14733                              <1> stsfnf_2:
 14734 00010F1C FE05[3F840100]      <1> 	inc	byte [SWP_DRV_chg]
 14735                              <1> 
 14736 00010F22 E86B68FFFF          <1> 	call	change_current_drive
 14737 00010F27 7245                <1> 	jc	short sysfnf_err_1 ; read error ! 
 14738                              <1> 				   ; (do not stop, because
 14739                              <1> 				   ; we don't have a
 14740                              <1> 				   ; 'no more files'
 14741                              <1> 				   ; -file not found- error,
 14742                              <1> 				   ; next sysfnf system call
 14743                              <1> 				   ; may solve the problem,
 14744                              <1> 				   ; after re-placing the disk)
 14745                              <1> sysfnf_3:
 14746 00010F29 A1[60810100]        <1> 	mov	eax, [FindFile_DirCluster]
 14747 00010F2E 21C0                <1> 	and	eax, eax
 14748 00010F30 7550                <1> 	jnz	short sysfnf_6
 14749                              <1>         
 14750 00010F32 803D[49780100]02    <1> 	cmp	byte [Current_FATType], 2
 14751 00010F39 772C                <1> 	ja	short sysfnf_err_0 ; invalid, we neeed to stop !?
 14752 00010F3B 803D[49780100]01    <1> 	cmp	byte [Current_FATType], 1
 14753 00010F42 7223                <1> 	jb	short sysfnf_err_0 ; invalid, we neeed to stop !?
 14754                              <1> 
 14755 00010F44 3805[717F0100]      <1> 	cmp	byte [DirBuff_ValidData], al ; 0
 14756 00010F4A 7608                <1> 	jna	short sysfnf_4 
 14757                              <1> 
 14758 00010F4C 3B05[767F0100]      <1> 	cmp	eax, [DirBuff_Cluster] ; 0 ?
 14759 00010F52 74A5                <1> 	je	short sysfnf_9
 14760                              <1> 
 14761                              <1> 	;cmp	byte [Current_Dir_Level], 0
 14762                              <1>         ;ja	short sysfnf_4  
 14763                              <1>         ;jna	short sysfnf_9 
 14764                              <1> 
 14765                              <1> sysfnf_4:
 14766 00010F54 FE05[3F840100]      <1> 	inc	byte [SWP_DRV_chg]
 14767 00010F5A E896B3FFFF          <1> 	call 	load_FAT_root_directory
 14768 00010F5F 7398                <1> 	jnc	short sysfnf_9
 14769                              <1> 	; eax = error code (17, 'drv not ready or read error')
 14770 00010F61 EB0B                <1> 	jmp	short sysfnf_err_1 ; read error ! (no FNF stop)
 14771                              <1> 				   ; (if you want, try again, 
 14772                              <1> 				   ;  after re-placing the disk)
 14773                              <1> sysfnf_5:	
 14774 00010F63 3C0C                <1> 	cmp	al, 12 ; 'no more files' error
 14775 00010F65 7507                <1> 	jne	short sysfnf_err_1 ; (no FNF stop -sysfnf will try
 14776                              <1> 				   ;  to read the directory again,
 14777                              <1> 				   ;  if the user calls sysfnf
 14778                              <1> 				   ;  just after this error return-)
 14779                              <1> 	; (FNF stop -sysfnf will not try
 14780                              <1> 	;  to read the directory again-)	
 14781                              <1> 
 14782                              <1> sysfnf_err_0:
 14783 00010F67 C605[38840100]00    <1> 	mov	byte [FFF_Valid], 0 ; FNF stop sign
 14784                              <1> sysfnf_err_1:
 14785 00010F6E A3[1C010300]        <1> 	mov	[u.r0], eax
 14786 00010F73 A3[84010300]        <1> 	mov	[u.error], eax
 14787 00010F78 E8C1120000          <1> 	call	reset_working_path
 14788 00010F7D E97DBDFFFF          <1> 	jmp	error
 14789                              <1> 	  
 14790                              <1> sysfnf_6:
 14791 00010F82 803D[717F0100]00    <1> 	cmp	byte [DirBuff_ValidData], 0
 14792 00010F89 760D                <1> 	jna	short sysfnf_7
 14793                              <1> 
 14794 00010F8B 3B05[767F0100]      <1> 	cmp	eax, [DirBuff_Cluster]
 14795                              <1> 	;je	short sysfnf_9
 14796                              <1> 	; 08/08/2022
 14797 00010F91 7505                <1> 	jne	short sysfnf_7
 14798 00010F93 E961FFFFFF          <1> 	jmp	sysfnf_9
 14799                              <1> sysfnf_7:
 14800 00010F98 FE05[3F840100]      <1> 	inc	byte [SWP_DRV_chg]
 14801 00010F9E 803D[49780100]01    <1> 	cmp	byte [Current_FATType], 1
 14802                              <1> 	;jnb	short sysfnf_8
 14803                              <1> 	; 08/08/2022
 14804 00010FA5 7205                <1> 	jb	short sysfnf_13
 14805 00010FA7 E946FFFFFF          <1> 	jmp	sysfnf_8
 14806                              <1> sysfnf_13:
 14807                              <1> 	; Singlix (TRFS) File System 
 14808                              <1> 	; (access via compatibility buffer)
 14809 00010FAC E8FCB3FFFF          <1> 	call	load_FS_sub_directory
 14810                              <1> 	;jnc	short sysfnf_9
 14811                              <1> 	;jmp	short sysfnf_err_1 ; read error (no FNF stop)
 14812                              <1> 	; 08/08/2022
 14813 00010FB1 72BB                <1> 	jc	short sysfnf_err_1
 14814 00010FB3 E941FFFFFF          <1> 	jmp	sysfnf_9
 14815                              <1> 
 14816                              <1> writei:
 14817                              <1> 	; 08/08/2022
 14818                              <1> 	; 30/07/2022
 14819                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 14820                              <1> 	; 26/10/2016
 14821                              <1> 	; 25/10/2016
 14822                              <1> 	; 23/10/2016
 14823                              <1> 	; 22/10/2016
 14824                              <1> 	; 19/10/2016 - TRDOS 386 (TRDOS v2.0)
 14825                              <1> 	; 19/05/2015 - 20/05/2015 (Retro UNIX 386 v1)
 14826                              <1> 	; 12/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 14827                              <1> 	;
 14828                              <1> 	; Write data to file with first cluster number in EAX
 14829                              <1> 	; 
 14830                              <1> 	; INPUTS ->
 14831                              <1> 	;    EAX - First cluster number of the file
 14832                              <1> 	;    EBX - File number (Open file index number)
 14833                              <1> 	;    u.count - byte count to be written
 14834                              <1> 	;    u.base - points to user buffer
 14835                              <1> 	;    u.fofp - points to dword with current file offset
 14836                              <1> 	;    i.size - file size
 14837                              <1> 	;    cdev - logical dos drive number of the file
 14838                              <1> 	; OUTPUTS ->
 14839                              <1> 	;    u.count - cleared
 14840                              <1> 	;    u.nread - accumulates total bytes passed back
 14841                              <1> 	;    i.size - new file size (if file byte offset overs file size)
 14842                              <1> 	;    u.fofp - points to u.off (with new offset value)	
 14843                              <1> 	;
 14844                              <1> 	; (Retro UNIX Prototype : 11/11/2012 - 18/11/2012, UNIXCOPY.ASM)
 14845                              <1> 	; ((Modified registers: eax, edx, ebx, ecx, esi, edi, ebp)) 	
 14846                              <1> 
 14847 00010FB8 31C9                <1> 	xor	ecx, ecx
 14848 00010FBA 890D[48010300]      <1> 	mov 	[u.nread], ecx  ; 0
 14849 00010FC0 66890D[80010300]    <1> 	mov	[u.pcount], cx ; 19/05/2015
 14850 00010FC7 390D[44010300]      <1> 	cmp 	[u.count], ecx
 14851 00010FCD 7701                <1> 	ja 	short writei_1 ; 08/08/2022
 14852 00010FCF C3                  <1> 	retn
 14853                              <1> 	; 23/07/2022
 14854                              <1> 	;jna	short dskw_8 ; retn
 14855                              <1> 	
 14856                              <1> writei_1:
 14857                              <1> dskw:
 14858 00010FD0 881D[F8830100]      <1> 	mov	[writei.ofn], bl ; Open file number
 14859 00010FD6 880D[33840100]      <1> 	mov	[setfmod], cl ; 0 ; reset 'update lm date&time' sign
 14860                              <1> dskw_0: 
 14861                              <1> 	; 26/10/2016
 14862                              <1> 	; 22/10/2016, 23/10/2016, 25/10/2016
 14863                              <1> 	; 19/10/2016 - TRDOS 386 (TRDOS v2.0)
 14864                              <1> 	; 31/05/2015 - 25/07/2015 (Retro UNIX 386 v1)
 14865                              <1> 	; 26/04/2013 - 20/09/2013 (Retro UNIX 8086 v1)
 14866                              <1> 	;
 14867                              <1> 	; 01/08/2013 (mkdir_w check)
 14868 00010FDC E8D0000000          <1>  	call	mget_w
 14869                              <1> 	; eax = sector/block number
 14870                              <1> 
 14871 00010FE1 8B1D[30010300]      <1> 	mov     ebx, [u.fofp]
 14872 00010FE7 8B13                <1> 	mov	edx, [ebx]
 14873 00010FE9 81E2FF010000        <1> 	and	edx, 1FFh  ; / test the lower 9 bits of the file offset
 14874 00010FEF 750C                <1> 	jnz	short dskw_1 ; / if its non-zero, branch
 14875                              <1> 			     ; if zero, file offset = 0,
 14876                              <1> 		       	     ; / 512, 1024,...(i.e., start of new block)
 14877 00010FF1 813D[44010300]0002- <1> 	cmp	dword [u.count], 512
 14877 00010FF9 0000                <1>
 14878                              <1> 				; / if zero, is there enough data to fill
 14879                              <1> 				; / an entire block? (i.e., no. of
 14880 00010FFB 7331                <1> 	jnb	short dskw_2 ; / bytes to be written greater than 512.? 
 14881                              <1> 			     ; / Yes, branch. Don't have to read block
 14882                              <1> dskw_1: ; in as no past info. is to be saved 
 14883                              <1> 	; (the entire block will be overwritten).
 14884                              <1> 	; 23/10/2016
 14885                              <1> 
 14886 00010FFD BB[48050300]        <1> 	mov	ebx, writei_buffer
 14887                              <1> 	; esi = logical dos drive description table address
 14888                              <1> 	; eax = sector number
 14889                              <1> 	; ebx = buffer address (in kernel's memory space)
 14890                              <1> 	; ecx = sector count
 14891                              <1> 	; 30/07/2022
 14892                              <1> 	;mov	ecx, 1
 14893 00011002 31C9                <1> 	xor	ecx, ecx
 14894 00011004 FEC1                <1> 	inc	cl
 14895                              <1> 	; ecx = 1
 14896 00011006 E84A0D0000          <1> 	call	disk_read
 14897                              <1> 	;call	dskrd 	; / no, must retain old info.. 
 14898                              <1> 		       	; / Hence, read block 'r1' into an I/O buffer
 14899 0001100B 7321                <1> 	jnc	short dskw_2
 14900                              <1> 
 14901                              <1> 	; disk read error
 14902                              <1> 	; 30/07/2022
 14903                              <1> 	;mov	eax, 17 ; drive not ready or READ ERROR !
 14904 0001100D 29C0                <1> 	sub	eax, eax
 14905 0001100F B011                <1> 	mov	al, 17
 14906                              <1> dskw_err: ; jump from disk write error
 14907 00011011 A3[1C010300]        <1> 	mov	[u.r0], eax
 14908 00011016 A3[84010300]        <1> 	mov	[u.error], eax
 14909                              <1> 
 14910 0001101B 803D[33840100]00    <1> 	cmp	byte [setfmod], 0
 14911                              <1> 	;jna	error
 14912                              <1> 	; 23/07/2022
 14913 00011022 7605                <1> 	jna	short writei_err
 14914                              <1> 
 14915 00011024 E8A9030000          <1> 	call	update_file_lmdt ; update last modif. date&time of the file
 14916                              <1> 	;mov	byte [setfmod], 0	
 14917                              <1> writei_err:
 14918 00011029 E9D1BCFFFF          <1> 	jmp	error
 14919                              <1> 
 14920                              <1> dskw_2: ; 3:
 14921                              <1> 	; 23/10/2016
 14922 0001102E C605[D4830100]01    <1> 	mov	byte [writei.valid], 1 ; writei buffer contains valid data
 14923 00011035 56                  <1> 	push	esi ; logical dos drive description table address
 14924                              <1> 	; EAX (r1) = block/sector number
 14925                              <1> 	;call	wslot
 14926                              <1> 		; jsr r0,wslot / set write and inhibit bits in I/O queue, 
 14927                              <1> 			   ; / proc. status=0, r5 points to 1st word of data
 14928 00011036 803D[82010300]00    <1> 	cmp	byte [u.kcall], 0
 14929 0001103D 770F                <1> 	ja	short dskw_4 ; zf=0 -> the caller is 'mkdir'
 14930                              <1> 	;
 14931 0001103F 66833D[80010300]00  <1> 	cmp	word [u.pcount], 0
 14932 00011047 7705                <1> 	ja	short dskw_4
 14933                              <1> dskw_3:
 14934                              <1> 	; [u.base] = virtual address to transfer (as source address)
 14935 00011049 E832FAFFFF          <1> 	call	trans_addr_r ; translate virtual address to physical (r)
 14936                              <1> dskw_4:
 14937 0001104E BB[48050300]        <1> 	mov	ebx, writei_buffer
 14938                              <1> 	; EBX (r5) = system (I/O) buffer address
 14939 00011053 E894FAFFFF          <1> 	call	sioreg
 14940                              <1> 	; ESI = file (user data) offset
 14941                              <1> 	; EDI = sector (I/O) buffer offset
 14942                              <1> 	; ECX = byte count
 14943                              <1> 	;
 14944 00011058 F3A4                <1>   	rep	movsb
 14945                              <1> 	; 25/07/2015
 14946                              <1> 	; eax = remain bytes in buffer
 14947                              <1>         ;       (check if remain bytes in the buffer > [u.pcount])
 14948 0001105A 09C0                <1> 	or	eax, eax
 14949 0001105C 75EB                <1> 	jnz	short dskw_3 ; (page end before system buffer end!)	
 14950                              <1> 
 14951                              <1> 	; 23/10/2016
 14952 0001105E B101                <1> 	mov	cl, 1
 14953 00011060 5E                  <1> 	pop	esi
 14954 00011061 A1[D8830100]        <1> 	mov	eax, [writei.sector]
 14955                              <1> 	; esi = logical dos drive description table address
 14956                              <1> 	; eax = sector number
 14957                              <1> 	; ebx = writei buffer address
 14958                              <1> 	; ecx = sector count
 14959 00011066 E8DB0C0000          <1> 	call	disk_write ; / yes, write the block
 14960 0001106B 7313                <1> 	jnc	short dskw_5
 14961                              <1> 
 14962                              <1> 	;mov	eax, 18 ; drive not ready or WRITE ERROR !
 14963                              <1> 	; 30/08/2022
 14964 0001106D 29C0                <1> 	sub	eax, eax
 14965 0001106F B012                <1> 	mov	al, 18
 14966 00011071 EB9E                <1> 	jmp	short dskw_err
 14967                              <1> 
 14968                              <1> dskw_7:
 14969                              <1>  	; update last modif. date&time of the file
 14970                              <1> 	; (also updates file size as OF_SIZE)
 14971 00011073 E85A030000          <1> 	call	update_file_lmdt
 14972                              <1> 	;mov	byte [setfmod], 0	
 14973                              <1> 
 14974                              <1> 	; 03/08/2013
 14975 00011078 C605[82010300]00    <1> 	mov	byte [u.kcall], 0
 14976                              <1> 	; 23/10/2016
 14977                              <1> 	;mov	eax, [writei.fclust]
 14978                              <1> dskw_8:		; 23/07/2022
 14979 0001107F C3                  <1> 	retn
 14980                              <1> 
 14981                              <1> dskw_5:
 14982                              <1> 	; 26/10/2016
 14983 00011080 0FB61D[F8830100]    <1> 	movzx	ebx, byte [writei.ofn] ; open file number
 14984 00011087 C0E302              <1> 	shl	bl, 2 ; *4
 14985 0001108A 8B83[44850100]      <1> 	mov	eax, [ebx+OF_POINTER]
 14986 00011090 3B83[C4850100]      <1> 	cmp	eax, [ebx+OF_SIZE]
 14987 00011096 7606                <1> 	jna	short dskw_6
 14988 00011098 8983[C4850100]      <1> 	mov	[ebx+OF_SIZE], eax
 14989                              <1> dskw_6:
 14990                              <1> 	;shr	bl, 2
 14991 0001109E 833D[44010300]00    <1>         cmp     dword [u.count], 0 ; / any more data to write?
 14992 000110A5 76CC                <1> 	jna	short dskw_7
 14993 000110A7 A1[E8830100]        <1> 	mov	eax, [writei.fclust]
 14994 000110AC E92BFFFFFF          <1> 	jmp	dskw_0 ; / yes, branch
 14995                              <1> 
 14996                              <1> mget_w:
 14997                              <1> 	; 08/08/2022
 14998                              <1> 	; 25/07/2022
 14999                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
 15000                              <1> 	; 02/11/2016
 15001                              <1> 	; 01/11/2016
 15002                              <1> 	; 23/10/2016, 31/10/2016
 15003                              <1> 	; 22/10/2016 - TRDOS 386 (TRDOS v2.0)
 15004                              <1> 	; 03/06/2015 (Retro UNIX 386 v1, 'mget', u.5s)
 15005                              <1> 	; 22/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 15006                              <1> 	;
 15007                              <1> 	; Get existing or (allocate) a new disk block for file
 15008                              <1> 	; 
 15009                              <1> 	; INPUTS ->
 15010                              <1> 	;    [u.fofp] = file offset pointer
 15011                              <1> 	;    [i.size] = file size
 15012                              <1> 	;    [u.count] = byte count	 
 15013                              <1> 	;    EAX = First cluster
 15014                              <1> 	;    [cdev] = Logical dos drive number 	  
 15015                              <1> 	;    [writei.ofn] = File Number
 15016                              <1> 	;		   (Open file index, 0 based)
 15017                              <1> 	;    ([u.off] = file offset)
 15018                              <1> 	; OUTPUTS ->
 15019                              <1> 	;    EAX = logical sector number
 15020                              <1> 	;    ESI = Logical Dos Drive Description Table address
 15021                              <1> 	;
 15022                              <1> 	; Modified registers: EDX, EBX, ECX, ESI, EDI, EBP  
 15023                              <1> 
 15024 000110B1 8B35[30010300]      <1>         mov     esi, [u.fofp]
 15025 000110B7 8B2E                <1> 	mov	ebp, [esi] ; u.off (or EBX*4+OF_POINTER)
 15026                              <1> 
 15027 000110B9 29C9                <1> 	sub	ecx, ecx
 15028 000110BB 8A2D[01010300]      <1> 	mov	ch, [cdev]
 15029                              <1> 
 15030 000110C1 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 15031 000110C6 01CE                <1> 	add	esi, ecx
 15032                              <1> 
 15033                              <1> 	; 31/10/2016
 15034 000110C8 89C3                <1> 	mov	ebx, eax ; First Cluster or FDT address
 15035                              <1> 
 15036 000110CA 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 15037                              <1> 	;jna	mget_w_14 ; Singlix FS
 15038                              <1> 	; 23/07/2022
 15039 000110CE 7705                <1> 	ja	short mget_w_20
 15040 000110D0 E9D8010000          <1> 	jmp	mget_w_14  ; Singlix FS	
 15041                              <1>  
 15042                              <1> mget_w_20:
 15043 000110D5 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
 15044 000110D9 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
 15045 000110DD 8815[D6830100]      <1> 	mov	[writei.spc], dl  ; sectors per cluster
 15046 000110E3 F7E2                <1> 	mul	edx
 15047                              <1> 	; edx = 0
 15048                              <1> 	; eax = bytes per cluster (<= 65536)
 15049                              <1> 
 15050                              <1> 	; 02/11/2016
 15051 000110E5 89C1                <1> 	mov	ecx, eax
 15052 000110E7 48                  <1> 	dec	eax
 15053 000110E8 66A3[DC830100]      <1> 	mov	[writei.bpc], ax	
 15054                              <1> 	
 15055 000110EE 89E8                <1> 	mov	eax, ebp
 15056 000110F0 0305[44010300]      <1> 	add	eax, [u.count] ; next file position
 15057 000110F6 3B05[24020300]      <1> 	cmp	eax, [i.size] ; <= file size ?
 15058                              <1> 	;jna	mget_w_4 ; no
 15059                              <1> 	; 23/07/2022
 15060 000110FC 7705                <1> 	ja	short mget_w_21
 15061 000110FE E907010000          <1> 	jmp	mget_w_4
 15062                              <1> mget_w_21:
 15063 00011103 F7F1                <1> 	div	ecx
 15064 00011105 A3[E4830100]        <1> 	mov	[writei.c_index], eax ; cluster index
 15065                              <1> 	; edx = byte offset in cluster (<= 65535)
 15066                              <1> 	;mov	[writei.offset], dx
 15067                              <1> 	;shr	dx, 9 ; / 512
 15068                              <1> 	;mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 15069                              <1> 
 15070 0001110A 29D2                <1> 	sub	edx, edx ; 01/11/2016
 15071 0001110C 8915[D8830100]      <1> 	mov 	[writei.sector], edx ; 0
 15072 00011112 668915[DE830100]    <1> 	mov	[writei.offset], dx  ; byte offset in cluster 
 15073 00011119 8815[D7830100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 15074                              <1> 
 15075 0001111F 89D8                <1> 	mov	eax, ebx ; First Cluster
 15076                              <1> 
 15077                              <1> 	; is this the 1st mget_w or a next mget_w call ? (by 'writei')
 15078 00011121 3815[D4830100]      <1> 	cmp	byte [writei.valid], dl ; 0 
 15079 00011127 7624                <1> 	jna	short mget_w_0
 15080                              <1> 
 15081 00011129 8815[D4830100]      <1> 	mov 	byte [writei.valid], dl ; 0 ; reset ('writei' will set it) 
 15082                              <1> 
 15083 0001112F 3B05[E8830100]      <1> 	cmp	eax, [writei.fclust]
 15084 00011135 7516                <1> 	jne	short mget_w_0
 15085                              <1> 
 15086 00011137 8A0D[01010300]      <1> 	mov	cl, [cdev]
 15087 0001113D 3A0D[D5830100]      <1> 	cmp	cl, [writei.drv]
 15088 00011143 7508                <1> 	jne	short mget_w_0
 15089                              <1>  	; [writei.l_clust] & [writei.l_index] are valid, 
 15090                              <1> 	;  we don't need to get last cluster & last cluster index
 15091 00011145 8B0D[F4830100]      <1> 	mov	ecx, [writei.l_index]
 15092 0001114B EB61                <1> 	jmp	short mget_w_2
 15093                              <1> mget_w_0:
 15094 0001114D A3[E8830100]        <1> 	mov	[writei.fclust], eax ; first cluster
 15095                              <1> 	; edx = 0
 15096 00011152 A3[E0830100]        <1> 	mov	[writei.cluster], eax ; first cluster ; 01/11/2016
 15097 00011157 8915[EC830100]      <1> 	mov 	[writei.fs_index], edx ; 0 ; current cluster index
 15098                              <1> 
 15099                              <1> 	; FAT file system (FAT12, FAT16, FAT32)
 15100 0001115D E8D6B7FFFF          <1> 	call	get_last_cluster
 15101                              <1> 	;jc	short mget_w_err ; eax = error code
 15102                              <1> 	; 08/08/2022
 15103 00011162 7305                <1> 	jnc	short mget_w_25
 15104 00011164 E992000000          <1> 	jmp	mget_w_err
 15105                              <1> mget_w_25:		
 15106 00011169 A3[F0830100]        <1> 	mov	[writei.lclust], eax ; last cluster
 15107                              <1> 
 15108 0001116E 8B0D[14820100]      <1> 	mov	ecx, [glc_index] ; last cluster index
 15109 00011174 890D[F4830100]      <1> 	mov	[writei.l_index], ecx
 15110                              <1> 
 15111 0001117A A0[F8830100]        <1> 	mov	al, [writei.ofn]
 15112 0001117F FEC0                <1> 	inc	al
 15113 00011181 A2[33840100]        <1> 	mov	[setfmod], al ; update lm date&time sign
 15114                              <1> 
 15115                              <1> mget_w_1:
 15116 00011186 3B0D[E4830100]      <1> 	cmp	ecx, [writei.c_index]  ; last cluster index
 15117 0001118C 7320                <1> 	jnb	short mget_w_2 ; 01/11/2016
 15118                              <1> 
 15119 0001118E A1[F0830100]        <1> 	mov	eax, [writei.lclust]
 15120                              <1> 	; EAX = Last cluster
 15121 00011193 E8ABB8FFFF          <1> 	call	add_new_cluster
 15122 00011198 7261                <1> 	jc	short mget_w_err ; eax = error code
 15123                              <1> 	; edx = 0
 15124 0001119A A3[F0830100]        <1> 	mov	[writei.lclust], eax ; (new) last cluster
 15125 0001119F 8B0D[F4830100]      <1> 	mov	ecx, [writei.l_index]
 15126 000111A5 41                  <1> 	inc	ecx ; add 1 to last cluster index
 15127 000111A6 890D[F4830100]      <1> 	mov	[writei.l_index], ecx ; current last cluster index
 15128                              <1> 
 15129 000111AC EBD8                <1> 	jmp	short mget_w_1
 15130                              <1> 
 15131                              <1> mget_w_2:
 15132 000111AE 89E9                <1> 	mov	ecx, ebp
 15133 000111B0 030D[44010300]      <1> 	add	ecx, [u.count]
 15134 000111B6 890D[24020300]      <1> 	mov	[i.size], ecx ; save new file size
 15135                              <1> 	;sub	edx, edx ; 0
 15136                              <1> 
 15137 000111BC A0[01010300]        <1> 	mov	al, [cdev]
 15138 000111C1 A2[D5830100]        <1> 	mov	[writei.drv], al ; physical drive number
 15139                              <1> 	; edx = 0
 15140 000111C6 89E8                <1> 	mov	eax, ebp ; file offset
 15141 000111C8 0FB70D[DC830100]    <1> 	movzx	ecx, word [writei.bpc] ; bytes per cluster - 1
 15142 000111CF 41                  <1> 	inc	ecx ; bytes per cluster
 15143 000111D0 F7F1                <1> 	div	ecx
 15144                              <1> 	; edx = byte offset in cluster (<= 65535)
 15145                              <1> 	; eax = cluster index
 15146 000111D2 A3[E4830100]        <1> 	mov	[writei.c_index], eax
 15147 000111D7 668915[DE830100]    <1> 	mov	[writei.offset], dx
 15148                              <1> 	;shr	dx, 9 ; / 512
 15149                              <1> 	; 23/07/2022
 15150 000111DE C1EA09              <1> 	shr	edx, 9
 15151 000111E1 8815[D7830100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 15152                              <1> 
 15153                              <1> mget_w_3:
 15154 000111E7 3B05[F4830100]      <1> 	cmp	eax, [writei.l_index] ; last cluster index
 15155 000111ED 7538                <1> 	jne	short mget_w_5
 15156                              <1> 
 15157 000111EF A3[EC830100]        <1> 	mov	[writei.fs_index], eax ; cluster index (for next check)
 15158 000111F4 A1[F0830100]        <1> 	mov	eax, [writei.lclust] ; last cluster
 15159 000111F9 EB6E                <1> 	jmp	short mget_w_10
 15160                              <1> 
 15161                              <1> mget_w_err:
 15162 000111FB A3[84010300]        <1> 	mov	[u.error], eax
 15163 00011200 A3[1C010300]        <1> 	mov	[u.r0], eax
 15164 00011205 E9F5BAFFFF          <1> 	jmp	error
 15165                              <1> 
 15166                              <1> mget_w_4: ; 02/11/2016
 15167                              <1> 	; eax = next file position
 15168 0001120A 2B05[44010300]      <1> 	sub	eax, [u.count] ; current file position
 15169                              <1> 	; edx = 0
 15170                              <1> 	; ecx = bytes per cluster
 15171 00011210 F7F1                <1> 	div	ecx
 15172 00011212 A3[E4830100]        <1> 	mov	[writei.c_index], eax ; cluster index
 15173 00011217 668915[DE830100]    <1> 	mov	[writei.offset], dx
 15174                              <1> 	;shr	dx, 9 ; / 512
 15175                              <1> 	; 23/07/2022
 15176 0001121E C1EA09              <1> 	shr	edx, 9
 15177 00011221 8815[D7830100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 15178                              <1> 
 15179                              <1> mget_w_5:
 15180 00011227 21C0                <1> 	and	eax, eax ; 0 = First Cluster's index number
 15181 00011229 750C                <1> 	jnz	short mget_w_6
 15182                              <1> 
 15183 0001122B A3[EC830100]        <1> 	mov	[writei.fs_index], eax ; cluster index (for next check)
 15184 00011230 A1[E8830100]        <1> 	mov	eax, [writei.fclust] ; first cluster
 15185 00011235 EB32                <1> 	jmp	short mget_w_10
 15186                              <1> 
 15187                              <1> mget_w_6:
 15188 00011237 3B05[EC830100]      <1> 	cmp	eax, [writei.fs_index] ; current cluster index (>0)
 15189 0001123D 7507                <1> 	jne	short mget_w_7
 15190 0001123F A1[E0830100]        <1> 	mov	eax, [writei.cluster] ; current cluster 
 15191 00011244 EB3A                <1> 	jmp	short mget_w_11
 15192                              <1> 
 15193                              <1> mget_w_7:
 15194 00011246 89C1                <1> 	mov	ecx, eax
 15195 00011248 2B0D[EC830100]      <1> 	sub	ecx, [writei.fs_index]
 15196 0001124E 730D                <1> 	jnc	short mget_w_8
 15197                              <1> 	; get cluster by index from the first cluster
 15198 00011250 A1[E8830100]        <1> 	mov	eax, [writei.fclust]
 15199 00011255 8B0D[E4830100]      <1> 	mov	ecx, [writei.c_index]
 15200 0001125B EB05                <1> 	jmp	short mget_w_9
 15201                              <1> 
 15202                              <1> mget_w_8:
 15203 0001125D A1[E0830100]        <1> 	mov	eax, [writei.cluster] ; beginning cluster
 15204                              <1> 	; ecx = cluster sequence number after the beginning cluster
 15205                              <1> 	; sub	edx, edx ; 0
 15206                              <1> 
 15207                              <1> mget_w_9:
 15208                              <1> 	; EAX = Beginning cluster
 15209                              <1> 	; EDX = Sector index in disk/file section
 15210                              <1> 	;	(Only for SINGLIX file system!)
 15211                              <1> 	; ECX = Cluster sequence number after the beginning cluster
 15212                              <1> 	; ESI = Logical DOS Drive Description Table address
 15213 00011262 E8D0B8FFFF          <1> 	call	get_cluster_by_index
 15214 00011267 7292                <1> 	jc	short mget_w_err ; error code in EAX
 15215                              <1> 
 15216                              <1> 	; EAX = Cluster number		
 15217                              <1> mget_w_10:
 15218 00011269 A3[E0830100]        <1> 	mov	[writei.cluster], eax ; FDT number for Singlix File System
 15219                              <1> 
 15220 0001126E 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 15221 00011272 7628                <1> 	jna	short mget_w_13
 15222                              <1> 	; 01/11/2016
 15223 00011274 8B15[E4830100]      <1> 	mov	edx, [writei.c_index]
 15224 0001127A 8915[EC830100]      <1> 	mov	[writei.fs_index], edx
 15225                              <1> mget_w_11:
 15226                              <1> 	;sub	eax, 2
 15227                              <1> 	; 23/07/2022
 15228 00011280 48                  <1> 	dec	eax
 15229 00011281 48                  <1> 	dec	eax
 15230 00011282 0FB615[D6830100]    <1> 	movzx	edx, byte [writei.spc]
 15231 00011289 F7E2                <1> 	mul	edx
 15232                              <1> 
 15233 0001128B 034668              <1> 	add	eax, [esi+LD_DATABegin]
 15234 0001128E 8A15[D7830100]      <1> 	mov	dl, [writei.s_index]
 15235 00011294 01D0                <1> 	add	eax, edx
 15236                              <1> mget_w_12:
 15237 00011296 A3[D8830100]        <1> 	mov	[writei.sector], eax
 15238                              <1> 	;; buffer validation must be done in writei
 15239                              <1> 	;;mov	byte [writei.valid], 1 
 15240 0001129B C3                  <1> 	retn
 15241                              <1> 
 15242                              <1> mget_w_13:
 15243                              <1> 	; EAX = FDT number (Current Section)
 15244                              <1> 	; EDX = Sector index from the first section (0,1,2,3,4...)
 15245 0001129C 2B15[EC830100]      <1> 	sub	edx, [writei.fs_index]	
 15246                              <1> 	; EDX = Sector index from current section
 15247 000112A2 8915[EC830100]      <1> 	mov	[writei.fs_index], edx
 15248 000112A8 40                  <1> 	inc	eax ; the first data sector in FS disk section	
 15249 000112A9 01D0                <1> 	add	eax, edx
 15250 000112AB EBE9                <1> 	jmp	short mget_w_12
 15251                              <1> 
 15252                              <1> mget_w_14:
 15253 000112AD 8A4E12              <1> 	mov	cl, [esi+LD_FS_BytesPerSec+1]
 15254 000112B0 D0E9                <1> 	shr	cl, 1 ;  ; 1 for 512 bytes, 4 for 2048 bytes
 15255 000112B2 880D[D6830100]      <1> 	mov	[writei.spc], cl  ; sectors per cluster
 15256                              <1> 	; NOTE: writei bytes per sector value is always 512 ! 
 15257 000112B8 66C705[DC830100]00- <1> 	mov	word [writei.bpc], 512
 15257 000112C0 02                  <1>
 15258                              <1> 
 15259 000112C1 89E9                <1> 	mov	ecx, ebp
 15260 000112C3 030D[44010300]      <1> 	add	ecx, [u.count] ; next file position
 15261 000112C9 3B0D[24020300]      <1> 	cmp	ecx, [i.size] ; <= file size ?
 15262                              <1> 	;jna	mget_w_19 ; no
 15263 000112CF 7705                <1> 	ja	short mget_w_22
 15264                              <1> 	; 23/07/2022
 15265 000112D1 E9C6000000          <1> 	jmp	mget_w_19
 15266                              <1> 
 15267                              <1> mget_w_22:
 15268 000112D6 29D2                <1> 	sub	edx, edx ; 0
 15269 000112D8 8915[D8830100]      <1> 	mov 	[writei.sector], edx ; 0
 15270 000112DE 668915[DE830100]    <1> 	mov	[writei.offset], dx  ; byte offset in cluster 
 15271 000112E5 8815[D7830100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 15272                              <1> 
 15273 000112EB C1E909              <1> 	shr	ecx, 9 ; 1 cluster = 512 bytes
 15274 000112EE 890D[E4830100]      <1> 	mov	[writei.c_index], ecx ; section/cluster index
 15275                              <1> 	
 15276 000112F4 89D8                <1> 	mov	eax, ebx ; FDT number (First FDT address)
 15277                              <1> 
 15278                              <1> 	; is this the 1st mget_w or a next mget_w call ? (by 'writei')
 15279 000112F6 3815[D4830100]      <1> 	cmp	byte [writei.valid], dl ; 0 
 15280 000112FC 7624                <1> 	jna	short mget_w_15
 15281                              <1> 
 15282 000112FE 8815[D4830100]      <1> 	mov 	byte [writei.valid], dl ; 0 ; reset ('writei' will set it) 
 15283                              <1> 
 15284 00011304 3B05[E8830100]      <1> 	cmp	eax, [writei.fclust]
 15285 0001130A 7516                <1> 	jne	short mget_w_15
 15286                              <1> 
 15287 0001130C 8A0D[01010300]      <1> 	mov	cl, [cdev]
 15288 00011312 3A0D[D5830100]      <1> 	cmp	cl, [writei.drv]
 15289 00011318 7508                <1> 	jne	short mget_w_15
 15290                              <1>  	; [writei.l_clust] & [writei.l_index] are valid, 
 15291                              <1> 	;  we don't need to get last cluster & last cluster index
 15292 0001131A 8B0D[F4830100]      <1> 	mov	ecx, [writei.l_index]
 15293 00011320 EB4A                <1> 	jmp	short mget_w_17
 15294                              <1> mget_w_15:
 15295 00011322 A3[E8830100]        <1> 	mov	[writei.fclust], eax ; first section (FDT number)
 15296                              <1> 	; edx = 0
 15297 00011327 8915[E0830100]      <1> 	mov	[writei.cluster], edx ; 0 ; current section
 15298 0001132D 8915[EC830100]      <1> 	mov 	[writei.fs_index], edx ; 0 ; curret section index
 15299                              <1> 
 15300                              <1> 	; eax = FDT number (section 0 header address)
 15301 00011333 E828B8FFFF          <1> 	call	get_last_section
 15302                              <1> 	;jc	short mget_w_err ; eax = error code
 15303                              <1> 	; 08/08/2022
 15304 00011338 7305                <1> 	jnc	short mget_w_26
 15305 0001133A E9BCFEFFFF          <1> 	jmp	mget_w_err
 15306                              <1> mget_w_26:
 15307 0001133F 8915[EC830100]      <1> 	mov 	[writei.fs_index], edx ; sector index in last section
 15308                              <1> 		
 15309 00011345 A3[F0830100]        <1> 	mov	[writei.lclust], eax ; last section address
 15310                              <1> 
 15311 0001134A 8B0D[14820100]      <1> 	mov	ecx, [glc_index] ; last section index
 15312 00011350 890D[F4830100]      <1> 	mov	[writei.l_index], ecx
 15313                              <1> 
 15314 00011356 A0[F8830100]        <1> 	mov	al, [writei.ofn]
 15315 0001135B FEC0                <1> 	inc	al
 15316 0001135D A2[33840100]        <1> 	mov	[setfmod], al ; update lm date&time sign
 15317                              <1> 
 15318                              <1> mget_w_16:
 15319                              <1> 	; edx = (existing) last section (sector) index
 15320 00011362 8B0D[E4830100]      <1> 	mov	ecx, [writei.c_index] ; final section (sector) index
 15321 00011368 29D1                <1> 	sub	ecx, edx
 15322 0001136A 7630                <1> 	jna	short mget_w_19
 15323                              <1> 	; ecx = sector count
 15324                              <1> mget_w_17:
 15325 0001136C A1[F0830100]        <1> 	mov	eax, [writei.lclust]
 15326                              <1> 	; ESI = Logical dos drv desc. table address
 15327                              <1>         ; EAX = Last section
 15328                              <1>         ; (ECX = 0 for directory) 
 15329                              <1>         ; ECX = sector count (except FDT)
 15330 00011371 E840AEFFFF          <1> 	call	add_new_fs_section
 15331 00011376 730F                <1> 	jnc	short mget_w_18
 15332                              <1> 
 15333                              <1> 	; If error number = 27h (insufficient disk space)
 15334                              <1> 	; it is needed to check free consequent sectors
 15335                              <1> 	; (1 data sector at least and +1 section header sector) 
 15336                              <1> 
 15337 00011378 83F827              <1> 	cmp	eax, 27h
 15338                              <1> 	;jne	mget_w_err ; eax = error code
 15339                              <1> 	; 25/07/2022
 15340 0001137B 7405                <1> 	je	short mget_w_24
 15341                              <1> mget_w_23:
 15342 0001137D E979FEFFFF          <1> 	jmp	mget_w_err
 15343                              <1> mget_w_24:
 15344                              <1> 	; ecx = count of free consequent sectors
 15345                              <1> 	; ecx must be > 1 (1 data + 1 header sector)
 15346 00011382 49                  <1> 	dec	ecx
 15347                              <1> 	;jz	short mget_w_err
 15348                              <1> 	;jmp	short mget_w_17
 15349                              <1> 	; 23/07/2022
 15350 00011383 75E7                <1> 	jnz	short mget_w_17
 15351                              <1> 	;jmp	mget_w_err
 15352                              <1> 	; 25/07/2022
 15353 00011385 EBF6                <1> 	jmp	short mget_w_23
 15354                              <1> 
 15355                              <1> mget_w_18:
 15356 00011387 A3[F0830100]        <1> 	mov	[writei.lclust], eax ; (new) last section
 15357                              <1> 	; ecx = sector count (except section header)
 15358 0001138C 8B15[F4830100]      <1> 	mov	edx, [writei.l_index]
 15359 00011392 01CA                <1> 	add	edx, ecx ; add sector count to index
 15360 00011394 8915[F4830100]      <1> 	mov	[writei.l_index], edx
 15361 0001139A EBC6                <1> 	jmp	short mget_w_16
 15362                              <1> 
 15363                              <1> mget_w_19:
 15364 0001139C 89E9                <1> 	mov	ecx, ebp
 15365 0001139E 030D[44010300]      <1> 	add	ecx, [u.count]
 15366 000113A4 890D[24020300]      <1> 	mov	[i.size], ecx ; save new file size
 15367                              <1> 	;sub	edx, edx ; 0
 15368                              <1> 
 15369 000113AA A0[01010300]        <1> 	mov	al, [cdev]
 15370 000113AF A2[D5830100]        <1> 	mov	[writei.drv], al ; physical drive number
 15371                              <1> 	; edx = 0
 15372 000113B4 89E8                <1> 	mov	eax, ebp ; file offset
 15373 000113B6 89C2                <1> 	mov	edx, eax
 15374                              <1> 	; 1 cluster = 512 bytes (for Singlix FS)
 15375 000113B8 C1E809              <1> 	shr	eax, 9  ; / 512
 15376 000113BB 81E2FF010000        <1> 	and	edx, 1FFh
 15377                              <1> 	; edx = byte offset in cluster/sector (<= 511)
 15378                              <1> 	; eax = section (sector/cluster) index
 15379 000113C1 A3[E4830100]        <1> 	mov	[writei.c_index], eax
 15380 000113C6 668915[DE830100]    <1> 	mov	[writei.offset], dx
 15381                              <1> 	;mov	byte [writei.s_index], 0 ; sector index in cluster
 15382 000113CD E915FEFFFF          <1> 	jmp	mget_w_3
 15383                              <1> 
 15384                              <1> update_file_lmdt: ; & update file size
 15385                              <1> 	; 30/07/2022
 15386                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 15387                              <1> 	; 26/10/2016
 15388                              <1> 	; 24/10/2016
 15389                              <1> 	; 23/10/2016
 15390                              <1> 	; 22/10/2016 - TRDOS 386 (TRDOS v2.0)
 15391                              <1> 	;
 15392                              <1> 	; Update last modification date&time of file
 15393                              <1> 	; (call from syswrite -> writei)
 15394                              <1> 	; ((also updates file size)) // 26/10/2016
 15395                              <1> 	; 
 15396                              <1> 	; INPUT:
 15397                              <1> 	;      byte [setfmod] = open file number
 15398                              <1> 	; OUTPUT:
 15399                              <1> 	;      cf = 0 -> success !
 15400                              <1> 	;      cf = 1 -> lmdt update has been failed!
 15401                              <1> 	;
 15402                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi
 15403                              <1> 	;
 15404                              <1> 
 15405                              <1> 	;cmp	byte [setfmod], 0
 15406                              <1> 	;jna	short uflmdt_2 ; nothing to do
 15407                              <1> 
 15408 000113D2 31C0                <1> 	xor	eax, eax
 15409                              <1> 
 15410 000113D4 0FB61D[33840100]    <1> 	movzx	ebx, byte [setfmod]
 15411 000113DB FECB                <1> 	dec	bl ; open file index number (0 based)
 15412                              <1> 
 15413 000113DD 8AA3[C4840100]      <1> 	mov	ah, [ebx+OF_DRIVE]
 15414 000113E3 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 15415 000113E8 01C6                <1> 	add	esi, eax
 15416 000113EA C0E302              <1> 	shl	bl, 2 ; *4	
 15417 000113ED 8B8B[44840100]      <1> 	mov	ecx, [ebx+OF_FCLUSTER] ; first cluster
 15418 000113F3 8B93[C4860100]      <1> 	mov	edx, [ebx+OF_DIRCLUSTER] ; dir cluster
 15419                              <1> 
 15420 000113F9 D0EB                <1> 	shr	bl, 1 ; /2
 15421 000113FB 0FB7BB[C4880100]    <1> 	movzx	edi, word [ebx+OF_DIRENTRY]
 15422                              <1> 	
 15423 00011402 803D[717F0100]01    <1> 	cmp	byte [DirBuff_ValidData], 1
 15424 00011409 7265                <1> 	jb	short uflmdt_4
 15425                              <1> 
 15426 0001140B A0[6F7F0100]        <1> 	mov	al, [DirBuff_DRV]
 15427 00011410 2C41                <1> 	sub	al, 'A'	
 15428 00011412 38E0                <1> 	cmp	al, ah
 15429 00011414 755A                <1> 	jne	short uflmdt_4 ; different drive
 15430 00011416 8A4603              <1> 	mov	al, [esi+LD_FATType] 
 15431 00011419 3A05[707F0100]      <1> 	cmp	al, [DirBuff_FATType]
 15432 0001141F 7552                <1> 	jne	short uflmdt_5 ; different FS type
 15433 00011421 3B15[767F0100]      <1> 	cmp	edx, [DirBuff_Cluster]
 15434 00011427 754A                <1> 	jne	short uflmdt_5 ; different cluster
 15435                              <1> 
 15436                              <1> uflmdt_1:
 15437                              <1> 	; Directory buffer is ready here!
 15438                              <1> 	; OF_FCLUSTER must be compared/verified
 15439 00011429 BE00000800          <1> 	mov	esi, Directory_Buffer
 15440                              <1> 	;shl	di, 5 ; dir entry index * 32
 15441                              <1> 	; 23/07/2022
 15442 0001142E C1E705              <1> 	shl	edi, 5 
 15443 00011431 01FE                <1> 	add	esi, edi ; offset
 15444                              <1> 	;
 15445 00011433 F6460B18            <1> 	test	byte [esi+DirEntry_Attr], 18h ; Vol & Dir
 15446 00011437 7564                <1> 	jnz	short uflmdt_2 ; not a valid file !
 15447 00011439 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI]
 15448 0001143D C1E010              <1> 	shl	eax, 16
 15449 00011440 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO]
 15450 00011444 39C8                <1> 	cmp	eax, ecx ; same first cluster ?
 15451                              <1> 	;je	short uflmdt_3 ; yes, it is OK !!!	
 15452                              <1> 	; 23/07/2022
 15453 00011446 7555                <1> 	jne	short uflmdt_2
 15454                              <1> 	
 15455                              <1> uflmdt_3:
 15456                              <1> 	; Update directory entry
 15457                              <1> 	; 26/10/2016
 15458 00011448 D0E3                <1> 	shl	bl, 1 ; *2 
 15459 0001144A 8B83[C4850100]      <1> 	mov	eax, [ebx+OF_SIZE] ; file size
 15460 00011450 89461C              <1> 	mov	[esi+DirEntry_FileSize], eax
 15461                              <1> 	;
 15462 00011453 E8539AFFFF          <1> 	call	convert_current_date_time
 15463                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
 15464                              <1>         ; 	    AX = Time in dos dir entry format	
 15465 00011458 66894616            <1> 	mov	[esi+DirEntry_WrtTime], ax
 15466 0001145C 66895618            <1> 	mov	[esi+DirEntry_WrtDate], dx	
 15467 00011460 66895612            <1> 	mov	[esi+DirEntry_LastAccDate], dx
 15468 00011464 C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2
 15469                              <1> 	;call	save_directory_buffer
 15470                              <1> 	;retn
 15471                              <1> 	; 23/07/2022
 15472 0001146B E9D09AFFFF          <1> 	jmp	save_directory_buffer	
 15473                              <1> 
 15474                              <1> uflmdt_4:
 15475                              <1> 	; Directory buffer sector read&write
 15476                              <1> 	; 23/10/2016
 15477                              <1> 	;
 15478 00011470 8A4603              <1> 	mov	al, [esi+LD_FATType]
 15479                              <1> uflmdt_5:
 15480 00011473 BB[50070300]        <1> 	mov	ebx, rw_buffer ; Common r/w sector buffer addr
 15481                              <1> 		
 15482 00011478 20C0                <1> 	and	al, al ; 0 = Singlix FS
 15483 0001147A 7428                <1> 	jz	short uflmdt_11
 15484                              <1> 
 15485                              <1> ;uflmdt_12:
 15486 0001147C 21D2                <1> 	and	edx, edx
 15487 0001147E 752B                <1> 	jnz	short uflmdt_9
 15488                              <1> 
 15489 00011480 3C02                <1> 	cmp	al, 2  ; 3 = FAT32
 15490 00011482 7724                <1> 	ja	short uflmdt_8
 15491                              <1> 
 15492 00011484 89F8                <1> 	mov	eax, edi ; directory entry index number
 15493                              <1> 	;shr	ax, 4 ; 16 entries per sector	 
 15494                              <1> 	; 23/07/2022
 15495 00011486 C1E804              <1> 	shr	eax, 4
 15496 00011489 034664              <1> 	add	eax, [esi+LD_ROOTBegin]
 15497                              <1> 	; eax = root directory sector
 15498                              <1> uflmdt_6:
 15499 0001148C 50                  <1> 	push	eax ; * ; disk sector address
 15500 0001148D 51                  <1> 	push	ecx ; first cluster	
 15501 0001148E B901000000          <1> 	mov	ecx, 1
 15502                              <1> 	; ecx = sector count
 15503 00011493 E8BD080000          <1> 	call	disk_read
 15504 00011498 59                  <1> 	pop	ecx
 15505 00011499 7324                <1> 	jnc	short uflmdt_10
 15506 0001149B 58                  <1> 	pop	eax ; *
 15507                              <1> uflmdt_7:
 15508 0001149C C3                  <1> 	retn
 15509                              <1> 
 15510                              <1> uflmdt_2:	
 15511                              <1> 	; save directory buffer if has modified/changed sign
 15512                              <1> 	; (It is good to save dir buff even if the searched
 15513                              <1> 	; directory entry is not found !?)
 15514 0001149D E89E9AFFFF          <1> 	call	save_directory_buffer
 15515 000114A2 F9                  <1> 	stc	; update failed
 15516 000114A3 C3                  <1> 	retn
 15517                              <1> 
 15518                              <1> uflmdt_11:
 15519                              <1> 	; 24/10/2016
 15520                              <1> 	; Update last modification date & time of a file
 15521                              <1> 	; on a disk with Singlix File System.
 15522                              <1> 	;
 15523                              <1> 	; (Method: Read the FDT -File Description Table-
 15524                              <1> 	; sector of the file and update the lmdt data fields,
 15525                              <1> 	; then write FDT sector to the disk.
 15526                              <1> 	; /// It is easy but there is compatibility buffer
 15527                              <1> 	; method also for changing directory entry data and
 15528                              <1> 	; also there are some programming issues for Singlix
 15529                              <1> 	; file system (TRFS), which are not completed yet!)
 15530                              <1> 	;
 15531                              <1> 	; Not ready yet ! (24/10/2016)
 15532                              <1> 	; /// Temporary code for error return ! ///
 15533 000114A4 31C0                <1> 	xor	eax, eax
 15534 000114A6 F9                  <1> 	stc
 15535 000114A7 C3                  <1> 	retn	
 15536                              <1> 
 15537                              <1> uflmdt_8:
 15538 000114A8 8B5632              <1> 	mov	edx, [esi+LD_BPB+FAT32_RootFClust]
 15539                              <1> uflmdt_9:
 15540 000114AB 83FA02              <1> 	cmp	edx, 2
 15541 000114AE 72EC                <1> 	jb	short uflmdt_7 ; invalid, nothing to do
 15542                              <1> 
 15543                              <1> 	;sub	edx, 2
 15544                              <1> 	; 30/07/2022
 15545 000114B0 4A                  <1> 	dec	edx
 15546 000114B1 4A                  <1> 	dec	edx
 15547 000114B2 89D0                <1> 	mov	eax, edx
 15548 000114B4 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
 15549 000114B8 F7E2                <1> 	mul	edx
 15550 000114BA 034668              <1> 	add	eax, [esi+LD_DATABegin]
 15551                              <1> 	; eax = sub directory (data) sector 
 15552 000114BD EBCD                <1> 	jmp	short uflmdt_6
 15553                              <1> 
 15554                              <1> uflmdt_10:
 15555                              <1> 	; Directory sector buffer is ready here!
 15556                              <1> 	; OF_FCLUSTER must be compared/verified
 15557                              <1> 	; edi = dir entry index number (<= 2047)
 15558 000114BF 6683E70F            <1> 	and	di, 0Fh ; 16 entries per sector
 15559                              <1> 	;shl	di, 5 ; dir entry index * 32
 15560                              <1> 	; 23/07/2022
 15561 000114C3 C1E705              <1> 	shl	edi, 5
 15562 000114C6 81C7[50070300]      <1> 	add	edi, rw_buffer
 15563                              <1> 	;
 15564 000114CC F6470B18            <1> 	test	byte [edi+DirEntry_Attr], 18h ; Vol & Dir
 15565 000114D0 75CB                <1> 	jnz	short uflmdt_2 ; not a valid file !
 15566 000114D2 668B5714            <1> 	mov	dx, [edi+DirEntry_FstClusHI]
 15567 000114D6 C1E210              <1> 	shl	edx, 16
 15568 000114D9 668B571A            <1> 	mov	dx, [edi+DirEntry_FstClusLO]
 15569 000114DD 39CA                <1> 	cmp	edx, ecx ; same first cluster ?
 15570 000114DF 75BC                <1> 	jne	short uflmdt_2 ; no !?
 15571                              <1> 
 15572                              <1> 	; Update directory entry
 15573 000114E1 E8C599FFFF          <1> 	call	convert_current_date_time
 15574                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
 15575                              <1>         ; 	    AX = Time in dos dir entry format	
 15576 000114E6 66894716            <1> 	mov	[edi+DirEntry_WrtTime], ax
 15577 000114EA 66895718            <1> 	mov	[edi+DirEntry_WrtDate], dx	
 15578 000114EE 66895712            <1> 	mov	[edi+DirEntry_LastAccDate], dx
 15579                              <1> 	
 15580 000114F2 58                  <1> 	pop	eax ; *
 15581                              <1> 
 15582 000114F3 BB[50070300]        <1> 	mov	ebx, rw_buffer ; Common r/w sector buffer addr
 15583 000114F8 B901000000          <1> 	mov	ecx, 1
 15584                              <1> 	; esi = logical dos description table address
 15585                              <1> 	; eax = disk sector number/address (LBA)
 15586                              <1> 	; ecx = sector count
 15587                              <1> 	; ebx = buffer address
 15588 000114FD E844080000          <1> 	call	disk_write
 15589 00011502 7299                <1> 	jc	short uflmdt_2
 15590                              <1> ;uflmdt_12:	
 15591                              <1> 	; save directory buffer if has modified/changed sign
 15592                              <1> 	;call	save_directory_buffer
 15593                              <1> 	;retn
 15594                              <1> 	; 23/07/2022
 15595 00011504 E9379AFFFF          <1> 	jmp	save_directory_buffer
 15596                              <1> 
 15597                              <1> 
 15598                              <1> sysalloc:
 15599                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 15600                              <1> 	; 14/10/2017
 15601                              <1> 	; 20/08/2017 - 01/09/2017
 15602                              <1> 	; 20/02/2017 - 04/03/2017 - 15/05/2017
 15603                              <1> 	; 19/02/2017 - TRDOS 386 (TRDOS v2.0)
 15604                              <1> 	; (TRDOS 386 feature only!)
 15605                              <1> 	;
 15606                              <1> 	; Allocate Contiguous Memory Block/Pages (for user)
 15607                              <1> 	; (System call for DMA Buffer allocation etc.)	
 15608                              <1> 	;
 15609                              <1> 	; INPUT ->
 15610                              <1> 	;	EBX = Virtual address (for user)
 15611                              <1> 	;	     (Physical memory block/aperture
 15612                              <1> 	;	     will be mapped to this virtual address) 
 15613                              <1> 	;	ECX = Byte Count
 15614                              <1> 	;	     (will be rounded up to page border)
 15615                              <1> 	;	If ECX = 0
 15616                              <1> 	;	    System call will return with an error (cf=1)
 15617                              <1> 	;	    but ECX will contain maximum size of
 15618                              <1> 	;	    available memory aperture and physical
 15619                              <1> 	;	    (beginning) address of that aperture
 15620                              <1> 	;	    (which have maximum size) will be in EAX.
 15621                              <1> 	;	EDX = Upper limit of the requested physical memory
 15622                              <1> 	;	      block/pages.
 15623                              <1> 	;	     (The last byte address of the memory aperture 
 15624                              <1> 	;	      must not be equal to or above this limit.)	
 15625                              <1> 	;	If EDX = 0
 15626                              <1> 	; 	   there is NOLIMIT !
 15627                              <1> 	;	If EDX = 0FFFFFFFFh (-1) 
 15628                              <1> 	;	   ESI = Lower Limit !
 15629                              <1> 	;		(Beginning of the block must not be 'less'
 15630                              <1> 	;		than this.) (Must be equal to or above...)
 15631                              <1> 	;	   EDI = Upper Limit !
 15632                              <1> 	;		(End of the block must be !less! than this)
 15633                              <1> 	;		(The last byte addr of the memory aperture 
 15634                              <1> 	;		must not be equal to or above this limit.)
 15635                              <1> 	;
 15636                              <1> 	; OUTPUT ->
 15637                              <1> 	;	If CF = 0
 15638                              <1> 	;	EAX = Physical address of the allocated memory block
 15639                              <1> 	;	ECX = Allocated bytes (as rounded up to page borders)
 15640                              <1> 	;	EBX = Virtual address (as rounded up)
 15641                              <1> 	;	IF CF = 1
 15642                              <1> 	;	    Requested (size of) Memory block could not be 
 15643                              <1> 	;	    allocated to the user!	
 15644                              <1> 	;	IF CF = 1 & EAX = 0 (Insufficient memory error!)
 15645                              <1> 	;	   ECX = Total number of free bytes
 15646                              <1> 	;	         (not size of available contiguous bytes!)		 	
 15647                              <1> 	;	If CF = 1 & EAX > 0
 15648                              <1> 	;	   there is not a memory aperture with requested size
 15649                              <1> 	;	   but total free mem is not less than requested size.
 15650                              <1> 	;	   EAX = Physical addr of available memory aperture
 15651                              <1> 	;	   	 with max size 
 15652                              <1> 	;	        (but it doesn't fit to the conditions!) 	
 15653                              <1> 	;	   ECX = Size of available memory aperture in bytes.
 15654                              <1> 	;	If CF = 1 -> EAX = 0FFFFFFFFh	
 15655                              <1> 	;	   Conditions/Parameters are wrong !		 		
 15656                              <1> 	;	   ECX is same with input value.
 15657                              <1> 	;
 15658                              <1> 	; Note:	Previously allocated pages will be deallocated if
 15659                              <1> 	;       new allocation conditions are met.
 15660                              <1> 	;
 15661                              <1> 	; Note: u.break control may be included in future versions	
 15662                              <1> 	;
 15663                              <1> 
 15664 00011509 31C0                <1> 	xor	eax, eax ; 0
 15665                              <1> 	; 14/10/2017
 15666 0001150B 4A                  <1> 	dec	edx ; is there a limit ?
 15667 0001150C 7810                <1> 	js	short sysalloc_1 ;  0 -> 0FFFFFFFFh -> NO LIMIT
 15668 0001150E 42                  <1> 	inc	edx ; > 0
 15669                              <1> 	; Check upper address limit
 15670                              <1> 	;(round up to page borders)
 15671 0001150F 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
 15672 00011515 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
 15673 0001151A 39CA                <1> 	cmp	edx, ecx ; upper limit - block size
 15674 0001151C 7224                <1> 	jb	short sysalloc_err
 15675                              <1> sysalloc_1:
 15676                              <1> 	; EAX = Beginning address (physical)
 15677                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
 15678                              <1> 	; ECX = Number of bytes to be allocated		
 15679 0001151E E8C946FFFF          <1> 	call	allocate_memory_block
 15680 00011523 721D                <1> 	jc	short sysalloc_err
 15681                              <1> 	; 01/09/2017
 15682 00011525 29C2                <1> 	sub	edx, eax ; upper limit address - beginning address
 15683 00011527 760F                <1> 	jna	short sysalloc_3 ; begin addr not less than the limit
 15684 00011529 39CA                <1> 	cmp	edx, ecx
 15685 0001152B 720B                <1> 	jb	short sysalloc_3 ; end address overs the limit
 15686                              <1> sysalloc_2:	
 15687                              <1> 	; EAX = Beginning (physical) addr of the allocated mem block
 15688                              <1> 	; ECX = Num of allocated bytes (rounded up to page borders) 
 15689 0001152D 50                  <1> 	push	eax ; * ; 04/03/2017	
 15690                              <1> 	; Here, requested contiquous memory pages have been allocated
 15691                              <1> 	; on Memory Allocation Table but user's page directory 
 15692                              <1> 	; and page tables have not been updated yet!
 15693 0001152E 51                  <1> 	push	ecx ; **
 15694                              <1> 	; ebx = virtual address (will be rounded up to page border)
 15695                              <1> 	; ecx = number of bytes to be deallocated
 15696                              <1> 	;	will be adjusted to ebx+ecx round down - ebx round up
 15697 0001152F E8124AFFFF          <1> 	call	deallocate_user_pages 
 15698 00011534 731F                <1> 	jnc	short sysalloc_4 ; EAX = Deallocated memory bytes
 15699 00011536 59                  <1> 	pop	ecx ; **
 15700 00011537 58                  <1> 	pop	eax ; *
 15701                              <1> sysalloc_3:
 15702                              <1> 	; error !
 15703                              <1> 	; restore Memory Allocation Table Content
 15704 00011538 E8CB48FFFF          <1> 	call	deallocate_memory_block
 15705 0001153D 31C0                <1> 	xor	eax, eax ; 0
 15706 0001153F 48                  <1> 	dec	eax ; 0FFFFFFFFh ; 15/05/2017
 15707 00011540 EB09                <1> 	jmp	short sysalloc_wrong
 15708                              <1> sysalloc_err:
 15709 00011542 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 15710 00011548 894D18              <1> 	mov	[ebp+24], ecx ; return to user with ecx value 
 15711                              <1> sysalloc_wrong:
 15712                              <1> 	; eax = 0FFFFFFFFh
 15713 0001154B A3[1C010300]        <1> 	mov	[u.r0], eax
 15714 00011550 E9AAB7FFFF          <1> 	jmp	error
 15715                              <1> sysalloc_4:
 15716 00011555 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 15717 0001155B 894518              <1> 	mov	[ebp+24], eax ; return to user with ecx value 
 15718 0001155E 895D10              <1> 	mov	[ebp+16], ebx ; new value of ebx (rounded up)
 15719 00011561 89C1                <1> 	mov	ecx, eax ; byte count (from 'deallocate_user_pages')
 15720 00011563 5A                  <1> 	pop	edx ; ** ; discard (another) byte count
 15721 00011564 58                  <1> 	pop	eax ; *
 15722 00011565 A3[1C010300]        <1> 	mov	[u.r0], eax ; physical address
 15723                              <1> 	
 15724 0001156A 51                  <1> 	push	ecx ; 20/08/2017
 15725                              <1> 	;
 15726                              <1> 	; Write newly allocated contiguous (physical) pages
 15727                              <1> 	; on page dir and page tables of current user/process	
 15728                              <1> 	; as PRESENT, USER, WRITABLE
 15729                              <1> 	; (then clear allocated pages)
 15730 0001156B E8BE4AFFFF          <1> 	call	allocate_user_pages
 15731                              <1> 	;jnc	sysret ; OK! return to process with success...
 15732                              <1> 
 15733                              <1> 	; 20/08/2017 ('sysdma' modification)
 15734 00011570 59                  <1> 	pop	ecx
 15735 00011571 A1[1C010300]        <1> 	mov	eax, [u.r0]   ; physical address (of the block)
 15736                              <1> 
 15737 00011576 7219                <1> 	jc	short sysalloc_6
 15738                              <1> 
 15739 00011578 833D[F48D0100]FF    <1> 	cmp	dword [dma_addr], 0FFFFFFFFh ; -1	
 15740                              <1> 	;jb	sysret
 15741                              <1> 	; 23/07/2022
 15742 0001157F 720B                <1> 	jb	short sysalloc_5 ; jmp sysret
 15743                              <1> 
 15744 00011581 A3[F48D0100]        <1> 	mov	[dma_addr], eax ; save dma address for sysdma
 15745 00011586 890D[F88D0100]      <1> 	mov	[dma_size], ecx ; save dma buff size for sysdma
 15746                              <1> sysalloc_5:
 15747 0001158C E98EB7FFFF          <1> 	jmp	sysret
 15748                              <1> 		
 15749                              <1> sysalloc_6:
 15750                              <1> 	;
 15751                              <1> 	; unexpected error ! insufficient memory !? conflict !?
 15752                              <1> 	; (!!?there is not a free page for a new page table?!!)
 15753                              <1> 	; We need to terminate process with error message !!!  
 15754                              <1> 	;
 15755 00011591 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 15756 00011597 8B4D18              <1> 	mov	ecx, [ebp+24] ; byte count
 15757                              <1> 	
 15758                              <1> 	; 20/08/2017
 15759                              <1> 	;mov	eax, [u.r0]   ; physical address (of the block)
 15760                              <1> 	
 15761                              <1> 	;
 15762                              <1> 	; restore Memory Allocation Table Content
 15763 0001159A E86948FFFF          <1> 	call	deallocate_memory_block
 15764                              <1> 	;
 15765 0001159F 803D[CE660000]03    <1> 	cmp	byte [CRT_MODE], 3 ; 80x25 text mode?
 15766 000115A6 7407                <1> 	je	short sysalloc_7 ; yes
 15767                              <1> 	; Current mode is VGA (or CGA graphics) mode,
 15768                              <1> 	; We need to return to text mode for displaying
 15769                              <1> 	; error message just before 'sysexit'.  
 15770 000115A8 B003                <1> 	mov	al, 3
 15771 000115AA E85705FFFF          <1> 	call	_set_mode
 15772                              <1> sysalloc_7:
 15773 000115AF BE[FB330100]        <1> 	mov	esi, beep_Insufficient_Memory ; error message
 15774 000115B4 E8A156FFFF          <1> 	call	print_msg ; print/display the message
 15775 000115B9 B801000000          <1> 	mov	eax, 1 ; ax=1 is needed for 'sysexit' procedure
 15776 000115BE E999B8FFFF          <1> 	jmp	sysexit ; and terminate the process !
 15777                              <1> 
 15778                              <1> sysdalloc:
 15779                              <1> 	; 19/02/2017 - TRDOS 386 (TRDOS v2.0)
 15780                              <1> 	; (TRDOS 386 feature only!)
 15781                              <1> 	;
 15782                              <1> 	; Deallocate Memory Block/Pages (for user)
 15783                              <1> 	; (Complementary call for sysalloc.)	
 15784                              <1> 	;
 15785                              <1> 	; INPUT ->
 15786                              <1> 	;	EBX = Virtual address (for user)
 15787                              <1> 	;	      (will be rounded up to page border)
 15788                              <1> 	;	ECX = Byte Count
 15789                              <1> 	;	     (will be adjusted to page borders)
 15790                              <1> 	;	If ICX = 0
 15791                              <1> 	;	   nothing to do
 15792                              <1> 	;	If EBX + ECX > User's ESP
 15793                              <1> 	;	   nothing to do		
 15794                              <1> 	; 
 15795                              <1> 	; Note: u.break control may be included in future versions	
 15796                              <1> 	;
 15797                              <1> 	; OUTPUT ->
 15798                              <1> 	;	If CF = 0
 15799                              <1> 	;	   EAX = Deallocated memory bytes
 15800                              <1> 	;	   EBX = Virtual address (as rounded up)	
 15801                              <1> 	;	IF CF = 1
 15802                              <1> 	;	   EAX = 0
 15803                              <1> 	;
 15804                              <1> 	; Note:	Main purpose of this call is to deallocate/release
 15805                              <1> 	;	previously allocated (physically) contiguous memory
 15806                              <1> 	;	pages but beginning (virtual) address may not be
 15807                              <1> 	;	followed by physically contiguous pages. So, this
 15808                              <1> 	;	system call will deallocate user's virtually
 15809                              <1> 	;	contiguous memory pages. Also, there is not any
 15810                              <1> 	;	objections to use this system call without sysalloc
 15811                              <1> 	;	system call; only possible objection is to lost data
 15812                              <1> 	;	within user's memory space, if the beginning address
 15813                              <1> 	;	and size is not proper.
 15814                              <1> 	;
 15815                              <1> 	; Note: Empty page tables will not be deallocated!!!
 15816                              <1> 	;       (they will be deallocated at process termination)
 15817                              <1> 	;
 15818                              <1> 	; Note: When the program terminates itself or when it is 
 15819                              <1> 	;	terminated by operating system kernel, all allocated
 15820                              <1> 	;	memory pages will be deallocated during termination
 15821                              <1> 	;	stage. So, 'sysdalloc' is not necessary except 
 15822                              <1> 	;	forgiving memory block to other programs/processes.
 15823                              <1> 	;	
 15824 000115C3 8B15[14010300]      <1> 	mov	edx, [u.sp]
 15825 000115C9 8B420C              <1> 	mov	eax, [edx+12] ; user's stack pointer
 15826 000115CC 29C8                <1> 	sub	eax, ecx ; esp - byte count
 15827 000115CE 24FC                <1> 	and	al, 0FCh ; dword alignment
 15828 000115D0 39D8                <1> 	cmp	eax, ebx
 15829 000115D2 7220                <1> 	jb	short sysdalloc_err ; deallocation overlaps with stack 	
 15830                              <1> 
 15831 000115D4 31C0                <1> 	xor	eax, eax
 15832 000115D6 21C9                <1> 	and	ecx, ecx
 15833 000115D8 7407                <1> 	jz	short sysdalloc_2
 15834                              <1> 	
 15835 000115DA E86749FFFF          <1> 	call	deallocate_user_pages
 15836 000115DF 7213                <1> 	jc	short sysdalloc_err
 15837                              <1> 
 15838                              <1> sysdalloc_2:
 15839 000115E1 A3[1C010300]        <1> 	mov	[u.r0], eax
 15840 000115E6 8B2D[18010300]      <1> 	mov	ebp, [u.usp]
 15841 000115EC 895D10              <1> 	mov	[ebp+16], ebx ; new value of ebx
 15842 000115EF E92BB7FFFF          <1> 	jmp	sysret
 15843                              <1> 
 15844                              <1> sysdalloc_err:
 15845 000115F4 A3[1C010300]        <1> 	mov	[u.r0], eax ; 0
 15846 000115F9 E901B7FFFF          <1> 	jmp	error
 15847                              <1> 
 15848                              <1> syscalbac:
 15849                              <1> 	; SYS CALLBACK
 15850                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 15851                              <1> 	; 03/08/2020
 15852                              <1> 	; 16/04/2017
 15853                              <1> 	; 14/04/2017
 15854                              <1> 	; 13/04/2017
 15855                              <1> 	; 28/02/2017
 15856                              <1> 	; 26/02/2017
 15857                              <1> 	; 24/02/2017
 15858                              <1> 	; 21/02/2017 - TRDOS 386 (TRDOS v2.0)
 15859                              <1> 	; (TRDOS 386 feature only!)
 15860                              <1> 	;
 15861                              <1> 	; Link or unlink IRQ callback service to/from user (ring 3)	
 15862                              <1> 	;
 15863                              <1> 	; INPUT ->
 15864                              <1> 	;	BL = IRQ number (Hardware interrupt request number)
 15865                              <1> 	;	     (0 t0 15 but IRQ 0,1,2,6,8,14,15 are prohibited)
 15866                              <1> 	;	     IRQ numbers 3,4,5,7,9,10,11,12,13 are valid
 15867                              <1> 	;	     (numbers >15 are invalid)
 15868                              <1> 	;
 15869                              <1> 	;	BH = 0 = Unlink IRQ (in BL) from user (ring 3) service
 15870                              <1> 	;	     1 = Link IRQ by using Signal Response Byte method
 15871                              <1> 	;	     2 = Link IRQ by using Callback service method 		
 15872                              <1> 	;	     3 = Link IRQ by using Auto Increment S.R.B. method 	
 15873                              <1> 	;	    >3 = invalid 
 15874                              <1> 	;	
 15875                              <1> 	;	CL = Signal Return/Response Byte value 
 15876                              <1> 	;
 15877                              <1> 	;	If BH = 3, kernel will put a counter value  ; 03/08/2020
 15878                              <1> 	;	          (into the S.R.B. addr)
 15879                              <1> 	;		  between 0 to 255. (start value = CL+1)
 15880                              <1> 	;	
 15881                              <1> 	;	NOTE: counter value, for example: even and odd numbers
 15882                              <1> 	;	      may be used for -audio- DMA buffer switch 
 15883                              <1> 	;	      within double buffer method, etc. 		
 15884                              <1> 	;
 15885                              <1> 	;	EDX = Signal return (Response) byte address
 15886                              <1> 	;	       		  - or -
 15887                              <1> 	;	      Interrupt/Callback service/routine address
 15888                              <1> 	; 	
 15889                              <1> 	;	      (virtual address in user's memory space)
 15890                              <1> 	;
 15891                              <1> 	; OUTPUT ->
 15892                              <1> 	;	CF = 0 & EAX = 0 -> Successful setting
 15893                              <1> 	;	CF = 1 & EAX > 0 -> IRQ is prohibited or locked 
 15894                              <1> 	;			by another process
 15895                              <1> 	;		 eax = ERR_PERM_DENIED -> prohibited or locked
 15896                              <1> 	;		 eax = ERR_INV_PARAMETER -> 
 15897                              <1> 	;		       invalid parameter/option or bad address
 15898                              <1> 	;
 15899                              <1> 	;	NOTE: Timer callbacks are set by using 'systimer'
 15900                              <1> 	;	      system call (IRQ 0, PIT and IRQ 8, RTC)
 15901                              <1> 	;
 15902                              <1> 	;	      Direct keyboard access is performed by using
 15903                              <1> 	;	      Keyboard Interrupt (INT 32h)	 	
 15904                              <1> 	;	
 15905                              <1> 	;	      It is prohibited here because:
 15906                              <1> 	;		1) Signal Response Byte method has not advantage
 15907                              <1> 	;		   against INT 32h, function AH = 1. Also,
 15908                              <1> 	;		   keyboard service interrupt will return with
 15909                              <1> 	;		   ascii and scan codes (AL, AH) while
 15910                              <1> 	;		   SRB method has only 1 byte space for ascii code
 15911                              <1> 	;		   or scan code. One byte signal response is used 
 15912                              <1> 	;		   for ensuring very simple and very fast
 15913                              <1> 	;		   virtual to physical memory address conversion
 15914                              <1> 	;		   without any memory page crossover risk. 
 15915                              <1> 	;		   (Otherwise double page conversion or word 
 15916                              <1> 	;		   alignment would be needed.)
 15917                              <1> 	;		2) Badly written user code (callback code)
 15918                              <1> 	;		   can prevent keyboard and timesharing functions
 15919                              <1> 	;		   of the operating system via continuous and long
 15920                              <1> 	;		   keyboard event handling by callback service.
 15921                              <1> 	;		   (It can cause to lose immediate keystroke 
 15922                              <1> 	;		   response from hardware to user.)
 15923                              <1> 	;		3) If user will check any keyboard events, 'getkey'
 15924                              <1> 	;		   (or 'getchar') must have more priority than other
 15925                              <1> 	;		   (video etc.) events because only control ability
 15926                              <1> 	;		   on a procedural infinite loop is a keyboard or
 15927                              <1> 	;		   mouse event. So user can use keyboard function
 15928                              <1> 	;		   at the end or at the beginning of a loop.
 15929                              <1> 	;		   In this case, INT 32h is used for that purpose
 15930                              <1> 	;		   and timer interrupt etc. callbacks can be used
 15931                              <1> 	;		   for dynamic and synchronized data refresh/transfer
 15932                              <1> 	;		   while cpu is in a static loop (without polling).
 15933                              <1> 	;		   Keyboard Int callback is not more useful because 
 15934                              <1> 	;		   already a manual check (a key is pressed or not)
 15935                              <1> 	;		   can be performed (via INT 32h, AH = 1) efficiently
 15936                              <1> 	;		   in a loop to prevent a locked infinitive loop.
 15937                              <1> 	;
 15938                              <1> 	;	    Disk IRQs (6,14,15) have been phohibited from ring 3 
 15939                              <1> 	;	    callback because, disk operations (file system services
 15940                              <1> 	;	    etc.) are independent from user program, for fast disk r/w.
 15941                              <1> 	;	    They are not more useful at ring 3 while they are in use
 15942                              <1> 	;	    by standard diskio functions which are mandatory part of 
 15943                              <1> 	;	    (monolithic) OS kernel and mainprog command interpreter.
 15944                              <1> 	;	    INT 33h diskio functions are enough for user level disk
 15945                              <1> 	;	    r/w.				
 15946                              <1> 	;
 15947                              <1> 	; TRDOS 386 - IRQ CALLBACK structures (parameters):
 15948                              <1> 	;	
 15949                              <1> 	;	   [u.irqlock] = 1 word, IRQ flags (0-15) that indicates
 15950                              <1> 	;			which IRQs are locked by (that) user.
 15951                              <1> 	;		        Lock and unlock (by user) will change
 15952                              <1> 	;			these flags or 'terminate process' (sysexit)
 15953                              <1> 	;			will clear these flags and unlock those IRQs.
 15954                              <1> 	;			               
 15955                              <1> 	;		   	Bit 0 is for IRQ 0 and Bit 15 is for IRQ 15
 15956                              <1> 	;
 15957                              <1> 	;	   IRQ(x).owner	 : 1 byte, user, [u.uno], 0 = free (unlocked)	
 15958                              <1> 	;
 15959                              <1> 	;	   IRQ(x).method : 1 byte for callback method & status
 15960                              <1> 	;			   0 = Signal Response Byte method
 15961                              <1> 	;			   1 = Callback service method
 15962                              <1> 	;			   >1 = invalid for current 'syscalback'.
 15963                              <1> 	;			or(+) 80h = IRQ is in use by system (ring 0)
 15964                              <1> 	;			            function (audio etc.) or
 15965                              <1> 	;			   	    a device driver.	   	
 15966                              <1> 	;			(system function will ignore the lock/owner)
 15967                              <1> 	;
 15968                              <1> 	;	   IRQ(x).srb	: 1 byte, Signal Return/Response byte value
 15969                              <1> 	;			  (a fixed value by user or a counter value
 15970                              <1> 	;			 from 0 to 255, which is increased by every
 15971                              <1> 	;			 interrupt just before putting it into 
 15972                              <1> 	;			 the Signal Response byte address
 15973                              <1> 	;			 (This is not used in callback serv method)
 15974                              <1> 	;	    	  
 15975                              <1> 	;	   IRQ(x).addr	: 1 dword
 15976                              <1> 	;			  Signal Response Byte address (physical)
 15977                              <1> 	;			  		-or-
 15978                              <1> 	;			  Callback service address (virtual)
 15979                              <1> 	;
 15980                              <1> 	;	   IRQ(x).dev	: 1 byte
 15981                              <1> 	;			  0 = Default device or kernel function
 15982                              <1> 	;			  		-or-
 15983                              <1> 	;			  1-255 = Assigned device driver number
 15984                              <1> 	;
 15985                              <1> 	;	   (x) = 3,4,5,7,9,10,11,12,13
 15986                              <1> 	;
 15987                              <1> 	;	
 15988                              <1> 	;	NOTE: If user's process/program calls the kernel (INT 40h)
 15989                              <1> 	;	      while it is already running in a (ring 3) callback
 15990                              <1> 	;	      service, kernel will force (convert) system call to
 15991                              <1> 	;	      'sysrele' (sys release). So, this feature provides
 15992                              <1> 	;	      easy and simple usage of callback services without
 15993                              <1> 	;	      falling into deepless <please 'callback me' then 
 15994                              <1> 	;	      let me 'callback you'> cycles! (User must return
 15995                              <1> 	;	      from callback service by using 'sysrele' system
 15996                              <1> 	;	      call, without a significant delay. Otherwise user
 15997                              <1> 	;	      process/program may be late to catch the next event
 15998                              <1> 	;	      within same callback purpose.	    		 	
 15999                              <1> 	;
 16000                              <1> 
 16001 000115FE 30C0                <1> 	xor	al, al ; the caller is 'syscalbac' sign/flag
 16002 00011600 E88C160000          <1>  	call	set_irq_callback_service
 16003                              <1> 	; 16/04/2017
 16004 00011605 A3[1C010300]        <1> 	mov	[u.r0], eax
 16005                              <1> 	;jnc	sysret
 16006                              <1> 	; 23/07/2022
 16007 0001160A 7205                <1> 	jc	short syscalbac_err
 16008 0001160C E90EB7FFFF          <1> 	jmp	sysret
 16009                              <1> syscalbac_err:
 16010 00011611 A3[84010300]        <1> 	mov	dword [u.error], eax
 16011 00011616 E9E4B6FFFF          <1> 	jmp	error
 16012                              <1> 
 16013                              <1> sysfpstat:
 16014                              <1> 	; 28/02/2017 - TRDOS 386 (TRDOS v2.0)
 16015                              <1> 	; (TRDOS 386 feature only!)
 16016                              <1> 	;
 16017                              <1> 	; Set or reset FPU registers save/restore option (for user)
 16018                              <1> 	;	       (during software task switching, wswap-rswap)
 16019                              <1> 	;
 16020                              <1> 	; INPUT ->
 16021                              <1> 	;	BL = 0 -> reset
 16022                              <1> 	;	BL = 1 -> set (FPU register will be saved and restored)
 16023                              <1> 	;	
 16024                              <1> 	; OUTPUT ->
 16025                              <1> 	;	cf = 0 -> no error, FPU is ready... 
 16026                              <1> 	;		  (EAX = 0)
 16027                              <1> 	;	Cf = 1 -> error, 80387 FPU is not ready !
 16028                              <1> 	;		  (EAX = 0FFFFFFFFh)
 16029                              <1> 
 16030 0001161B 31C0                <1> 	xor	eax, eax
 16031 0001161D 803D[40840100]00    <1> 	cmp	byte [fpready], 0
 16032 00011624 7613                <1> 	jna	short sysfpstat_err	
 16033                              <1> 
 16034 00011626 80E301              <1> 	and	bl, 1 ; use BIT 0 only !
 16035 00011629 881D[97010300]      <1> 	mov	[u.fpsave], bl
 16036 0001162F A3[1C010300]        <1> 	mov	[u.r0], eax ; 0
 16037 00011634 E9E6B6FFFF          <1> 	jmp	sysret	 	
 16038                              <1> 
 16039                              <1> sysfpstat_err:
 16040 00011639 48                  <1> 	dec 	eax ; 0FFFFFFFFh
 16041 0001163A A3[1C010300]        <1> 	mov 	[u.r0], eax ; -1
 16042 0001163F E9BBB6FFFF          <1> 	jmp 	error
 16043                              <1> 
 16044                              <1> sysdelete: ; Delete (Remove, Unlink) File
 16045                              <1> 	; 29/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16046                              <1> 	;	
 16047                              <1>         ; INPUT ->
 16048                              <1>         ;          EBX = File name (ASCIIZ string) address
 16049                              <1> 	; OUTPUT ->
 16050                              <1> 	;          cf = 0 -> eax = 0
 16051                              <1> 	;          cf = 1 -> Error code in AL
 16052                              <1> 	;
 16053                              <1> 	; Modified Registers: EAX (at the return of system call)
 16054                              <1> 	;   
 16055                              <1> 
 16056 00011644 89DE                <1> 	mov	esi, ebx
 16057                              <1> 	; file name is forced, change directory as temporary
 16058                              <1> 	;mov	ax, 1
 16059                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 16060                              <1> 	;call	set_working_path 
 16061 00011646 E81E0B0000          <1> 	call	set_working_path_x
 16062 0001164B 731D                <1> 	jnc	short sysdelete_1
 16063                              <1> 
 16064 0001164D 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 16065 0001164F 7505                <1> 	jnz	short sysdelete_err
 16066                              <1> 	; eax = 0
 16067                              <1> sysdelete_path_err:
 16068 00011651 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'bad path name !'
 16069                              <1> sysdelete_err:
 16070 00011656 A3[1C010300]        <1> 	mov	[u.r0], eax
 16071 0001165B A3[84010300]        <1> 	mov	[u.error], eax
 16072 00011660 E8D90B0000          <1> 	call 	reset_working_path
 16073 00011665 E995B6FFFF          <1> 	jmp	error
 16074                              <1> sysdelete_1:
 16075                              <1> 	;mov	esi, FindFile_Name
 16076 0001166A 66B80018            <1> 	mov	ax, 1800h ; Only files
 16077 0001166E E8CD73FFFF          <1> 	call	find_first_file
 16078 00011673 72E1                <1> 	jc	short sysdelete_err
 16079                              <1> sysdelete_2:
 16080                              <1> 	; check file attributes
 16081                              <1> 
 16082                              <1> 	;test	bl, 17 ; system, hidden, readonly, directory
 16083 00011675 F6C307              <1>         test	bl, 7 ; system, hidden, readonly 
 16084 00011678 7407                <1>         jz	short sysdelete_3
 16085                              <1> 
 16086 0001167A B80B000000          <1>         mov	eax, ERR_FILE_ACCESS ; 11 = 'permission denied !'
 16087 0001167F EBD5                <1>         jmp	short sysdelete_err
 16088                              <1> sysdelete_3:
 16089 00011681 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 16090 00011684 7407                <1> 	jz	short sysdelete_4
 16091 00011686 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 26 = 'invalid file name !'
 16092 0001168B EBC9                <1>         jmp	short sysdelete_err
 16093                              <1> sysdelete_4:
 16094                              <1> 	;mov	bh, [LongName_EntryLength]
 16095 0001168D 883D[B2810100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
 16096                              <1> 	; edi = Directory Entry Offset (DirBuff)
 16097                              <1> 	; esi = Directory Entry (FFF Structure)
 16098 00011693 E8D99BFFFF          <1> 	call	remove_file
 16099 00011698 72BC                <1> 	jc	short sysdelete_err
 16100                              <1> sysrmdir_5:
 16101 0001169A 31C0                <1> 	xor	eax, eax ; 0
 16102 0001169C A3[1C010300]        <1> 	mov	[u.r0], eax
 16103                              <1> 	;mov	[u.error], eax
 16104 000116A1 E8980B0000          <1> 	call 	reset_working_path
 16105 000116A6 E974B6FFFF          <1> 	jmp	sysret
 16106                              <1> 
 16107                              <1> 
 16108                              <1> sysrmdir: ; Remove (Unlink) Directory
 16109                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 16110                              <1> 	; 19/01/2021
 16111                              <1> 	; 29/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16112                              <1> 	;	
 16113                              <1>         ; INPUT ->
 16114                              <1>         ;          EBX = Pointer to directory name
 16115                              <1> 	; OUTPUT ->
 16116                              <1> 	;          cf = 0 -> eax = 0
 16117                              <1> 	;          cf = 1 -> Error code in AL
 16118                              <1> 	;
 16119                              <1> 	; Modified Registers: EAX (at the return of system call)
 16120                              <1> 	;  
 16121                              <1> 
 16122                              <1> 	; 19/01/2021
 16123 000116AB 803D[6E010300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 16124 000116B2 7614                <1> 	jna	short sysrmdir_0
 16125                              <1> 
 16126                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 16127 000116B4 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; ERR_NOT_SUPERUSER
 16128 000116B9 A3[1C010300]        <1> 	mov	[u.r0], eax
 16129 000116BE A3[84010300]        <1> 	mov	[u.error], eax
 16130 000116C3 E937B6FFFF          <1> 	jmp	error
 16131                              <1> 
 16132                              <1> sysrmdir_0:
 16133 000116C8 89DE                <1> 	mov	esi, ebx
 16134                              <1> 	; file name is forced, change directory as temporary
 16135                              <1> 	;mov	ax, 1
 16136                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 16137                              <1> 	;call	set_working_path 
 16138 000116CA E89A0A0000          <1> 	call	set_working_path_x
 16139 000116CF 7308                <1> 	jnc	short sysrmdir_1
 16140                              <1> 
 16141 000116D1 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 16142 000116D3 7513                <1> 	jnz	short sysrmdir_err
 16143                              <1> 	; eax = 0
 16144                              <1> sysrmdir_not_found:
 16145                              <1> 	;mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 16146                              <1> 	; 23/07/2022
 16147 000116D5 B00C                <1> 	mov	al, ERR_DIR_NOT_FOUND
 16148 000116D7 EB0F                <1> 	jmp	short sysrmdir_err
 16149                              <1> ;sysrmdir_err:
 16150                              <1> ;	mov	[u.r0], eax
 16151                              <1> ;	mov	[u.error], eax
 16152                              <1> ;	call 	reset_working_path
 16153                              <1> ;	jmp	error
 16154                              <1> sysrmdir_1:
 16155                              <1> 	;mov	esi, FindFile_Name
 16156 000116D9 66B81008            <1> 	mov	ax, 0810h ; Only directories
 16157 000116DD E85E73FFFF          <1> 	call	find_first_file
 16158 000116E2 7318                <1> 	jnc	short sysrmdir_2
 16159                              <1> 
 16160                              <1> 	; eax = 2 (File not found !)
 16161 000116E4 3C02                <1> 	cmp	al, 2 ; ERR_NOT_FOUND
 16162 000116E6 74ED                <1> 	je	short sysrmdir_not_found
 16163                              <1> 	;jmp	short sysrmdir_err
 16164                              <1> 	; 23/07/2022
 16165                              <1> sysrmdir_err:
 16166 000116E8 A3[1C010300]        <1> 	mov	[u.r0], eax
 16167 000116ED A3[84010300]        <1> 	mov	[u.error], eax
 16168                              <1> sysrmdir_8:	; 23/07/2022
 16169 000116F2 E8470B0000          <1> 	call 	reset_working_path
 16170 000116F7 E903B6FFFF          <1> 	jmp	error
 16171                              <1> sysrmdir_2:
 16172                              <1> 	; check directory attributes
 16173                              <1> 
 16174 000116FC F6C307              <1>         test	bl, 7 ; system, hidden, readonly 
 16175 000116FF 7407                <1>         jz	short sysrmdir_3
 16176                              <1> 
 16177 00011701 B80B000000          <1>         mov	eax, ERR_DIR_ACCESS ; 11 = 'permission denied !'
 16178 00011706 EBE0                <1>         jmp	short sysrmdir_err
 16179                              <1> sysrmdir_3:
 16180 00011708 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 16181 0001170B 7407                <1> 	jz	short sysrmdir_4
 16182                              <1> 	;mov	eax, ERR_NOT_DIR ; 'not a valid directory !'
 16183 0001170D B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'bad path name !'
 16184 00011712 EBD4                <1>         jmp	short sysrmdir_err
 16185                              <1> sysrmdir_4:
 16186                              <1> 	;mov	bh, [LongName_EntryLength]
 16187 00011714 883D[B2810100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
 16188                              <1> 	; edi = Directory Entry Offset (DirBuff)
 16189                              <1> 	; esi = Directory Entry (FFF Structure)
 16190 0001171A E8C179FFFF          <1> 	call	delete_sub_directory
 16191                              <1> 	;jnc	sysrmdir_5
 16192                              <1> 	; 23/07/2022
 16193 0001171F 7205                <1> 	jc	short sysrmdir_6
 16194 00011721 E974FFFFFF          <1> 	jmp	sysrmdir_5
 16195                              <1> 
 16196                              <1> ;	jc	short sysrmdir_6
 16197                              <1> ;
 16198                              <1> ;	xor	eax, eax ; 0
 16199                              <1> ;sysrmdir_5:
 16200                              <1> ;	mov	[u.r0], eax
 16201                              <1> ;	;mov	[u.error], eax
 16202                              <1> ;	call 	reset_working_path
 16203                              <1> ;	jmp	sysret
 16204                              <1> 
 16205                              <1> sysrmdir_6:
 16206 00011726 A3[1C010300]        <1> 	mov	[u.r0], eax
 16207 0001172B A3[84010300]        <1> 	mov	[u.error], eax
 16208                              <1> 
 16209 00011730 09C0                <1> 	or	eax, eax ; EAX = 0 -> Directory not empty!
 16210 00011732 7414                <1> 	jz	short sysrmdir_9
 16211                              <1> 
 16212                              <1> 	; EAX > 0 -> Error code in AL (or AX or EAX)
 16213                              <1> 
 16214 00011734 833D[667F0100]01    <1> 	cmp	dword [FAT_ClusterCounter], 1
 16215 0001173B 72B5                <1> 	jb	short sysrmdir_8
 16216                              <1> sysrmdir_7:
 16217                              <1> 	; ESI = Logical DOS Drive Description Table address	
 16218 0001173D 66BB00FF            <1> 	mov	bx, 0FF00h ; BH = FFh -> use ESI for Drive parameters
 16219                              <1> 	           ; BL = 0 -> Recalculate free cluster count
 16220 00011741 E874B0FFFF          <1> 	call	calculate_fat_freespace	
 16221                              <1> 	; 23/07/2022
 16222 00011746 EBAA                <1> 	jmp	short sysrmdir_8
 16223                              <1> ;sysrmdir_8:
 16224                              <1> ;	call 	reset_working_path
 16225                              <1> ;	jmp	error
 16226                              <1> 
 16227                              <1> sysrmdir_9:
 16228 00011748 A1[667F0100]        <1> 	mov	eax, [FAT_ClusterCounter]
 16229 0001174D 09C0                <1> 	or	eax, eax ; 0 ?
 16230                              <1> 	;jz	short sysrmdir_err
 16231                              <1> 	; 23/07/2022
 16232 0001174F 74A1                <1> 	jz	short sysrmdir_8
 16233                              <1> 
 16234                              <1> 	; ESI = Logical DOS Drive Description Table address	
 16235 00011751 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> use ESI for Drive parameters
 16236                              <1> 	           ; BL = 1 -> add free clusters
 16237 00011755 E860B0FFFF          <1> 	call	calculate_fat_freespace
 16238 0001175A 09C9                <1> 	or	ecx, ecx
 16239 0001175C 7494                <1>         jz	short sysrmdir_8 ; ecx = 0 -> OK
 16240                              <1> 	; ecx > 0 -> Error (Recalculation is needed)
 16241 0001175E EBDD                <1> 	jmp	short sysrmdir_7
 16242                              <1> 
 16243                              <1> 
 16244                              <1> syschdir: ; Change Current (Working) Drive & Directory (for user)
 16245                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16246                              <1> 	;	
 16247                              <1>         ; INPUT ->
 16248                              <1>         ;          EBX = Directory name (ASCIIZ string) address
 16249                              <1> 	; OUTPUT ->
 16250                              <1> 	;          cf = 0 -> eax = 0
 16251                              <1> 	;          cf = 1 -> Error code in AL
 16252                              <1> 	;
 16253                              <1> 	; Modified Registers: EAX (at the return of system call)
 16254                              <1> 	;
 16255                              <1> 	; NOTE: If drive name is not included, only the working
 16256                              <1> 	; directory (for user, not for drive/OS) will be chanded.
 16257                              <1> 	; If there is a drive name (as A:, B:, C:, D: etc.)
 16258                              <1> 	; at the beginning of the ASCIIZ (directory) string,
 16259                              <1> 	; working drive and working directory (for user) 
 16260                              <1> 	; will be changed together.
 16261                              <1> 	; (When the program is terminated, MainProg -internal 
 16262                              <1> 	; shell- will reset working directory to the previous
 16263                              <1> 	; -current- logical drive's current directory again.) 	
 16264                              <1>   
 16265 00011760 89DE                <1> 	mov	esi, ebx
 16266                              <1> 	; file name is not forced, change directory as temporary
 16267 00011762 31C0                <1> 	xor	eax, eax
 16268                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 16269                              <1> 	;call	set_working_path 
 16270 00011764 E8040A0000          <1> 	call	set_working_path_xx
 16271 00011769 731D                <1> 	jnc	short syschdir_ok
 16272 0001176B 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 16273 0001176D 7505                <1> 	jnz	short syschdir_err
 16274                              <1> 	; eax = 0
 16275                              <1> syschdir_not_found:
 16276 0001176F B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 16277                              <1> syschdir_err:
 16278 00011774 A3[1C010300]        <1> 	mov	[u.r0], eax
 16279 00011779 A3[84010300]        <1> 	mov	[u.error], eax
 16280 0001177E E8BB0A0000          <1> 	call 	reset_working_path
 16281 00011783 E977B5FFFF          <1> 	jmp	error
 16282                              <1> syschdir_ok:
 16283 00011788 31C0                <1> 	xor	eax, eax ; 0
 16284 0001178A A3[1C010300]        <1> 	mov	[u.r0], eax
 16285                              <1> 	;mov	[u.error], eax
 16286 0001178F E98BB5FFFF          <1> 	jmp	sysret
 16287                              <1> 
 16288                              <1> 
 16289                              <1> syschmod: ; Get & Change File (or Directory) Attributes
 16290                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 16291                              <1> 	; 19/01/2021
 16292                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16293                              <1> 	;	
 16294                              <1>         ; INPUT ->
 16295                              <1>         ;          EBX = File/Directory (ASCIIZ) name address
 16296                              <1> 	;	    CL = New attributes (if CL < 40h)
 16297                              <1> 	;	    CL >= 40h -> Get File Attributes		
 16298                              <1> 	; OUTPUT ->
 16299                              <1> 	;          cf = 0 -> EAX = File attributes (in AL)
 16300                              <1> 	;          cf = 1 -> Error code in AL
 16301                              <1> 	;
 16302                              <1> 	; Modified Registers: EAX (at the return of system call)
 16303                              <1> 	;  
 16304                              <1> 	; MSDOS File Attributes:    (bit value of attrib byte)
 16305                              <1> 	;	ATTR_READ_ONLY	=	01h  (bit 0, 'R')
 16306                              <1> 	;	ATTR_HIDDEN	=	02h  (bit 1, 'H')
 16307                              <1> 	;	ATTR_SYSTEM	=	04h  (bit 2, 'S')
 16308                              <1> 	;	ATTR_VOLUME_ID	=	08h  (bit 3)
 16309                              <1> 	;	ATTR_DIRECTORY	=	10h  (bit 4)
 16310                              <1> 	;	ATTR_ARCHIVE	=	20h  (bit 5, 'A')
 16311                              <1> 	;	ATTR_LONG_NAME	=	ATTR_READONLY |
 16312                              <1> 	;				ATTR_HIDDEN |
 16313                              <1> 	;				ATTR_SYSTEM |
 16314                              <1> 	;				ATTR_VOLUME_ID				
 16315                              <1> 	;	The upper two bits of attributes must be 0.
 16316                              <1> 
 16317                              <1> 	; Note:	* If ATTR_DIRECTORY is set, only directory names
 16318                              <1> 	;	  will be searched (and S,H,R,A attributeds of 
 16319                              <1> 	;	  the directory will be changed.)
 16320                              <1> 	;	* If ATTR_VOLUME_ID is set, 'syschmod' system call
 16321                              <1> 	;	  will return with 'permission denied' error.
 16322                              <1> 	;	* If ATTR_DIRECTORY is not set, only file names
 16323                              <1> 	;	  will be searched (and S,H,R,A attributes of the
 16324                              <1> 	;	  file will be changed.)
 16325                              <1> 	;
 16326                              <1> 	; (Ony Super User can change S,H,R attributes.) 
 16327                              <1> 
 16328 00011794 80F940              <1> 	cmp	cl, 40h	
 16329 00011797 7327                <1> 	jnb	short syschmod_0
 16330                              <1> 
 16331 00011799 F6C108              <1> 	test	cl, 08h ; ATTR_VOLUME_ID
 16332 0001179C 750E                <1> 	jnz	short syschmod_perm_err
 16333                              <1> 
 16334                              <1> 	; 19/01/2021
 16335 0001179E 803D[6E010300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 16336 000117A5 7619                <1> 	jna	short syschmod_0
 16337                              <1> 
 16338                              <1> 	; Not super user..
 16339 000117A7 F6C107              <1> 	test	cl, 07h	; S,H,R attributes
 16340 000117AA 7414                <1> 	jz	short syschmod_0
 16341                              <1> 
 16342                              <1> syschmod_perm_err:
 16343                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 16344 000117AC B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; 'permission denied !'
 16345 000117B1 A3[1C010300]        <1> 	mov	[u.r0], eax
 16346 000117B6 A3[84010300]        <1> 	mov	[u.error], eax
 16347 000117BB E93FB5FFFF          <1> 	jmp	error
 16348                              <1> 
 16349                              <1> syschmod_0:
 16350 000117C0 880D[00820100]      <1> 	mov	[Attributes], cl
 16351 000117C6 89DE                <1> 	mov	esi, ebx
 16352                              <1> 	; file name is forced, change directory as temporary
 16353                              <1> 	;mov	ax, 1
 16354                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 16355                              <1> 	;call	set_working_path 
 16356 000117C8 E89C090000          <1> 	call	set_working_path_x
 16357 000117CD 7308                <1> 	jnc	short syschmod_1
 16358 000117CF 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 16359 000117D1 751E                <1> 	jnz	short syschmod_err
 16360                              <1> 	; eax = 0
 16361                              <1> syschmod_path_not_found:
 16362                              <1> 	;mov	eax, ERR_INV_PATH_NAME ; 'Bad path name !'
 16363                              <1> 	; 23/07/2022
 16364 000117D3 B013                <1> 	mov	al, ERR_INV_PATH_NAME
 16365                              <1> ;syschmod_err:
 16366                              <1> 	;mov	[u.r0], eax
 16367                              <1> 	;mov	[u.error], eax
 16368                              <1> 	;call 	reset_working_path
 16369                              <1> 	;jmp	error
 16370                              <1> 	; 23/07/2022
 16371 000117D5 EB1A                <1> 	jmp	short syschmod_err
 16372                              <1> syschmod_1:
 16373 000117D7 B008                <1> 	mov	al, 08h ; Except volume labels (& long names)
 16374 000117D9 A0[00820100]        <1> 	mov	al, [Attributes]
 16375 000117DE 2410                <1> 	and	al, 10h ;
 16376                              <1> 	;mov	esi, FindFile_Name
 16377                              <1> 	;mov	ax, 1800h ; Only files
 16378                              <1> 	;mov	ax, 0810h ; Only directories
 16379 000117E0 E85B72FFFF          <1> 	call	find_first_file
 16380                              <1> 	;jnc	short syschmod_2
 16381 000117E5 720A                <1> 	jc	short syschmod_err
 16382                              <1> 
 16383                              <1> 	;; eax = 2 (File not found !)
 16384                              <1> 	;cmp	al, 2 ; ERR_NOT_FOUND
 16385                              <1> 	;jne	short syschmod_err
 16386                              <1> 
 16387                              <1> 	;and	byte [Attributes], 10h
 16388                              <1> 	;jz	short syschmod_err
 16389                              <1> 
 16390                              <1> 	;; Directory not found !
 16391                              <1> 	;mov	al, 3 ; ERR_PATH_NOT_FOUND
 16392                              <1> 	;jmp	short syschmod_err
 16393                              <1> 
 16394                              <1> syschmod_2:
 16395 000117E7 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 16396 000117EA 7419                <1> 	jz	short syschmod_3
 16397 000117EC B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 'invalid file name !'
 16398                              <1>         ;jmp	short syschmod_err
 16399                              <1> syschmod_err:
 16400 000117F1 A3[1C010300]        <1> 	mov	[u.r0], eax
 16401 000117F6 A3[84010300]        <1> 	mov	[u.error], eax
 16402 000117FB E83E0A0000          <1> 	call 	reset_working_path
 16403 00011800 E9FAB4FFFF          <1> 	jmp	error
 16404                              <1> syschmod_3:
 16405                              <1> 	; EDI = Directory buffer entry offset/address
 16406                              <1> 	; BL = File (or Directory) Attributes 
 16407                              <1> 	; mov	bl, [EDI+0Bh]
 16408                              <1> 
 16409                              <1> 	; check directory attributes
 16410 00011805 8A3D[00820100]      <1> 	mov	bh, [Attributes] ; new attributes
 16411 0001180B 80FF40              <1> 	cmp	bh, 40h  ;>=40 -> get file/directory attributes
 16412 0001180E 732D                <1> 	jnb	short syschmod_6
 16413                              <1> 
 16414                              <1> 	; set file/directory attributes
 16415 00011810 F6C307              <1> 	test	bl, 7 ; system, hidden, readonly 
 16416 00011813 7409                <1>         jz	short syschmod_4
 16417                              <1> 
 16418                              <1> 	; 19/01/2021
 16419 00011815 803D[6E010300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 16420 0001181C 778E                <1> 	ja	short syschmod_perm_err
 16421                              <1> syschmod_4:
 16422 0001181E 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
 16423 00011824 7424                <1> 	je	short syschmod_7
 16424                              <1> 
 16425 00011826 887F0B              <1> 	mov	[edi+0Bh], bh    ; Attributes (New!)
 16426                              <1> 
 16427 00011829 C605[717F0100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; modified sign
 16428                              <1> 					    ; to force write	
 16429 00011830 E80B97FFFF          <1> 	call 	save_directory_buffer
 16430 00011835 72BA                <1> 	jc	short syschmod_err
 16431                              <1> 
 16432                              <1> syschmod_5:
 16433 00011837 8A1D[00820100]      <1> 	mov	bl, [Attributes]
 16434                              <1> syschmod_6:
 16435 0001183D 0FB6C3              <1> 	movzx	eax, bl
 16436 00011840 A3[1C010300]        <1> 	mov	[u.r0], eax
 16437                              <1> 	;mov	dword [u.error], 0
 16438 00011845 E9D5B4FFFF          <1> 	jmp	sysret
 16439                              <1> 
 16440                              <1> syschmod_7:
 16441 0001184A 29C0                <1> 	sub	eax, eax
 16442 0001184C 8A25[6F7F0100]      <1>         mov     ah, [DirBuff_DRV]
 16443 00011852 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 16444 00011857 01C6                <1>         add     esi, eax
 16445 00011859 807E04A1            <1>         cmp     byte [esi+LD_FSType], 0A1h
 16446 0001185D 7304                <1> 	jnc	short syschmod_8
 16447 0001185F B01D                <1> 	mov	al, ERR_INV_DATA ; 29 = Invalid Data
 16448 00011861 EB8E                <1> 	jmp	short syschmod_err
 16449                              <1> 
 16450                              <1> syschmod_8:
 16451                              <1> 	; BH = New MS-DOS File Attributes
 16452 00011863 88F8                <1> 	mov	al, bh ; File/Directory Attributes
 16453 00011865 30E4                <1> 	xor	ah, ah ; Attributes in MS-DOS format sign	  
 16454 00011867 E8B682FFFF          <1> 	call	change_fs_file_attributes
 16455                              <1> 	;jc	syschmod_err
 16456                              <1> 	;jmp	short syschmod_5
 16457                              <1> 	; 23/07/2022
 16458 0001186C 73C9                <1> 	jnc	short syschmod_5
 16459 0001186E EB81                <1> 	jmp	short syschmod_err
 16460                              <1> 
 16461                              <1> 
 16462                              <1> sysdrive: ; Get/Set Current (Working) Drive (for user)
 16463                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16464                              <1> 	;	
 16465                              <1>         ; INPUT ->
 16466                              <1>         ;          BL = Logical DOS Drive number (0=A: ... 2=C:)
 16467                              <1> 	;	   If BL = 0FFh -> Get Current Drive 	
 16468                              <1> 	; OUTPUT ->
 16469                              <1> 	;          cf = 0 -> 
 16470                              <1> 	;		   AL = Current Drive number	
 16471                              <1> 	;		   AH = The Last Logical DOS Drive no.
 16472                              <1> 	;          cf = 1 -> Error code in AL
 16473                              <1> 	;
 16474                              <1> 	; Modified Registers: EAX (at the return of system call)
 16475                              <1> 	;
 16476                              <1> 	; NOTE: If the requested logical dos drive is ready, 
 16477                              <1> 	;	it's current current directory will be the user's
 16478                              <1> 	;	(program's) current directory.
 16479                              <1> 	;	(When the program is terminated, MainProg -internal 
 16480                              <1> 	;	shell- will reset the previous -current- logical drive
 16481                              <1> 	;       as current drive again).	
 16482                              <1>   
 16483 00011870 80FBFF              <1> 	cmp	bl, 0FFh
 16484 00011873 7435                <1> 	je	short sysdrive_ok
 16485 00011875 3A1D[91300100]      <1> 	cmp	bl, [Last_DOS_DiskNo]
 16486 0001187B 771E                <1> 	ja	short sysdrive_err	
 16487                              <1> 
 16488                              <1> 	; Save current drive and reset mode
 16489                              <1> 	; for 'reset_working_path' procedure (for MainProg)
 16490 0001187D 30C0                <1> 	xor	al, al
 16491 0001187F 66A3[3C840100]      <1> 	mov	[SWP_Mode], ax ; ah = 0
 16492 00011885 A0[4A780100]        <1> 	mov	al, [Current_Drv]
 16493 0001188A FEC4                <1> 	inc	ah ; mov ah, 1
 16494 0001188C 66A3[3E840100]      <1> 	mov	[SWP_DRV], ax 
 16495                              <1> 
 16496 00011892 88DA                <1> 	mov	dl, bl
 16497 00011894 E8F95EFFFF          <1> 	call	change_current_drive
 16498 00011899 730F                <1> 	jnc	short sysdrive_ok
 16499                              <1> sysdrive_err:
 16500 0001189B C705[1C010300]0F00- <1> 	mov	dword [u.r0], ERR_DRV_NOT_RDY ; 'drive not ready !'
 16500 000118A3 0000                <1>
 16501 000118A5 E955B4FFFF          <1> 	jmp	error
 16502                              <1> sysdrive_ok:
 16503 000118AA A0[4A780100]        <1> 	mov	al, [Current_Drv]
 16504 000118AF 8A25[91300100]      <1> 	mov	ah, [Last_DOS_DiskNo]
 16505 000118B5 A3[1C010300]        <1> 	mov	[u.r0], eax
 16506 000118BA E960B4FFFF          <1> 	jmp	sysret
 16507                              <1> 
 16508                              <1> 
 16509                              <1> sysdir: ; Get Current (Working) Drive & Directory (for user)
 16510                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16511                              <1> 	;	
 16512                              <1>         ; INPUT ->
 16513                              <1>         ;          EBX = Current directory name buffer address
 16514                              <1> 	;		(Buffer length = 92 bytes)
 16515                              <1> 	; OUTPUT ->
 16516                              <1> 	;          AL = Current drive (0=A: .. 2=C:)
 16517                              <1> 	;	   If CF = 1 -> AL = error code
 16518                              <1> 	;
 16519                              <1> 	; Modified Registers: EAX (at the return of system call)
 16520                              <1> 	;
 16521                              <1> 	; Note: Required directory name buffer length may be 
 16522                              <1> 	;	<= 92 bytes for current TRDOS 386 version.
 16523                              <1> 	;	(7*12 name chars + 7 slash + 0)
 16524                              <1> 
 16525 000118BF 89E5                <1> 	mov	ebp, esp
 16526 000118C1 83EC60              <1> 	sub	esp, 96
 16527 000118C4 53                  <1> 	push	ebx ; User's buffer address
 16528 000118C5 30D2                <1> 	xor	dl, dl ; 0 = current drive
 16529 000118C7 E8F28BFFFF          <1>   	call	get_current_directory
 16530 000118CC 72CD                <1> 	jc	short sysdrive_err ; 'drive not ready !' error
 16531 000118CE 89E6                <1> 	mov	esi, esp ; System's buffer address
 16532 000118D0 5F                  <1> 	pop	edi  ; User's buffer address
 16533                              <1> 	; ecx = transfer (byte) count (<=92)
 16534 000118D1 E883F4FFFF          <1> 	call	transfer_to_user_buffer
 16535 000118D6 89EC                <1> 	mov	esp, ebp
 16536 000118D8 730F                <1> 	jnc	short sysdir_ok
 16537                              <1> sysdir_err:
 16538 000118DA C705[1C010300]2E00- <1> 	mov	dword [u.r0], ERR_BUFFER  ; 'buffer error !'
 16538 000118E2 0000                <1>
 16539 000118E4 E916B4FFFF          <1> 	jmp	error
 16540                              <1> sysdir_ok:	
 16541 000118E9 8A0D[4A780100]      <1> 	mov	cl, [Current_Drv]
 16542 000118EF 890D[1C010300]      <1> 	mov	[u.r0], ecx
 16543 000118F5 E925B4FFFF          <1> 	jmp	sysret
 16544                              <1> 
 16545                              <1> 
 16546                              <1> sysldrvt: ; Get copy of Logical DOS Drive Description Table
 16547                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16548                              <1> 	;	
 16549                              <1>         ; INPUT ->
 16550                              <1> 	;	    BL = Logical DOS drive number (zero based)	
 16551                              <1>         ;          ECX = Logical DOS drv desc table buffer addr
 16552                              <1> 	;		(Buffer length = 256 bytes)
 16553                              <1> 	; OUTPUT ->
 16554                              <1> 	;          cf = 0 -> 
 16555                              <1> 	;		   AL = Current Drive number	
 16556                              <1> 	;		   AH = The Last Logical DOS Drive no.
 16557                              <1> 	;          cf = 1 -> Error code in AL
 16558                              <1> 	;		   AH = The Last Logical DOS Drive no.
 16559                              <1> 	;
 16560                              <1> 	; Modified Registers: EAX (at the return of system call)
 16561                              <1> 	;
 16562                              <1> 	; Note: Required description table buffer length is
 16563                              <1> 	;	256 bytes for current TRDOS 386 version.
 16564                              <1> 	
 16565 000118FA 89CF                <1> 	mov	edi, ecx ; Destination address (user space)
 16566 000118FC 88DC                <1> 	mov	ah, bl
 16567 000118FE 30C0                <1> 	xor	al, al
 16568 00011900 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 16569 00011905 01C6                <1> 	add	esi, eax ; Source address (system space)	 
 16570 00011907 B900010000          <1> 	mov	ecx, 256 ; Byte count 
 16571                              <1> 			 ; Logical Dos Drv Desc Table size
 16572 0001190C E848F4FFFF          <1> 	call	transfer_to_user_buffer
 16573 00011911 72C7                <1> 	jc	short sysdir_err
 16574 00011913 8A2D[91300100]      <1> 	mov	ch, [Last_DOS_DiskNo]
 16575 00011919 EBCE                <1> 	jmp	short sysdir_ok
 16576                              <1> 
 16577                              <1> 
 16578                              <1> systime: ; Get System Date&Time
 16579                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16580                              <1> 	;	
 16581                              <1>         ; INPUT -> BL =
 16582                              <1> 	;	    0 = Get Date&Time in Unix/Epoch format
 16583                              <1> 	;	    1 = Get Time in MSDOS format
 16584                              <1> 	;	    2 = Get Date in MSDOS format
 16585                              <1> 	;	    3 = Get Date&Time in MSDOS format
 16586                              <1> 	;	    4 & other values =
 16587                              <1> 	;		System timer ticks will be returned
 16588                              <1> 	;		in EAX and Carry Flag will be set.
 16589                              <1> 	;		(CF will not be set if BL = 4)	 	
 16590                              <1> 	; OUTPUT ->
 16591                              <1> 	;	For BL input = 3
 16592                              <1> 	;          EAX = Current Time (RTC)
 16593                              <1> 	;		AL = Second (DL in MSDOS)
 16594                              <1> 	;		AH = Minute (CL in MSDOS)
 16595                              <1> 	;	   	HW of EAX = Hour (CH in MSDOS)	
 16596                              <1> 	;	   EDX = Current System Date (RTC)
 16597                              <1> 	;		DL = Day (DL in MSDOS)
 16598                              <1> 	;		DH = Month (DH in MSDOS)
 16599                              <1> 	;		HW of EDX = Year (CX in MSDOS)	
 16600                              <1> 	;
 16601                              <1> 	;	For BL input = 2
 16602                              <1> 	;	   EAX = Current System Date (RTC)
 16603                              <1> 	;		DL = Day (DL in MSDOS)
 16604                              <1> 	;		DH = Month (DH in MSDOS)
 16605                              <1> 	;		HW of EDX = Year (CX in MSDOS)
 16606                              <1> 	;
 16607                              <1> 	;	For BL input = 1
 16608                              <1> 	;          EAX = Current Time (RTC)
 16609                              <1> 	;		AL = Second (DL in MSDOS)
 16610                              <1> 	;		AH = Minute (CL in MSDOS)
 16611                              <1> 	;	   	HW of EAX = Hour (CH in MSDOS)	
 16612                              <1> 	;
 16613                              <1> 	;	For BL input = 0
 16614                              <1> 	;          EAX = Unix (Epoch) Time Ticks/Seconds
 16615                              <1> 	;
 16616                              <1> 	;	For BL input  = 4
 16617                              <1> 	;	   EAX = System timer ticks
 16618                              <1> 	;
 16619                              <1> 	;	If CF = 1 (for other values of BL input)
 16620                              <1> 	;	   EAX = System timer ticks (no error code!)	
 16621                              <1> 	;		
 16622                              <1> 	; Modified Registers: EAX, (EDX)
 16623                              <1> 	;		 (at the return of system call)
 16624                              <1> 	;
 16625                              <1> 
 16626 0001191B 20DB                <1> 	and	bl, bl
 16627 0001191D 750F                <1> 	jnz	short systime_1
 16628 0001191F E88B54FFFF          <1> 	call	epoch
 16629                              <1> systime_0:
 16630 00011924 A3[1C010300]        <1> 	mov	[u.r0], eax
 16631 00011929 E9F1B3FFFF          <1> 	jmp	sysret
 16632                              <1> systime_1:
 16633 0001192E 80FB04              <1> 	cmp	bl, 4
 16634 00011931 7211                <1> 	jb	short systime_2
 16635 00011933 A1[08780100]        <1> 	mov	eax, [TIMER_LH] ; 18.2 Hz timer ticks
 16636                              <1> 				; Note: [TIMER_LH] may be set
 16637                              <1> 				; to wrong timer value due to
 16638                              <1> 				; program functions.
 16639                              <1> 				; (This value must not be
 16640                              <1> 				; accepted as [TIMER_LH]/18.2
 16641                              <1> 				; seconds since the midnight.)
 16642 00011938 76EA                <1> 	jna	short systime_0
 16643 0001193A A3[1C010300]        <1> 	mov	[u.r0], eax	
 16644 0001193F E9BBB3FFFF          <1> 	jmp	error ; cf = 1 & [u.r0] = eax = timer ticks 
 16645                              <1> 
 16646                              <1> systime_2:
 16647                              <1> 	;push	ebx
 16648 00011944 E8E053FFFF          <1> 	call	get_rtc_date_time
 16649                              <1> 	;pop	ebx
 16650 00011949 F6C301              <1> 	test	bl, 1
 16651 0001194C 7429                <1> 	jz	short systime_4
 16652 0001194E 30E4                <1> 	xor	ah, ah
 16653 00011950 A0[56740100]        <1> 	mov	al, [hour]
 16654 00011955 88C2                <1> 	mov	dl, al
 16655 00011957 C1E010              <1> 	shl	eax, 16
 16656 0001195A A0[5A740100]        <1> 	mov	al, [second]
 16657 0001195F 8A25[58740100]      <1> 	mov	ah, [minute]
 16658 00011965 F6C302              <1> 	test	bl, 2
 16659 00011968 74BA                <1> 	jz	short systime_0
 16660                              <1> 	; Check time & date match risk 
 16661                              <1> 	; (23:59:59 may cause to wrong
 16662                              <1> 	; date -new day with previous date-...)
 16663 0001196A 80FA17              <1> 	cmp	dl, 23
 16664 0001196D 7206                <1> 	jb	short systime_3
 16665 0001196F 663D3B3B            <1> 	cmp	ax, (59*256)+59 ; if hour is 23:59:59
 16666 00011973 73CF                <1> 	jnb	short systime_2 ; wait for 1 second
 16667                              <1> systime_3:
 16668                              <1> 	; eax = time
 16669 00011975 89C6                <1> 	mov	esi, eax
 16670                              <1> systime_4:	
 16671 00011977 66A1[50740100]      <1> 	mov	ax, [year]
 16672 0001197D C1E010              <1> 	shl	eax, 16
 16673 00011980 A0[54740100]        <1> 	mov	al, [day]
 16674 00011985 8A25[52740100]      <1> 	mov	ah, [month]
 16675                              <1> 	; eax = date
 16676 0001198B 80E301              <1> 	and	bl, 1
 16677 0001198E 7494                <1> 	jz	short systime_0
 16678 00011990 96                  <1> 	xchg	esi, eax
 16679                              <1> 	; eax = time, esi = date
 16680 00011991 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; EBP points to user's registers
 16681                              <1> 	; (user) edx <-- (system) esi
 16682 00011997 897514              <1> 	mov	[ebp+20], esi ; return to user with EDX value 
 16683 0001199A EB88                <1> 	jmp	short systime_0
 16684                              <1> 
 16685                              <1> 
 16686                              <1> sysstime: ; Set System Date&Time
 16687                              <1> 	; 31/12/2017
 16688                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16689                              <1> 	;	
 16690                              <1>         ; INPUT -> BL =
 16691                              <1> 	;	    0 = Set Date&Time in Unix/Epoch format
 16692                              <1> 	;	    1 = Set Time in MSDOS format
 16693                              <1> 	;	    2 = Set Date in MSDOS format
 16694                              <1> 	;	    3 = Set Date&Time in MSDOS format
 16695                              <1> 	;	    4 = Set System Timer (Ticks)
 16696                              <1> 	;	    5 = Convert/Save current time to/as
 16697                              <1> 	;		18.2 Hz system timer ticks
 16698                              <1> 	;	    6 = Convert MSDOS Date&Time to UNIX format
 16699                              <1> 	;		without setting system date&time ; (test)
 16700                              <1> 	;	    7 = Convert UNIX Date&Time to MSDOS format
 16701                              <1> 	;		without setting system date&time ; (test)
 16702                              <1> 	;	   8-0FFh = invalid !
 16703                              <1> 	;	  ECX = Time (or Timer) value in selected format  	
 16704                              <1> 	;	  EDX = Date value in MSDOS format if BL=2,3,6	
 16705                              <1> 	; 	
 16706                              <1> 	; OUTPUT ->
 16707                              <1> 	;	If CF = 0 ->
 16708                              <1> 	;          EAX = Set value
 16709                              <1> 	;	If CF = 1 -> (invalid BL input)
 16710                              <1> 	;	   EAX = Ticks count [TIMER_LH]	
 16711                              <1> 	;
 16712                              <1> 
 16713 0001199C 20DB                <1> 	and	bl, bl ; 0
 16714 0001199E 7511                <1> 	jnz	short sysstime_0
 16715 000119A0 89C8                <1> 	mov	eax, ecx
 16716 000119A2 E88D54FFFF          <1> 	call	convert_from_epoch
 16717 000119A7 E82D55FFFF          <1> 	call	set_rtc_date_time
 16718 000119AC E96EB3FFFF          <1> 	jmp	sysret
 16719                              <1> sysstime_0:
 16720 000119B1 80FB08              <1> 	cmp	bl, 8
 16721 000119B4 722D                <1> 	jb	short sysstime_1
 16722                              <1> 	; invalid input (>7)
 16723 000119B6 A1[08780100]        <1> 	mov	eax, [TIMER_LH] ; 18.2 Hz timer ticks
 16724                              <1> 				; Note: [TIMER_LH] may be set
 16725                              <1> 				; to wrong timer value due to
 16726                              <1> 				; program functions.
 16727                              <1> 				; (This value must not be
 16728                              <1> 				; accepted as [TIMER_LH]/18.2
 16729                              <1> 				; seconds since the midnight.)
 16730 000119BB A3[1C010300]        <1> 	mov	[u.r0], eax	
 16731 000119C0 E93AB3FFFF          <1> 	jmp	error ; cf = 1 & [u.r0] = eax = timer ticks 
 16732                              <1> 
 16733                              <1> sysstime_8:	
 16734                              <1> 	; BL = 7
 16735 000119C5 89C8                <1> 	mov	eax, ecx ; seconds since 1/1/1970 00:00:00
 16736 000119C7 E86854FFFF          <1> 	call	convert_from_epoch
 16737 000119CC 30E4                <1> 	xor	ah, ah
 16738 000119CE A0[56740100]        <1> 	mov	al, [hour]
 16739 000119D3 C1E010              <1> 	shl	eax, 16
 16740 000119D6 A0[5A740100]        <1> 	mov	al, [second]
 16741 000119DB 8A25[58740100]      <1> 	mov	ah, [minute]
 16742 000119E1 EB92                <1> 	jmp	short systime_3
 16743                              <1> 
 16744                              <1> sysstime_1:
 16745 000119E3 80FB04              <1> 	cmp	bl, 4
 16746 000119E6 743F                <1> 	je	short sysstime_2 ; set system timer ticks	
 16747 000119E8 80FB05              <1> 	cmp	bl, 5
 16748 000119EB 754B                <1> 	jne	short sysstime_4
 16749                              <1> 	; convert current time to system timer ticks (18.2Hz)
 16750 000119ED E83753FFFF          <1> 	call	get_rtc_date_time
 16751 000119F2 0FB60D[56740100]    <1> 	movzx	ecx, byte [hour]
 16752 000119F9 B8100E0000          <1> 	mov	eax, 60*60 ; 1 hour = 3600 seconds
 16753 000119FE F7E1                <1> 	mul	ecx
 16754 00011A00 89C3                <1> 	mov	ebx, eax	
 16755 00011A02 B13C                <1> 	mov	cl, 60  ; 1 minute = 60 seconds
 16756 00011A04 0FB605[58740100]    <1> 	movzx	eax, byte [minute]
 16757 00011A0B F7E1                <1> 	mul	ecx
 16758 00011A0D 01D8                <1> 	add	eax, ebx  
 16759 00011A0F 8A0D[5A740100]      <1> 	mov	cl, [second]
 16760 00011A15 01C8                <1> 	add	eax, ecx
 16761 00011A17 B1B6                <1> 	mov	cl, 182
 16762 00011A19 F7E1                <1> 	mul	ecx
 16763 00011A1B 83C009              <1> 	add	eax, 9
 16764 00011A1E 83D200              <1> 	adc	edx, 0
 16765 00011A21 B10A                <1> 	mov	cl, 10
 16766 00011A23 F7F1                <1> 	div	ecx
 16767                              <1> 	; eax = ((182*seconds)+9)/10
 16768 00011A25 89C1                <1> 	mov	ecx, eax
 16769                              <1> sysstime_2:
 16770 00011A27 890D[08780100]      <1> 	mov	[TIMER_LH], ecx ; 18.2 * seconds
 16771                              <1> sysstime_3:
 16772 00011A2D 890D[1C010300]      <1> 	mov	[u.r0], ecx
 16773 00011A33 E9E7B2FFFF          <1> 	jmp	sysret
 16774                              <1> sysstime_4:
 16775 00011A38 80FB06              <1> 	cmp	bl, 6
 16776 00011A3B 7788                <1> 	ja	short sysstime_8
 16777                              <1> 
 16778 00011A3D 890D[1C010300]      <1> 	mov	[u.r0], ecx
 16779                              <1> 
 16780 00011A43 880D[5A740100]      <1> 	mov	[second], cl
 16781 00011A49 882D[58740100]      <1> 	mov	[minute], ch
 16782 00011A4F C1E910              <1> 	shr	ecx, 16
 16783 00011A52 880D[56740100]      <1> 	mov	[hour], cl
 16784                              <1> 	; BL = 1,2,3,6
 16785 00011A58 80FB01              <1> 	cmp	bl, 1
 16786 00011A5B 762A                <1> 	jna	short sysstime_5
 16787                              <1> 	; BL = 2,3,6
 16788 00011A5D 8815[54740100]      <1> 	mov	[day], dl
 16789 00011A63 8835[52740100]      <1> 	mov	[month], dh
 16790 00011A69 C1EA10              <1> 	shr	edx, 16
 16791 00011A6C 668915[50740100]    <1> 	mov	[year], dx
 16792 00011A73 80E303              <1> 	and	bl, 3
 16793 00011A76 742D                <1> 	jz	short sysstime_7 ; 6
 16794                              <1> 	; BL = 2,3
 16795 00011A78 F6C301              <1> 	test	bl, 1
 16796 00011A7B 7419                <1> 	jz	short sysstime_6 ; 2
 16797                              <1> 	; BL = 3
 16798 00011A7D E85754FFFF          <1> 	call	set_rtc_date_time
 16799 00011A82 E998B2FFFF          <1> 	jmp	sysret
 16800                              <1> sysstime_5:
 16801                              <1> 	; BL = 1
 16802 00011A87 E88E54FFFF          <1> 	call	set_time_bcd
 16803 00011A8C E89D47FFFF          <1> 	call	set_rtc_time
 16804 00011A91 E989B2FFFF          <1> 	jmp	sysret	
 16805                              <1> sysstime_6:
 16806                              <1> 	; BL = 2
 16807 00011A96 E85254FFFF          <1> 	call	set_date_bcd
 16808 00011A9B E8F147FFFF          <1> 	call	set_rtc_date
 16809 00011AA0 E97AB2FFFF          <1> 	jmp	sysret
 16810                              <1> sysstime_7:
 16811                              <1> 	; BL = 6
 16812                              <1> 	; [year], [month], [day], 
 16813                              <1> 	; [hour], [minute], [second]
 16814 00011AA5 E80A53FFFF          <1> 	call	convert_to_epoch
 16815 00011AAA 89C1                <1> 	mov	ecx, eax ; seconds since 1/1/1970 00:00:00
 16816 00011AAC E97CFFFFFF          <1> 	jmp	sysstime_3
 16817                              <1> 
 16818                              <1> sysrename: ; Rename File (or Directory)
 16819                              <1> 	; 08/08/2022
 16820                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 16821                              <1> 	; 19/01/2021
 16822                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16823                              <1> 	;	
 16824                              <1>         ; INPUT ->
 16825                              <1>         ;          EBX = File/Directory (ASCIIZ) name address
 16826                              <1> 	;	   ECX = New name (in same dir, no path name)			
 16827                              <1> 	; OUTPUT ->
 16828                              <1> 	;          cf = 0 -> EAX = 0
 16829                              <1> 	;          cf = 1 -> Error code in AL
 16830                              <1> 
 16831                              <1> 	; 19/01/2021
 16832 00011AB1 803D[6E010300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 16833                              <1> 	;jna	short sysrename_0
 16834                              <1> 	; 23/07/2022
 16835 00011AB8 7717                <1> 	ja	short sysrename_perm_err
 16836                              <1> 
 16837                              <1> ;sysrename_perm_err:
 16838                              <1> ;	;mov	dword [u.r0], ERR_PERM_DENIED
 16839                              <1> ;	mov	eax, ERR_PERM_DENIED ; 'permission denied !'
 16840                              <1> ;	mov	[u.r0], eax
 16841                              <1> ;	mov	[u.error], eax
 16842                              <1> ;	jmp	error
 16843                              <1> 
 16844                              <1> sysrename_0:
 16845 00011ABA 51                  <1> 	push	ecx ; new file name address (in user space)
 16846 00011ABB 89DE                <1> 	mov	esi, ebx
 16847                              <1> 	; file name is forced, change directory as temporary
 16848                              <1> 	;mov	ax, 1
 16849                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 16850                              <1> 	;call	set_working_path 
 16851 00011ABD E8A7060000          <1> 	call	set_working_path_x
 16852 00011AC2 7321                <1> 	jnc	short sysrename_1
 16853 00011AC4 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 16854 00011AC6 753B                <1> 	jnz	short sysrename_err
 16855                              <1> 	; eax = 0
 16856                              <1> sysrename_path_not_found:
 16857 00011AC8 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'Bad path name !'
 16858                              <1> 	; 23/07/2022
 16859 00011ACD B013                <1> 	mov	al, ERR_INV_PATH_NAME
 16860 00011ACF EB32                <1> 	jmp	short sysrename_err
 16861                              <1> ;sysrename_err:
 16862                              <1> ;	pop	ecx ; new file name address (in user space)
 16863                              <1> ;sysrename_error:
 16864                              <1> ;	mov	[u.r0], eax
 16865                              <1> ;	mov	[u.error], eax
 16866                              <1> ;	call 	reset_working_path
 16867                              <1> ;	jmp	error
 16868                              <1> 	
 16869                              <1> 	; 23/07/2022
 16870                              <1> sysrename_perm_err:
 16871                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 16872 00011AD1 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; 'permission denied !'
 16873 00011AD6 A3[1C010300]        <1> 	mov	[u.r0], eax
 16874 00011ADB A3[84010300]        <1> 	mov	[u.error], eax
 16875 00011AE0 E91AB2FFFF          <1> 	jmp	error
 16876                              <1> 
 16877                              <1> sysrename_1:
 16878 00011AE5 B008                <1> 	mov	al, 08h ; Except volume labels (& long names)
 16879 00011AE7 A0[00820100]        <1> 	mov	al, [Attributes]
 16880 00011AEC 2410                <1> 	and	al, 10h ;
 16881                              <1> 	;mov	esi, FindFile_Name
 16882                              <1> 	;mov	ax, 1800h ; Only files
 16883                              <1> 	;mov	ax, 0810h ; Only directories
 16884 00011AEE 66B80008            <1> 	mov	ax, 0800h ; Find File or Directory
 16885 00011AF2 E8496FFFFF          <1> 	call	find_first_file
 16886                              <1> 	;jnc	short sysrename_2
 16887 00011AF7 720A                <1> 	jc	short sysrename_err
 16888                              <1> sysrename_2:
 16889                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
 16890                              <1> 	; EDI = Directory Buffer Directory Entry Location
 16891                              <1> 	; EAX = File Size
 16892                              <1> 	;  BL = Attributes of The File/Directory
 16893                              <1> 	;  BH = Long Name Yes/No Status (>0 is YES)
 16894                              <1> 	;  DX > 0 : Ambiguous filename chars are used
 16895                              <1> 
 16896 00011AF9 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 16897 00011AFC 741A                <1> 	jz	short sysrename_3
 16898 00011AFE B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 'invalid file name !'
 16899                              <1> 	;jmp	short sysrename_err
 16900                              <1> 	; 23/07/2022	
 16901                              <1> sysrename_err:
 16902 00011B03 59                  <1> 	pop	ecx ; new file name address (in user space)
 16903                              <1> sysrename_error:
 16904 00011B04 A3[1C010300]        <1> 	mov	[u.r0], eax
 16905 00011B09 A3[84010300]        <1> 	mov	[u.error], eax
 16906 00011B0E E82B070000          <1> 	call 	reset_working_path
 16907 00011B13 E9E7B1FFFF          <1> 	jmp	error
 16908                              <1> sysrename_3:
 16909                              <1> 	; EDI = Directory buffer entry offset/address
 16910                              <1> 	; BL = File (or Directory) Attributes 
 16911                              <1> 	; mov	bl, [EDI+0Bh]
 16912                              <1> 
 16913 00011B18 5A                  <1> 	pop	edx ; new file name address (in user space)
 16914                              <1> 
 16915                              <1> 	; check file/directory attributes
 16916 00011B19 F6C307              <1> 	test	bl, 7 ; system, hidden, readonly 
 16917 00011B1C 75B3                <1>         jnz	short sysrename_perm_err
 16918                              <1> sysrename_4:
 16919 00011B1E 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
 16920 00011B24 74AB                <1> 	je	short sysrename_perm_err ; -temporary!-
 16921                              <1> 
 16922                              <1> 	; save old file name & file info (FFF structure)
 16923 00011B26 BE[EA800100]        <1> 	mov	esi, FindFile_Drv
 16924 00011B2B BF[30820100]        <1> 	mov	edi, SourceFile_Drv
 16925                              <1> 	;mov	ecx, 128/4
 16926                              <1> 	; 23/07/2022
 16927 00011B30 29C9                <1> 	sub	ecx, ecx
 16928 00011B32 B120                <1> 	mov	cl, 128/4
 16929 00011B34 F3A5                <1> 	rep	movsd
 16930                              <1> 
 16931 00011B36 89D6                <1> 	mov	esi, edx ; new file name address (in user space)
 16932 00011B38 BF[B0820100]        <1> 	mov	edi, DestinationFile_Drv
 16933 00011B3D E8C28FFFFF          <1> 	call	parse_path_name
 16934 00011B42 72C0                <1> 	jc	short sysrename_error ; eax = 1 (Bad file name)
 16935                              <1> 
 16936                              <1> 	; same drive ? 
 16937 00011B44 A0[EA800100]        <1> 	mov	al, [FindFile_Drv]
 16938 00011B49 3A05[B0820100]      <1> 	cmp	al, [DestinationFile_Drv]
 16939                              <1> 	;jne	short sysrename_perm_err ; Permission denied
 16940 00011B4F 7509                <1> 	jne	short sysrename_5 ; Bad file name
 16941                              <1>  
 16942                              <1> 	; no path name !? (rename file in same directory)
 16943 00011B51 803D[B1820100]20    <1> 	cmp	byte [DestinationFile_Directory], 20h
 16944 00011B58 7607                <1> 	jna	short sysrename_6
 16945                              <1> sysrename_5:
 16946 00011B5A B801000000          <1> 	mov	eax, ERR_BAD_CMD_ARG ; 1 = Bad file name 
 16947                              <1> 				     ; (Bad argument)
 16948 00011B5F EBA3                <1> 	jmp	short sysrename_error
 16949                              <1> sysrename_6:
 16950 00011B61 803D[F2820100]20    <1> 	cmp	byte [DestinationFile_Name], 20h
 16951 00011B68 76F0                <1> 	jna	short sysrename_5
 16952                              <1> 
 16953 00011B6A BE[F2820100]        <1> 	mov	esi, DestinationFile_Name
 16954 00011B6F E87172FFFF          <1> 	call	check_filename ; is it a valid msdos file name?
 16955 00011B74 728E                <1> 	jc	short sysrename_error ; 26 = ERR_INV_FILE_NAME 
 16956                              <1> 	
 16957                              <1> 	;mov	esi, DestinationFile_Name
 16958 00011B76 66B80008            <1> 	mov	ax, 0800h ; Find File or Directory
 16959 00011B7A E8C16EFFFF          <1> 	call	find_first_file
 16960 00011B7F 720A                <1> 	jc	short sysrename_7
 16961                              <1> 	
 16962 00011B81 B80E000000          <1> 	mov	eax, ERR_FILE_EXISTS  ; file already exists !
 16963                              <1> jmp_sysrename_err:	; 08/08/2022
 16964 00011B86 E979FFFFFF          <1> 	jmp	sysrename_error
 16965                              <1> sysrename_7:
 16966                              <1> 	; eax = 2 (File not found !)
 16967 00011B8B 3C02                <1> 	cmp	al, 2 ; ERR_NOT_FOUND
 16968                              <1> 	;jne	short sysrename_error
 16969                              <1> 	; 08/08/2022
 16970 00011B8D 75F7                <1> 	jne	short jmp_sysrename_err
 16971                              <1> 
 16972                              <1> 	; 31/12/2017
 16973                              <1> 	; Following code is also part of 'rename_file' in
 16974                              <1> 	; 'trdosk3.s' (MainProg's 'rename' command) ; 13/11/2017
 16975 00011B8F BE[F2820100]        <1> 	mov	esi, DestinationFile_Name ; (Rename_NewName)
 16976 00011B94 668B0D[AA820100]    <1> 	mov	cx, [SourceFile_DirEntryNumber] 
 16977 00011B9B 66A1[96820100]      <1> 	mov	ax, [SourceFile_DirEntry+20] ; First Cluster, HW 
 16978 00011BA1 C1E010              <1> 	shl	eax, 16
 16979 00011BA4 66A1[9C820100]      <1> 	mov	ax, [SourceFile_DirEntry+26] ; First Cluster, LW 
 16980 00011BAA 0FB61D[7F820100]    <1>   	movzx	ebx, byte [SourceFile_LongNameEntryLength]  
 16981 00011BB1 E85697FFFF          <1>    	call	rename_directory_entry
 16982                              <1> 	;jc	short sysrename_error
 16983                              <1> 	; 08/08/2022
 16984 00011BB6 72CE                <1> 	jc	short jmp_sysrename_err
 16985                              <1> 	;xor	eax, eax
 16986 00011BB8 A3[1C010300]        <1> 	mov	[u.r0], eax ; 0
 16987                              <1> 	;mov	[u.error], eax
 16988 00011BBD E87C060000          <1> 	call 	reset_working_path
 16989 00011BC2 E958B1FFFF          <1> 	jmp	sysret
 16990                              <1> 
 16991                              <1> sysmem: ; Get Total&Free Memory amount 
 16992                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16993                              <1> 	;	
 16994                              <1>         ; INPUT -> 
 16995                              <1> 	;	none	
 16996                              <1> 	; OUTPUT ->
 16997                              <1> 	;	EAX = Total memory count (in bytes)
 16998                              <1> 	;	EBX = Virtually available memory amount (in bytes)
 16999                              <1> 	;	      = 4GB - CORE (4MB)	
 17000                              <1> 	;	ECX = Free memory count (in bytes)
 17001                              <1> 	;	EDX = Calculated free memory count (in bytes)
 17002                              <1> 	
 17003 00011BC7 A1[8C770100]        <1> 	mov	eax, [memory_size] ; in pages
 17004 00011BCC C1E00C              <1> 	shl	eax, 12		   ; in bytes
 17005 00011BCF A3[1C010300]        <1> 	mov	[u.r0], eax
 17006 00011BD4 E8D625FFFF          <1> 	call	calc_free_mem
 17007                              <1> 	; edx = calculated free pages
 17008                              <1> 	; ecx = 0
 17009 00011BD9 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; EBP points to user's registers
 17010 00011BDF C745100000C0FF      <1> 	mov	dword [ebp+16], ECORE ; EBX (for user)
 17011                              <1> 				; 0FFC00000h ; 4GB - 4MB
 17012 00011BE6 C1E20C              <1> 	shl	edx, 12
 17013 00011BE9 895514              <1> 	mov	[ebp+20], edx ; EDX (for user)
 17014 00011BEC 8B0D[90770100]      <1> 	mov 	ecx, [free_pages]
 17015 00011BF2 C1E10C              <1> 	shl	ecx, 12	; free bytes
 17016 00011BF5 894D18              <1> 	mov	[ebp+24], ecx ; ECX (for user)
 17017                              <1> 	;mov	[free_pages], edx	
 17018 00011BF8 E922B1FFFF          <1> 	jmp	sysret
 17019                              <1> 
 17020                              <1> sysprompt:
 17021                              <1> 	; Set TRDOS 386 Command Interpreter (MainProg) prompt 
 17022                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
 17023                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 17024                              <1> 	;	
 17025                              <1>         ; INPUT -> 
 17026                              <1> 	;	EBX = 0 -> use default prompt
 17027                              <1> 	;	EBX > 0 -> prompt string (ASCIIZ) address
 17028                              <1> 	;		  (Max. 11 characters except ZERO tail)	
 17029                              <1> 	; OUTPUT ->
 17030                              <1> 	;	(EAX = 0)
 17031                              <1> 	;	CF = 0 -> Successful
 17032                              <1> 	;	CF = 1 -> Failed
 17033                              <1> 
 17034 00011BFD 21DB                <1> 	and	ebx, ebx
 17035 00011BFF 750A                <1> 	jnz	short sysprompt_0
 17036                              <1> 
 17037 00011C01 E86068FFFF          <1> 	call	default_command_prompt ; '['+'TRDOS'+']'
 17038 00011C06 E914B1FFFF          <1> 	jmp	sysret
 17039                              <1> 
 17040                              <1> sysprompt_0:
 17041 00011C0B 31C0                <1> 	xor	eax, eax
 17042 00011C0D A3[1C010300]        <1> 	mov	[u.r0], eax 
 17043 00011C12 89DE                <1> 	mov	esi, ebx
 17044                              <1> 	;mov	ecx, 12
 17045                              <1> 	; 30/07/2022
 17046 00011C14 31C9                <1> 	xor	ecx, ecx
 17047 00011C16 B10C                <1> 	mov	cl, 12
 17048 00011C18 89E5                <1> 	mov	ebp, esp
 17049 00011C1A 29CC                <1> 	sub	esp, ecx
 17050 00011C1C 49                  <1> 	dec	ecx ; 11
 17051 00011C1D 89E7                <1> 	mov	edi, esp
 17052 00011C1F E87FF1FFFF          <1> 	call	transfer_from_user_buffer
 17053 00011C24 7211                <1> 	jc	short sysprompt_err
 17054 00011C26 803E20              <1> 	cmp	byte [esi], 20h
 17055 00011C29 760C                <1> 	jna	short sysprompt_err
 17056 00011C2B E84868FFFF          <1> 	call	set_command_prompt
 17057 00011C30 89EC                <1> 	mov	esp, ebp
 17058 00011C32 E9E8B0FFFF          <1> 	jmp	sysret
 17059                              <1> sysprompt_err:
 17060                              <1> syspath_err:
 17061 00011C37 89EC                <1> 	mov	esp, ebp
 17062 00011C39 E9C1B0FFFF          <1> 	jmp	error
 17063                              <1> 
 17064                              <1> syspath:
 17065                              <1> 	; Get/Set Run Path
 17066                              <1> 	;
 17067                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
 17068                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 17069                              <1> 	;	
 17070                              <1>         ; INPUT -> 
 17071                              <1> 	;	EBX = 0 -> get path (to buffer address in ECX)
 17072                              <1> 	;	EBX > 0 -> set path
 17073                              <1> 	;	    EBX = Path string buffer address (ASCIIZ)
 17074                              <1> 	;	    	  (Path description except 'PATH=')
 17075                              <1> 	;	ECX = Buffer address (if EBX = 0)
 17076                              <1> 	;	      (ECX will not be used if EBX > 0)	
 17077                              <1> 	;	DL = Buffer size (0 = 256 byte)	
 17078                              <1> 	;
 17079                              <1> 	; OUTPUT ->
 17080                              <1> 	;	CF = 0 -> Successful (EAX = String length)
 17081                              <1> 	;	CF = 1 -> Failed (EAX = 0)
 17082                              <1> 	;
 17083                              <1> 	; NOTE: 'PATH=' or 'PATH' must be excluded
 17084                              <1> 	;  (It must not be at the beginning of the string.)
 17085                              <1> 
 17086 00011C3E 89E5                <1> 	mov	ebp, esp
 17087 00011C40 81EC00010000        <1> 	sub	esp, 256
 17088 00011C46 89E7                <1> 	mov	edi, esp
 17089                              <1> 
 17090 00011C48 31C0                <1> 	xor	eax, eax
 17091 00011C4A A3[1C010300]        <1> 	mov	[u.r0], eax 
 17092                              <1> 	
 17093 00011C4F 21DB                <1> 	and	ebx, ebx
 17094 00011C51 752A                <1> 	jnz	short syspath_0
 17095                              <1> 
 17096                              <1> 	; EBX = 0 -> get run path
 17097 00011C53 89CB                <1> 	mov	ebx, ecx ; buffer addr (in user's mem space)
 17098 00011C55 BE[66310100]        <1> 	mov	esi, Cmd_Path  ; 'PATH' address
 17099 00011C5A 0FB6CA              <1> 	movzx	ecx, dl
 17100                              <1> 	;sub	cl, 1 ; 0 -> 255, 1 -> 0
 17101                              <1> 	;adc	cx, 1 ; 255 -> 256, 0 -> 1
 17102                              <1> 	; 30/07/2022
 17103 00011C5D FEC9                <1> 	dec	cl ; 0 -> 255, 1 -> 0
 17104 00011C5F 41                  <1> 	inc	ecx ; 255 -> 256, 0 -> 1 
 17105                              <1> 	; EDI = Output buffer 
 17106                              <1> 	; CX = Buffer length
 17107                              <1> 	; AL = 0 -> use ASCIIZ word in [ESI]
 17108                              <1> 	; ESI = 'PATH' address (with zero tail)
 17109 00011C60 E8837FFFFF          <1> 	call	get_environment_string
 17110 00011C65 72D0                <1> 	jc	short syspath_err
 17111 00011C67 89DF                <1> 	mov	edi, ebx ; User's buffer address
 17112 00011C69 89E6                <1> 	mov	esi, esp 
 17113                              <1> 	; EDI = User's buffer address
 17114                              <1> 	; ECX = transfer (byte) count
 17115 00011C6B E8E9F0FFFF          <1> 	call	transfer_to_user_buffer
 17116 00011C70 72C5                <1> 	jc	short syspath_err
 17117 00011C72 890D[1C010300]      <1> 	mov	[u.r0], ecx 
 17118 00011C78 E9A2B0FFFF          <1> 	jmp	sysret
 17119                              <1> 
 17120                              <1> syspath_0:
 17121 00011C7D 89DE                <1> 	mov	esi, ebx
 17122 00011C7F 0FB6CA              <1> 	movzx	ecx, dl
 17123                              <1> 	;sub	cl, 1 ; 0 -> 255, 1 -> 0
 17124                              <1> 	;adc	cx, 1 ; 255 -> 256, 0 -> 1
 17125                              <1> 	; 30/07/2022
 17126 00011C82 FEC9                <1> 	dec	cl ; 0 -> 255, 1 -> 0
 17127 00011C84 41                  <1> 	inc	ecx ; 255 -> 256, 0 -> 1
 17128 00011C85 E819F1FFFF          <1> 	call	transfer_from_user_buffer
 17129 00011C8A 72AB                <1> 	jc	short syspath_err
 17130                              <1> 	;(*) 'PATH=' will be added to 
 17131                              <1> 	;         the head of the string
 17132 00011C8C 83EC08              <1> 	sub	esp, 8 ;(*)
 17133 00011C8F 89FE                <1> 	mov	esi, edi ;(*)
 17134 00011C91 E8367FFFFF          <1> 	call	set_path_x ;(*)
 17135 00011C96 729F                <1> 	jc	short syspath_err
 17136 00011C98 8915[1C010300]      <1> 	mov	[u.r0], edx ; run path string length
 17137 00011C9E E97CB0FFFF          <1> 	jmp	sysret	
 17138                              <1> 
 17139                              <1> sysenv:
 17140                              <1> 	; Get/Set Environment Variables
 17141                              <1> 	;
 17142                              <1> 	; 30/07/2022
 17143                              <1> 	; 23/07/2022 - TRDOS 386 v2.0.5
 17144                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 17145                              <1> 	;	
 17146                              <1>         ; INPUT -> 
 17147                              <1> 	;	EBX = 0 -> get (all) environment variables
 17148                              <1> 	;	      (Required Buffer length = 512 bytes)
 17149                              <1> 	;	EBX > 0 -> set (one) environment variable
 17150                              <1> 	;	      (If there is not a '=' after
 17151                              <1> 	;	      the environment variable name, it will
 17152                              <1> 	;	      accepted as 'get environment variable'.) 
 17153                              <1> 	;	       EBX = Buffer address
 17154                              <1> 	;	ECX = Buffer address (if EBX = 0)
 17155                              <1> 	;	      (ECX will not be used if EBX > 0)	
 17156                              <1> 	;	      (Note: Buffer size is 512 bytes.)	
 17157                              <1> 	;	DL = Buffer size (0 = 256 byte)
 17158                              <1> 	;	     (For one envrionment variable)		
 17159                              <1> 	;
 17160                              <1> 	; OUTPUT ->
 17161                              <1> 	;	(EAX = 0)
 17162                              <1> 	;	CF = 0 -> Successful (EAX = String length)
 17163                              <1> 	;	CF = 1 -> Failed (EAX = 0)
 17164                              <1> 	;
 17165                              <1> 	; Note: Environment variable name, for example,
 17166                              <1> 	;	'PATH=' must be included at the beginning
 17167                              <1> 	;	of the environment string. If the variable
 17168                              <1> 	;	name is as 'PATH' but it is not as 'PATH='
 17169                              <1> 	;	the variable string (row) will be returned.
 17170                              <1> 	;	If variable name is as 'PATH=' but there is
 17171                              <1> 	;	not a following text after the variable name,
 17172                              <1> 	;	the environment variable will be reset/deleted.
 17173                              <1> 
 17174 00011CA3 89E5                <1> 	mov	ebp, esp
 17175 00011CA5 81EC00020000        <1> 	sub	esp, 512
 17176 00011CAB 89E7                <1> 	mov	edi, esp
 17177                              <1> 
 17178 00011CAD 31C0                <1> 	xor	eax, eax
 17179 00011CAF A3[1C010300]        <1> 	mov	[u.r0], eax 
 17180                              <1> 	
 17181 00011CB4 21DB                <1> 	and	ebx, ebx
 17182 00011CB6 751F                <1> 	jnz	short sysenv_0
 17183                              <1> 
 17184                              <1> 	; EBX = 0 -> get (all) environment variables
 17185 00011CB8 89EC                <1> 	mov	esp, ebp
 17186 00011CBA BE00300900          <1> 	mov	esi, Env_Page  ; Environment page
 17187 00011CBF 89CF                <1> 	mov	edi, ecx ; buffer addr (in user's mem space)
 17188                              <1> 	;mov	ecx, 512
 17189                              <1> 	; 30/07/2022
 17190 00011CC1 29C9                <1> 	sub	ecx, ecx
 17191 00011CC3 B502                <1> 	mov	ch, 2
 17192                              <1> 	; ecx = 512
 17193 00011CC5 E88FF0FFFF          <1> 	call	transfer_to_user_buffer
 17194                              <1> 	;jc	error
 17195                              <1> 	; 23/07/2022
 17196 00011CCA 725B                <1> 	jc	short sysenv_error
 17197 00011CCC 890D[1C010300]      <1> 	mov	[u.r0], ecx 
 17198 00011CD2 E948B0FFFF          <1> 	jmp	sysret
 17199                              <1> 
 17200                              <1> sysenv_0:
 17201 00011CD7 89DE                <1> 	mov	esi, ebx ; * ; user's buffer address
 17202 00011CD9 0FB6CA              <1> 	movzx	ecx, dl
 17203                              <1> 	;sub	cl, 1 ; 0 -> 255, 1 -> 0
 17204                              <1> 	;adc	cx, 1 ; 255 -> 256, 0 -> 1
 17205                              <1> 	; 30/07/2022
 17206 00011CDC FEC9                <1> 	dec	cl ; 0 -> 255, 1 -> 0
 17207 00011CDE 41                  <1> 	inc	ecx ; 255 -> 256, 0 -> 1
 17208 00011CDF E8BFF0FFFF          <1> 	call	transfer_from_user_buffer
 17209 00011CE4 723F                <1> 	jc	short sysenv_err
 17210 00011CE6 89FE                <1> 	mov	esi, edi
 17211 00011CE8 8A06                <1> 	mov	al, [esi]
 17212 00011CEA 3C20                <1> 	cmp	al, 20h
 17213 00011CEC 7637                <1> 	jna	short sysenv_err
 17214 00011CEE 3C3D                <1> 	cmp	al, '='
 17215 00011CF0 7433                <1> 	je	short sysenv_err
 17216 00011CF2 56                  <1> 	push	esi
 17217                              <1> sysenv_1:
 17218 00011CF3 46                  <1> 	inc	esi
 17219 00011CF4 803E3D              <1> 	cmp	byte [esi], '='
 17220 00011CF7 7433                <1> 	je	short sysenv_3
 17221 00011CF9 803E20              <1> 	cmp	byte [esi], 20h
 17222 00011CFC 73F5                <1> 	jnb	short sysenv_1
 17223 00011CFE C60600              <1> 	mov	byte [esi], 0 
 17224 00011D01 5E                  <1> 	pop	esi
 17225                              <1> 	; EDI = Output buffer 
 17226                              <1> 	; CX = Buffer length
 17227 00011D02 30C0                <1> 	xor	al, al
 17228                              <1> 	; AL = 0 -> use ASCIIZ word in [ESI]
 17229                              <1> 	; ESI = Environment variable name address
 17230 00011D04 E8DF7EFFFF          <1> 	call	get_environment_string
 17231 00011D09 721A                <1> 	jc	short sysenv_err
 17232 00011D0B 89DF                <1> 	mov	edi, ebx ; * ; user's buffer address
 17233 00011D0D 89C1                <1> 	mov	ecx, eax ; String length
 17234 00011D0F 89E6                <1> 	mov	esi, esp 
 17235                              <1> 	; ESI = system buffer address
 17236                              <1> 	; EDI = User's buffer address
 17237                              <1> 	; ECX = transfer (byte) count
 17238 00011D11 E843F0FFFF          <1> 	call	transfer_to_user_buffer
 17239 00011D16 720D                <1> 	jc	short sysenv_err
 17240 00011D18 890D[1C010300]      <1> 	mov	[u.r0], ecx ; transfer (byte) count
 17241                              <1> sysenv_2:
 17242 00011D1E 89EC                <1> 	mov	esp, ebp
 17243 00011D20 E9FAAFFFFF          <1> 	jmp	sysret
 17244                              <1> sysenv_err:
 17245 00011D25 89EC                <1> 	mov	esp, ebp
 17246                              <1> sysenv_error:	; 23/07/2022
 17247 00011D27 E9D3AFFFFF          <1> 	jmp	error
 17248                              <1> sysenv_3:
 17249 00011D2C 46                  <1> 	inc	esi
 17250 00011D2D 803E20              <1> 	cmp	byte [esi], 20h
 17251 00011D30 73FA                <1> 	jnb	short sysenv_3
 17252 00011D32 C60600              <1> 	mov	byte [esi], 0	
 17253 00011D35 5E                  <1> 	pop	esi
 17254 00011D36 E8707FFFFF          <1> 	call	set_environment_string
 17255 00011D3B 72E8                <1> 	jc	short sysenv_err
 17256 00011D3D 8915[1C010300]      <1> 	mov	[u.r0], edx
 17257 00011D43 EBD9                <1> 	jmp	short sysenv_2
 17258                              <1> 
 17259                              <1> ; 23/07/2022 - TRDOS 386 v2.0.5
 17260                              <1> 
 17261                              <1> ; 22/01/2021
 17262                              <1> ; temporary - 24/01/2016
 17263                              <1> 
 17264                              <1> iget:
 17265                              <1> 	;retn
 17266                              <1> isintr:
 17267                              <1> 	;retn
 17268                              <1> iopen:
 17269                              <1> 	;retn
 17270                              <1> iclose:
 17271                              <1> 	;retn
 17272                              <1> sndc:
 17273                              <1> 	;retn
 17274                              <1> access:
 17275                              <1> 	;retn
 17276                              <1> sleep:
 17277 00011D45 C3                  <1> 	retn
  3243                                  %include 'trdosk7.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.6) - DISK READ&WRITE : trdosk7.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 29/08/2023  (Previous: 25/07/2022 - Kernel v2.0.5)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; DISK_IO.ASM (20/07/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; DISK_IO.ASM (c) 2009-2011 Erdogan TAN [ 04/07/2009 ] Last Update: 20/07/2011
    14                              <1> 
    15                              <1> disk_write:
    16                              <1> 	; 25/02/2016
    17                              <1> 	; 24/02/2016
    18                              <1> 	; 23/02/2016
    19 00011D46 807E0500            <1> 	cmp	byte [esi+LD_LBAYes], 0
    20 00011D4A 7774                <1>         ja      short lba_write
    21                              <1> 
    22                              <1> chs_write:
    23                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
    24                              <1> 	; 25/02/2016
    25                              <1> 	; 23/02/2016
    26 00011D4C C605[39800100]03    <1> 	mov	byte [disk_rw_op], 3 ; CHS write
    27 00011D53 EB0D                <1> 	jmp	short chs_rw
    28                              <1> 
    29                              <1> disk_read:
    30                              <1> 	; 25/02/2016
    31                              <1> 	; 24/02/2016
    32                              <1> 	; 23/02/2016
    33                              <1> 	; 17/02/2016
    34                              <1> 	; 14/02/2016
    35                              <1> 	; 31/01/2016 (TRDOS 386 = TRDOS v2.0)
    36                              <1> 	; 17/10/2010
    37                              <1> 	; 18/04/2010
    38                              <1> 	;
    39                              <1> 	; INPUT -> EAX = Logical Block Address
    40                              <1> 	;	   ESI = Logical Dos Disk Table Offset (DRV)	
    41                              <1> 	;	   ECX = Sector Count	
    42                              <1> 	; 	   EBX = Destination Buffer
    43                              <1> 	; OUTPUT -> 
    44                              <1> 	;	   cf = 0 or cf = 1
    45                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
    46                              <1> 
    47 00011D55 807E0500            <1> 	cmp	byte [esi+LD_LBAYes], 0
    48 00011D59 776E                <1>         ja      short lba_read
    49                              <1> 
    50                              <1> chs_read:
    51                              <1> 	; 29/08/2023 (TRDOS 386 Kernel v2.0.6)
    52                              <1> 	; 25/07/2022 (TRDOS 386 Kernel v2.0.5)
    53                              <1> 	; 25/02/2016
    54                              <1> 	; 24/02/2016
    55                              <1> 	; 23/02/2016
    56                              <1> 	; 31/01/2016 (TRDOS 386 = TRDOS v2.0)
    57                              <1> 	; 20/07/2011
    58                              <1> 	; 04/07/2009
    59                              <1> 	;
    60                              <1> 	; INPUT -> EAX = Logical Block Address
    61                              <1> 	;	   ECX = Number of sectors to read
    62                              <1> 	; 	   ESI = Logical Dos Disk Table Offset (DRV)
    63                              <1> 	; 	   EBX = Destination Buffer
    64                              <1> 	; OUTPUT -> 
    65                              <1> 	;	   cf = 0 or cf = 1
    66                              <1> 	; (Modified registers: EAX; EBX, ECX, EDX)
    67                              <1> 
    68                              <1> 	; 23/02/2016
    69 00011D5B C605[39800100]02    <1> 	mov	byte [disk_rw_op], 2 ; CHS read
    70                              <1> 
    71                              <1> chs_rw:
    72                              <1> 	;;movzx	edx, word [esi+LD_BPB+SecPerTrack]
    73                              <1> 	;movzx	edx, byte [esi+LD_BPB+SecPerTrack] ; <= 63
    74                              <1> 	;mov	[disk_rw_spt], dl
    75                              <1> 
    76                              <1> chs_read_next_sector:
    77 00011D62 C605[3A800100]04    <1> 	mov	byte [retry_count], 4
    78                              <1>      
    79                              <1> chs_read_retry:
    80                              <1> 	;mov	[sector_count], ecx ; 23/02/2016
    81                              <1> 
    82 00011D69 50                  <1> 	push	eax			; Linear sector #
    83 00011D6A 51                  <1> 	push	ecx			; # of FAT/FILE/DIR sectors
    84                              <1>                 
    85 00011D6B 0FB74E1E            <1> 	movzx	ecx, word [esi+LD_BPB+SecPerTrack]
    86                              <1> 	;movzx	ecx, byte [disk_rw_spt] ; 23/02/2016
    87 00011D6F 29D2                <1> 	sub	edx, edx
    88 00011D71 F7F1                <1> 	div	ecx
    89                              <1> 	; eax = track, dx (dl ) = sector (on track)
    90                              <1> 	;sub	cl, dl ; 24/02/2016 (spt - sec)
    91                              <1> 	;push	ecx ; *
    92                              <1> 	; 25/07/2022
    93                              <1> 	;mov	cx, dx			; Sector (zero based)
    94                              <1> 	;inc	cx			; To make it 1 based
    95                              <1> 	;push	cx
    96                              <1> 	; 29/08/2023
    97                              <1> 	;mov	ecx, edx
    98                              <1> 	;inc	ecx
    99                              <1> 	;push	ecx
   100 00011D73 42                  <1> 	inc	edx
   101 00011D74 52                  <1> 	push	edx ; dl = sector number (on track)
   102                              <1> 	;
   103 00011D75 668B4E20            <1> 	mov	cx, [esi+LD_BPB+Heads]
   104                              <1> 	;sub	dx, dx
   105                              <1> 	; 25/07/2022
   106 00011D79 29D2                <1> 	sub	edx, edx
   107 00011D7B F7F1                <1> 	div	ecx			; Convert track to head & cyl
   108                              <1> 	; eax (ax) = cylinder, dx (dl) = head (max. FFh)
   109 00011D7D 88D6                <1> 	mov	dh, dl
   110                              <1> 	;pop	cx			; AX=Cyl, DH=Head, CX=Sector
   111                              <1> 	; 25/07/2022
   112 00011D7F 59                  <1> 	pop	ecx ; sector number (on track)
   113 00011D80 8A5602              <1> 	mov	dl, [esi+LD_PhyDrvNo]
   114                              <1> 
   115 00011D83 88C5                <1> 	mov	ch, al			; NOTE: max. 1023 cylinders !                   
   116 00011D85 C0CC02              <1> 	ror	ah, 2			; Rotate 2 bits right
   117 00011D88 08E1                <1> 	or	cl, ah
   118                              <1> 
   119                              <1> 	; 24/02/2016
   120                              <1> 	;pop	eax ; * (spt - sec) (example: 63 - 0 = 63)
   121                              <1> 	;cmp	eax, [sector_count]
   122                              <1> 	;jb	short chs_write_sectors
   123                              <1> 	;je	short chs_read_sectors
   124                              <1> 	;; (# of sectors to read is more than remaining sectors on the track)
   125                              <1> 	;mov	al, [sector_count]
   126                              <1> ;chs_read_sectors: ; read or write !
   127 00011D8A B001                <1> 	mov	al, 1 ; 25/02/2016
   128 00011D8C 8A25[39800100]      <1> 	mov	ah, [disk_rw_op]  ; 02h = chs read, 03h = chs write 
   129                              <1> 	;
   130 00011D92 E8E031FFFF          <1> 	call	int13h			; BIOS Service func ( ah ) = 2
   131                              <1>                                         ; Read disk sectors
   132                              <1>                                         ; AL-sec num CH-track CL-sec
   133                              <1>                                         ; DH-head DL-drive ES:BX-buffer
   134                              <1>                                         ; CF-flag AH-stat AL-sec read
   135                              <1> 	                                ; If CF = 1 then (If AH > 0)
   136 00011D97 8825[3B800100]      <1> 	mov	[disk_rw_err], ah
   137                              <1> 	
   138 00011D9D 59                  <1> 	pop	ecx
   139 00011D9E 58                  <1> 	pop	eax
   140 00011D9F 7314                <1> 	jnc	short chs_read_ok
   141                              <1> 
   142 00011DA1 803D[3B800100]09    <1> 	cmp	byte [disk_rw_err], 09h ; DMA crossed 64K segment boundary
   143 00011DA8 7408                <1> 	je	short chs_read_error_retn
   144                              <1>              
   145 00011DAA FE0D[3A800100]      <1> 	dec	byte [retry_count]
   146 00011DB0 75B7                <1> 	jnz	short chs_read_retry
   147                              <1> 
   148                              <1> chs_read_error_retn:
   149 00011DB2 F9                  <1> 	stc
   150                              <1> 	;retn
   151 00011DB3 EB67                <1> 	jmp	short update_drv_error_byte
   152                              <1> 
   153                              <1> ;chs_write_sectors: ; read or write 
   154                              <1> 	;; (# of sectors to read is less than remaining sectors on the track)
   155                              <1> 	;mov	[sector_count], al
   156                              <1> 	;jmp	short chs_read_sectors
   157                              <1> 
   158                              <1> chs_read_ok:
   159                              <1> 	;; 23/02/2016
   160                              <1> 	;movzx	edx, byte [sector_count] ; sector count (<= spt)	
   161                              <1>         ;sub    ecx, edx  ; remaining sector count
   162                              <1> 	;jna	short update_drv_error_byte	
   163                              <1> 	;add	eax, edx ; next disk sector
   164                              <1> 	;shl	edx, 9 ; 512 * sector count
   165                              <1> 	;add	ebx, edx ; next buffer byte address 
   166                              <1>         ;jmp	chs_read_next_sector        
   167                              <1> 	; 25/02/2016
   168 00011DB5 40                  <1> 	inc	eax ; next sector
   169 00011DB6 81C300020000        <1> 	add	ebx, 512
   170 00011DBC E2A4                <1> 	loop	chs_read_next_sector
   171 00011DBE EB5C                <1> 	jmp	short update_drv_error_byte
   172                              <1> 
   173                              <1> lba_write:
   174                              <1> 	; 23/02/2016
   175 00011DC0 C605[39800100]1C    <1> 	mov	byte [disk_rw_op], 1Ch ; LBA write
   176 00011DC7 EB07                <1> 	jmp	short lba_rw
   177                              <1> 
   178                              <1> lba_read:
   179                              <1> 	; 14/07/2022
   180                              <1> 	; 23/02/2016
   181                              <1> 	; 17/02/2016
   182                              <1> 	; 14/02/2016
   183                              <1> 	; 13/02/2016
   184                              <1> 	; 31/01/2016 (TRDOS 386 = TRDOS v2.0)
   185                              <1> 	; 10/07/2015 (Retro UNIX 386 v1)
   186                              <1> 	;
   187                              <1> 	; INPUT -> EAX = Logical Block Address
   188                              <1> 	;	   ESI = Logical Dos Disk Table Offset (DRV)	
   189                              <1> 	;	   ECX = Sector Count	
   190                              <1> 	; 	   EBX = Destination Buffer
   191                              <1> 	; OUTPUT -> 
   192                              <1> 	;	   cf = 0 or cf = 1
   193                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
   194                              <1> 
   195                              <1> 	; LBA read/write (with private LBA function) 
   196                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
   197                              <1> 
   198                              <1> 	; 23/02/2016
   199 00011DC9 C605[39800100]1B    <1> 	mov	byte [disk_rw_op], 1Bh ; LBA read
   200                              <1> 
   201                              <1> lba_rw:
   202                              <1> 	; 17/02/2016
   203 00011DD0 57                  <1> 	push	edi
   204                              <1> 
   205 00011DD1 890D[3C800100]      <1> 	mov	[sector_count], ecx ; total sector (read) count
   206                              <1> 
   207 00011DD7 8A5602              <1> 	mov	dl, [esi+LD_PhyDrvNo]
   208                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
   209                              <1> 
   210                              <1> lba_read_next:
   211                              <1> 	; 14/07/2022
   212 00011DDA BF00010000          <1> 	mov	edi, 256
   213 00011DDF 39F9                <1> 	cmp	ecx, edi
   214                              <1> 	;cmp	ecx, 256
   215 00011DE1 7602                <1> 	jna	short lba_read_rsc
   216                              <1> 	;mov	ecx, 256 ; 17/02/2016
   217 00011DE3 89F9                <1> 	mov	ecx, edi
   218                              <1> lba_read_rsc:
   219 00011DE5 290D[3C800100]      <1> 	sub	[sector_count], ecx ; remain sectors
   220                              <1> 
   221 00011DEB 89CF                <1> 	mov	edi, ecx 
   222 00011DED 89C1                <1> 	mov	ecx, eax ; sector number/address
   223                              <1> 
   224 00011DEF C605[3A800100]04    <1> 	mov	byte [retry_count], 4
   225                              <1> lba_read_retry:
   226 00011DF6 89F8                <1> 	mov	eax, edi
   227                              <1> 	;
   228                              <1> 	; ecx = sector number
   229                              <1> 	; al = sector count (0 - 255) /// (0 = 256)
   230                              <1> 	; dl = drive number
   231                              <1> 	; ebx = buffer offset
   232                              <1> 	;
   233                              <1> 	; Function 1Bh = LBA read, 1Ch = LBA write
   234                              <1> 	; 23/02/2016
   235 00011DF8 8A25[39800100]      <1> 	mov	ah, [disk_rw_op] ; 1Bh = LBA read, 1Ch = LBA write
   236 00011DFE E87431FFFF          <1> 	call	int13h
   237                              <1> 	; al = ? (changed)
   238                              <1> 	; ah = error code
   239 00011E03 8825[3B800100]      <1> 	mov	[disk_rw_err], ah
   240 00011E09 7332                <1> 	jnc	short lba_read_ok
   241 00011E0B 80FC80              <1> 	cmp	ah, 80h ; time out?
   242 00011E0E 740A                <1>         je      short lba_read_stc_retn
   243 00011E10 FE0D[3A800100]      <1> 	dec	byte [retry_count]
   244 00011E16 7FDE                <1> 	jg	short lba_read_retry
   245 00011E18 7438                <1> 	jz	short lba_read_reset
   246                              <1> 	; sf = 1
   247                              <1> 
   248                              <1> lba_read_stc_retn:
   249 00011E1A F9                  <1> 	stc
   250                              <1> lba_read_retn:
   251 00011E1B 5F                  <1> 	pop	edi
   252                              <1> 
   253                              <1> update_drv_error_byte:
   254 00011E1C 9C                  <1> 	pushf
   255 00011E1D 53                  <1> 	push	ebx
   256                              <1> 	;push	cx
   257 00011E1E 51                  <1> 	push	ecx ; 14/07/2022
   258                              <1> 	;or	ecx, ecx
   259                              <1> 	;jz	short udrv_errb0
   260 00011E1F 8A0D[3B800100]      <1> 	mov	cl, [disk_rw_err]
   261                              <1> udrv_errb0:
   262 00011E25 0FB65E02            <1> 	movzx	ebx, byte [esi+LD_PhyDrvNo]
   263 00011E29 80FB02              <1> 	cmp	bl, 2
   264 00011E2C 7203                <1>         jb      short udrv_errb1
   265 00011E2E 80EB7E              <1> 	sub	bl, 7Eh
   266                              <1> 	;cmp	bl, 5
   267                              <1> 	;ja	short udrv_errb2	
   268                              <1> udrv_errb1:
   269 00011E31 81C3[55650000]      <1>         add     ebx, drv.error ; 13/02/2016
   270 00011E37 880B                <1> 	mov	[ebx], cl ; error code
   271                              <1> udrv_errb2:
   272                              <1> 	;pop	cx
   273 00011E39 59                  <1> 	pop	ecx  ; 14/07/2022
   274 00011E3A 5B                  <1> 	pop	ebx
   275 00011E3B 9D                  <1> 	popf
   276 00011E3C C3                  <1> 	retn
   277                              <1> 
   278                              <1> lba_read_ok:
   279 00011E3D 89C8                <1> 	mov	eax, ecx ; sector number
   280 00011E3F 01F8                <1> 	add	eax, edi ; sector number (next)
   281 00011E41 C1E709              <1> 	shl	edi, 9 ; sector count * 512
   282 00011E44 01FB                <1> 	add	ebx, edi ; next buffer offset
   283                              <1> 
   284 00011E46 8B0D[3C800100]      <1> 	mov	ecx, [sector_count] ; remaining sectors
   285 00011E4C 09C9                <1> 	or	ecx, ecx
   286 00011E4E 758A                <1> 	jnz	short lba_read_next
   287 00011E50 EBC9                <1> 	jmp	short lba_read_retn
   288                              <1> 
   289                              <1> lba_read_reset:
   290 00011E52 B40D                <1> 	mov	ah, 0Dh ; Alternate reset
   291 00011E54 E81E31FFFF          <1>         call	int13h
   292                              <1> 	; al = ? (changed)
   293                              <1> 	; ah = error code
   294 00011E59 739B                <1> 	jnc	short lba_read_retry
   295 00011E5B EBBE                <1> 	jmp	short lba_read_retn
  3244                                  %include 'trdosk8.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - MAIN PROGRAM : trdosk8.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 09/08/2022  (Previous: 17/04/2021)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    11                              <1> ; u0.s (20/11/2015), u4.s (14/10/2015)
    12                              <1> ; ****************************************************************************
    13                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    14                              <1> ; TRDOS2.ASM (09/11/2011)
    15                              <1> ; ----------------------------------------------------------------------------
    16                              <1> ; DIR.ASM (c) 2004-2011 Erdogan TAN  [07/01/2004] Last Update: 09/10/2011
    17                              <1> 
    18                              <1> set_run_sequence:
    19                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
    20                              <1> 	; 23/12/2016
    21                              <1> 	; 10/06/2016
    22                              <1> 	; 22/05/2016
    23                              <1> 	; 20/05/2016
    24                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
    25                              <1> 	; TRDOS 386 feature only !
    26                              <1> 	;
    27                              <1> 	; INPUT ->
    28                              <1> 	;	AL = process number (next process)
    29                              <1> 	;
    30                              <1> 	;	this process must be added to run sequence
    31                              <1> 	;
    32                              <1> 	;	[u.pri] = priority of present process
    33                              <1> 	;
    34                              <1> 	;	DL = priority (queue)
    35                              <1> 	;	     0 = background (low) ; run on background 
    36                              <1> 	;	     1 = regular (normal) ; run as regular
    37                              <1> 	;	     2 = event (high)     ; run for event
    38                              <1> 	;
    39                              <1> 	;	1) If the requested process is already running:
    40                              <1> 	;	   a) If present priority is high ([u.pri]=2) 
    41                              <1> 	;	      and requested priority is also high, 
    42                              <1> 	;	      there is nothing to do! Because it has been
    43                              <1> 	;	      done already (before this attempt).		 	
    44                              <1> 	;	   b) If present priority is high ([u.pri]=2)
    45                              <1> 	;	      and requested priority is not high, there is
    46                              <1> 	;	      nothing to do! Because, it's current
    47                              <1> 	;	      run queue is unspecified, here. (It may be in
    48                              <1> 	;	      a waiting list or in a run queue; if the new
    49                              <1> 	;	      priority would be used to add it to relavant
    50                              <1>         ;             run queue, this would be wrong, unnecessary
    51                              <1> 	;	      and destabilizing duplication!)
    52                              <1> 	;	   c) If present priority is not high ([u.pri]<2)
    53                              <1>         ;             and requested priority is high (event),
    54                              <1> 	;	      process will be added to present priority's
    55                              <1> 	;	      run queue and then, priority will be changed
    56                              <1> 	;	      to high ([u.pri]=2).
    57                              <1> 	;	   d) If present priority is not high ([u.pri]<2)
    58                              <1> 	;	      and requested priority is not high, [u.pri]
    59                              <1> 	;	      value will be changed. There is nothing to do
    60                              <1> 	;	      in addition. (The new priority value will be
    61                              <1> 	;	      used by 'tswap/tswitch' procedure at 'sysret'
    62                              <1> 	;	      or 'sysrele' stage.)
    63                              <1> 	;
    64                              <1> 	;	2) If the requested process is not running:
    65                              <1> 	;	   a) If requested priority of the requested
    66                              <1> 	;	      (next) process is high (event) and priority
    67                              <1> 	;	      of present process is not high, the requested
    68                              <1> 	;	      process will be added to ('runq_event') high
    69                              <1> 	;	      priority run queue and then present (running)
    70                              <1> 	;	      process will be stopped (swapped/switched out)
    71                              <1> 	;	      immediately if it is in user mode, or it's 
    72                              <1> 	;	      [u.quant] value will be reset to 0 and (then) 
    73                              <1> 	;	      it will be stopped at 'sysret' stage.			
    74                              <1> 	;	   b) If requested priority of the requested
    75                              <1> 	;	      (next) process is high (event) and priority
    76                              <1> 	;	      of present process is also high, the requested
    77                              <1> 	;	      process will be added to ('runq_event') high
    78                              <1> 	;	      priority run queue and present (running) 
    79                              <1> 	;	      process will be allowed to run until it's 
    80                              <1> 	;	      time quantum will be elapsed ([u.quant]=0).	
    81                              <1> 	;	   c) If requested priority of the requested
    82                              <1> 	;	      (next) process is not high ('run for event'), 
    83                              <1> 	;	      there is nothing to do. Because, it's current
    84                              <1> 	;	      run queue is unspecified, here. (It may be in
    85                              <1> 	;	      a waiting list or in a run queue; if the new
    86                              <1> 	;	      priority would be used to add it to relavant
    87                              <1>         ;             run queue, this would be wrong, unnecessary
    88                              <1> 	;	      and destabilizing duplication!) 
    89                              <1> 	;
    90                              <1> 	; OUTPUT ->
    91                              <1> 	;	none
    92                              <1> 	;
    93                              <1> 	;	[u.pri] = priority of present process
    94                              <1> 	;
    95                              <1> 	;	cf = 1, if the request could not be fulfilled.
    96                              <1> 	;			 	     	  
    97                              <1> 	;	NOTE: 
    98                              <1>         ;          * Processes in 'run as regular' queue can run
    99                              <1> 	;	     if there is no process in 'run for event' queue
   100                              <1> 	;	     ('run for event' processes have higher priority)	 		 
   101                              <1> 	;	   * When [u.quant] time quantum of a process is
   102                              <1> 	;	     elapsed, it's high priority ('run for event')
   103                              <1> 	;	     status will be disabled, it can be run in sequence
   104                              <1> 	;	     of it's actual run queue.
   105                              <1> 	;	   * A 'run on background' process will always be 
   106                              <1> 	;	     sequenced in 'run on background' (low priority)
   107                              <1> 	;	     queue, it can run only when other priority queues
   108                              <1> 	;	     are empty. (idle time processes, e.g. printing)  	 	
   109                              <1> 	;
   110                              <1> 	; Modified registers: eax, ebx, edx
   111                              <1> 	;
   112                              <1> 
   113                              <1> srunseq_0:
   114 00011E5D 3A05[6D010300]      <1>         cmp     al, [u.uno]     ; same process ?
   115 00011E63 750C                <1> 	jne	short srunseq_2 ; no
   116                              <1> 
   117 00011E65 8A25[66010300]      <1> 	mov	ah, [u.pri] 	; present/current priority
   118 00011E6B 80FC02              <1> 	cmp	ah, 2       	; 'run for event' priority level
   119 00011E6E 7220                <1> 	jb	short srunseq_6 ; no
   120                              <1> 
   121                              <1> srunseq_1:
   122                              <1> 	; there is nothing to do!
   123 00011E70 C3                  <1> 	retn
   124                              <1> 
   125                              <1> srunseq_2:
   126                              <1> 	;;this not necessary ! 23/12/2016
   127                              <1>         ;;cmp	al, nproc	; number of processes = 16 
   128                              <1> 	;;jnb	short srunseq_5	; error ! invalid process number 
   129                              <1> 
   130                              <1> 	; dl = priority
   131 00011E71 80FA02              <1> 	cmp	dl, 2 		; event queue
   132 00011E74 72FA                <1> 	jb	short srunseq_1 ; requested process is not present
   133                              <1> 				; process and priority of requested
   134                              <1> 				; process is not high (event), 
   135                              <1> 				; there is nothing to do!
   136                              <1> 	
   137                              <1> 	; requested process is not present process
   138                              <1> 	; & priority of requested process is high
   139 00011E76 3A15[66010300]      <1> 	cmp	dl, [u.pri] 	; priority of present process
   140 00011E7C 7606                <1> 	jna	short srunseq_3 ; is high, also
   141                              <1> 	;
   142                              <1> 	; present process will be swapped/switched out
   143 00011E7E FE05[15840100]      <1> 	inc	byte [p_change] ; 1
   144                              <1> 
   145                              <1> srunseq_3:
   146                              <1> 	; add process to 'runq_event' queue for new event
   147 00011E84 BB[0A010300]        <1> 	mov	ebx, runq_event ; high priority run queue
   148                              <1> 
   149                              <1> srunseq_4:
   150                              <1> 	; al = process number
   151                              <1> 	; ebx = run queue
   152                              <1> 	;call	putlu
   153                              <1> 	;retn
   154                              <1> 	; 29/07/2022
   155 00011E89 E9F7EDFFFF          <1> 	jmp	putlu
   156                              <1> 
   157                              <1> srunseq_5:
   158 00011E8E F5                  <1> 	cmc
   159 00011E8F C3                  <1> 	retn
   160                              <1> 
   161                              <1> srunseq_6:
   162                              <1> 	; present priority of the process is not high
   163                              <1> 	
   164 00011E90 8815[66010300]      <1> 	mov	[u.pri], dl ; new priority 
   165                              <1> 			    ; (will be used by 'tswap')
   166                              <1> 
   167 00011E96 80FA02              <1> 	cmp	dl, 2 		; high priority ?
   168 00011E99 72F3                <1> 	jb	short srunseq_5 ; no, there is nothing to do
   169                              <1> 				; in addition
   170                              <1> 
   171                              <1> 	; process must be added to relevant run queue, here!
   172                              <1> 	; (new priority is high/event priority and process
   173                              <1> 	; will not be added to a run queue by 'tswap')
   174                              <1> 
   175 00011E9B BB[0C010300]        <1> 	mov	ebx, runq_normal ; 'run as regular' queue
   176                              <1> 
   177 00011EA0 20E4                <1> 	and	ah, ah  ;  previous value of [u.pri]
   178 00011EA2 75E5                <1> 	jnz	short srunseq_4
   179                              <1> 
   180 00011EA4 43                  <1> 	inc	ebx
   181 00011EA5 43                  <1> 	inc	ebx
   182                              <1> 	; ebx = runq_background ; 'run on backgroud' queue 
   183                              <1> 
   184 00011EA6 EBE1                <1> 	jmp	short srunseq_4
   185                              <1> clock:
   186                              <1> 	; 23/05/2016
   187                              <1> 	; 22/05/2016
   188                              <1> 	; 20/05/2016
   189                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
   190                              <1> 	; 14/05/2015 - 14/10/2015 (Retro UNIX 386 v1)
   191                              <1> 	; 07/12/2013 - 10/04/2014 (Retro UNIX 8086 v1)
   192                              <1> 
   193 00011EA8 803D[64010300]00    <1> 	cmp	byte [u.quant], 0
   194 00011EAF 772C                <1> 	ja	short clk_1
   195                              <1> 	;
   196 00011EB1 803D[6D010300]01    <1> 	cmp     byte [u.uno], 1 ; /etc/init ? (for Retro UNIX 8086 & 386 v1)
   197                              <1> 				; MainProg (Kernel's Command Interpreter)
   198                              <1> 				; for TRDOS 386.
   199 00011EB8 7623                <1> 	jna	short clk_1 ; yes, do not swap out
   200                              <1> 	;
   201 00011EBA 803D[10010300]FF    <1> 	cmp     byte [sysflg], 0FFh ; user or system space ?
   202 00011EC1 7520                <1> 	jne	short clk_2 	    ; system space (sysflg <> 0FFh)
   203                              <1> 	;
   204 00011EC3 66833D[68010300]00  <1> 	cmp	word [u.intr], 0
   205 00011ECB 7616                <1> 	jna	short clk_2
   206                              <1> 	;
   207                              <1> 	; 23/05/2016
   208 00011ECD 803D[16840100]00    <1> 	cmp	byte [multi_tasking], 0
   209 00011ED4 760D                <1> 	jna	short clk_2
   210                              <1> 	;
   211 00011ED6 FE05[15840100]      <1> 	inc	byte [p_change] ; it is time to change running process	
   212 00011EDC C3                  <1> 	retn
   213                              <1> clk_1:
   214 00011EDD FE0D[64010300]      <1> 	dec	byte [u.quant]
   215                              <1> clk_2:
   216 00011EE3 C3                  <1> 	retn   ; return to (hardware) timer interrupt routine
   217                              <1> 
   218                              <1> ; 12/10/2017
   219                              <1> ; 15/01/2017
   220                              <1> ; 14/01/2017
   221                              <1> ; 07/01/2017
   222                              <1> ; 02/01/2017
   223                              <1> ; 17/08/2016
   224                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   225                              <1> int34h: ; #IOCTL# (I/O port access support for ring 3)
   226                              <1> 	;
   227                              <1> 	; 23/05/2016
   228                              <1> 	; 20/06/2016
   229                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   230                              <1> 	;
   231                              <1> 	; INPUT ->
   232                              <1> 	;	AH = 0 -> read port  (physical IO port) -byte-
   233                              <1> 	;	AH = 1 -> write port (physical IO port) -byte-
   234                              <1> 	;		AL = data byte
   235                              <1> 	;	AH = 2 -> read port  (physical IO port) -word-
   236                              <1> 	;	AH = 3 -> write port (physical IO port) -word-
   237                              <1> 	;		BX = data word
   238                              <1> 	;	AH = 4 -> read port  (physical IO port) -dword-
   239                              <1> 	;	AH = 5 -> write port (physical IO port) -dword-
   240                              <1> 	;		EBX = data dword
   241                              <1> 	;	; 12/10/2017
   242                              <1> 	;	AH = 6 -> read port (physical IO port) twice -byte-
   243                              <1> 	;	AH = 7 -> write port (physical IO port) twice -byte-
   244                              <1> 	;		BX = data word	
   245                              <1> 	;
   246                              <1> 	;	DX = Port number (<= 0FFFFh)
   247                              <1> 	;
   248                              <1> 	; OUTPUT ->
   249                              <1> 	;	AL = data byte (in al, dx)
   250                              <1> 	;	AX = data word (in ax, dx)
   251                              <1> 	;	EAX = data dword (in eax, dx)
   252                              <1> 	;
   253                              <1> 	;	(ECX = actual TRANSFER COUNT for string functions)
   254                              <1> 	;
   255                              <1> 	;
   256                              <1> 	; Modified registers: EAX
   257                              <1> 	;
   258                              <1> 
   259                              <1> 	;cmp	ah, 5
   260                              <1> 	;ja	short int34h_5 ; invalid function !
   261                              <1> 
   262                              <1> 	; 12/10/2017
   263 00011EE4 80FC07              <1> 	cmp	ah, 7
   264 00011EE7 7743                <1> 	ja	short int34h_5 ; invalid function !
   265                              <1> 
   266                              <1> 	;; 15/01/2017
   267                              <1> 	; 14/01/2017
   268                              <1> 	; 02/01/2017
   269                              <1> 	;;mov	byte [ss:intflg], 34h	; IOCTL interrupt 
   270 00011EE9 FB                  <1> 	sti
   271                              <1> 	
   272                              <1> 	;sti	; enable interrupts
   273 00011EEA 80642408FE          <1> 	and	byte [esp+8], 11111110b	; clear carry bit of eflags register
   274                              <1> 
   275 00011EEF 80FC01              <1> 	cmp	ah, 1
   276 00011EF2 7205                <1> 	jb	short int34h_0
   277 00011EF4 7705                <1> 	ja	short int34h_1
   278                              <1> 
   279 00011EF6 EE                  <1> 	out	dx, al
   280                              <1> 	;iretd
   281 00011EF7 EB01                <1> 	jmp	short int34h_iret
   282                              <1> 
   283                              <1> int34h_0:
   284 00011EF9 EC                  <1> 	in	al, dx
   285                              <1> 	;iretd
   286                              <1> int34h_iret:
   287                              <1> 	;cli	; 07/01/2017
   288                              <1> 	;; 15/01/2017
   289                              <1> 	;;mov	byte [ss:intflg], 0 ; reset
   290 00011EFA CF                  <1> 	iretd 
   291                              <1> 
   292                              <1> int34h_1:
   293 00011EFB F6C401              <1> 	test	ah, 1
   294 00011EFE 7516                <1> 	jnz	short int34h_3 ; out
   295                              <1> 
   296                              <1> 	; in
   297 00011F00 80FC02              <1> 	cmp	ah, 2
   298 00011F03 7707                <1> 	ja	short int34h_2
   299                              <1> 
   300 00011F05 6689D8              <1> 	mov	ax, bx
   301 00011F08 66ED                <1> 	in	ax, dx
   302                              <1> 	;iretd
   303 00011F0A EBEE                <1> 	jmp	short int34h_iret
   304                              <1> 
   305                              <1> int34h_2:
   306 00011F0C 80FC04              <1> 	cmp	ah, 4
   307 00011F0F 772C                <1> 	ja	short int34h_7	; 12/10/2017
   308                              <1> 	; ah = 4
   309 00011F11 89D8                <1> 	mov	eax, ebx
   310 00011F13 ED                  <1> 	in	eax, dx
   311                              <1> 	;iretd
   312 00011F14 EBE4                <1> 	jmp	short int34h_iret
   313                              <1> 
   314                              <1> int34h_3:
   315 00011F16 80FC03              <1> 	cmp	ah, 3
   316 00011F19 7707                <1> 	ja	short int34h_4
   317                              <1> 
   318 00011F1B 6689D8              <1> 	mov	ax, bx
   319 00011F1E 66EF                <1> 	out	dx, ax
   320                              <1> 	;iretd
   321 00011F20 EBD8                <1> 	jmp	short int34h_iret
   322                              <1> 
   323                              <1> int34h_4:
   324 00011F22 80FC05              <1> 	cmp	ah, 5
   325 00011F25 770B                <1> 	ja	short int34h_6	; 12/10/2017
   326                              <1> 	; ah = 5
   327 00011F27 89D8                <1> 	mov	eax, ebx
   328 00011F29 EF                  <1> 	out	dx, eax
   329                              <1> 	;iretd
   330 00011F2A EBCE                <1> 	jmp	short int34h_iret
   331                              <1> 
   332                              <1> int34h_5:
   333 00011F2C 804C240801          <1> 	or	byte [esp+8], 1	; set carry bit of eflags register
   334 00011F31 CF                  <1> 	iretd
   335                              <1> 
   336                              <1> 	; 12/10/2017
   337                              <1> int34h_6:
   338 00011F32 6689D8              <1> 	mov	ax, bx
   339 00011F35 EE                  <1> 	out	dx, al
   340 00011F36 EB00                <1> 	jmp	short $+2
   341 00011F38 86E0                <1> 	xchg	ah, al
   342 00011F3A EE                  <1> 	out	dx, al
   343                              <1> 	;xchg	al, ah
   344                              <1> 	;iretd
   345 00011F3B EB06                <1> 	jmp	short int34h_8
   346                              <1> int34h_7:
   347 00011F3D EC                  <1> 	in	al, dx
   348 00011F3E EB00                <1> 	jmp	short $+2
   349 00011F40 88C4                <1> 	mov	ah, al
   350 00011F42 EC                  <1> 	in	al, dx
   351                              <1> int34h_8:
   352 00011F43 86C4                <1> 	xchg	al, ah
   353 00011F45 CF                  <1> 	iretd
   354                              <1> 			
   355                              <1> INT4Ah:
   356                              <1> 	; 24/01/2016
   357                              <1> 	; this procedure will be called by 'RTC_INT' (in 'timer.s')
   358 00011F46 C3                  <1> 	retn
   359                              <1> 
   360                              <1> ; u0.s
   361                              <1> ; Retro UNIX 386 v1 Kernel (v0.2) - SYS0.INC
   362                              <1> ; Last Modification: 20/11/2015
   363                              <1> 
   364                              <1> com2_int:
   365                              <1> 	; 07/11/2015 
   366                              <1> 	; 24/10/2015
   367                              <1> 	; 23/10/2015
   368                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - Beginning)
   369                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1)
   370                              <1> 	; < serial port 2 interrupt handler >
   371                              <1> 	;
   372 00011F47 890424              <1> 	mov 	[esp], eax ; overwrite call return address
   373                              <1> 	;push	eax
   374 00011F4A 66B80900            <1> 	mov	ax, 9
   375 00011F4E EB07                <1> 	jmp	short comm_int
   376                              <1> com1_int:
   377                              <1> 	; 07/11/2015
   378                              <1> 	; 24/10/2015
   379 00011F50 890424              <1> 	mov 	[esp], eax ; overwrite call return address
   380                              <1> 	; 23/10/2015
   381                              <1> 	;push	eax
   382 00011F53 66B80800            <1> 	mov	ax, 8
   383                              <1> comm_int:
   384                              <1> 	; 20/11/2015
   385                              <1> 	; 18/11/2015
   386                              <1> 	; 17/11/2015
   387                              <1> 	; 16/11/2015
   388                              <1> 	; 09/11/2015
   389                              <1> 	; 08/11/2015
   390                              <1> 	; 07/11/2015
   391                              <1> 	; 06/11/2015 (serial4.asm, 'serial')	
   392                              <1> 	; 01/11/2015
   393                              <1> 	; 26/10/2015
   394                              <1> 	; 23/10/2015
   395 00011F57 53                  <1> 	push	ebx
   396 00011F58 56                  <1> 	push	esi
   397 00011F59 57                  <1> 	push	edi
   398 00011F5A 1E                  <1> 	push 	ds
   399 00011F5B 06                  <1> 	push 	es
   400                              <1> 	; 18/11/2015
   401 00011F5C 0F20DB              <1> 	mov	ebx, cr3
   402 00011F5F 53                  <1> 	push	ebx ; ****
   403                              <1> 	;
   404 00011F60 51                  <1> 	push	ecx ; ***
   405 00011F61 52                  <1> 	push	edx ; **
   406                              <1> 	;
   407 00011F62 BB10000000          <1> 	mov	ebx, KDATA
   408 00011F67 8EDB                <1> 	mov	ds, bx
   409 00011F69 8EC3                <1> 	mov	es, bx
   410                              <1> 	;
   411 00011F6B 8B0D[88770100]      <1> 	mov	ecx, [k_page_dir]
   412 00011F71 0F22D9              <1> 	mov	cr3, ecx
   413                              <1> 	; 20/11/2015
   414                              <1> 	; Interrupt identification register
   415 00011F74 66BAFA02            <1> 	mov	dx, 2FAh ; COM2
   416                              <1> 	;
   417 00011F78 3C08                <1> 	cmp 	al, 8 
   418 00011F7A 7702                <1> 	ja 	short com_i0
   419                              <1> 	;
   420                              <1> 	; 20/11/2015
   421                              <1> 	; 17/11/2015
   422                              <1> 	; 16/11/2015
   423                              <1> 	; 15/11/2015
   424                              <1> 	; 24/10/2015
   425                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - Beginning)
   426                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1)
   427                              <1> 	; < serial port 1 interrupt handler >
   428                              <1> 	;
   429 00011F7C FEC6                <1> 	inc	dh ; 3FAh ; COM1 Interrupt id. register
   430                              <1> com_i0:
   431                              <1> 	;push	eax ; *
   432                              <1> 	; 07/11/2015
   433 00011F7E A2[F2770100]        <1> 	mov 	byte [ccomport], al
   434                              <1> 	; 09/11/2015
   435 00011F83 0FB7D8              <1> 	movzx	ebx, ax ; 8 or 9
   436                              <1> 	; 17/11/2015
   437                              <1>  	; reset request for response status
   438 00011F86 88A3[E8770100]      <1> 	mov	[ebx+req_resp-8], ah ; 0
   439                              <1> 	;
   440                              <1> 	; 20/11/2015
   441 00011F8C EC                  <1> 	in	al, dx		; read interrupt id. register
   442 00011F8D EB00                <1> 	JMP	$+2	   	; I/O DELAY
   443 00011F8F 2404                <1> 	and	al, 4		; received data available?	
   444 00011F91 7470                <1> 	jz	short com_eoi	; (transmit. holding reg. empty)
   445                              <1> 	;
   446                              <1> 	; 20/11/2015
   447 00011F93 80EA02              <1> 	sub	dl, 3FAh-3F8h	; data register (3F8h, 2F8h)
   448 00011F96 EC                  <1> 	in	al, dx     	; read character
   449                              <1> 	;JMP	$+2	   	; I/O DELAY
   450                              <1> 	; 08/11/2015
   451                              <1> 	; 07/11/2015
   452 00011F97 89DE                <1> 	mov	esi, ebx 
   453 00011F99 89DF                <1> 	mov	edi, ebx
   454 00011F9B 81C6[EC770100]      <1> 	add 	esi, rchar - 8 ; points to last received char
   455 00011FA1 81C7[EE770100]      <1> 	add	edi, schar - 8 ; points to last sent char
   456 00011FA7 8806                <1> 	mov	[esi], al ; received char (current char)
   457                              <1> 	; query
   458 00011FA9 20C0                <1> 	and	al, al
   459 00011FAB 7527                <1> 	jnz	short com_i2
   460                              <1>    	; response
   461                              <1> 	; 17/11/2015
   462                              <1> 	; set request for response status
   463 00011FAD FE83[E8770100]      <1>         inc     byte [ebx+req_resp-8] ; 1 
   464                              <1> 	;
   465 00011FB3 6683C205            <1> 	add	dx, 3FDh-3F8h	; (3FDh, 2FDh)
   466 00011FB7 EC                  <1> 	in	al, dx	   	; read line status register 
   467 00011FB8 EB00                <1> 	JMP	$+2	   	; I/O DELAY
   468 00011FBA 2420                <1> 	and	al, 20h	   	; transmitter holding reg. empty?
   469 00011FBC 7445                <1> 	jz	short com_eoi 	; no
   470 00011FBE B0FF                <1> 	mov 	al, 0FFh   	; response			
   471 00011FC0 6683EA05            <1> 	sub	dx, 3FDh-3F8h 	; data port (3F8h, 2F8h)
   472 00011FC4 EE                  <1> 	out	dx, al	   	; send on serial port
   473                              <1> 	; 17/11/2015
   474 00011FC5 803F00              <1> 	cmp 	byte [edi], 0   ; query ? (schar)
   475 00011FC8 7502                <1> 	jne 	short com_i1    ; no
   476 00011FCA 8807                <1> 	mov	[edi], al 	; 0FFh (responded)
   477                              <1> com_i1:
   478                              <1> 	; 17/11/2015
   479                              <1> 	; reset request for response status (again)
   480 00011FCC FE8B[E8770100]      <1>         dec     byte [ebx+req_resp-8] ; 0 
   481 00011FD2 EB2F                <1> 	jmp	short com_eoi
   482                              <1> com_i2:	
   483                              <1> 	; 08/11/2015
   484 00011FD4 3CFF                <1> 	cmp 	al, 0FFh	; (response ?)
   485 00011FD6 7417                <1> 	je	short com_i3	; (check for response signal)
   486                              <1> 	; 07/11/2015
   487 00011FD8 3C04                <1> 	cmp	al, 04h	; EOT
   488 00011FDA 751C                <1> 	jne	short com_i4	
   489                              <1> 	; EOT = 04h (End of Transmit) - 'CTRL + D'
   490                              <1> 	;(an EOT char is supposed as a ctrl+brk from the terminal)
   491                              <1> 	; 08/11/2015
   492                              <1> 		; ptty -> tty 0 to 7 (pseudo screens)
   493 00011FDC 861D[B6770100]      <1> 	xchg	bl, [ptty]  ; tty number (8 or 9)
   494 00011FE2 E8F74CFFFF          <1> 	call 	ctrlbrk
   495 00011FE7 861D[B6770100]      <1> 	xchg	[ptty], bl ; (restore ptty value and BL value)
   496                              <1> 	;mov	al, 04h ; EOT
   497                              <1> 	; 08/11/2015
   498 00011FED EB09                <1> 	jmp	short com_i4	
   499                              <1> com_i3:
   500                              <1> 	; 08/11/2015
   501                              <1> 	; If 0FFh has been received just after a query
   502                              <1> 	; (schar, ZERO), it is a response signal.
   503                              <1> 	; 17/11/2015
   504 00011FEF 803F00              <1>         cmp     byte [edi], 0 ; query ? (schar)
   505 00011FF2 7704                <1> 	ja	short com_i4 ; no
   506                              <1> 	; reset query status (schar)
   507 00011FF4 8807                <1> 	mov	[edi], al ; 0FFh
   508 00011FF6 FEC0                <1> 	inc	al ; 0
   509                              <1> com_i4:
   510                              <1> 	; 27/07/2014
   511                              <1> 	; 09/07/2014
   512 00011FF8 D0E3                <1> 	shl	bl, 1	
   513 00011FFA 81C3[B8770100]      <1> 	add	ebx, ttychr
   514                              <1> 	; 23/07/2014 (always overwrite)
   515                              <1> 	;;cmp	word [ebx], 0
   516                              <1> 	;;ja	short com_eoi
   517                              <1> 	;
   518 00012000 668903              <1> 	mov	[ebx], ax   ; Save ascii code
   519                              <1> 			    ; scan code = 0
   520                              <1> com_eoi:
   521                              <1> 	;mov	al, 20h
   522                              <1> 	;out	20h, al	   ; end of interrupt
   523                              <1> 	;
   524                              <1> 	; 07/11/2015
   525                              <1>       	;pop	eax ; *
   526 00012003 A0[F2770100]        <1> 	mov	al, byte [ccomport] ; current COM port
   527                              <1> 	 ; al = tty number (8 or 9)
   528 00012008 E85B010000          <1>         call	wakeup
   529                              <1> com_iret:
   530                              <1> 	; 23/10/2015
   531 0001200D 5A                  <1> 	pop	edx ; **
   532 0001200E 59                  <1> 	pop	ecx ; ***
   533                              <1> 	; 18/11/2015
   534                              <1> 	;pop	eax ; ****
   535                              <1> 	;mov	cr3, eax
   536                              <1> 	;jmp	iiret
   537 0001200F E9BCEDFEFF          <1> 	jmp	iiretp
   538                              <1> 
   539                              <1> ;iiretp: ; 01/09/2015
   540                              <1> ;	; 28/08/2015
   541                              <1> ;	pop	eax ; (*) page directory
   542                              <1> ;	mov	cr3, eax
   543                              <1> ;iiret:
   544                              <1> ;	; 22/08/2014
   545                              <1> ;	mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
   546                              <1> ;	out	20h, al	; 8259 PORT
   547                              <1> ;	;
   548                              <1> ;	pop	es
   549                              <1> ;	pop	ds
   550                              <1> ;	pop	edi
   551                              <1> ;	pop	esi
   552                              <1> ;	pop	ebx ; 29/08/2014
   553                              <1> ;	pop 	eax
   554                              <1> ;	iretd
   555                              <1> 
   556                              <1> sp_init:
   557                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
   558                              <1> 	; 07/11/2015
   559                              <1> 	; 29/10/2015
   560                              <1> 	; 26/10/2015
   561                              <1> 	; 23/10/2015
   562                              <1> 	; 29/06/2015
   563                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - 115200 baud)
   564                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1 - 9600 baud)
   565                              <1> 	; Initialization of Serial Port Communication Parameters
   566                              <1> 	; (COM1 base port address = 3F8h, COM1 Interrupt = IRQ 4)
   567                              <1> 	; (COM2 base port address = 2F8h, COM1 Interrupt = IRQ 3)
   568                              <1> 	;
   569                              <1> 	; ((Modified registers: EAX, ECX, EDX, EBX))
   570                              <1> 	;
   571                              <1> 	; INPUT:  (29/06/2015)
   572                              <1> 	;	AL = 0 for COM1
   573                              <1> 	;	     1 for COM2
   574                              <1> 	;	AH = Communication parameters	
   575                              <1> 	;
   576                              <1> 	;  (*) Communication parameters (except BAUD RATE):
   577                              <1> 	;	Bit	4	3	2	1	0
   578                              <1> 	;		-PARITY--   STOP BIT  -WORD LENGTH-	 		 
   579                              <1> 	;  this one -->	00 = none    0 = 1 bit  11 = 8 bits
   580                              <1> 	;		01 = odd     1 = 2 bits	10 = 7 bits
   581                              <1> 	;		11 = even
   582                              <1> 	;  Baud rate setting bits: (29/06/2015)
   583                              <1> 	;		Retro UNIX 386 v1 feature only !
   584                              <1> 	;	Bit	7    6    5  | Baud rate
   585                              <1> 	;		------------------------
   586                              <1> 	;	value	0    0    0  | Default (Divisor = 1)
   587                              <1> 	;		0    0    1  | 9600 (12)
   588                              <1> 	;		0    1    0  | 19200 (6) 
   589                              <1> 	;		0    1	  1  | 38400 (3) 
   590                              <1> 	;		1    0	  0  | 14400 (8)
   591                              <1> 	;		1    0	  1  | 28800 (4)
   592                              <1> 	;		1    1    0  | 57600 (2)
   593                              <1> 	;		1    1    1  | 115200 (1) 	
   594                              <1> 	
   595                              <1> 	; References:	
   596                              <1> 	; (1) IBM PC-XT Model 286 BIOS Source Code
   597                              <1> 	;     RS232.ASM --- 10/06/1985 COMMUNICATIONS BIOS (RS232)
   598                              <1> 	; (2) Award BIOS 1999 - ATORGS.ASM
   599                              <1> 	; (3) http://wiki.osdev.org/Serial_Ports
   600                              <1> 	;
   601                              <1> 	; Set communication parameters for COM1 (= 03h)	
   602                              <1> 	;
   603 00012014 BB[EE770100]        <1> 	mov	ebx, com1p		; COM1 parameters  
   604 00012019 66BAF803            <1> 	mov	dx, 3F8h		; COM1
   605                              <1> 	 ; 29/10/2015
   606 0001201D 66B90103            <1> 	mov	cx, 301h  ; divisor = 1 (115200 baud)
   607 00012021 E86D000000          <1> 	call	sp_i3	; call A4	
   608 00012026 A880                <1> 	test	al, 80h
   609 00012028 7410                <1> 	jz	short sp_i0 ; OK..
   610                              <1> 		; Error !
   611                              <1> 	;mov	dx, 3F8h
   612 0001202A 80EA05              <1> 	sub	dl, 5 ; 3FDh -> 3F8h
   613 0001202D 66B90E03            <1> 	mov	cx, 30Eh  ; divisor = 12 (9600 baud)
   614 00012031 E85D000000          <1> 	call	sp_i3	; call A4	
   615 00012036 A880                <1> 	test	al, 80h
   616 00012038 7508                <1> 	jnz	short sp_i1
   617                              <1> sp_i0:
   618                              <1>         ; (Note: Serial port interrupts will be disabled here...)	
   619                              <1>         ; (INT 14h initialization code disables interrupts.)
   620                              <1> 	;
   621 0001203A C603E3              <1> 	mov	byte [ebx], 0E3h ; 11100011b
   622 0001203D E8DB000000          <1> 	call	sp_i5 ; 29/06/2015
   623                              <1> sp_i1:
   624 00012042 43                  <1> 	inc	ebx
   625 00012043 66BAF802            <1> 	mov	dx, 2F8h		; COM2
   626                              <1> 	 ; 29/10/2015
   627 00012047 66B90103            <1> 	mov	cx, 301h  ; divisor = 1 (115200 baud)
   628 0001204B E843000000          <1> 	call	sp_i3	; call A4	
   629 00012050 A880                <1> 	test	al, 80h
   630 00012052 7410                <1> 	jz	short sp_i2 ; OK..
   631                              <1> 		; Error !
   632                              <1> 	;mov	dx, 2F8h
   633 00012054 80EA05              <1> 	sub	dl, 5 ; 2FDh -> 2F8h
   634 00012057 66B90E03            <1> 	mov	cx, 30Eh  ; divisor = 12 (9600 baud)
   635 0001205B E833000000          <1> 	call	sp_i3	; call A4	
   636 00012060 A880                <1> 	test	al, 80h
   637 00012062 752E                <1> 	jnz	short sp_i7
   638                              <1> sp_i2:
   639 00012064 C603E3              <1> 	mov	byte [ebx], 0E3h ; 11100011b
   640                              <1> sp_i6:
   641                              <1> 	;; COM2 - enabling IRQ 3
   642                              <1> 	; 29/07/2022
   643                              <1> 	; 07/11/2015
   644                              <1> 	; 26/10/2015
   645 00012067 9C                  <1> 	pushf
   646 00012068 FA                  <1> 	cli
   647                              <1> 	;
   648 00012069 66BAFC02            <1> 	mov	dx, 2FCh   		; modem control register
   649 0001206D EC                  <1> 	in	al, dx 	   		; read register
   650 0001206E EB00                <1> 	JMP	$+2	   		; I/O DELAY
   651 00012070 0C08                <1> 	or	al, 8      		; enable bit 3 (OUT2)
   652 00012072 EE                  <1> 	out	dx, al     		; write back to register
   653 00012073 EB00                <1> 	JMP	$+2	   		; I/O DELAY
   654                              <1> 	;mov	dx, 2F9h   		; interrupt enable register
   655                              <1> 	; 29/07/2022
   656 00012075 B2F9                <1> 	mov	dl, 0F9h
   657 00012077 EC                  <1> 	in	al, dx     		; read register
   658 00012078 EB00                <1> 	JMP	$+2	   		; I/O DELAY
   659                              <1> 	;or	al, 1      		; receiver data interrupt enable and
   660 0001207A 0C03                <1> 	or	al, 3	   		; transmitter empty interrupt enable
   661 0001207C EE                  <1> 	out	dx, al 	   		; write back to register
   662 0001207D EB00                <1> 	JMP	$+2        		; I/O DELAY
   663 0001207F E421                <1> 	in	al, 21h    		; read interrupt mask register
   664 00012081 EB00                <1> 	JMP	$+2	   		; I/O DELAY
   665 00012083 24F7                <1> 	and	al, 0F7h   		; enable IRQ 3 (COM2)
   666 00012085 E621                <1> 	out	21h, al    		; write back to register
   667                              <1> 	;
   668                              <1> 	; 23/10/2015
   669 00012087 B8[471F0100]        <1> 	mov 	eax, com2_int
   670 0001208C A3[63210100]        <1> 	mov	[com2_irq3], eax
   671                              <1> 	; 26/10/2015
   672 00012091 9D                  <1> 	popf	
   673                              <1> sp_i7:
   674 00012092 C3                  <1> 	retn
   675                              <1> 
   676                              <1> sp_i3:
   677                              <1> ;A4:  	;-----	INITIALIZE THE COMMUNICATIONS PORT
   678                              <1> 	; 28/10/2015
   679 00012093 FEC2                <1> 	inc	dl	; 3F9h (2F9h)	; 3F9h, COM1 Interrupt enable register 
   680 00012095 B000                <1> 	mov	al, 0
   681 00012097 EE                  <1> 	out	dx, al			; disable serial port interrupt
   682 00012098 EB00                <1> 	JMP	$+2			; I/O DELAY
   683 0001209A 80C202              <1> 	add	dl, 2 	; 3FBh (2FBh)	; COM1 Line control register (3FBh)
   684 0001209D B080                <1> 	mov	al, 80h			
   685 0001209F EE                  <1> 	out	dx, al			; SET DLAB=1 ; divisor latch access bit
   686                              <1> 	;-----	SET BAUD RATE DIVISOR
   687                              <1> 	; 26/10/2015
   688 000120A0 80EA03              <1> 	sub 	dl, 3   ; 3F8h (2F8h)	; register for least significant byte
   689                              <1> 					; of the divisor value
   690 000120A3 88C8                <1> 	mov	al, cl	; 1
   691 000120A5 EE                  <1> 	out	dx, al			; 1 = 115200 baud (Retro UNIX 386 v1)
   692                              <1> 					; 2 = 57600 baud
   693                              <1> 					; 3 = 38400 baud
   694                              <1> 					; 6 = 19200 baud
   695                              <1> 					; 12 = 9600 baud (Retro UNIX 8086 v1)
   696 000120A6 EB00                <1> 	JMP	$+2			; I/O DELAY
   697 000120A8 28C0                <1> 	sub	al, al
   698 000120AA FEC2                <1> 	inc	dl      ; 3F9h (2F9h)	; register for most significant byte
   699                              <1> 					; of the divisor value
   700 000120AC EE                  <1> 	out	dx, al ; 0
   701 000120AD EB00                <1> 	JMP	$+2			; I/O DELAY
   702                              <1> 	;	
   703 000120AF 88E8                <1> 	mov	al, ch ; 3		; 8 data bits, 1 stop bit, no parity
   704                              <1> 	;and	al, 1Fh ; Bits 0,1,2,3,4	
   705 000120B1 80C202              <1> 	add	dl, 2	; 3FBh (2FBh)	; Line control register
   706 000120B4 EE                  <1> 	out	dx, al			
   707 000120B5 EB00                <1> 	JMP	$+2			; I/O DELAY
   708                              <1> 	; 29/10/2015
   709 000120B7 FECA                <1> 	dec 	dl 	; 3FAh (2FAh)	; FIFO Control register (16550/16750)
   710 000120B9 30C0                <1> 	xor	al, al			; 0
   711 000120BB EE                  <1> 	out	dx, al			; Disable FIFOs (reset to 8250 mode)
   712 000120BC EB00                <1> 	JMP	$+2	
   713                              <1> sp_i4:
   714                              <1> ;A18:	;-----	COMM PORT STATUS ROUTINE
   715                              <1> 	; 29/06/2015 (line status after modem status)
   716 000120BE 80C204              <1> 	add	dl, 4	; 3FEh (2FEh)	; Modem status register
   717                              <1> sp_i4s:
   718 000120C1 EC                  <1> 	in	al, dx			; GET MODEM CONTROL STATUS
   719 000120C2 EB00                <1> 	JMP	$+2			; I/O DELAY
   720 000120C4 88C4                <1> 	mov	ah, al			; PUT IN (AH) FOR RETURN
   721 000120C6 FECA                <1> 	dec	dl	; 3FDh (2FDh)	; POINT TO LINE STATUS REGISTER
   722                              <1> 					; dx = 3FDh for COM1, 2FDh for COM2
   723 000120C8 EC                  <1> 	in	al, dx			; GET LINE CONTROL STATUS
   724                              <1> 	; AL = Line status, AH = Modem status
   725 000120C9 C3                  <1> 	retn
   726                              <1> 
   727                              <1> sp_status:
   728                              <1> 	; 29/06/2015
   729                              <1> 	; 27/06/2015 (Retro UNIX 386 v1)
   730                              <1> 	; Get serial port status
   731 000120CA 66BAFE03            <1> 	mov	dx, 3FEh		; Modem status register (COM1)
   732 000120CE 28C6                <1> 	sub	dh, al			; dh = 2 for COM2 (al = 1)
   733                              <1> 					; dx = 2FEh for COM2
   734 000120D0 EBEF                <1> 	jmp	short sp_i4s
   735                              <1> 
   736                              <1> sp_setp: ; Set serial port communication parameters
   737                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
   738                              <1> 	; 07/11/2015
   739                              <1> 	; 29/10/2015
   740                              <1> 	; 29/06/2015
   741                              <1> 	; Retro UNIX 386 v1 feature only !	
   742                              <1> 	;
   743                              <1> 	; INPUT:
   744                              <1> 	;	AL = 0 for COM1
   745                              <1> 	;	     1 for COM2
   746                              <1> 	;	AH = Communication parameters (*)
   747                              <1> 	; OUTPUT:
   748                              <1> 	;	CL = Line status
   749                              <1> 	;	CH = Modem status
   750                              <1> 	;   If cf = 1 -> Error code in [u.error]
   751                              <1> 	;		 'invalid parameter !' 
   752                              <1> 	;		 	 or
   753                              <1> 	;		 'device not ready !' error
   754                              <1> 	;	
   755                              <1> 	;  (*) Communication parameters (except BAUD RATE):
   756                              <1> 	;	Bit	4	3	2	1	0
   757                              <1> 	;		-PARITY--   STOP BIT  -WORD LENGTH-	 		 
   758                              <1> 	;  this one -->	00 = none    0 = 1 bit  11 = 8 bits
   759                              <1> 	;		01 = odd     1 = 2 bits	10 = 7 bits
   760                              <1> 	;		11 = even
   761                              <1> 	;  Baud rate setting bits: (29/06/2015)
   762                              <1> 	;		Retro UNIX 386 v1 feature only !
   763                              <1> 	;	Bit	7    6    5  | Baud rate
   764                              <1> 	;		------------------------
   765                              <1> 	;	value	0    0    0  | Default (Divisor = 1)
   766                              <1> 	;		0    0    1  | 9600 (12)
   767                              <1> 	;		0    1    0  | 19200 (6) 
   768                              <1> 	;		0    1	  1  | 38400 (3) 
   769                              <1> 	;		1    0	  0  | 14400 (8)
   770                              <1> 	;		1    0	  1  | 28800 (4)
   771                              <1> 	;		1    1    0  | 57600 (2)
   772                              <1> 	;		1    1    1  | 115200 (1) 
   773                              <1> 	;
   774                              <1> 	; (COM1 base port address = 3F8h, COM1 Interrupt = IRQ 4)
   775                              <1> 	; (COM2 base port address = 2F8h, COM1 Interrupt = IRQ 3)
   776                              <1> 	;
   777                              <1> 	; ((Modified registers: EAX, ECX, EDX, EBX))
   778                              <1> 	;
   779 000120D2 66BAF803            <1> 	mov	dx, 3F8h
   780 000120D6 BB[EE770100]        <1> 	mov	ebx, com1p ; COM1 control byte offset
   781 000120DB 3C01                <1> 	cmp	al, 1
   782 000120DD 776A                <1> 	ja 	short sp_invp_err
   783 000120DF 7203                <1> 	jb	short sp_setp1 ;  COM1 (AL = 0)
   784 000120E1 FECE                <1> 	dec	dh ; 2F8h
   785 000120E3 43                  <1> 	inc	ebx ; COM2 control byte offset
   786                              <1> sp_setp1:
   787                              <1> 	; 29/10/2015
   788 000120E4 8823                <1> 	mov	[ebx], ah
   789 000120E6 0FB6CC              <1> 	movzx 	ecx, ah
   790 000120E9 C0E905              <1> 	shr	cl, 5 ; -> baud rate index
   791 000120EC 80E41F              <1> 	and	ah, 1Fh ; communication parameters except baud rate
   792 000120EF 8A81[58210100]      <1> 	mov	al, [ecx+b_div_tbl]
   793 000120F5 6689C1              <1> 	mov	cx, ax
   794 000120F8 E896FFFFFF          <1> 	call	sp_i3
   795 000120FD 6689C1              <1> 	mov	cx, ax ; CL = Line status, CH = Modem status
   796 00012100 A880                <1> 	test	al, 80h
   797 00012102 740F                <1> 	jz	short sp_setp2
   798 00012104 C603E3              <1>         mov     byte [ebx], 0E3h ; Reset to initial value (11100011b)
   799                              <1> stp_dnr_err:
   800 00012107 C705[84010300]0F00- <1> 	mov	dword [u.error], ERR_DEV_NOT_RDY ; 'device not ready !'
   800 0001210F 0000                <1>
   801                              <1> 	; CL = Line status, CH = Modem status
   802 00012111 F9                  <1> 	stc
   803 00012112 C3                  <1> 	retn
   804                              <1> sp_setp2:
   805 00012113 80FE02              <1> 	cmp	dh, 2 ; COM2 (2F?h)
   806                              <1> 	;jna	sp_i6 
   807                              <1> 		      ; COM1 (3F?h)
   808                              <1> 	; 29/07/2022
   809 00012116 7705                <1> 	ja	short sp_i5
   810 00012118 E94AFFFFFF          <1> 	jmp	sp_i6
   811                              <1> sp_i5: 
   812                              <1> 	; 29/07/2022
   813                              <1> 	; 07/11/2015
   814                              <1> 	; 26/10/2015
   815                              <1> 	; 29/06/2015
   816                              <1> 	;
   817                              <1> 	;; COM1 - enabling IRQ 4
   818 0001211D 9C                  <1> 	pushf
   819 0001211E FA                  <1> 	cli
   820 0001211F 66BAFC03            <1> 	mov	dx, 3FCh   		; modem control register
   821 00012123 EC                  <1> 	in	al, dx 	   		; read register
   822 00012124 EB00                <1> 	JMP	$+2			; I/O DELAY
   823 00012126 0C08                <1> 	or	al, 8      		; enable bit 3 (OUT2)
   824 00012128 EE                  <1> 	out	dx, al     		; write back to register
   825 00012129 EB00                <1> 	JMP	$+2			; I/O DELAY
   826                              <1> 	;mov	dx, 3F9h   		; interrupt enable register
   827                              <1> 	; 29/07/2022
   828 0001212B B2F9                <1> 	mov	dl, 0F9h
   829 0001212D EC                  <1> 	in	al, dx     		; read register
   830 0001212E EB00                <1> 	JMP	$+2			; I/O DELAY
   831                              <1> 	;or	al, 1      		; receiver data interrupt enable and
   832 00012130 0C03                <1> 	or	al, 3	   		; transmitter empty interrupt enable
   833 00012132 EE                  <1> 	out	dx, al 	   		; write back to register
   834 00012133 EB00                <1> 	JMP	$+2        		; I/O DELAY
   835 00012135 E421                <1> 	in	al, 21h    		; read interrupt mask register
   836 00012137 EB00                <1> 	JMP	$+2			; I/O DELAY
   837 00012139 24EF                <1> 	and	al, 0EFh   		; enable IRQ 4 (COM1)
   838 0001213B E621                <1> 	out	21h, al    		; write back to register
   839                              <1> 	;
   840                              <1> 	; 23/10/2015
   841 0001213D B8[501F0100]        <1> 	mov 	eax, com1_int
   842 00012142 A3[5F210100]        <1> 	mov	[com1_irq4], eax
   843                              <1> 	; 26/10/2015
   844 00012147 9D                  <1> 	popf
   845 00012148 C3                  <1> 	retn
   846                              <1> 
   847                              <1> sp_invp_err:
   848 00012149 C705[84010300]1700- <1> 	mov	dword [u.error], ERR_INV_PARAMETER ; 'invalid parameter !' 
   848 00012151 0000                <1>
   849 00012153 31C9                <1> 	xor	ecx, ecx
   850 00012155 49                  <1> 	dec	ecx ; 0FFFFh
   851 00012156 F9                  <1> 	stc
   852 00012157 C3                  <1> 	retn
   853                              <1> 
   854                              <1> ; 29/10/2015
   855                              <1> b_div_tbl: ; Baud rate divisor table (115200/divisor)
   856 00012158 010C0603080401      <1> 	db 1, 12, 6, 3, 8, 4, 1
   857                              <1> 
   858                              <1> 
   859                              <1> ; 23/10/2015
   860                              <1> com1_irq4:
   861 0001215F [67210100]          <1> 	dd dummy_retn
   862                              <1> com2_irq3:
   863 00012163 [67210100]          <1> 	dd dummy_retn
   864                              <1> 
   865                              <1> dummy_retn:
   866 00012167 C3                  <1> 	retn
   867                              <1> 
   868                              <1> wakeup:
   869                              <1> 	; 24/01/2016
   870 00012168 C3                  <1> 	retn
   871                              <1> 
   872                              <1> set_working_path_x:
   873                              <1> 		; 17/10/2016 (TRDOS 386 - FFF & FNF)
   874                              <1> 		;mov	ax, 1 
   875                              <1> 			; File name is needed/forced (AL=1)
   876                              <1> 			; Change directory as temporary (AH=0)	
   877                              <1> 		; 29/07/2022
   878 00012169 31C0                <1> 		xor	eax, eax
   879 0001216B FEC0                <1> 		inc	al
   880                              <1> 		; eax = 1
   881                              <1> set_working_path_xx: ; 30/12/2017 (syschdir)
   882                              <1> 		; This is needed for preventing wrong Find Next File
   883                              <1> 		; system call after sysopen, syscreate, sysmkdir etc. 
   884                              <1> 		; Find Next File must immediate follow Find First File)
   885                              <1> 
   886 0001216D 8825[38840100]      <1> 		mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
   887                              <1> 
   888                              <1> set_working_path:
   889                              <1> 		; 08/08/2022
   890                              <1> 		; 29/07/2022 - TRDOS 386 Kernel v2.0.5
   891                              <1> 		; 16/10/2016
   892                              <1> 		; 12/10/2016
   893                              <1> 		; 10/10/2016
   894                              <1> 		; 05/10/2016 - TRDOS 386 (TRDOS v2.0)
   895                              <1> 		;
   896                              <1> 		; TRDOS v1.0 (DIR.ASM, "proc_set_working_path")
   897                              <1>                 ; 27/01/2011 - 08/02/2011 
   898                              <1> 		; Set/Changes current drive, directory and file
   899                              <1> 		; depending on command tail
   900                              <1> 		; (procedure is derivated from CMD_INTR.ASM 
   901                              <1> 		; file or dir locating code of internal commands)
   902                              <1> 		; (This procedure is prepared for INT 21H file/dir 
   903                              <1> 		; functions and also to get compact code for 
   904                              <1> 		; internal mainprog -command interpreter- commands)
   905                              <1> 		; 
   906                              <1> 		; INPUT: DS:SI -> Command tail (ASCIIZ string)
   907                              <1> 		; AL = 0 -> any, AL > 0 -> file name is forced
   908                              <1> 		; AH = CD -> Change directory permanently 
   909                              <1> 		; AH <> CD -> Change directory as temporary    
   910                              <1> 		; 
   911                              <1> 		; OUTPUT: ES=DS, FindFile structure has been set
   912                              <1> 		;        RUN_CDRV points previous current drive  
   913                              <1> 		;        DS:SI = FindFile structure address
   914                              <1> 		;        (DS=CS)       
   915                              <1> 		;        AX, BX, CX, DX, DI will be changed
   916                              <1> 		;   cf = 1 -> Error code in AX (AL)
   917                              <1> 		;        stc & AX = 0 -> Bad command or path name 
   918                              <1> 		; -----------------------------------------------
   919                              <1> 		;
   920                              <1> 		; TRDOS 386 (05/10/2016)
   921                              <1> 		; INPUT:
   922                              <1> 		;	ESI = File/Directory Path (ASCIIZ string)
   923                              <1> 		;             address in user's memory space
   924                              <1> 		;       AL = 0 -> any
   925                              <1> 		;       AL > 0 -> file name is forced
   926                              <1> 		;       AH = CD -> change directory as permanent
   927                              <1> 		;       AH <> CD -> change directory as temporary
   928                              <1> 		; 
   929                              <1> 		; OUTPUT:
   930                              <1> 		;	FindFile structure has been set
   931                              <1> 		;       RUN_CDRV points previous current drive  
   932                              <1> 		;       ESI = FindFile_Name address ; 12/10/2016
   933                              <1> 		;
   934                              <1> 		;       cf = 1 -> Error code in EAX (AL)
   935                              <1> 		;       stc & EAX = 0 -> Bad command or path name
   936                              <1> 		;  
   937                              <1> 		; Modified registers: EAX, EBX, ECX, EDX, ESI, EDI
   938                              <1> 
   939 00012173 66A3[3C840100]      <1> 		mov	[SWP_Mode], ax
   940 00012179 A0[4A780100]        <1> 		mov	al, [Current_Drv]
   941 0001217E 30E4                <1> 		xor	ah, ah
   942 00012180 66A3[3E840100]      <1> 		mov	[SWP_DRV], ax
   943                              <1> 
   944                              <1> 		; TRDOS 386 ring 3 (user's page directory)
   945                              <1> 		; to ring 0 (kernel's page directory) 
   946                              <1> 		; transfer modifications (05/10/2016).
   947                              <1> 
   948 00012186 55                  <1> 		push	ebp
   949 00012187 89E5                <1> 		mov	ebp, esp
   950                              <1> 		
   951                              <1> 		;mov	ecx, 128 ; maximum path length = 128 bytes
   952                              <1> 		; 29/07/2022
   953 00012189 31C9                <1> 		xor	ecx, ecx
   954 0001218B B180                <1> 		mov	cl, 128
   955 0001218D 29CC                <1> 		sub	esp, ecx ; reserve 128 bytes (buffer) on stack
   956 0001218F 89E7                <1> 		mov	edi, esp ; destination address (kernel space)
   957                              <1> 		; esi = source address (virtual, in user's memory space)
   958 00012191 E80DECFFFF          <1> 		call	transfer_from_user_buffer
   959 00012196 720D                <1> 		jc	short loc_swp_xor_retn 
   960                              <1> 		
   961 00012198 89E6                <1> 		mov	esi, esp ; temporary buffer (the path) on stack
   962                              <1> loc_swp_fchar:
   963 0001219A 8A06                <1> 		mov	al, [esi]
   964 0001219C 3C20                <1> 		cmp	al, 20h
   965 0001219E 7711                <1> 		ja	short loc_swp_parse_path_name
   966                              <1> 		;je	short loc_swp_fchar_next
   967                              <1> 		; 29/07/2022
   968 000121A0 7203                <1> 		jb	short loc_swp_xor_retn
   969                              <1> 
   970                              <1> loc_swp_fchar_next:
   971 000121A2 46                  <1> 		inc	esi
   972 000121A3 EBF5                <1> 		jmp	short loc_swp_fchar
   973                              <1> 
   974                              <1> loc_swp_xor_retn:
   975 000121A5 31C0                <1> 		xor	eax, eax
   976 000121A7 F9                  <1> 		stc
   977                              <1> loc_swp_retn:
   978 000121A8 89EC                <1> 		mov	esp, ebp
   979 000121AA 5D                  <1> 		pop	ebp
   980                              <1> 
   981                              <1> 		;mov	esi, FindFile_Drv
   982 000121AB BE[2C810100]        <1> 		mov	esi, FindFile_Name ; 12/10/2016
   983 000121B0 C3                  <1> 		retn 
   984                              <1> 
   985                              <1> ;loc_swp_fchar_next:
   986                              <1> ;		inc	esi
   987                              <1> ;		jmp	short loc_swp_fchar  
   988                              <1> 
   989                              <1> loc_swp_parse_path_name:
   990 000121B1 BF[EA800100]        <1> 		mov	edi, FindFile_Drv
   991 000121B6 E84989FFFF          <1> 		call	parse_path_name
   992 000121BB 72EB                <1> 		jc	short loc_swp_retn
   993                              <1> 
   994                              <1> loc_swp_checkfile_name:
   995 000121BD 803D[3C840100]00    <1> 		cmp	byte [SWP_Mode], 0
   996 000121C4 761E                <1> 		jna	short loc_swp_drv
   997                              <1> 
   998                              <1> 		; 10/10/2016 (valid file name checking)
   999 000121C6 BE[2C810100]        <1> 		mov	esi, FindFile_Name
  1000 000121CB 803E20              <1> 		cmp	byte [esi], 20h
  1001 000121CE 76D5                <1> 		jna	short loc_swp_xor_retn
  1002                              <1> 
  1003                              <1> 		; 16/10/2016
  1004 000121D0 C605[3B840100]00    <1> 		mov	byte [SWP_inv_fname], 0 ; reset 
  1005                              <1> 		; esi = file name address (ASCIIZ)
  1006 000121D7 E8096CFFFF          <1> 		call	check_filename
  1007 000121DC 7306                <1> 		jnc	short loc_swp_drv
  1008                              <1> 
  1009 000121DE FE05[3B840100]      <1> 		inc	byte [SWP_inv_fname] ; set 	
  1010                              <1> loc_swp_drv:
  1011 000121E4 8A35[4A780100]      <1> 		mov	dh, [Current_Drv]
  1012                              <1>                ;mov	[RUN_CDRV], dh
  1013                              <1> 
  1014 000121EA 8A15[EA800100]      <1> 		mov	dl, [FindFile_Drv]
  1015                              <1>                ;cmp	dl, dh
  1016 000121F0 3A15[4A780100]      <1> 		cmp	dl, [Current_Drv]
  1017 000121F6 740D                <1> 		je	short loc_swp_change_directory
  1018                              <1> 
  1019 000121F8 FE05[3F840100]      <1> 		inc	byte [SWP_DRV_chg]
  1020 000121FE E88F55FFFF          <1> 		call	change_current_drive
  1021 00012203 72A3                <1> 		jc	short loc_swp_retn ; eax = error code
  1022                              <1> 		; eax = 0
  1023                              <1> 
  1024                              <1> loc_swp_change_directory:
  1025 00012205 803D[EB800100]21    <1> 		cmp	byte [FindFile_Directory], 21h
  1026 0001220C F5                  <1> 		cmc
  1027 0001220D 7399                <1> 		jnc	short loc_swp_retn
  1028                              <1> 
  1029 0001220F FE05[3F840100]      <1> 		inc	byte [SWP_DRV_chg]
  1030 00012215 FE05[92300100]      <1> 		inc	byte [Restore_CDIR]
  1031 0001221B BE[EB800100]        <1> 		mov	esi, FindFile_Directory
  1032 00012220 8A25[3D840100]      <1> 		mov	ah, [SWP_Mode+1] 
  1033 00012226 E8ED82FFFF          <1> 		call	change_current_directory
  1034                              <1> 		;jc	short loc_swp_retn ; eax = error code
  1035                              <1> 		; 08/08/2022
  1036 0001222B 7305                <1> 		jnc	short loc_swp_change_prompt_dir_string
  1037 0001222D E976FFFFFF          <1> 		jmp	loc_swp_retn	
  1038                              <1> 
  1039                              <1> loc_swp_change_prompt_dir_string:
  1040                              <1> 		; esi = PATH_Array
  1041                              <1> 		; eax = Current Directory First Cluster
  1042                              <1> 		; edi = Logical DOS Drive Description Table	
  1043 00012232 E80F82FFFF          <1> 		call	change_prompt_dir_str 
  1044 00012237 29C0                <1> 		sub	eax, eax ; 0
  1045 00012239 E96AFFFFFF          <1> 		jmp	loc_swp_retn 
  1046                              <1> 
  1047                              <1> reset_working_path:
  1048                              <1> 		; 06/10/2016 - TRDOS 386 (TRDOS v2.0)
  1049                              <1> 		;
  1050                              <1> 		; TRDOS v1.0 (DIR.ASM, "proc_reset_working_path")
  1051                              <1> 		; 05/02/2011 - 08/02/2011 
  1052                              <1> 		;
  1053                              <1> 		; Restores current drive and directory 
  1054                              <1> 		; 
  1055                              <1> 		; INPUT: none
  1056                              <1> 		; OUTPUT: DL = SWP_DRV, EAX = 0 -> OK
  1057                              <1> 		;
  1058                              <1> 		;    AX = 0 -> ESI = Logical Dos Drv Desc. Table
  1059                              <1> 		;
  1060                              <1> 		;    EAX, EBX, ECX, EDX, ESI, EDI will be changed
  1061                              <1> 		;
  1062                              <1> 
  1063                              <1>   
  1064 0001223E 31C0                <1> 		xor	eax, eax
  1065 00012240 48                  <1> 		dec	eax 
  1066                              <1> 
  1067 00012241 668B15[3E840100]    <1> 		mov	dx, [SWP_DRV]
  1068 00012248 08F6                <1> 		or	dh, dh
  1069 0001224A 742E                <1> 		jz	short loc_rwp_return
  1070                              <1> 
  1071 0001224C 3A15[4A780100]      <1> 		cmp	dl, [Current_Drv]
  1072 00012252 7407                <1> 		je	short loc_rwp_restore_cdir
  1073                              <1> loc_rwp_restore_cdrv:
  1074 00012254 E83955FFFF          <1> 		call	change_current_drive 
  1075 00012259 EB10                <1> 		jmp	short loc_rwp_restore_ok
  1076                              <1> loc_rwp_restore_cdir:
  1077 0001225B 31DB                <1> 		xor	ebx, ebx
  1078 0001225D 88D7                <1> 		mov	bh, dl
  1079 0001225F BE00010900          <1> 		mov	esi, Logical_DOSDisks
  1080 00012264 01DE                <1> 		add	esi, ebx
  1081                              <1> 
  1082 00012266 E8DD55FFFF          <1> 		call	restore_current_directory
  1083                              <1> 
  1084                              <1> loc_rwp_restore_ok:
  1085 0001226B 668B15[3E840100]    <1> 		mov	dx, [SWP_DRV]
  1086 00012272 31C0                <1> 		xor	eax, eax  
  1087 00012274 66A3[3F840100]      <1> 		mov	[SWP_DRV_chg], ax
  1088                              <1> loc_rwp_return:
  1089 0001227A C3                  <1> 		retn
  1090                              <1> 
  1091                              <1> get_file_name:
  1092                              <1> 		; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  1093                              <1> 		; 15/10/2016 - TRDOS 386 (TRDOS v2.0)
  1094                              <1> 		; Convert file name 
  1095                              <1> 		;	from directory entry format
  1096                              <1>                 ; 	to (8.3) dot file name format 
  1097                              <1> 		;
  1098                              <1> 		; TRDOS v1.0 (DIR.ASM, "get_file_name")
  1099                              <1>                 ; 2005 - 09/10/2011 	
  1100                              <1> 		; INPUT: 
  1101                              <1> 		;	DS:SI -> Directory Entry Format File Name
  1102                              <1> 		;       ES:DI -> DOS Dot File Name Address
  1103                              <1> 		; OUTPUT:
  1104                              <1> 		;	DS:SI -> DOS Dot File Name Address
  1105                              <1>                 ;	ES:DI -> Directory Entry Format File Name
  1106                              <1> 		;	
  1107                              <1> 		; TRDOS 386 (15/10/2016)
  1108                              <1> 		; INPUT:
  1109                              <1> 		;	ESI = File name addr in dir entry format
  1110                              <1> 		;	EDI = Dot file name address (destination)
  1111                              <1> 		; OUTPUT: 
  1112                              <1> 		;	File name is converted and moved
  1113                              <1> 		;	to destination (as 8.3 dot filename)
  1114                              <1> 		;  
  1115                              <1> 		; Modified registers: EAX, ECX
  1116                              <1> 
  1117                              <1>                 ; 2005 (TRDOS 8086) - 2016 (TRDOS 386)
  1118                              <1>                             
  1119 0001227B 57                  <1> 		push	edi
  1120 0001227C 56                  <1> 		push	esi
  1121 0001227D AC                  <1> 		lodsb
  1122 0001227E 3C20                <1> 		cmp	al, 20h
  1123 00012280 7629                <1> 		jna	short pass_gfn_ext
  1124 00012282 56                  <1> 		push	esi
  1125 00012283 AA                  <1> 		stosb
  1126                              <1> 		;mov	ecx, 7
  1127                              <1> 		; 29/07/2022
  1128 00012284 31C9                <1> 		xor	ecx, ecx
  1129 00012286 B107                <1> 		mov	cl, 7
  1130                              <1> loc_gfn_next_char:
  1131 00012288 AC                  <1> 		lodsb
  1132 00012289 3C20                <1> 		cmp	al, 20h
  1133 0001228B 7603                <1> 		jna	short pass_gfn_fn
  1134 0001228D AA                  <1> 		stosb
  1135 0001228E E2F8                <1> 		loop	loc_gfn_next_char
  1136                              <1> pass_gfn_fn:
  1137 00012290 5E                  <1> 		pop	esi
  1138 00012291 83C607              <1> 		add	esi, 7
  1139 00012294 AC                  <1> 		lodsb
  1140 00012295 3C20                <1> 		cmp	al, 20h
  1141 00012297 7612                <1> 		jna	short pass_gfn_ext
  1142 00012299 B42E                <1> 		mov	ah, '.'
  1143 0001229B 86E0                <1> 		xchg	ah, al
  1144 0001229D 66AB                <1> 		stosw
  1145 0001229F AC                  <1> 		lodsb
  1146 000122A0 3C20                <1> 		cmp	al, 20h
  1147 000122A2 7607                <1> 		jna	short pass_gfn_ext
  1148 000122A4 AA                  <1> 		stosb
  1149 000122A5 AC                  <1> 		lodsb
  1150 000122A6 3C20                <1> 		cmp	al, 20h
  1151 000122A8 7601                <1> 		jna	short pass_gfn_ext
  1152 000122AA AA                  <1> 		stosb
  1153                              <1> pass_gfn_ext:		
  1154 000122AB 30C0                <1> 		xor	al, al
  1155 000122AD AA                  <1> 		stosb
  1156 000122AE 5E                  <1> 		pop	esi
  1157 000122AF 5F                  <1> 		pop	edi
  1158 000122B0 C3                  <1> 		retn
  1159                              <1> 
  1160                              <1> set_hardware_int_vector:
  1161                              <1> 		; 18/03/2017
  1162                              <1> 		; 03/03/2017
  1163                              <1> 		; 28/02/2017 - TRDOS 386 (TRDOS v2.0)
  1164                              <1> 		;
  1165                              <1> 		; SET/RESET HARDWARE INTERRUPT GATE
  1166                              <1> 		;
  1167                              <1> 		; Changes interrupt gate descriptor table
  1168                              <1> 		; (without changing default interrupt list)
  1169                              <1> 		;
  1170                              <1> 		; INPUT:
  1171                              <1> 		;	AL = IRQ number (0 to 15)
  1172                              <1> 		;	AH > 0 -> set
  1173                              <1> 		;	AH = 0 -> reset
  1174                              <1> 		;	
  1175                              <1> 		; Modified registers: eax, ebx, edx, edi 
  1176                              <1> 		;
  1177                              <1> 		
  1178 000122B1 C0E002              <1> 		shl	al, 2 ; IRQ number * 4
  1179 000122B4 0FB6D8              <1> 		movzx	ebx, al
  1180                              <1> 
  1181 000122B7 08E4                <1> 		or	ah, ah
  1182 000122B9 7508                <1> 		jnz	short shintv_1 ; set (for user call service)
  1183                              <1> 		
  1184                              <1> 		; 18/03/2017
  1185 000122BB 81C3[7C380100]      <1> 		add	ebx, IRQ_list ; reset to default interrupt list
  1186 000122C1 EB06                <1> 		jmp	short shintv_2
  1187                              <1> shintv_1:
  1188 000122C3 81C3[EA220100]      <1> 		add	ebx, IRQ_u_list
  1189                              <1> shintv_2:	
  1190 000122C9 8B13                <1> 		mov	edx, [ebx] ; IRQ handler address
  1191                              <1> 		
  1192                              <1> 		; 03/03/2017
  1193 000122CB D0E0                <1> 		shl	al, 1 ; IRQ number * 8 
  1194                              <1> 		; 18/03/2017
  1195 000122CD 0FB6F8              <1> 		movzx	edi, al 
  1196 000122D0 81C7[A0750100]      <1> 		add	edi, idt + (8*32) ; IRQ 0 offset = idt + 256
  1197                              <1> 		
  1198 000122D6 89D0                <1> 		mov	eax, edx ; IRQ handler address
  1199 000122D8 BB00000800          <1> 		mov	ebx, 80000h
  1200                              <1> 
  1201                              <1> 		;mov	edx, eax
  1202 000122DD 66BA008E            <1> 		mov	dx, 8E00h
  1203 000122E1 6689C3              <1> 		mov	bx, ax
  1204 000122E4 89D8                <1> 		mov	eax, ebx ; /* selector = 0x0008 = cs */
  1205                              <1>        			         ; /* interrupt gate - dpl=0, present */
  1206 000122E6 AB                  <1> 		stosd	; selector & offset bits 0-15 	
  1207 000122E7 8917                <1> 		mov	[edi], edx ; attributes & offset bits 16-23
  1208                              <1> 
  1209 000122E9 C3                  <1> 		retn
  1210                              <1> IRQ_u_list:
  1211                              <1> 		; 28/02/2017
  1212 000122EA [7B090000]          <1> 		dd	timer_int
  1213 000122EE [D9100000]          <1> 		dd	kb_int
  1214 000122F2 [5E0B0000]          <1> 		dd	irq2
  1215 000122F6 [2A230100]          <1> 		dd	IRQ_service3
  1216 000122FA [34230100]          <1> 		dd	IRQ_service4
  1217 000122FE [3E230100]          <1> 		dd	IRQ_service5
  1218 00012302 [0C4E0000]          <1> 		dd	fdc_int	
  1219 00012306 [48230100]          <1> 		dd	IRQ_service7
  1220 0001230A [E60A0000]          <1> 		dd	rtc_int
  1221 0001230E [52230100]          <1> 		dd	IRQ_service9
  1222 00012312 [5C230100]          <1> 		dd	IRQ_service10
  1223 00012316 [66230100]          <1> 		dd	IRQ_service11
  1224 0001231A [70230100]          <1> 		dd	IRQ_service12
  1225 0001231E [7A230100]          <1> 		dd	IRQ_service13
  1226 00012322 [8E560000]          <1> 		dd	hdc1_int
  1227 00012326 [B1560000]          <1> 		dd	hdc2_int
  1228                              <1> 
  1229                              <1> 		; 03/03/2017
  1230                              <1> 		; 27/02/2017
  1231                              <1> IRQ_service3:
  1232 0001232A 36C605[AC890100]03  <1> 		mov	byte [ss:IRQnum], 3
  1233 00012332 EB4E                <1> 		jmp	short IRQ_service
  1234                              <1> IRQ_service4:
  1235 00012334 36C605[AC890100]04  <1> 		mov	byte [ss:IRQnum], 4
  1236 0001233C EB44                <1> 		jmp	short IRQ_service
  1237                              <1> IRQ_service5:
  1238 0001233E 36C605[AC890100]05  <1> 		mov	byte [ss:IRQnum], 5
  1239 00012346 EB3A                <1> 		jmp	short IRQ_service
  1240                              <1> IRQ_service7:
  1241 00012348 36C605[AC890100]07  <1> 		mov	byte [ss:IRQnum], 7
  1242 00012350 EB30                <1> 		jmp	short IRQ_service
  1243                              <1> IRQ_service9:
  1244 00012352 36C605[AC890100]09  <1> 		mov	byte [ss:IRQnum], 9
  1245 0001235A EB26                <1> 		jmp	short IRQ_service
  1246                              <1> IRQ_service10:
  1247 0001235C 36C605[AC890100]0A  <1> 		mov	byte [ss:IRQnum], 10
  1248 00012364 EB1C                <1> 		jmp	short IRQ_service
  1249                              <1> IRQ_service11:
  1250 00012366 36C605[AC890100]0B  <1> 		mov	byte [ss:IRQnum], 11
  1251 0001236E EB12                <1> 		jmp	short IRQ_service
  1252                              <1> IRQ_service12:
  1253 00012370 36C605[AC890100]0C  <1> 		mov	byte [ss:IRQnum], 12
  1254 00012378 EB08                <1> 		jmp	short IRQ_service
  1255                              <1> IRQ_service13:
  1256 0001237A 36C605[AC890100]0D  <1> 		mov	byte [ss:IRQnum], 13
  1257                              <1> 		;jmp	short IRQ_service
  1258                              <1> IRQ_service:
  1259                              <1> 		; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  1260                              <1> 		; 13/06/2017
  1261                              <1> 		; 11/06/2017
  1262                              <1> 		; 10/06/2017
  1263                              <1> 		; 01/03/2017, 04/03/2017
  1264                              <1> 		; 27/02/2017, 28/02/2017
  1265 00012382 1E                  <1> 		push	ds
  1266 00012383 06                  <1> 		push	es
  1267 00012384 0FA0                <1> 		push	fs
  1268 00012386 0FA8                <1> 		push	gs
  1269                              <1> 
  1270 00012388 60                  <1> 		pushad	; eax,ecx,edx,ebx,esp,ebp,esi,edi
  1271 00012389 66B91000            <1> 		mov     cx, KDATA
  1272 0001238D 8ED9                <1>         	mov     ds, cx
  1273 0001238F 8EC1                <1>         	mov     es, cx
  1274 00012391 8EE1                <1>         	mov     fs, cx
  1275 00012393 8EE9                <1>         	mov     gs, cx
  1276                              <1> 
  1277 00012395 0F20D8              <1> 		mov	eax, cr3
  1278 00012398 A3[A8890100]        <1> 		mov	[IRQ_cr3], eax
  1279                              <1> 
  1280 0001239D A1[88770100]        <1> 		mov	eax, [k_page_dir]
  1281 000123A2 0F22D8              <1> 		mov	cr3, eax 
  1282                              <1> 
  1283 000123A5 A0[AC890100]        <1> 		mov	al, [IRQnum]
  1284                              <1> 
  1285                              <1> 		;mov	cl, [sysflg]
  1286                              <1> 		;mov	[u.r_mode], cl  ; system (0) or user mode (FFh) 
  1287                              <1> IRQsrv_0:
  1288 000123AA 0FB6D8              <1> 		movzx	ebx, al
  1289 000123AD 8A9B[B4370100]      <1> 		mov	bl, [ebx+IRQenum] ; IRQ (available) index number + 1
  1290                              <1> 		; 01/03/2017
  1291 000123B3 FECB                <1> 		dec	bl  ; IRQ index number, 0 to 8
  1292                              <1> 		;js	IRQsrv_5 ; not available to use here!?
  1293                              <1> 		; 29/07/2022
  1294 000123B5 785E                <1> 		js	short IRQsrv_j5  ; (jump to IRQsrv_5)		
  1295                              <1> 		;		 
  1296 000123B7 80BB[72890100]80    <1> 		cmp	byte [ebx+IRQ.method], 80h ; using by a dev or kernel? 
  1297 000123BE 7205                <1> 		jb	short IRQsrv_1 ; no
  1298                              <1> 
  1299                              <1> 		; If the IRQ service is already owned by TRDOS 386 kernel
  1300                              <1> 		;	 or a Device driver
  1301                              <1> 		; we need to call 'dev_IRQ_service'
  1302                              <1> 
  1303                              <1> 		; IRQ number in AL
  1304 000123C0 E80E010000          <1> 		call	dev_IRQ_service	 ; IRQ service for device drivers	
  1305                              <1> 		; IRQ number in AL
  1306                              <1> IRQsrv_1:		
  1307                              <1> 		; check user callback service status
  1308                              <1> 		; AL = IRQ number
  1309                              <1> 		; EBX = IRQ (Available) Index number
  1310                              <1> 
  1311 000123C5 A2[93010300]        <1> 		mov	[u.irqwait], al ; set waiting IRQ flag
  1312                              <1> 
  1313 000123CA 8A83[60890100]      <1> 		mov	al, [ebx+IRQ.owner]
  1314 000123D0 20C0                <1> 		and	al, al
  1315                              <1> 		;jz	IRQsrv_5 ; it is not owned by a user/proc
  1316                              <1> 		; 29/07/2022
  1317 000123D2 7441                <1> 		jz	short IRQsrv_j5  ; (jump to IRQsrv_5)
  1318                              <1> 
  1319                              <1> 		; 03/03/2017
  1320 000123D4 89DA                <1> 		mov	edx, ebx
  1321 000123D6 C0E202              <1> 		shl	dl, 2
  1322 000123D9 8B92[84890100]      <1> 		mov	edx, [edx+IRQ.addr] ; S.R.B. or Callback service addr
  1323                              <1> 		
  1324 000123DF 8AA3[72890100]      <1> 		mov	ah, [ebx+IRQ.method]
  1325 000123E5 F6C401              <1> 		test	ah, 1
  1326 000123E8 7530                <1> 		jnz	short IRQsrv_4 ; Callback service method
  1327                              <1> 
  1328                              <1> 		; Signal Response Byte method
  1329                              <1> 		;mov	edx, [edx+IRQ.addr] ; Signal Response Byte address
  1330                              <1> 		;			    ; (Physical address, non-swappable) 	
  1331 000123EA 80E402              <1> 		and	ah, 2 ; bit 1, (S.R.B.) counter (auto increment) method
  1332 000123ED 8AA3[7B890100]      <1> 		mov	ah, [ebx+IRQ.srb] ; Signal Response Byte value
  1333 000123F3 7408                <1> 		jz	short IRQsrv_2 ; fixed S.R.B. value
  1334                              <1> 		; counter method (auto increment)
  1335 000123F5 FEC4                <1> 		inc	ah
  1336 000123F7 88A3[7B890100]      <1> 		mov	[ebx+IRQ.srb], ah ; next (count) number
  1337                              <1> IRQsrv_2:
  1338 000123FD 8822                <1> 		mov	[edx], ah ; put S.R.B. val to the user's S.R.B. addr
  1339 000123FF C605[93010300]00    <1> 		mov	byte [u.irqwait], 0 ; clear waiting IRQ flag
  1340                              <1> 
  1341 00012406 3A05[6D010300]      <1> 		cmp	al, [u.uno]
  1342                              <1> 		;je	IRQsrv_5 ; the owner is current user/process
  1343                              <1> 		; 29/07/2022
  1344 0001240C 7407                <1> 		je	short IRQsrv_j5  ; (jump to IRQsrv_5)
  1345                              <1> IRQsrv_3:
  1346                              <1> 		; the owner is not current user/process
  1347                              <1> 		; AL = process number
  1348 0001240E B202                <1> 		mov	dl, 2 ; priority, 2 = event (high)	
  1349 00012410 E848FAFFFF          <1> 		call	set_run_sequence
  1350                              <1> 
  1351                              <1> 		; [u.irqwait] = waiting IRQ number for callback service
  1352                              <1> IRQsrv_j5:		; 29/07/2022
  1353 00012415 E998000000          <1> 		jmp	IRQsrv_5
  1354                              <1> IRQsrv_4:
  1355 0001241A 3A05[6D010300]      <1> 		cmp	al, [u.uno]  ; is the owner is current user/process?
  1356 00012420 75EC                <1> 		jne	short IRQsrv_3 ; no !
  1357                              <1> 
  1358                              <1> 		; Check if an IRQ callback service already in progress
  1359 00012422 803D[94010300]00    <1> 		cmp	byte [u.r_lock], 0
  1360                              <1> 		;ja	IRQsrv_5 ; nothing to do !  
  1361                              <1> 				     ; (we need to complete prev callback)
  1362                              <1> 		; 29/07/2022
  1363 00012429 77EA                <1> 		ja	short IRQsrv_j5  ; (jump to IRQsrv_5)
  1364                              <1> 
  1365 0001242B 803D[90010300]00    <1> 		cmp	byte [u.t_lock], 0
  1366 00012432 777E                <1> 		ja	short IRQsrv_5 ; nothing to do !  
  1367                              <1> 				     ; (we need to complete timer callback)
  1368                              <1> 
  1369                              <1> 		; 04/03/2017
  1370 00012434 C605[93010300]00    <1> 		mov	byte [u.irqwait], 0 ; reset/clear waiting IRQ flag
  1371                              <1> 
  1372 0001243B FE05[94010300]      <1> 		inc	byte [u.r_lock] ; 'IRQ callback service in progress' flag
  1373                              <1> 
  1374 00012441 8A0D[10010300]      <1> 		mov	cl, [sysflg]   ; (system call) mode flag (kernel/user)
  1375 00012447 880D[95010300]      <1> 		mov	[u.r_mode], cl ; system mode (0) or user mode (FFh)
  1376                              <1> 
  1377                              <1> 		; 
  1378 0001244D 8B2D[24770100]      <1> 		mov	ebp, [tss.esp0] ; kernel stack address (for ring 0)
  1379 00012453 83ED14              <1> 		sub	ebp, 20		; eip, cs, eflags, esp, ss
  1380 00012456 892D[14010300]      <1> 	 	mov	[u.sp], ebp
  1381 0001245C 8925[18010300]      <1> 		mov	[u.usp], esp
  1382                              <1> 
  1383                              <1> 		;or	word [ebp+8], 200h ; 22/01/2017, force enabling interrupts
  1384                              <1> 
  1385 00012462 8B44241C            <1> 		mov	eax, [esp+28] ; pushed eax
  1386 00012466 A3[1C010300]        <1> 		mov	[u.r0], eax
  1387                              <1> 
  1388 0001246B E8A5E7FFFF          <1> 		call	wswap ; save user's registers & status
  1389                              <1> 
  1390                              <1> 		; software int is in ring 0 but IRQ handler must return to ring 3
  1391                              <1> 		; so, ring 3 return address and stack registers
  1392                              <1> 		; (eip, cs, eflags, esp, ss) 
  1393                              <1> 		; must be copied to IRQ handler return
  1394                              <1> 		; eip will be replaced by callback service routine address
  1395                              <1> 
  1396 00012470 C605[10010300]FF    <1> 		mov	byte [sysflg], 0FFh ; user mode
  1397                              <1> 
  1398                              <1> 		; system mode (system call)
  1399                              <1> 		;mov	ebp, [u.sp] ; EIP (u), CS (UCODE), EFLAGS (u),
  1400                              <1> 				    ; ESP (u), SS (UDATA)
  1401                              <1> 
  1402 00012477 8B4510              <1> 		mov	eax, [ebp+16]	; SS (UDATA)
  1403 0001247A 89E6                <1> 		mov	esi, esp
  1404 0001247C 50                  <1> 		push	eax
  1405 0001247D 50                  <1> 		push	eax
  1406 0001247E 89E7                <1> 		mov	edi, esp
  1407 00012480 893D[18010300]      <1> 		mov	[u.usp], edi
  1408 00012486 B908000000          <1> 		mov	ecx, ((ESPACE/4) - 4) ; except DS, ES, FS, GS
  1409 0001248B F3A5                <1> 		rep	movsd
  1410 0001248D B104                <1> 		mov	cl, 4	
  1411 0001248F F3AB                <1> 		rep	stosd
  1412 00012491 893D[14010300]      <1> 		mov	[u.sp], edi
  1413 00012497 89EE                <1> 		mov	esi, ebp
  1414 00012499 B105                <1> 		mov	cl, 5 ; EIP (u), CS (UCODE), EFLAGS (u), ESP (u), SS (UDATA)
  1415 0001249B F3A5                <1> 		rep	movsd
  1416                              <1> 		;
  1417                              <1> 
  1418 0001249D 8B0D[74010300]      <1> 		mov	ecx, [u.pgdir]
  1419 000124A3 890D[A8890100]      <1> 		mov	[IRQ_cr3], ecx
  1420                              <1> 
  1421                              <1> set_IRQ_callback_addr:
  1422                              <1> 		;
  1423                              <1> 		; This routine sets return address
  1424                              <1> 		; to start of user's interrupt
  1425                              <1> 		; service (callback) address
  1426                              <1> 		;
  1427                              <1> 		; INPUT:
  1428                              <1> 		;	EDX = callback routine/service address
  1429                              <1> 		;	      (virtual, not physical address!)	
  1430                              <1> 		;	[u.sp] = kernel stack, points to
  1431                              <1> 		;		 user's EIP,CS,EFLAGS,ESP,SS
  1432                              <1> 		;		 registers.
  1433                              <1> 		; OUTPUT:
  1434                              <1> 		;	EIP (user) = callback (service) address
  1435                              <1> 		;	CS (user) = UCODE
  1436                              <1> 		;	EFLAGS (user) = flags before callback 	 
  1437                              <1> 		;       ESP (user) = ESP-4 (user, before callback) 
  1438                              <1> 		;	[ESP](user) = EIP (user) before callback
  1439                              <1> 		;
  1440                              <1> 		; Note: If CPU was in user mode while entering 
  1441                              <1> 		;	the timer interrupt service routine,
  1442                              <1> 		;	'IRET' will get return to callback routine
  1443                              <1> 		;	immediately. If CPU was in system/kernel mode  
  1444                              <1> 		;	'iret' will get return to system call and
  1445                              <1> 		;	then, callback routine will be return address
  1446                              <1> 		;	from system call. (User's callback/service code
  1447                              <1> 		;	will be able to return to normal return address
  1448                              <1> 		;	via a 'sysrele' system call at the end.) 
  1449                              <1> 		;
  1450                              <1> 		; Note: User's IRQ callback service code must be ended
  1451                              <1> 		;	with a 'sysrele' system call !
  1452                              <1> 		;
  1453                              <1> 		;	For example:
  1454                              <1> 		;
  1455                              <1> 		;	audio_IRQ_callback:
  1456                              <1> 		;	    ...	 
  1457                              <1> 		;	    <load DMA buffer with audio data>
  1458                              <1> 		;	    ...
  1459                              <1> 		;	    mov eax, 39 ; 'sysrele'
  1460                              <1> 		;	    int 40h ; TRDOS 386 system call (interrupt)		
  1461                              <1> 		;
  1462                              <1> 		
  1463                              <1> 		;mov	edx, [edx+IRQ.addr] ; Callback service address
  1464                              <1> 		;			    ; (Virtual address)
  1465                              <1> 		
  1466 000124A9 8B2D[14010300]      <1> 		mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
  1467 000124AF 895500              <1> 		mov	[ebp], edx
  1468                              <1> IRQsrv_5:
  1469                              <1> 		; EOI & return
  1470                              <1> 		; 01/08/2020
  1471                              <1> 		; 11/06/2017
  1472                              <1> 		; 10/06/2017 
  1473                              <1> 		;mov	al, [IRQnum]
  1474 000124B2 B020                <1> 		mov	al, 20h ; 01/08/2020
  1475 000124B4 FA                  <1> 		cli
  1476                              <1> 		;cmp	al, 7
  1477 000124B5 803D[AC890100]07    <1> 		cmp	byte [IRQnum], 7 ; 01/08/2020	
  1478 000124BC 7602                <1> 		jna	short IRQsrv_6
  1479                              <1> 		;
  1480                              <1> 		;;mov	al, EOI	; end of interrupt
  1481                              <1> 		;mov	al, 20h ; 01/08/2020
  1482                              <1> 		;cli		; disable interrupts till stack cleared
  1483                              <1> 		;out	INTB00, al ; For controll2 #2
  1484 000124BE E6A0                <1> 		out	0A0h, al
  1485                              <1> IRQsrv_6:
  1486                              <1> 		;mov	byte [IRQnum], 0 ; reset
  1487                              <1> 		;;mov	al, EOI	; end of interrupt
  1488                              <1> 		;mov	al, 20h ; 01/08/2020
  1489                              <1> 		;cli		; disable interrupts till stack cleared
  1490                              <1> 		;out	INTA00, al ; end of interrupt to 8259 - 1
  1491 000124C0 E620                <1> 		out	20h, al	
  1492                              <1> IRQsrv_7:	
  1493                              <1> 		;; 13/06/2017
  1494                              <1> 		;or	word [ebp+8], 200h ; force enabling interrupts
  1495                              <1> 		;
  1496 000124C2 8B0D[A8890100]      <1> 		mov 	ecx, [IRQ_cr3]	; previous content of cr3 register
  1497 000124C8 0F22D9              <1>  		mov	cr3, ecx	; restore cr3 register content
  1498                              <1> 		;
  1499 000124CB 61                  <1> 		popad ; edi,esi,ebp,(icrement esp by 4),ebx,edx,ecx,eax
  1500                              <1> 		;
  1501 000124CC 0FA9                <1> 		pop	gs
  1502 000124CE 0FA1                <1> 		pop	fs
  1503 000124D0 07                  <1> 		pop	es
  1504 000124D1 1F                  <1> 		pop	ds
  1505                              <1> 		;
  1506 000124D2 CF                  <1> 		iretd	; return from interrupt
  1507                              <1> 
  1508                              <1> ; 17/04/2021
  1509                              <1> ; ('get_device_number' procedure is disabled as temporary)
  1510                              <1> 
  1511                              <1> ;get_device_number:
  1512                              <1> ;		; 08/10/2016
  1513                              <1> ;		; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  1514                              <1> ;		;
  1515                              <1> ;		; This procedure compares name of requested
  1516                              <1> ;		; device with kernel device names and
  1517                              <1> ;		; installable device names. If names match, 
  1518                              <1> ;		; the relevant device index (entry) number 
  1519                              <1> ;		; will be returned the caller (sysopen) 
  1520                              <1> ;		; for the requested device.
  1521                              <1> ;		;
  1522                              <1> ;		; NOTE: Installable device drivers must
  1523                              <1> ;		; be loaded before using 'sysopen'
  1524                              <1> ;		; (opendev) system call.
  1525                              <1> ;		;
  1526                              <1> ;		; INPUT:
  1527                              <1> ;		;    ESI = device name address (ASCIIZ)
  1528                              <1> ;		;         (in kernel's memory space)  
  1529                              <1> ;  		;    max name length = 8 without '/dev/')
  1530                              <1> ;		;    Device name will be capitalized 
  1531                              <1> ;		;    and if there is, '/dev/' will be
  1532                              <1> ;		;    removed from name before comparising)
  1533                              <1> ;		;
  1534                              <1> ;		; OUTPUT:
  1535                              <1> ;		;    cf = 0 -> 
  1536                              <1> ;		;      EAX (AL) = device entry/index number 	 	
  1537                              <1> ;		;    cf = 1 -> device not found (installed)
  1538                              <1> ;		;	       or invalid device name
  1539                              <1> ;		;	       (AL=0)
  1540                              <1> ;		;    device_name = device name address (asciiz)
  1541                              <1> ;			;
  1542                              <1> ;		; Modified registers: EAX, EBX, ESI, EDI
  1543                              <1> ;
  1544                              <1> ;		mov	edi, device_name
  1545                              <1> ;		call 	lodsb_capitalize
  1546                              <1> ;		mov	ah, al
  1547                              <1> ;		cmp	al, '/'
  1548                              <1> ;		jne	short gdn_1
  1549                              <1> ;		mov	edi, device_name
  1550                              <1> ;		call 	lodsb_capitalize
  1551                              <1> ;gdn_0:
  1552                              <1> ;		and	al, al ; 0 ?
  1553                              <1> ;		jz	short gdn_err ; null name after '/'
  1554                              <1> ;gdn_1:
  1555                              <1> ;		cmp	al, 'D'
  1556                              <1> ;		jne	short gdn_2
  1557                              <1> ;		call 	lodsb_capitalize
  1558                              <1> ;		cmp	al, 'E'
  1559                              <1> ;		jne	short gdn_2
  1560                              <1> ;		call 	lodsb_capitalize
  1561                              <1> ;		cmp	al, 'V'
  1562                              <1> ;		jne	short gdn_2			
  1563                              <1> ;		lodsb
  1564                              <1> ;		cmp	al, '/'
  1565                              <1> ;		je	short gdn_4
  1566                              <1> ;gdn_2:
  1567                              <1> ;		cmp	ah, '/'
  1568                              <1> ;		jne	short gdn_5
  1569                              <1> ;gdn_err:		
  1570                              <1> ;		; invalid device name or device not found
  1571                              <1> ;		xor	eax, eax ; 0
  1572                              <1> ;		stc
  1573                              <1> ;		retn
  1574                              <1> ;gdn_3:
  1575                              <1> ;		cmp	al, '/'
  1576                              <1> ;		jne	short gdn_5
  1577                              <1> ;gdn_4:
  1578                              <1> ;		mov	edi, device_name
  1579                              <1> ;		jmp	short gdn_6
  1580                              <1> ;gdn_5:
  1581                              <1> ;		cmp	al, 0
  1582                              <1> ;		je	short gdn_7
  1583                              <1> ;gdn_6:
  1584                              <1> ;		call	lodsb_capitalize
  1585                              <1> ;		cmp	edi, device_name + 8
  1586                              <1> ;		jb	short gdn_3
  1587                              <1> ;		cmp	al, 0
  1588                              <1> ;		jne	short gdn_err
  1589                              <1> ;		cmp	edi, device_name + 1
  1590                              <1> ;		jna	short gdn_err ; null name after '/'
  1591                              <1> ;gdn_7:
  1592                              <1> ;		stosb
  1593                              <1> ;		; zero padding ("NAME",0,0,0,0)
  1594                              <1> ;		cmp	edi, device_name + 8
  1595                              <1> ;		jb	short gdn_7
  1596                              <1> ;gdn_8:
  1597                              <1> ;		; search for kernel device names
  1598                              <1> ;		mov	esi, device_name 
  1599                              <1> ;		mov	edi, KDEV_NAME
  1600                              <1> ;		xor	eax, eax
  1601                              <1> ;gdn_9:
  1602                              <1> ;		cmpsd	
  1603                              <1> ;		jne	short gdn_10
  1604                              <1> ;		cmpsd
  1605                              <1> ;		jne	short gdn_11
  1606                              <1> ;		jmp	short gdn_17 ; match
  1607                              <1> ;gdn_10:
  1608                              <1> ;		cmpsd  ; add esi, 4 & add edi, 4
  1609                              <1> ;gdn_11:
  1610                              <1> ;		mov	esi, device_name
  1611                              <1> ;		inc	al
  1612                              <1> ;		cmp	al, NumOfKernelDevNames
  1613                              <1> ;		jb	short gdn_9
  1614                              <1> ;gdn_12:
  1615                              <1> ;		; search for installable device names
  1616                              <1> ;		; esi = offset device_name 
  1617                              <1> ;		mov	edi, IDEV_NAME
  1618                              <1> ;		sub	al, al ; 0
  1619                              <1> ;gdn_13:
  1620                              <1> ;		cmpsd	
  1621                              <1> ;		jne	short gdn_14
  1622                              <1> ;		cmpsd
  1623                              <1> ;		jne	short gdn_15
  1624                              <1> ;		jmp	short gdn_19 ; match
  1625                              <1> ;gdn_14:
  1626                              <1> ;		cmpsd  ; add esi, 4 & add edi, 4
  1627                              <1> ;gdn_15:
  1628                              <1> ;		mov	esi, device_name
  1629                              <1> ;		inc	al
  1630                              <1> ;		cmp	al, NumOfInstallableDevices
  1631                              <1> ;		jb	short gdn_13
  1632                              <1> ;
  1633                              <1> ;gdn_16: 	; error: invalid device name (not found) !
  1634                              <1> ;		xor	al, al
  1635                              <1> ;		stc
  1636                              <1> ;		retn
  1637                              <1> ;
  1638                              <1> ;gdn_17:	; name match (with one of kernel device names)
  1639                              <1> ;		;
  1640                              <1> ;		; convert KDEV_NAME index to 
  1641                              <1> ;		; KDEV_NUMBER index
  1642                              <1> ;		; (different names are used for same devices)
  1643                              <1> ;		; (example: "COM1" & "TTY8" = device number 18) 
  1644                              <1> ;		mov	ebx, eax ; < 256
  1645                              <1> ;		mov	al, [KDEV_NUMBER+ebx]
  1646                              <1> ;
  1647                              <1> ;		; check if empty dev entry in the list
  1648                              <1> ;		cmp	byte [DEV_OPENMODE+eax], 0
  1649                              <1> ;		ja	short gdn_18 ; it must be already set
  1650                              <1> ;
  1651                              <1> ;		; (re)set device name and access flags
  1652                              <1> ;		; (remain open work will be easy after that)
  1653                              <1> ;		; (NOTE: here, data will be copied to bss section)
  1654                              <1> ;		mov	bl, al
  1655                              <1> ;		sub	edi, 8 ; kernel device name address (data)
  1656                              <1> ;		shl	bx, 2 
  1657                              <1> ;		mov	[DEV_NAME_PTR+ebx], edi ; (all) device names
  1658                              <1> ;		mov	bl, [KDEV_ACCESS+eax] ; kernel dev list (data)
  1659                              <1> ;		mov	[DEV_ACCESS+eax], bl ; (all) device list (bss)
  1660                              <1> ;gdn_18:
  1661                              <1> ;		inc	al ; 1 to NumOfKernelDevNames (<=7Fh)
  1662                              <1> ;		; eax = device index/entry number
  1663                              <1> ;		retn		
  1664                              <1> ;
  1665                              <1> ;gdn_19:	; name match (with one of installable device names)
  1666                              <1> ;		;
  1667                              <1> ;		; al = 0 to NumOfInstallableDevices - 1 (<=7Fh)
  1668                              <1> ;
  1669                              <1> ;		mov	ebx, eax
  1670                              <1> ;		add	bl, NumOfKernelDevices 	; < NUMOFDEVICES	
  1671                              <1> ;
  1672                              <1> ;		; check if empty dev entry in the list
  1673                              <1> ;		cmp	byte [DEV_OPENMODE+ebx], 0
  1674                              <1> ;		ja	short gdn_20 ; it must be already set
  1675                              <1> ;
  1676                              <1> ;		; (re)set device name and access flags
  1677                              <1> ;		; (remain open work will be easy after that)
  1678                              <1> ;		sub	edi, 8 ; installable device name address
  1679                              <1> ;		shl	bx, 2 ;*4
  1680                              <1> ;		mov	[DEV_NAME_PTR+ebx], edi ; (all) device names
  1681                              <1> ;		shr	bx, 2
  1682                              <1> ;		mov	al, [IDEV_FLAGS+eax] ; installable dev list
  1683                              <1> ;		mov	[DEV_ACCESS+ebx], al ; (all) device list
  1684                              <1> ;gdn_20:	
  1685                              <1> ;		mov	al, bl
  1686                              <1> ;		; eax = device index/entry number ; < NUMOFDEVICES  
  1687                              <1> ;		retn
  1688                              <1> 
  1689                              <1> ;lodsb_capitalize:
  1690                              <1> ;	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  1691                              <1> ;	; INPUT -> [esi] = character
  1692                              <1> ;	;          edi = destination
  1693                              <1> ;	; OUTPUT -> AL contains capitalized character
  1694                              <1> ;	;	   esi = esi+1
  1695                              <1> ;	;	   edi = edi+1	
  1696                              <1> ;	; 
  1697                              <1> ;	lodsb	
  1698                              <1> ;	cmp	al, 61h
  1699                              <1> ;    	jb	short lodsb_cap_retn
  1700                              <1> ;     	cmp	al, 7Ah
  1701                              <1> ;     	ja	short lodsb_cap_retn
  1702                              <1> ;     	and	al, 0DFh
  1703                              <1> ;lodsb_cap_retn:
  1704                              <1> ;	stosb
  1705                              <1> ;	retn
  1706                              <1> 
  1707                              <1> ; 17/04/2021
  1708                              <1> ; ('device_open' procedure is disabled as temporary)
  1709                              <1> 
  1710                              <1> ;device_open:
  1711                              <1> ;	; 08/10/2016 - TRDOS 386 (TRDOS v2.0)
  1712                              <1> ;	; Complete device opening work for sysopen (device)
  1713                              <1> ;	;
  1714                              <1> ;	; INPUT -> 
  1715                              <1> ;	;	EAX = Device Number (AL)
  1716                              <1> ;	;        CL = Open mode (1 = read, 2 = write)
  1717                              <1> ;	;	 CH = Device access byte (bit 0 = 0)		
  1718                              <1> ;	; OUTPUT ->
  1719                              <1> ;	;	EAX = Device Number	
  1720                              <1> ;	;	CF = 0 -> device has been opened
  1721                              <1> ;	;	CF = 1 -> device could not be opened
  1722                              <1> ;	;
  1723                              <1> ;	;  Modified registers: ebx, (edx, ecx, esi, edi, ebp)
  1724                              <1> ;	;
  1725                              <1> ;
  1726                              <1> ;	mov	ebx, eax
  1727                              <1> ;	shl	bx, 2 ; *4
  1728                              <1> ;
  1729                              <1> ;	test	ch, 80h ; bit 7, installable device driver flag
  1730                              <1> ;	jz	short d_open_2 ; Kernel device
  1731                              <1> ;	; installable device
  1732                              <1> ;d_open_1:
  1733                              <1> ;       jmp	dword [ebx+IDEV_OADDR-4]
  1734                              <1> ;d_open_2:
  1735                              <1> ;	jmp	dword [ebx+KDEV_OADDR-4]
  1736                              <1> 
  1737                              <1> ; 17/04/2021
  1738                              <1> ; ('device_close' procedure is disabled as temporary)
  1739                              <1> 
  1740                              <1> ;device_close:
  1741                              <1> ;	; 08/10/2016 - TRDOS 386 (TRDOS v2.0)
  1742                              <1> ;	; Complete device closing work for sysclose (device)
  1743                              <1> ;	;
  1744                              <1> ;	; INPUT -> 
  1745                              <1> ;	;	EAX = Device Number (AL)
  1746                              <1> ;	;        CL = Open mode (1 = read, 2 = write)
  1747                              <1> ;	;	 CH = Device access byte (bit 0 = 0)		
  1748                              <1> ;	; OUTPUT ->
  1749                              <1> ;	;	EAX = Device Number	
  1750                              <1> ;	;	CF = 0 -> device has been closed
  1751                              <1> ;	;	CF = 1 -> device could not be closed
  1752                              <1> ;	;
  1753                              <1> ;	; Modified registers: ebx, (edx, ecx, esi, edi, ebp)
  1754                              <1> ;	;
  1755                              <1> ;
  1756                              <1> ;	mov	ebx, eax
  1757                              <1> ;	shl	bx, 2 ; *4
  1758                              <1> ;
  1759                              <1> ;	test	ch, 80h ; bit 7, installable device driver flag
  1760                              <1> ;	jz	short d_close_2 ; Kernel device
  1761                              <1> ;	; installable device
  1762                              <1> ;d_close_1:
  1763                              <1> ;       jmp	dword [ebx+IDEV_CADDR-4]
  1764                              <1> ;d_close_2:
  1765                              <1> ;	jmp	dword [ebx+KDEV_CADDR-4]	
  1766                              <1> 
  1767                              <1> ;rnull:
  1768                              <1> ;	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  1769                              <1> ;	; read null (read from null device)
  1770                              <1> ;	retn
  1771                              <1> 
  1772                              <1> ;wnull:
  1773                              <1> ;	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  1774                              <1> ;	; write null (write to null device)
  1775                              <1> ;	retn
  1776                              <1> 
  1777                              <1> dev_IRQ_service:
  1778                              <1> 	; 12/05/2017
  1779                              <1> 	; 13/04/2017
  1780                              <1> 	; 27/02/2017 - TRDOS 386 (TRDOS v2.0)
  1781                              <1> 	; INPUT ->
  1782                              <1> 	;	AL = IRQ Number (0 to 15)
  1783                              <1> 	;	
  1784 000124D3 53                  <1> 	push	ebx
  1785 000124D4 0FB6D8              <1> 	movzx	ebx, al
  1786 000124D7 C0E302              <1> 	shl	bl, 2 ; * 4	
  1787 000124DA 8B9B[20890100]      <1> 	mov	ebx, [ebx+DEV_INT_HNDLR]
  1788 000124E0 21DB                <1> 	and 	ebx, ebx
  1789 000124E2 7404                <1>         jz	short dIRQ_s_retn
  1790 000124E4 50                  <1> 	push	eax
  1791                              <1> 
  1792 000124E5 FFD3                <1> 	call	ebx
  1793                              <1> 
  1794 000124E7 58                  <1> 	pop	eax
  1795                              <1> dIRQ_s_retn:
  1796 000124E8 5B                  <1> 	pop	ebx
  1797 000124E9 C3                  <1> 	retn		
  1798                              <1> 
  1799                              <1> set_dev_IRQ_service:
  1800                              <1> 	; 09/08/2022
  1801                              <1> 	; 29/07/2022 (TRDOS 386 Kernel v2.0.5)
  1802                              <1> 	; 13/04/2017 - TRDOS 386 (TRDOS v2.0)
  1803                              <1> 	;
  1804                              <1> 	; Set Device Interrupt Service
  1805                              <1> 	;
  1806                              <1> 	; INPUT ->
  1807                              <1> 	;	AL = IRQ Number
  1808                              <1> 	;	EBX = Hardware Interrupt Service Address
  1809                              <1> 	;
  1810                              <1> 	; Note: There is not a validation check here
  1811                              <1> 	;	because this procedure is called by
  1812                              <1> 	;	TRDOS 386 kernel !
  1813                              <1> 	;       (Even if a device driver does not exist
  1814                              <1> 	;	this setting may be used by sysaudio
  1815                              <1> 	;	and other system calls for hardware
  1816                              <1> 	;	components which use IRQ method for I/O.)
  1817                              <1> 	;
  1818                              <1> 	;push	esi
  1819 000124EA 0FB6F0              <1> 	movzx	esi, al
  1820                              <1> 	;shl	si, 2 ; * 4	
  1821                              <1> 	; 09/08/2022
  1822 000124ED C1E602              <1> 	shl	esi, 2 ; * 4
  1823 000124F0 899E[20890100]      <1> 	mov	[esi+DEV_INT_HNDLR], ebx
  1824                              <1> 	;pop	esi
  1825 000124F6 C3                  <1> 	retn		
  1826                              <1> 
  1827                              <1> sysaudio: ; AUDIO FUNCTIONS
  1828                              <1> 	; 29/07/2022 (TRDOS 386 v2.0.5)
  1829                              <1> 	; 12/02/2021 (TRDOS 386 v2.0.3) 
  1830                              <1> 	; 28/07/2020
  1831                              <1> 	; 27/07/2020
  1832                              <1> 	; 10/10/2017
  1833                              <1> 	; 22/06/2017
  1834                              <1> 	; 28/05/2017, 04/06/2017, 05/06/2017, 10/06/2017
  1835                              <1> 	; 01/05/2017, 12/05/2017, 15/05/2017, 20/05/2017
  1836                              <1> 	; 21/04/2017, 22/04/2017, 23/04/2017, 24/04/2017
  1837                              <1> 	; 10/04/2017, 13/04/2017, 14/04/2017, 16/04/2017
  1838                              <1> 	; 03/04/2017 (VIA VT8237R)
  1839                              <1> 	; 01/04/2016 (trdosk6.s -> tdosk8.s)
  1840                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
  1841                              <1> 	;
  1842                              <1> 	; Inputs:
  1843                              <1> 	;
  1844                              <1> 	;	BH = 0 -> Beep (PC Speaker)
  1845                              <1> 	;	     BL = Duration Counter (1 for 1/64 second)
  1846                              <1> 	;	     CX = Frequency Divisor (1193180/Frequency)
  1847                              <1> 	;		 (1331 for 886 Hz)
  1848                              <1> 	;
  1849                              <1> 	;	01/04/2017	
  1850                              <1> 	;
  1851                              <1> 	; 	BH = 1 -> DETECT (& ENABLE) AUDIO DEVICE
  1852                              <1> 	;	     BL = 0 : PC SPEAKER
  1853                              <1> 	;		  1 : SOUND BLASTER 16
  1854                              <1> 	;		  2 : INTEL AC'97
  1855                              <1> 	;		  3 : VIA VT8237R (VT8233)			 				
  1856                              <1> 	;		  4 : INTEL HDA
  1857                              <1> 	;	      5-FEh : unknown/invalid
  1858                              <1> 	;	        ; 04/06/2017
  1859                              <1> 	;		FFh : Get current audio device id
  1860                              <1> 	;
  1861                              <1> 	; 	BH = 2 -> ALLOCATE AUDIO BUFFER (for user)
  1862                              <1> 	;		ECX = Audio Buffer Size (must be equal to
  1863                              <1> 	;		      the half of DMA buffer size) 
  1864                              <1> 	;		EDX = Virtual Address of the buffer
  1865                              <1> 	;		      (This is not DMA buffer!)
  1866                              <1> 	;
  1867                              <1> 	;	BH = 3 -> INITIALIZE AUDIO DEVICE
  1868                              <1> 	;	     BL = 0,2 -> for Signal Response Byte	 	
  1869                              <1> 	;	     	CL = Signal Response Byte Value (fixed)
  1870                              <1> 	;				if BL = 0
  1871                              <1> 	;	             auto increment of S.R.B. value
  1872                              <1> 	;			 	if BL = 2
  1873                              <1> 	;	        EDX = Signal Response (Return) Byte Address
  1874                              <1> 	;	     	   			
  1875                              <1> 	;	     BL = 1 for CallBack Method	 	
  1876                              <1> 	;	    	EDX = CallBack Service Address (Virtual)
  1877                              <1> 	;
  1878                              <1> 	;	     BL > 2 -> invalid function	
  1879                              <1> 	;
  1880                              <1> 	;	    (Audio buffer must be allocated before
  1881                              <1> 	;	     initialization.) 		
  1882                              <1> 	;
  1883                              <1> 	;	BH = 4 -> START TO PLAY
  1884                              <1> 	;	     BL = Mode
  1885                              <1> 	;		  Bit 0 = mono/stereo (1 = stereo)		
  1886                              <1> 	;		  Bit 1 = 8 bit / 16 bit (1 = 16 bit)
  1887                              <1> 	;	     CX = Sampling Rate (Hz)
  1888                              <1> 	;
  1889                              <1> 	;	BH = 5 -> PAUSE
  1890                              <1> 	;	     BL = Any
  1891                              <1> 	;
  1892                              <1> 	;	BH = 6 -> CONTINUE TO PLAY
  1893                              <1> 	;	     BL = Any
  1894                              <1> 	;
  1895                              <1> 	;	BH = 7 -> STOP
  1896                              <1> 	;	     BL = Any
  1897                              <1> 	;
  1898                              <1> 	;	BH = 8 -> RESET 
  1899                              <1> 	;	     BL = Any
  1900                              <1> 	;
  1901                              <1> 	;	BH = 9 -> CANCEL (CALLBACK or S.R.B. SERVICE)
  1902                              <1> 	;	     BL = Any	
  1903                              <1> 	;	
  1904                              <1> 	;	BH = 10 -> DEALLOCATE AUDIO BUFFER (for user)
  1905                              <1> 	;	     BL = Any
  1906                              <1> 	;
  1907                              <1> 	;	BH = 11 -> SET VOLUME LEVEL
  1908                              <1> 	;	     BL: (Bit 0 to 6)
  1909                              <1> 	;		  0 = Master (Playback, Lineout) volume
  1910                              <1> 	;	     CL = Left Channel Volume
  1911                              <1> 	;	     CH = Right Channel Volume
  1912                              <1> 	;	
  1913                              <1> 	;	     Note: If BL >= 80h (Bit 7 of BL is set),
  1914                              <1> 	;	     volume level will be set for next playing
  1915                              <1> 	;	     (actual volume level will not be changed
  1916                              <1> 	;	     immediately)	
  1917                              <1> 	;
  1918                              <1> 	;	BH = 12 -> DISABLE AUDIO DEVICE
  1919                              <1> 	;	     (reset audio device and unlink dma buffer)	
  1920                              <1> 	;	     BL = Any	  		  	  	
  1921                              <1> 	;
  1922                              <1> 	;    	12/05/2017
  1923                              <1> 	;	BH = 13 -> MAP DMA BUFFER TO USER
  1924                              <1> 	;	    (for direct access to system's dma buffer)
  1925                              <1> 	;
  1926                              <1> 	;	     ECX = map size in bytes 
  1927                              <1> 	;		  (will be rounded up to page borders)
  1928                              <1> 	;	     EDX = Virtual Address of the buffer
  1929                              <1> 	;		  (Will be rounded up to page borders)
  1930                              <1> 	;
  1931                              <1> 	;	05/06/2017	
  1932                              <1> 	;    	04/06/2017
  1933                              <1> 	;	BH = 14 -> GET AUDIO DEVICE INFO
  1934                              <1> 	;	     BL: 0 = Audio Controller Info
  1935                              <1> 	;	       > 0 = Invalid for now! 
  1936                              <1> 	;
  1937                              <1> 	;	22/06/2017	
  1938                              <1> 	;	BH = 15 -> GET CURRENT SOUND DATA (for graphics)
  1939                              <1> 	;	     BL: 0 -> PCM OUT data
  1940                              <1> 	;	       > 0 -> Invalid for now! 
  1941                              <1> 	;	     ECX = 0 -> Get DMA Buffer Pointer
  1942                              <1> 	;		 EDX = Not Used
  1943                              <1> 	;	     ECX > 0 -> Byte count for buffer (EDX)	 	
  1944                              <1> 	;	         EDX = Buffer Address (Virtual)	
  1945                              <1> 	;
  1946                              <1> 	;	10/10/2017	
  1947                              <1> 	;	BH = 16 -> UPDATE DMA BUFFER DATA
  1948                              <1> 	;		   (by using the Audio Buffer content)
  1949                              <1> 	;	     BL = 0 : Update dma half buffer in sequence
  1950                              <1> 	;		      (automatic destination)	
  1951                              <1> 	;		  1 : Update 1st half of the dma buffer
  1952                              <1> 	;		  2 : Update 2nd half of the dma buffer
  1953                              <1> 	;		  3-FEh: Invalid!
  1954                              <1> 	;		  FFh = Get current flag value
  1955                              <1> 	;			(Half buffer number -1)
  1956                              <1> 	;
  1957                              <1> 	;
  1958                              <1> 	; Outputs:
  1959                              <1> 	;
  1960                              <1> 	;	For BH = 0 -> Beep
  1961                              <1> 	;	    None
  1962                              <1> 	;
  1963                              <1> 	;	01/04/2017
  1964                              <1> 	;
  1965                              <1> 	; 	For BH = 1 -> DETECT (& ENABLE) AUDIO DEVICE
  1966                              <1> 	;	    AH = 0 : PC SPEAKER
  1967                              <1> 	;		 1 : SOUND BLASTER 16
  1968                              <1> 	;		 2 : INTEL AC'97
  1969                              <1> 	;		 3 : VIA VT8237R (VT8233)			 				
  1970                              <1> 	;		 4 : INTEL HDA
  1971                              <1> 	;	      5-FFh : unknown/invalid
  1972                              <1> 	;	    AL = mode status
  1973                              <1> 	;		 bit 0 = mono /stereo (1 = stereo)
  1974                              <1> 	;		 bit 1 = 8 bit / 16 bit ( 1 = 16 bit)
  1975                              <1> 	;	    04/06/2017
  1976                              <1> 	;	    EBX = PCI DEVICE/VENDOR ID (if >0)
  1977                              <1> 	;		 (BX = VENDOR ID) 
  1978                              <1> 	;	    (if CF = 1 -> Error code in EAX)
  1979                              <1> 	;
  1980                              <1> 	; 	For BH = 2 -> ALLOCATE AUDIO BUFFER (for user)
  1981                              <1> 	;	    EAX = Physical Address of the buffer
  1982                              <1> 	;	    (if CF = 1 -> Error code in EAX)
  1983                              <1> 	;
  1984                              <1> 	;	For BH = 3 -> INITIALIZE AUDIO DEVICE
  1985                              <1> 	;	    (if CF = 1 -> Error code in EAX)
  1986                              <1> 	;
  1987                              <1> 	;	For BH = 4 -> START TO PLAY
  1988                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
  1989                              <1> 	;
  1990                              <1> 	;	For BH = 5 -> PAUSE
  1991                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
  1992                              <1> 	;
  1993                              <1> 	;	For BH = 6 -> CONTINUE TO PLAY
  1994                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
  1995                              <1> 	;
  1996                              <1> 	;	For BH = 7 -> STOP
  1997                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  1998                              <1> 	;
  1999                              <1> 	;	For BH = 8 -> RESET 
  2000                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  2001                              <1> 	;
  2002                              <1> 	;	For BH = 9 -> CANCEL (CALLBACK or S.R.B. SERVICE)
  2003                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  2004                              <1> 	;	
  2005                              <1> 	;	For BH = 10 -> DEALLOCATE AUDIO BUFFER (for user)
  2006                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  2007                              <1> 	;
  2008                              <1> 	;	For BH = 11 -> SET VOLUME LEVEL
  2009                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  2010                              <1> 	;
  2011                              <1> 	;	For BH = 12 -> DISABLE AUDIO DEVICE
  2012                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  2013                              <1> 	; 
  2014                              <1> 	;    	12/05/2017
  2015                              <1> 	;	For BH = 13 -> MAP DMA BUFFER TO USER
  2016                              <1> 	;	    EAX = Physical Address of the buffer
  2017                              <1> 	;	    (if CF = 1 -> Error code in EAX)	
  2018                              <1> 	;
  2019                              <1> 	;    	04/06/2017
  2020                              <1> 	;	For BH = 14 -> GET AUDIO DEVICE INFO
  2021                              <1> 	;	(for BL = 0) ; 05/06/2017	
  2022                              <1> 	;	    EAX = IRQ Number in AL
  2023                              <1> 	;		  Audio Device Number in AH 
  2024                              <1> 	;	    EBX = DEV/VENDOR ID
  2025                              <1> 	;		 (DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
  2026                              <1> 	;	    ECX = BUS/DEV/FN 
  2027                              <1> 	;		 (00000000BBBBBBBBDDDDDFFF00000000)
  2028                              <1> 	;	    EDX = NABMBAR/NAMBAR (for AC97)
  2029                              <1> 	;		  (Low word, DX = NAMBAR address)
  2030                              <1> 	;	    EDX = Base IO Addr (DX) for SB16 & VT8233	  			  		
  2031                              <1> 	;	    (if CF = 1 -> Error code in EAX)	
  2032                              <1> 	;	                 (ERR_DEV_NOT_RDY = 15)  
  2033                              <1> 	;
  2034                              <1> 	;	22/06/2017	
  2035                              <1> 	;	For BH = 15 -> GET CURRENT SOUND DATA
  2036                              <1> 	;			 (for graphics)
  2037                              <1> 	;	(for BL = 0)
  2038                              <1> 	;	 If ECX input is 0 
  2039                              <1> 	;	    EAX = DMA Buffer Current Position (Offset)
  2040                              <1> 	;	 If ECX input >  0
  2041                              <1> 	;	    EAX = Actual transfer count 		 	
  2042                              <1> 	;	    (Sound samples will be copied from 
  2043                              <1> 	;	     Current DMA Buffer Position to EDX
  2044                              <1> 	;	     virtual address as EAX bytes.)
  2045                              <1> 	;	 ((If CF = 1 ->  Error code in EAX))
  2046                              <1> 	;
  2047                              <1> 	;
  2048                              <1> 	;	10/10/2017	
  2049                              <1> 	;	For BH = 16 -> UPDATE DMA BUFFER DATA
  2050                              <1> 	;	    EAX = 0, if the updated (or current)
  2051                              <1> 	;		     half buffer is DMA half buffer 1
  2052                              <1> 	;	    EAX = 1, if the updated (or current)
  2053                              <1> 	; 		     half buffer is DMA half buffer 2 	  	
  2054                              <1> 	;	    (If CF = 1 -> Error code in EAX)	
  2055                              <1> 	;	
  2056                              <1> 
  2057 000124F7 80FF11              <1> 	cmp	bh, AUDIO1L/4
  2058 000124FA 0F831FA8FFFF        <1> 	jnb	sysret
  2059                              <1> 
  2060 00012500 C0E702              <1> 	shl	bh, 2 ; *4	
  2061 00012503 0FB6F7              <1> 	movzx	esi, bh
  2062                              <1> 
  2063                              <1> 	; 22/04/2017
  2064 00012506 31C0                <1> 	xor	eax, eax
  2065 00012508 A3[1C010300]        <1> 	mov	[u.r0], eax  ; 0
  2066                              <1> 		
  2067 0001250D FF96[18250100]      <1> 	call	dword [esi+AUDIO1]
  2068                              <1> 	;jc	error
  2069 00012513 E907A8FFFF          <1> 	jmp	sysret	
  2070                              <1> 
  2071 00012518 [3A230000]          <1> AUDIO1:	dd	_beep ; 12/02/2021	
  2072                              <1> 	;dd	beep ; FUNCTION = 0 (bl = Duration Counter
  2073                              <1> 		     ; 		     cx = Frequency Divisor
  2074 0001251C [5C250100]          <1> 	dd	soundc_detect
  2075 00012520 [F8250100]          <1> 	dd	sound_alloc
  2076 00012524 [B6260100]          <1> 	dd	soundc_init
  2077 00012528 [64280100]          <1> 	dd	sound_play
  2078 0001252C [F7280100]          <1> 	dd	sound_pause
  2079 00012530 [21290100]          <1> 	dd	sound_continue
  2080 00012534 [4B290100]          <1> 	dd	sound_stop
  2081 00012538 [76290100]          <1> 	dd	soundc_reset
  2082 0001253C [A9290100]          <1> 	dd	soundc_cancel
  2083 00012540 [CF290100]          <1> 	dd	sound_dalloc
  2084 00012544 [FA290100]          <1> 	dd	sound_volume
  2085 00012548 [3A2A0100]          <1> 	dd	soundc_disable
  2086 0001254C [A92A0100]          <1> 	dd	sound_dma_map
  2087 00012550 [172B0100]          <1> 	dd	soundc_info
  2088 00012554 [762B0100]          <1> 	dd	sound_data
  2089 00012558 [182C0100]          <1> 	dd	sound_update
  2090                              <1> 	
  2091                              <1> AUDIO1L	EQU	$ - AUDIO1
  2092                              <1> 
  2093                              <1> soundc_detect:
  2094                              <1> 	; FUNCTION = 1
  2095                              <1> 	; bl = Audio device type number 
  2096                              <1> 	; (0= pc speaker, 1 = sound blaster 16, 2 = intel ac97
  2097                              <1> 	;  3= via vt823x, 4 = intel HDA, 0FFh= any)
  2098                              <1> 	
  2099                              <1> 	; 04/06/2017
  2100 0001255C 8A25[B1890100]      <1> 	mov	ah, [audio_device]
  2101 00012562 80FBFF              <1> 	cmp	bl, 0FFh ; get current audio device id
  2102 00012565 7408                <1> 	je	short sysaudio0
  2103                              <1> 
  2104 00012567 20E4                <1> 	and	ah, ah
  2105 00012569 741E                <1> 	jz	short soundc_get_dev
  2106                              <1> 
  2107 0001256B 38DC                <1> 	cmp	ah, bl
  2108 0001256D 7567                <1> 	jne	short soundc_dev_err
  2109                              <1> 
  2110                              <1> sysaudio0:	
  2111 0001256F A0[B2890100]        <1> 	mov	al, [audio_mode]
  2112                              <1> sysaudio1:
  2113 00012574 A3[1C010300]        <1> 	mov	[u.r0], eax
  2114 00012579 8B1D[BC890100]      <1> 	mov	ebx, [audio_vendor] ; (DEVICE/VENDOR ID)
  2115 0001257F 8B2D[18010300]      <1> 	mov	ebp, [u.usp]
  2116 00012585 895D10              <1> 	mov	[ebp+16], ebx  ; ebx
  2117 00012588 C3                  <1> 	retn
  2118                              <1> 
  2119                              <1> soundc_get_dev:
  2120                              <1> 	; 28/05/2017
  2121                              <1> 	; 03/04/2017, 24/04/2017
  2122 00012589 C605[B0890100]00    <1> 	mov	byte [audio_pci], 0
  2123 00012590 80FB03              <1> 	cmp	bl, 3 ; VIA VT8233 (VT8237R) Audio Controller & AC97 Codec
  2124                              <1> 	;jne	short soundc_get_dev_sb
  2125                              <1> 	; 28/05/2017
  2126 00012593 7220                <1> 	jb	short soundc_get_dev_sb
  2127 00012595 773F                <1> 	ja	short soundc_dev_err  ; temporary (28/05/2017)
  2128                              <1> 	;  		
  2129 00012597 E8FD150000          <1> 	call	DetectVT8233
  2130 0001259C 7238                <1> 	jc	short soundc_dev_err
  2131                              <1> 	; eax = 0
  2132                              <1> 
  2133                              <1> 	;mov	ebx, [audio_vendor]
  2134                              <1> 	; ebx = DEVICE/VENDOR ID
  2135                              <1> 	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  2136                              <1> 
  2137 0001259E B003                <1> 	mov	al, 3  ; VIA VT8237R (VT3233) Audio Controller
  2138 000125A0 88C4                <1> 	mov	ah, al
  2139                              <1> 
  2140                              <1> soundc_get_pci_dev_ok: ; 28/05/2017
  2141 000125A2 FE05[B0890100]      <1> 	inc	byte [audio_pci] ; = 1
  2142                              <1> soundc_get_dev_ok:
  2143                              <1> 	
  2144                              <1> soundc_get_dev_sb16_ok:
  2145 000125A8 A2[B1890100]        <1> 	mov	[audio_device], al
  2146 000125AD 8825[B2890100]      <1> 	mov	[audio_mode], ah ; stereo (bit0), 16 bit (bit1) capability	
  2147 000125B3 EBBF                <1> 	jmp	short sysaudio1
  2148                              <1> 
  2149                              <1> soundc_get_dev_sb:
  2150                              <1> 	; 24/04/2017
  2151 000125B5 80FB01              <1> 	cmp	bl, 1 ; Sound Blaster 16
  2152 000125B8 750E                <1> 	jne	short soundc_get_dev_ich ; 28/05/2017
  2153                              <1> 	;
  2154 000125BA E8D31A0000          <1> 	call	DetectSB
  2155 000125BF 7215                <1> 	jc	short soundc_dev_err
  2156 000125C1 B801030000          <1> 	mov	eax, 0301h ; Sound Blaster 16
  2157 000125C6 EBE0                <1> 	jmp	short soundc_get_dev_sb16_ok
  2158                              <1> 
  2159                              <1> soundc_get_dev_ich:
  2160                              <1> 	; 28/05/2017
  2161                              <1> 	;cmp	bl, 2 ; Intel AC'97 Audio Controller (ICH)
  2162                              <1> 	;jne	short soundc_dev_err ; Temporary  (28/05/2017)
  2163                              <1> 	;			     ; (Here will be modified just after
  2164                              <1> 	;			     ; new sound card code will be ready!)  	
  2165 000125C8 E8BF150000          <1> 	call	DetectICH
  2166 000125CD 7207                <1> 	jc	short soundc_dev_err
  2167                              <1> 	;
  2168 000125CF B802030000          <1> 	mov	eax, 0302h ; AC'97 (ICH)
  2169 000125D4 EBCC                <1> 	jmp	short soundc_get_pci_dev_ok
  2170                              <1> 
  2171                              <1> soundc_dev_err:
  2172 000125D6 B80F000000          <1> 	mov	eax, ERR_DEV_NOT_RDY ; Device not ready !
  2173                              <1> 	; 29/07/2022
  2174                              <1> 	;sub	eax, eax
  2175                              <1> 	;mov	al, ERR_DEV_NOT_RDY
  2176 000125DB EB0C                <1> 	jmp	short sysaudio_err
  2177                              <1> 
  2178                              <1> sound_buff_error:
  2179 000125DD B82E000000          <1> 	mov	eax, ERR_BUFFER ; Buffer error !
  2180                              <1> 	; 29/07/2022
  2181                              <1> 	;sub	eax, eax
  2182                              <1> 	;mov	al, ERR_BUFFER
  2183 000125E2 EB05                <1> 	jmp	short sysaudio_err
  2184                              <1> 
  2185                              <1> soundc_respond_err:
  2186                              <1> 	; ERR_TIME_OUT ; 'time out !' error	
  2187 000125E4 B819000000          <1> 	mov	eax, ERR_DEV_NOT_RESP ; 'device not responding !' error
  2188                              <1> 	; 29/07/2022
  2189                              <1> 	;sub	eax, eax
  2190                              <1> 	;mov	al, ERR_DEV_NOT_RESP
  2191                              <1> sysaudio_err:
  2192 000125E9 A3[1C010300]        <1> 	mov	[u.r0], eax
  2193 000125EE A3[84010300]        <1> 	mov	[u.error], eax
  2194 000125F3 E907A7FFFF          <1> 	jmp	error
  2195                              <1> 
  2196                              <1> sound_alloc:
  2197                              <1> 	; FUNCTION =  2
  2198                              <1> 	; ecx = audio buffer size (in bytes)
  2199                              <1> 	; edx = audio buffer address (virtual)
  2200                              <1> 	; 27/07/2020
  2201                              <1> 	; 28/05/2017
  2202                              <1> 	; 01/05/2017, 15/05/2017
  2203                              <1> 	; 21/04/2017, 24/04/2017
  2204 000125F8 803D[B0890100]00    <1> 	cmp	byte [audio_pci], 0
  2205 000125FF 7708                <1> 	ja	short snd_alloc_0
  2206                              <1> 	; Max. 64KB DMA buffer !!!
  2207 00012601 81F900800000        <1> 	cmp	ecx, 32768
  2208 00012607 77D4                <1> 	ja	short sound_buff_error
  2209                              <1> snd_alloc_0:
  2210                              <1> 	; 15/05/2017
  2211 00012609 81F900100000        <1> 	cmp	ecx, 4096 ; PAGE_SIZE
  2212 0001260F 72CC                <1> 	jb	short sound_buff_error
  2213                              <1> 	;
  2214 00012611 A1[C4890100]        <1> 	mov	eax, [audio_buffer] ; audio buffer address (current)
  2215 00012616 09C0                <1> 	or	eax, eax
  2216 00012618 7445                <1> 	jz	short snd_alloc_2
  2217                              <1> 	; audio buffer exists !
  2218 0001261A 8A1D[6D010300]      <1> 	mov	bl, [u.uno]
  2219 00012620 3A1D[D9890100]      <1> 	cmp	bl, [audio_user]
  2220 00012626 0F85FE000000        <1> 	jne	sndc_owner_error ; not owner !
  2221 0001262C 39D0                <1> 	cmp	eax, edx ; same virtual buffer address ?
  2222 0001262E 7508                <1> 	jne	short snd_alloc_1
  2223 00012630 3B0D[CC890100]      <1> 	cmp	ecx, [audio_buff_size]
  2224 00012636 746C                <1> 	je	short snd_alloc_3 ; Nothing to do !
  2225                              <1> 				  ; Buffer has been set already!
  2226                              <1> snd_alloc_1:
  2227 00012638 51                  <1> 	push	ecx
  2228 00012639 52                  <1> 	push	edx
  2229 0001263A 89C3                <1> 	mov	ebx, eax ; audio buffer address (current)
  2230 0001263C 8B0D[CC890100]      <1> 	mov	ecx, [audio_buff_size]
  2231 00012642 E8FF38FFFF          <1> 	call	deallocate_user_pages
  2232 00012647 5A                  <1> 	pop	edx
  2233 00012648 59                  <1> 	pop	ecx
  2234 00012649 31C0                <1> 	xor	eax, eax ; 0
  2235 0001264B A3[C4890100]        <1> 	mov	[audio_buffer], eax  ; 0
  2236 00012650 A3[C8890100]        <1>  	mov	[audio_p_buffer], eax  ; 0
  2237 00012655 A3[CC890100]        <1>  	mov	[audio_buff_size], eax
  2238 0001265A A2[D9890100]        <1> 	mov	[audio_user], al ; 0
  2239                              <1> snd_alloc_2:
  2240 0001265F 89D3                <1> 	mov	ebx, edx
  2241                              <1> 	; 01/05/2017
  2242 00012661 BA00F0FFFF          <1> 	mov	edx, ~PAGE_OFF ; truncating page offsets
  2243                              <1> 			       ; for aligning to page borders	
  2244                              <1> 	;and	eax, edx
  2245 00012666 21D3                <1> 	and	ebx, edx
  2246 00012668 21D1                <1> 	and	ecx, edx
  2247                              <1> 	; 15/05/2017
  2248                              <1> 	; EAX = Beginning address (physical)
  2249                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
  2250                              <1> 	; ECX = Number of bytes to be allocated		
  2251 0001266A E87D35FFFF          <1> 	call	allocate_memory_block
  2252 0001266F 0F8268FFFFFF        <1> 	jc	sound_buff_error
  2253                              <1> 	; EAX = Physical address of the allocated memory block
  2254                              <1> 	; ECX = Allocated bytes (as truncated to page border)
  2255                              <1> 	; EBX = Virtual address (as truncated to page border)
  2256 00012675 50                  <1> 	push	eax
  2257 00012676 53                  <1> 	push	ebx
  2258 00012677 51                  <1> 	push	ecx
  2259 00012678 E8B139FFFF          <1> 	call	allocate_user_pages
  2260 0001267D 59                  <1> 	pop	ecx
  2261 0001267E 5B                  <1> 	pop	ebx
  2262 0001267F 58                  <1> 	pop	eax
  2263 00012680 722A                <1> 	jc	short snd_alloc_4  ; insufficient memory, buff error
  2264                              <1> 	; eax = physical address of the user's audio buffer
  2265                              <1> 	; ebx = virtual address of the user's audio buffer
  2266                              <1> 	; ecx = buffer size (in bytes)
  2267 00012682 A3[C8890100]        <1> 	mov	[audio_p_buffer], eax
  2268 00012687 891D[C4890100]      <1> 	mov	[audio_buffer], ebx
  2269 0001268D 890D[CC890100]      <1>  	mov	[audio_buff_size], ecx
  2270 00012693 8A15[6D010300]      <1> 	mov	dl, [u.uno]
  2271 00012699 8815[D9890100]      <1> 	mov	[audio_user], dl
  2272 0001269F A3[1C010300]        <1> 	mov	[u.r0], eax
  2273                              <1> snd_alloc_3:
  2274                              <1> 	; 27/07/2020
  2275 000126A4 C605[D8890100]00    <1> 	mov	byte [audio_flag], 0 ; clear dma half buffer flag
  2276                              <1> 	;	
  2277 000126AB C3                  <1> 	retn
  2278                              <1> snd_alloc_4:
  2279                              <1> 	; 15/05/2017
  2280                              <1> 	; EAX = Beginning address (physical)
  2281                              <1> 	; ECX = Number of bytes to be deallocated
  2282 000126AC E85737FFFF          <1> 	call	deallocate_memory_block
  2283 000126B1 E927FFFFFF          <1> 	jmp	sound_buff_error  ; insufficient memory, buff error
  2284                              <1> 
  2285                              <1> soundc_init:
  2286                              <1> 	; FUNCTION = 3 
  2287                              <1> 	; bl = method (0= s.r.b., 1= callback, 2= auto incr s.r.b.)
  2288                              <1> 	; cl = signal response byte (initial or fixed) value
  2289                              <1> 	; edx = signal response byte or callback address
  2290                              <1> 	; 07/08/2022
  2291                              <1> 	; 29/07/2022
  2292                              <1> 	; 27/07/2020
  2293                              <1> 	; 28/05/2017
  2294                              <1> 	; 12/05/2017, 20/05/2017
  2295                              <1> 	; 22/04/2017, 23/04/2017, 24/04/2017
  2296                              <1> 	; 13/04/2017, 14/04/2017, 16/04/2017, 21/04/2017
  2297                              <1> 	; 03/04/2017, 10/04/2017
  2298                              <1> 
  2299 000126B6 A0[B1890100]        <1> 	mov	al, [audio_device]
  2300 000126BB 20C0                <1> 	and	al, al
  2301 000126BD 754A                <1> 	jnz	short sndc_init6
  2302                              <1> 	;
  2303 000126BF C605[B0890100]00    <1> 	mov	byte [audio_pci], 0
  2304 000126C6 52                  <1> 	push	edx
  2305 000126C7 53                  <1> 	push	ebx
  2306 000126C8 51                  <1> 	push	ecx
  2307 000126C9 E8C4190000          <1> 	call	DetectSB
  2308 000126CE 7213                <1> 	jc	short sndc_init8
  2309 000126D0 66B80103            <1> 	mov	ax, 0301h ; Sound Blaster 16
  2310 000126D4 EB1E                <1> 	jmp	short sndc_init7
  2311                              <1> 
  2312                              <1> sndc_init11:
  2313                              <1> 	; 28/05/2017
  2314 000126D6 E8B1140000          <1> 	call	DetectICH ; Detect AC'97 (ICH) Audio Controller
  2315 000126DB 7217                <1> 	jc	short sndc_init7
  2316 000126DD 66B80203            <1> 	mov	ax, 0302h ; Intel AC'97 Audio Device
  2317 000126E1 EB0B                <1> 	jmp	short sndc_init12 ; (PCI device)
  2318                              <1> 
  2319                              <1> sndc_init8:
  2320 000126E3 E8B1140000          <1> 	call	DetectVT8233
  2321                              <1> 	;jc	short sndc_init7
  2322                              <1> 	; 29/07/2022
  2323 000126E8 72EC                <1> 	jc	short sndc_init11 ; 28/05/2017
  2324                              <1> 
  2325                              <1> 	; eax = 0
  2326 000126EA B003                <1> 	mov	al, 3	; VIA VT8237R (VT3233) Audio Controller
  2327 000126EC 88C4                <1> 	mov	ah, al
  2328                              <1> 
  2329                              <1> sndc_init12:
  2330 000126EE FE05[B0890100]      <1> 	inc	byte [audio_pci] ; = 1
  2331                              <1> sndc_init7:
  2332 000126F4 59                  <1> 	pop	ecx
  2333 000126F5 5B                  <1> 	pop	ebx
  2334 000126F6 5A                  <1> 	pop	edx
  2335                              <1> 	;jc	soundc_dev_err
  2336                              <1> 	; 29/07/2022
  2337 000126F7 7305                <1> 	jnc	short sndc_init14
  2338 000126F9 E9D8FEFFFF          <1> 	jmp	soundc_dev_err
  2339                              <1> sndc_init14:
  2340 000126FE A2[B1890100]        <1> 	mov	[audio_device], al
  2341 00012703 8825[B2890100]      <1> 	mov	[audio_mode], ah ; stereo (bit0), 16 bit (bit1) capability
  2342                              <1> 
  2343                              <1> sndc_init6:
  2344 00012709 833D[C4890100]00    <1> 	cmp	dword [audio_buffer], 0
  2345                              <1> 	;jna	sound_buff_error
  2346                              <1> 	; 29/07/2022
  2347 00012710 7705                <1> 	ja	short sndc_init19
  2348 00012712 E9C6FEFFFF          <1> 	jmp	sound_buff_error ; 07/08/2022
  2349                              <1> sndc_init19:
  2350 00012717 A0[6D010300]        <1> 	mov	al, [u.uno]
  2351 0001271C 8A25[D9890100]      <1> 	mov	ah, [audio_user]
  2352 00012722 08E4                <1> 	or	ah, ah
  2353 00012724 7418                <1> 	jz	short sndc_init0
  2354 00012726 38E0                <1> 	cmp	al, ah
  2355 00012728 7419                <1> 	je	short sndc_init1
  2356                              <1> 
  2357                              <1> sndc_owner_error:
  2358 0001272A B80B000000          <1> 	mov	eax, ERR_NOT_OWNER ; 'permission denied !' error
  2359                              <1> 	; 29/07/2022
  2360                              <1> 	;sub	eax, eax
  2361                              <1> 	;mov	al, ERR_NOT_OWNER
  2362                              <1> sndc_perm_error:
  2363 0001272F A3[1C010300]        <1> 	mov	[u.r0], eax
  2364 00012734 A3[84010300]        <1> 	mov	[u.error], eax
  2365 00012739 E9C1A5FFFF          <1> 	jmp	error
  2366                              <1> sndc_init0:
  2367 0001273E A2[D9890100]        <1> 	mov	[audio_user], al
  2368                              <1> sndc_init1:
  2369 00012743 8915[DC890100]      <1> 	mov	[audio_cb_addr], edx
  2370 00012749 881D[DA890100]      <1> 	mov	[audio_cb_mode], bl
  2371 0001274F 880D[DB890100]      <1> 	mov	[audio_srb], cl
  2372                              <1> 
  2373                              <1> 	; 27/07/2020
  2374                              <1> 	;mov	byte [audio_flag], 0  ; clear dma half buffer flag
  2375                              <1> 
  2376                              <1> 	; 24/04/2017
  2377 00012755 803D[B1890100]03    <1> 	cmp	byte [audio_device], 3 ; VT8233 (VT8237R)
  2378 0001275C 7435                <1> 	je	short sndc_init9
  2379                              <1> 	;ja	short soundc_respond_err ; temporary (28/05/2017)
  2380 0001275E 803D[B1890100]01    <1> 	cmp	byte [audio_device], 1 ; SB 16
  2381 00012765 7510                <1> 	jne	short sndc_init13
  2382 00012767 BB[AA420100]        <1> 	mov	ebx, sb16_int_handler
  2383                              <1> 	; Note: 'SbInit' is at 'Start to Play' stage
  2384                              <1> 	; 20/05/2017
  2385 0001276C 66C705[E6890100]08- <1> 	mov	word [audio_master_volume], 0808h ; 2/8
  2385 00012774 08                  <1>
  2386 00012775 EB34                <1> 	jmp	short sndc_init10
  2387                              <1> sndc_init13:
  2388                              <1> 	; 28/05/2017
  2389 00012777 803D[B1890100]02    <1> 	cmp	byte [audio_device], 2 ; AC 97 (ICH)	
  2390                              <1> 	;jne	soundc_respond_err ; temporary (28/05/2017)
  2391                              <1> 	; 29/07/2022
  2392 0001277E 7405                <1> 	je	short sndc_init16
  2393                              <1> sndc_init15:
  2394 00012780 E95FFEFFFF          <1> 	jmp	soundc_respond_err
  2395                              <1> sndc_init16:
  2396 00012785 E86A1C0000          <1> 	call	ac97_codec_config
  2397                              <1> 	;jc	soundc_respond_err ; codec error !
  2398                              <1> 	; 29/07/2022
  2399 0001278A 72F4                <1> 	jc	short sndc_init15
  2400                              <1> 
  2401 0001278C BB[D6450100]        <1> 	mov	ebx, ac97_int_handler
  2402 00012791 EB18                <1> 	jmp	short sndc_init10	
  2403                              <1> 
  2404                              <1> sndc_init9:
  2405                              <1> 	;call	reset_codec
  2406                              <1> 	;; eax = 1
  2407                              <1> 	;call	codec_io_w16 ; w32
  2408 00012793 E870150000          <1> 	call	init_codec ; 28/05/2017
  2409                              <1> 	;jc	soundc_respond_err ; codec error !
  2410                              <1> 	; 29/07/2022
  2411 00012798 72E6                <1> 	jc	short sndc_init15
  2412                              <1> 
  2413 0001279A E886170000          <1> 	call	channel_reset
  2414                              <1> 
  2415                              <1> 	; setup the Codec (actually mixer registers) 
  2416 0001279F E8AF160000          <1>         call    codec_config  ; unmute codec, set rates.
  2417                              <1> 	;jc	soundc_respond_err ; codec error !
  2418                              <1> 	; 29/07/2022
  2419 000127A4 72DA                <1> 	jc	short sndc_init15
  2420                              <1> 
  2421 000127A6 BB[B73E0100]        <1> 	mov	ebx, vt8233_int_handler
  2422                              <1> sndc_init10:
  2423                              <1> 	; 13/04/2017
  2424 000127AB A0[B3890100]        <1> 	mov	al, [audio_intr] ; IRQ number	
  2425 000127B0 E835FDFFFF          <1> 	call	set_dev_IRQ_service
  2426                              <1> 
  2427                              <1> 	; SETUP (audio) INTERRUPT CALLBACK SERVICE
  2428 000127B5 8A1D[B3890100]      <1> 	mov	bl, [audio_intr] ; IRQ number
  2429 000127BB 8A3D[DA890100]      <1> 	mov	bh, [audio_cb_mode]
  2430 000127C1 FEC7                <1> 	inc	bh  ; 1 = Signal Response Byte method (fixed value)
  2431                              <1> 		    ; 2 = Callback service method
  2432                              <1> 		    ; 3 = Auto Increment S.R.B. method 	
  2433 000127C3 8A0D[DB890100]      <1> 	mov	cl, [audio_srb]
  2434 000127C9 8B15[DC890100]      <1> 	mov	edx, [audio_cb_addr]
  2435 000127CF A0[D9890100]        <1> 	mov	al, [audio_user]
  2436                              <1> 	; 14/04/2017
  2437 000127D4 E8B8040000          <1>  	call	set_irq_callback_service
  2438                              <1> 	; 16/04/2017
  2439 000127D9 A3[1C010300]        <1> 	mov	[u.r0], eax
  2440                              <1> 	;jnc	sysret
  2441 000127DE 7316                <1> 	jnc	short sndc_init2 ; 21/04/2017
  2442                              <1> 	;
  2443 000127E0 A3[84010300]        <1> 	mov	dword [u.error], eax
  2444                              <1> 
  2445 000127E5 A0[B3890100]        <1> 	mov	al, [audio_intr] ; IRQ number	
  2446 000127EA 31DB                <1> 	xor	ebx, ebx ; reset IRQ handler address
  2447 000127EC E8F9FCFFFF          <1> 	call	set_dev_IRQ_service
  2448                              <1> 
  2449 000127F1 E909A5FFFF          <1> 	jmp	error
  2450                              <1> 
  2451                              <1> sndc_init2:
  2452                              <1> 	; 21/04/2017
  2453 000127F6 8B0D[CC890100]      <1> 	mov	ecx, [audio_buff_size] ; audio buffer size
  2454 000127FC D1E1                <1> 	shl	ecx, 1 ; *2
  2455 000127FE A1[D0890100]        <1> 	mov	eax, [audio_dma_buff]
  2456 00012803 21C0                <1> 	and	eax, eax
  2457 00012805 7415                <1> 	jz	short sndc_init3
  2458                              <1> 
  2459 00012807 8B15[D4890100]      <1> 	mov	edx, [audio_dmabuff_size] ; dma buffer size
  2460 0001280D 39D1                <1> 	cmp	ecx, edx
  2461 0001280F 7428                <1> 	je	short sndc_init5
  2462                              <1> 
  2463 00012811 87CA                <1> 	xchg	ecx, edx
  2464 00012813 E8F035FFFF          <1> 	call	deallocate_memory_block
  2465 00012818 87D1                <1> 	xchg	edx, ecx
  2466 0001281A 31C0                <1> 	xor	eax, eax
  2467                              <1> sndc_init3:
  2468                              <1> 	; 12/05/2017
  2469 0001281C 803D[B1890100]01    <1> 	cmp	byte [audio_device], 1 ; SB 16
  2470 00012823 7515                <1> 	jne	short sndc_init4
  2471 00012825 C705[D0890100]-     <1> 	mov	dword [audio_dma_buff], sb16_dma_buffer
  2471 0001282B [00000200]          <1>
  2472 0001282F C705[D4890100]0000- <1> 	mov	dword [audio_dmabuff_size], 65536
  2472 00012837 0100                <1>
  2473                              <1> 	;xor	eax, eax
  2474                              <1> 	;mov	[u.r0], eax ; 0 = no error, successful
  2475                              <1> sndc_init5:	; 29/07/2022
  2476 00012839 C3                  <1> 	retn 
  2477                              <1> 
  2478                              <1> sndc_init4:
  2479                              <1> 	; EAX = Beginning address (physical)
  2480                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
  2481                              <1> 	; ECX = Number of bytes to be allocated	(>0)	
  2482 0001283A E8AD33FFFF          <1> 	call	allocate_memory_block
  2483                              <1> 	;jc	sound_buff_error
  2484                              <1> 	; 29/07/2022
  2485 0001283F 7305                <1> 	jnc	short sndc_init17
  2486 00012841 E997FDFFFF          <1> 	jmp	sound_buff_error
  2487                              <1> 
  2488                              <1> sndc_init17:	; 29/07/2022
  2489                              <1> 	; set dma buffer address and size parameters
  2490 00012846 A3[D0890100]        <1> 	mov	[audio_dma_buff], eax ; dma buffer address
  2491 0001284B 890D[D4890100]      <1> 	mov	[audio_dmabuff_size], ecx ; dma buffer size
  2492                              <1> ;	; EAX = Beginning (physical) addr of the allocated mem block
  2493                              <1> ;	; ECX = Num of allocated bytes (rounded up to page borders)
  2494                              <1> ;	cmp	byte [audio_pci], 0 ; AC97 audio controller ?
  2495                              <1> ;	ja	short sndc_init4
  2496                              <1> ;
  2497                              <1> ;	; Sound Blaster 16 uses classic DMA
  2498                              <1> ;	mov	edx, eax
  2499                              <1> ;	add	edx, ecx
  2500                              <1> ;	cmp	edx, 1000000h ; 1st 16 MB
  2501                              <1> ;	jna	short sndc_init4
  2502                              <1> ;
  2503                              <1> ;	; error !
  2504                              <1> ;	; restore Memory Allocation Table Content
  2505                              <1> ;	; EAX = Beginning address (physical)
  2506                              <1> ;	; ECX = Number of bytes to be deallocated
  2507                              <1> ;	call	deallocate_memory_block
  2508                              <1> ;	; reset dma buffer address and size parameters
  2509                              <1> ;	xor	eax, eax ; 0
  2510                              <1> ;	mov	[audio_dma_buff], eax ; 0
  2511                              <1> ;	mov	[audio_dmabuff_size], ecx ; 0
  2512                              <1> ;	jmp	sound_buff_error				
  2513                              <1> ;
  2514                              <1> ;sndc_init4:
  2515 00012851 803D[B1890100]03    <1> 	cmp	byte [audio_device], 3
  2516                              <1> 	;jne	short sndc_init5
  2517                              <1> 	; 29/07/2022
  2518 00012858 7505                <1> 	jne	short sndc_init18 ; 28/05/2017
  2519                              <1> 
  2520                              <1> ; 29/07/2022
  2521                              <1> ;	call	set_vt8233_bdl	
  2522                              <1> ;sndc_init5:
  2523                              <1> ;	;sub	eax, eax ; 0
  2524                              <1> ;	;mov	[u.r0], eax ; 0 = no error, successful
  2525                              <1> ;	retn
  2526                              <1> 
  2527 0001285A E900170000          <1> 	jmp	set_vt8233_bdl
  2528                              <1> 
  2529                              <1> sndc_init18:
  2530                              <1> 	;call	set_ac97_bdl
  2531                              <1> 	;;jmp	short sndc_init5
  2532                              <1> 	;retn
  2533                              <1> 	; 29/07/2022
  2534 0001285F E9A81C0000          <1> 	jmp	set_ac97_bdl
  2535                              <1> 
  2536                              <1> sound_play:
  2537                              <1> 	; FUNCTION = 4 
  2538                              <1> 	; bl = Mode 
  2539                              <1> 	;      bit 0 = mono/stereo (1 = stereo)		
  2540                              <1> 	;      bit 1 = 8 bit / 16 bit (1 = 16 bit)
  2541                              <1> 	; cx = Sampling Rate (Hz)
  2542                              <1> 
  2543                              <1> 	; 13/06/2017
  2544                              <1> 	; Note: Even if Mode bits are not 11b,
  2545                              <1> 	; 	AC'97 Audio Controller (&Codec)
  2546                              <1> 	;	will play audio samples as 16 bit, stereo
  2547                              <1> 	;	samples.
  2548                              <1> 	;	(Program must fill the audio buffer
  2549                              <1> 	;	as required; 8 bit samples must be converted
  2550                              <1> 	;	to 16 bit samples and mono samples must be
  2551                              <1> 	;	converted to stereo samples...)
  2552                              <1> 	 
  2553                              <1> 	; 30/07/2022	
  2554                              <1> 	; 28/07/2020
  2555                              <1> 	; 27/07/2020	 	
  2556                              <1> 	; 28/05/2017
  2557                              <1> 	; 15/05/2017, 20/05/2017
  2558                              <1> 	; 21/04/2017, 24/04/2017
  2559                              <1> 	; ... device check at first
  2560 00012864 A0[B1890100]        <1> 	mov	al, [audio_device]
  2561 00012869 08C0                <1> 	or	al, al ; 0 ; pc speaker or invalid 
  2562                              <1> 	;jz	beeper_gfx ; 'video.s' ; temporary 
  2563                              <1> 	; 30/07/022
  2564 0001286B 7505                <1> 	jnz	short snd_play_7
  2565 0001286D E9D9FAFEFF          <1> 	jmp	beeper_gfx
  2566                              <1> 
  2567                              <1> snd_play_7:
  2568                              <1> ;	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2569                              <1> ;	je	short snd_play_1
  2570                              <1> ;	cmp	al, 1 ; SB 16
  2571                              <1> ;	jne	soundc_dev_err ; temporary !
  2572                              <1> ;snd_play_0:
  2573                              <1> 	; ... buffer & (buffer) owner check at second
  2574 00012872 833D[C4890100]00    <1> 	cmp	dword [audio_buffer], 0
  2575                              <1> 	;jna	sound_buff_error
  2576                              <1> 	; 30/07/2022
  2577 00012879 763C                <1> 	jna	short snd_play_4 ; jmp sound_buff_error
  2578 0001287B A0[6D010300]        <1> 	mov	al, [u.uno]
  2579 00012880 3A05[D9890100]      <1> 	cmp	al, [audio_user]
  2580                              <1> 	;jne	sndc_owner_error
  2581                              <1> 	; 30/07/2022
  2582 00012886 7405                <1> 	je	short snd_play_3
  2583 00012888 E99DFEFFFF          <1> 	jmp	sndc_owner_error
  2584                              <1> snd_play_3:
  2585 0001288D 66890D[E2890100]    <1> 	mov	[audio_freq], cx ; sample frequency (Hertz)
  2586 00012894 88D8                <1> 	mov	al, bl
  2587 00012896 2401                <1> 	and	al, 1 ; mono/stereo (1= stereo)
  2588 00012898 FEC0                <1> 	inc	al ; channels
  2589 0001289A A2[E1890100]        <1> 	mov	[audio_stmo], al ; sound channels (1 or 2)
  2590 0001289F B008                <1> 	mov	al, 8
  2591 000128A1 F6C302              <1> 	test	bl, 2 ; bits per sample (1= 16 bit)
  2592 000128A4 7402                <1> 	jz	short snd_play_bps
  2593 000128A6 D0E0                <1> 	shl	al, 1  
  2594                              <1> snd_play_bps:	
  2595 000128A8 A2[E0890100]        <1> 	mov	[audio_bps], al
  2596                              <1> 
  2597                              <1> 	; Transfer ring 3 (user's) audio buffer content to dma buffer
  2598 000128AD 8B3D[D0890100]      <1> 	mov	edi, [audio_dma_buff] ; dma buffer (ring 0)
  2599 000128B3 09FF                <1> 	or	edi, edi
  2600                              <1> 	;jz	sound_buff_error
  2601                              <1> 	; 30/07/2022
  2602 000128B5 7505                <1> 	jnz	short snd_play_5
  2603                              <1> snd_play_4:
  2604 000128B7 E921FDFFFF          <1> 	jmp	sound_buff_error
  2605                              <1> snd_play_5:
  2606                              <1> 	; 27/07/2020
  2607 000128BC 8B35[C8890100]      <1> 	mov	esi, [audio_p_buffer] ; physical address (ring 3)
  2608                              <1> 	;mov	ecx, [audio_buff_size] ; 15/05/2017
  2609 000128C2 8B0D[D4890100]      <1> 	mov	ecx, [audio_dmabuff_size] ; 27/07/2020
  2610                              <1> 	;or	ecx, ecx 
  2611                              <1> 	;jz	sound_buff_error
  2612                              <1> 	; 28/07/2020
  2613 000128C8 D1E9                <1> 	shr	ecx, 1  ; dma half buffer size
  2614                              <1> 
  2615 000128CA 8035[D8890100]01    <1> 	xor	byte [audio_flag], 1 ;  0 -> 1, 1 -> 0
  2616 000128D1 7502                <1> 	jnz	short snd_play_0 ; [audio_flag] = 1
  2617                              <1> 				 ; fill dma half buffer 1
  2618                              <1> 	; [audio_flag] = 0
  2619                              <1> 	
  2620                              <1> 	; fill dma half buffer 2
  2621 000128D3 01CF                <1> 	add	edi, ecx
  2622                              <1> 
  2623                              <1> snd_play_0:
  2624                              <1> 	;rep	movsb
  2625 000128D5 C1E902              <1> 	shr	ecx, 2  ; convert byte count to dword count
  2626 000128D8 F3A5                <1> 	rep	movsd
  2627                              <1> 
  2628                              <1> 	; here, if [audio_flag] = 0, interrupt handler will update
  2629                              <1> 				; dma half buffer 2 
  2630                              <1> 				; (user's audio buffer data will be 
  2631                              <1> 				; copied into dma half buffer 2) 
  2632                              <1> 	;; 20/05/2017
  2633                              <1> 	;mov	byte [audio_flag], 1 ; next half (on next time)
  2634                              <1> 
  2635                              <1> 	; 24/04/2017
  2636 000128DA A0[B1890100]        <1> 	mov	al, [audio_device]
  2637 000128DF 3C03                <1> 	cmp	al, 3 ; VT8233 (VT8237R) 
  2638 000128E1 7409                <1> 	je	short snd_play_1
  2639 000128E3 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2640 000128E5 750A                <1> 	jne	short snd_play_2  ; 28/05/2017
  2641                              <1> 
  2642                              <1> ; 30/07/2022
  2643                              <1> ;	call	SbInit_play
  2644                              <1> ;	;jc	soundc_respond_err
  2645                              <1> ;	;retn
  2646                              <1> ;	; 30/07/2022
  2647                              <1> ;	jnc	short snd_play_6  ; retn
  2648                              <1> ;	jmp	soundc_respond_err
  2649                              <1> 
  2650                              <1> 	; 30/07/2022
  2651 000128E7 E96C180000          <1> 	jmp	SbInit_play	; sb16_start_play
  2652                              <1> 
  2653                              <1> snd_play_1:	
  2654                              <1> 	;call	vt8233_start_play
  2655                              <1> 	;retn
  2656                              <1> 	; 30/07/2022
  2657 000128EC E9A4160000          <1> 	jmp	vt8233_start_play
  2658                              <1> 
  2659                              <1> snd_play_2:
  2660                              <1> 	; 28/05/2017
  2661                              <1> 	;cmp	al, 2 ; AC'97
  2662                              <1> 	;jne	short snd_play_3
  2663                              <1> 
  2664                              <1> 	;call	ac97_start_play
  2665                              <1> 	;retn
  2666                              <1> 	; 30/07/2022
  2667 000128F1 E9491C0000          <1> 	jmp	ac97_start_play
  2668                              <1> 
  2669                              <1> ;snd_play_3:
  2670                              <1> ;	;call	hda_start_play
  2671                              <1> ;	retn
  2672                              <1> 	; 30/07/2022
  2673                              <1> 	;jmp	hda_start_play
  2674                              <1> 
  2675                              <1> snd_play_6:
  2676                              <1> 	; 30/07/2022
  2677 000128F6 C3                  <1> 	retn
  2678                              <1> 
  2679                              <1> sound_pause:
  2680                              <1> 	; FUNCTION = 5
  2681                              <1> 	; Pause
  2682                              <1> 	; 28/05/2017
  2683                              <1> 	; 24/04/2017
  2684                              <1> 	; 22/04/2017
  2685 000128F7 E8F7020000          <1> 	call	snd_dev_check
  2686 000128FC 7277                <1> 	jc	short snd_nothing ; temporary.
  2687 000128FE E8FD020000          <1> 	call	snd_buf_check
  2688 00012903 7270                <1> 	jc	short snd_nothing ; temporary.
  2689 00012905 A0[B1890100]        <1> 	mov	al, [audio_device]
  2690 0001290A 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2691 0001290C 7409                <1> 	je	short snd_pause_1
  2692 0001290E 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2693 00012910 750A                <1> 	jne	short snd_pause_2 ; 28/05/2017
  2694 00012912 E9161A0000          <1> 	jmp	sb16_pause
  2695                              <1> snd_pause_1:
  2696 00012917 E92E170000          <1> 	jmp	vt8233_pause
  2697                              <1> snd_pause_2:
  2698                              <1> 	; 28/05/2017
  2699                              <1> 	;cmp	al, 2 ; AC'97
  2700                              <1> 	;jne	short snd_nothing ; temporary.
  2701 0001291C E99A1D0000          <1> 	jmp	ac97_pause
  2702                              <1> 
  2703                              <1> sound_continue:
  2704                              <1> 	; FUNCTION = 6
  2705                              <1> 	; Continue to play
  2706                              <1> 	; 28/05/2017
  2707                              <1> 	; 22/04/2017
  2708 00012921 E8CD020000          <1> 	call	snd_dev_check
  2709 00012926 724D                <1> 	jc	short snd_nothing ; temporary.
  2710 00012928 E8D3020000          <1> 	call	snd_buf_check
  2711 0001292D 7246                <1> 	jc	short snd_nothing ; temporary.
  2712 0001292F A0[B1890100]        <1> 	mov	al, [audio_device]
  2713 00012934 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2714 00012936 7409                <1> 	je	short snd_cont_1
  2715 00012938 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2716 0001293A 750A                <1> 	jne	short snd_cont_2 ; 28/05/2017
  2717 0001293C E90E1A0000          <1> 	jmp	sb16_continue
  2718                              <1> snd_cont_1:
  2719 00012941 E9B6160000          <1> 	jmp	vt8233_play
  2720                              <1> snd_cont_2:
  2721                              <1> 	; 28/05/2017
  2722                              <1> 	;cmp	al, 2 ; AC'97
  2723                              <1> 	;;jne	short snd_nothing ; temporary.
  2724                              <1> 	; 30/07/2022
  2725                              <1> 	;jne	short snd_cont_3
  2726 00012946 E9471C0000          <1> 	jmp	ac97_play
  2727                              <1> ;snd_cont_3:
  2728                              <1> 	;jmp	hda_play
  2729                              <1> 
  2730                              <1> sound_stop:
  2731                              <1> 	; FUNCTION = 7
  2732                              <1> 	; Stop playing
  2733                              <1> 	; 30/07/2022
  2734                              <1> 	; 28/05/2017
  2735                              <1> 	; 24/05/2017
  2736                              <1> 	; 21/04/2017, 22/04/2017, 24/04/2017
  2737 0001294B E8A3020000          <1> 	call	snd_dev_check
  2738 00012950 7223                <1> 	jc	short snd_nothing ; temporary.
  2739                              <1> 	;call	snd_buf_check
  2740 00012952 E8B2020000          <1> 	call	snd_user_check ; 24/05/2017
  2741 00012957 721C                <1> 	jc	short snd_nothing ; temporary.	
  2742                              <1> 	
  2743 00012959 A0[B1890100]        <1> 	mov	al, [audio_device]
  2744 0001295E 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2745                              <1> 	;je	vt8233_stop
  2746                              <1> 	;; 28/05/2017
  2747                              <1> 	;;ja	short snd_nothing
  2748                              <1> 	; 30/07/2022
  2749 00012960 7505                <1> 	jne	short snd_stop_1
  2750 00012962 E9EF150000          <1> 	jmp	vt8233_stop
  2751                              <1> snd_stop_1:
  2752 00012967 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2753                              <1> 	;je	sb16_stop
  2754                              <1> 	; 30/07/2022
  2755 00012969 7505                <1> 	jne	short snd_stop_2
  2756 0001296B E9011A0000          <1> 	jmp	sb16_stop
  2757                              <1> snd_stop_2:
  2758                              <1> 	;cmp	al, 2 
  2759                              <1> 	;;je	short ac97_stop
  2760                              <1> 	; 30/07/2022
  2761                              <1> 	;jne	short snd_stop_3
  2762 00012970 E9181D0000          <1> 	jmp	ac97_stop ; temporary.
  2763                              <1> ;snd_stop_3:
  2764                              <1> 	;jmp	hda_stop
  2765                              <1> 
  2766                              <1> sndc_cancel_ok:
  2767                              <1> 	; 30/07/2022
  2768                              <1> sndc_reset_ok:
  2769                              <1> 	; 30/07/2022
  2770                              <1> snd_nothing:
  2771                              <1> 	; 21/04/2017
  2772 00012975 C3                  <1> 	retn
  2773                              <1> 
  2774                              <1> soundc_reset:
  2775                              <1> 	; FUNCTION = 8
  2776                              <1> 	; Reset Audio Controller
  2777                              <1> 	; 30/07/2022
  2778                              <1> 	; 28/05/2017
  2779                              <1> 	; 22/04/2017
  2780 00012976 E878020000          <1> 	call	snd_dev_check
  2781 0001297B 72F8                <1> 	jc	short snd_nothing ; temporary.
  2782 0001297D E87E020000          <1> 	call	snd_buf_check
  2783 00012982 72F1                <1> 	jc	short snd_nothing ; temporary.	
  2784                              <1> 	
  2785 00012984 A0[B1890100]        <1> 	mov	al, [audio_device]
  2786                              <1> 	; 30/07/2022
  2787 00012989 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2788 0001298B 7207                <1> 	jb	short sndc_reset_1
  2789                              <1> 	;je	vt8233_reset
  2790 0001298D 77E6                <1> 	ja	short snd_nothing ; temporary.
  2791                              <1> 	;;ja	hda_reset
  2792                              <1> 	;ja	short sndc_reset_3
  2793                              <1> 	; 30/07/2022
  2794 0001298F E9C2160000          <1> 	jmp	vt8233_reset	
  2795                              <1> sndc_reset_1:
  2796 00012994 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2797                              <1> 	;jne	ac97_reset	
  2798                              <1> 	; 30/07/2022
  2799 00012996 750C                <1> 	jne	short sndc_reset_2
  2800 00012998 E8251A0000          <1> 	call	sb16_reset
  2801                              <1> 	;jc	soundc_respond_err
  2802                              <1> 	;retn
  2803                              <1> 	; 30/07/2022
  2804 0001299D 73D6                <1> 	jnc	short sndc_reset_ok
  2805 0001299F E940FCFFFF          <1> 	jmp	soundc_respond_err	
  2806                              <1> sndc_reset_2:
  2807                              <1> 	; 30/07/2022
  2808                              <1> 	;cmp	al, 2
  2809                              <1> 	;ja	short sndc_reset_3
  2810 000129A4 E9631D0000          <1> 	jmp	ac97_reset
  2811                              <1> ;sndc_reset_3:
  2812                              <1> 	;jmp	hda_reset
  2813                              <1> 
  2814                              <1> soundc_cancel:
  2815                              <1> 	; FUNCTION = 9
  2816                              <1> 	; Cancel audio callback service
  2817                              <1> 	; 30/07/2022
  2818                              <1> 	; 22/04/2017
  2819 000129A9 A0[D9890100]        <1> 	mov	al, [audio_user]	
  2820 000129AE 3A05[6D010300]      <1> 	cmp	al, [u.uno]
  2821 000129B4 75BF                <1> 	jne	short snd_nothing
  2822                              <1> 	; RESET (audio) INTERRUPT CALLBACK SERVICE
  2823 000129B6 8A1D[B3890100]      <1> 	mov	bl, [audio_intr] ; IRQ number
  2824 000129BC A0[6D010300]        <1> 	mov	al, [u.uno]
  2825 000129C1 28FF                <1> 	sub	bh, bh ; 0 ; unlink IRQ from user service
  2826 000129C3 E8C9020000          <1>  	call	set_irq_callback_service
  2827                              <1> 	;jc	sndc_perm_error ; 'permission denied' error
  2828                              <1> 	;retn
  2829                              <1> 	; 30/07/2022
  2830 000129C8 73AB                <1> 	jnc	short sndc_cancel_ok
  2831 000129CA E960FDFFFF          <1> 	jmp	sndc_perm_error
  2832                              <1> 
  2833                              <1> sound_dalloc:
  2834                              <1> 	; FUNCTION = 10
  2835                              <1> 	; Deallocate (ring 3) audio buffer
  2836                              <1> 	; 22/04/2017
  2837 000129CF A0[D9890100]        <1> 	mov	al, [audio_user]	
  2838 000129D4 3A05[6D010300]      <1> 	cmp	al, [u.uno]
  2839 000129DA 7599                <1> 	jne	short snd_nothing
  2840 000129DC 8B1D[C4890100]      <1> 	mov	ebx, [audio_buffer]
  2841                              <1> 	;or	ebx, ebx
  2842                              <1> 	;jz	short snd_nothing
  2843 000129E2 8B0D[CC890100]      <1> 	mov	ecx, [audio_buff_size]
  2844 000129E8 E85935FFFF          <1> 	call	deallocate_user_pages
  2845 000129ED 31C0                <1> 	xor	eax, eax
  2846 000129EF A3[C4890100]        <1> 	mov	[audio_buffer], eax ; 0
  2847 000129F4 A2[D9890100]        <1> 	mov	[audio_user], al ; 0
  2848                              <1> ;sndc_cancel_ok:
  2849 000129F9 C3                  <1> 	retn
  2850                              <1> 
  2851                              <1> sound_volume:
  2852                              <1> 	; FUNCTION = 11
  2853                              <1> 	; Set sound volume level
  2854                              <1> 	; 30/07/2022
  2855                              <1> 	; 28/05/2017
  2856                              <1> 	; 20/05/2017
  2857                              <1> 	; 22/04/2017, 24/04/2017
  2858                              <1> 	; bl = component (0 = master/playback/lineout volume)
  2859                              <1> 	; cl = left channel volume level (0 to 31)
  2860                              <1> 	; ch = right channel volume level (0 to 31)
  2861                              <1> 
  2862 000129FA 80FB80              <1> 	cmp	bl, 80h
  2863 000129FD 720A                <1> 	jb	short snd_vol_1
  2864                              <1> 	;ja	snd_nothing ; temporary.
  2865                              <1> 	; 30/07/2022
  2866 000129FF 7707                <1> 	ja	short snd_vol_0
  2867                              <1> 	; Set volume level for next play (BL>= 80h)
  2868 00012A01 66890D[E6890100]    <1> 	mov	[audio_master_volume], cx
  2869                              <1> snd_vol_0:
  2870 00012A08 C3                  <1> 	retn
  2871                              <1> snd_vol_1:
  2872                              <1> 	; set volume level immediate (BL< 80h)
  2873 00012A09 80FB00              <1> 	cmp	bl, 0
  2874                              <1> 	;ja	snd_nothing ; temporary.
  2875                              <1> 	; 30/07/2022
  2876 00012A0C 77FA                <1> 	ja	short snd_vol_0
  2877                              <1> 
  2878 00012A0E E8E0010000          <1> 	call	snd_dev_check
  2879                              <1> 	;jc	snd_nothing ; temporary.
  2880                              <1> 	; 30/07/2022
  2881 00012A13 72F3                <1> 	jc	short snd_vol_0
  2882 00012A15 E8E6010000          <1> 	call	snd_buf_check
  2883                              <1> 	;jc	snd_nothing ; temporary.
  2884                              <1> 	; 30/07/2022
  2885 00012A1A 72EC                <1> 	jc	short snd_vol_0	
  2886                              <1> 
  2887 00012A1C A0[B1890100]        <1> 	mov	al, [audio_device]
  2888 00012A21 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2889                              <1> 	;je	vt8233_volume
  2890                              <1> 	; 30/07/2022
  2891 00012A23 7207                <1> 	jb	short snd_vol_2
  2892                              <1> 	; 28/05/2017
  2893                              <1> 	;ja	snd_nothing ; temporary.
  2894                              <1> 	; 30/07/2022
  2895 00012A25 77E1                <1> 	ja	short snd_vol_0
  2896                              <1> 	;ja	hda_volume
  2897                              <1> 	; 30/07/2022
  2898 00012A27 E943160000          <1> 	jmp	vt8233_volume
  2899                              <1> snd_vol_2:	
  2900                              <1> 	; Sound Blaster 16
  2901 00012A2C 3C01                <1> 	cmp	al, 1 ; SB 16
  2902                              <1> 	;je	sb16_volume
  2903                              <1> 	; 30/07/2022
  2904 00012A2E 7705                <1> 	ja	short snd_vol_3
  2905 00012A30 E9C7180000          <1> 	jmp	sb16_volume
  2906                              <1> snd_vol_3:
  2907                              <1> 	; 30/07/2022
  2908                              <1> 	;cmp	al, 2
  2909                              <1> 	;ja	short snd_vol_4
  2910 00012A35 E9741B0000          <1> 	jmp	ac97_volume
  2911                              <1> ;snd_vol_4:
  2912                              <1> 	;jmp	hda_volume
  2913                              <1> 
  2914                              <1> soundc_disable:
  2915                              <1> 	; FUNCTION = 12 
  2916                              <1> 	; Disable audio device (and unlink DMA memory)
  2917                              <1> 	; 30/07/2022
  2918                              <1> 	; 28/05/2017
  2919                              <1> 	; 24/05/2017
  2920                              <1> 	; 22/04/2017
  2921 00012A3A E8B4010000          <1> 	call	snd_dev_check
  2922                              <1> 	;jc	soundc_dev_err ; temporary.
  2923                              <1> 	; 30/07/2022
  2924 00012A3F 7305                <1> 	jnc	short snd_disable_4
  2925 00012A41 E990FBFFFF          <1> 	jmp	soundc_dev_err
  2926                              <1> snd_disable_4:
  2927                              <1> 	;call	snd_buf_check
  2928                              <1> 	;;jc	sndc_owner_error ; temporary.
  2929                              <1> 	; 30/07/2022
  2930                              <1> 	;jnc	short snd_disable_5
  2931                              <1> 	;jmp	sndc_owner_error
  2932                              <1> ;snd_disable_5:
  2933 00012A46 A0[B1890100]        <1> 	mov	al, [audio_device]
  2934 00012A4B 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2935 00012A4D 7414                <1> 	je	short snd_disable_1
  2936                              <1> 	;ja	snd_nothing ; temporary.
  2937                              <1> 	; 30/07/2022
  2938 00012A4F 7757                <1> 	ja	short snd_disable_3 ; retn
  2939 00012A51 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2940 00012A53 7507                <1> 	jne	short snd_disable_0
  2941 00012A55 E817190000          <1> 	call	sb16_stop
  2942 00012A5A EB0C                <1> 	jmp	short snd_disable_2
  2943                              <1> snd_disable_0:
  2944 00012A5C E82C1C0000          <1> 	call	ac97_stop
  2945 00012A61 EB05                <1> 	jmp	short snd_disable_2
  2946                              <1> snd_disable_1:
  2947 00012A63 E8EE140000          <1> 	call	vt8233_stop
  2948                              <1> snd_disable_2:
  2949 00012A68 A0[B3890100]        <1> 	mov	al, [audio_intr]
  2950 00012A6D 29DB                <1> 	sub	ebx, ebx ; 0 = reset
  2951 00012A6F E876FAFFFF          <1> 	call	set_dev_IRQ_service
  2952                              <1> 
  2953                              <1> 	;mov	al, [audio_intr]
  2954 00012A74 28E4                <1> 	sub	ah, ah ; 0 = reset
  2955 00012A76 E836F8FFFF          <1> 	call	set_hardware_int_vector
  2956                              <1> 
  2957 00012A7B 31C0                <1> 	xor	eax, eax
  2958 00012A7D A2[B1890100]        <1> 	mov	byte [audio_device], al
  2959 00012A82 A2[B3890100]        <1> 	mov	byte [audio_intr], al
  2960 00012A87 8705[D0890100]      <1> 	xchg	eax, [audio_dma_buff]
  2961                              <1> 	; 24/05/2017
  2962                              <1> 	;or	eax, eax
  2963                              <1> 	;jz	short snd_disable_3
  2964                              <1> 	;cmp	eax, sb16_dma_buffer ; default DMA buffer
  2965                              <1> 	;je	short snd_disable_3
  2966 00012A8D 803D[B0890100]00    <1> 	cmp	byte [audio_pci], 0 ; AC97 audio controller ?
  2967 00012A94 7612                <1> 	jna	short snd_disable_3
  2968 00012A96 C605[B0890100]00    <1> 	mov	byte [audio_pci], 0
  2969                              <1> 	;sub	ecx, ecx
  2970                              <1> 	;xchg	ecx, [audio_dmabuff_size]
  2971 00012A9D 8B0D[D4890100]      <1> 	mov	ecx, [audio_dmabuff_size]
  2972 00012AA3 E86033FFFF          <1> 	call	deallocate_memory_block
  2973                              <1> snd_disable_3:
  2974 00012AA8 C3                  <1> 	retn
  2975                              <1> 
  2976                              <1> sound_dma_map:
  2977                              <1> 	; FUNCTION = 13 
  2978                              <1> 	; Map audio dma buff addr to user's buffer addr
  2979                              <1> 	; 30/07/2022
  2980                              <1> 	; 12/05/2017
  2981 00012AA9 21C9                <1> 	and	ecx, ecx
  2982                              <1> 	;jz	sound_buff_error
  2983                              <1> 	; 30/07/2022
  2984 00012AAB 7505                <1> 	jnz	short snd_dma_map_3
  2985 00012AAD E92BFBFFFF          <1> 	jmp	sound_buff_error
  2986                              <1> snd_dma_map_3:
  2987 00012AB2 803D[B1890100]01    <1> 	cmp	byte [audio_device], 1
  2988 00012AB9 722A                <1> 	jb	short snd_dma_map_1
  2989                              <1> snd_dma_map_0:
  2990 00012ABB A1[D0890100]        <1> 	mov	eax, [audio_dma_buff]
  2991 00012AC0 21C0                <1> 	and	eax, eax
  2992 00012AC2 7421                <1> 	jz	short snd_dma_map_1
  2993                              <1> 	;
  2994 00012AC4 8A1D[D9890100]      <1> 	mov	bl, [audio_user]
  2995 00012ACA 08DB                <1> 	or	bl, bl
  2996 00012ACC 7417                <1> 	jz	short snd_dma_map_1
  2997 00012ACE 3A1D[6D010300]      <1> 	cmp	bl, [u.uno]
  2998                              <1> 	;jne	sndc_owner_error
  2999                              <1> 	; 30/07/2022
  3000 00012AD4 7405                <1> 	je	short snd_dma_map_4
  3001 00012AD6 E94FFCFFFF          <1> 	jmp	sndc_owner_error
  3002                              <1> snd_dma_map_4:
  3003 00012ADB 8B1D[D4890100]      <1> 	mov	ebx, [audio_dmabuff_size]
  3004 00012AE1 21DB                <1> 	and	ebx, ebx
  3005 00012AE3 750A                <1> 	jnz	short snd_dma_map_2
  3006                              <1> snd_dma_map_1:
  3007 00012AE5 B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
  3008 00012AEA BB00000100          <1> 	mov	ebx, 65536
  3009                              <1> snd_dma_map_2:	
  3010 00012AEF 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
  3011 00012AF5 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
  3012 00012AFA 39D9                <1> 	cmp	ecx, ebx
  3013                              <1> 	;ja	sound_buff_error
  3014                              <1> 	; 30/07/2022
  3015 00012AFC 7605                <1> 	jna	short snd_dma_map_6
  3016                              <1> snd_dma_map_5:
  3017 00012AFE E9DAFAFFFF          <1> 	jmp	sound_buff_error
  3018                              <1> snd_dma_map_6:
  3019 00012B03 50                  <1> 	push	eax
  3020 00012B04 89D3                <1> 	mov	ebx, edx
  3021 00012B06 C1E90C              <1> 	shr	ecx, 12 ; byte count to page count
  3022                              <1> 	; eax = physical address of (audio) dma buffer
  3023                              <1> 	; ebx = virtual address of (audio) dma buffer (user's pgdir) 
  3024                              <1> 	; ecx = page count (>0)
  3025 00012B09 E86A33FFFF          <1> 	call	direct_memory_access
  3026 00012B0E 58                  <1> 	pop	eax
  3027                              <1> 	;jc	sound_buff_error
  3028                              <1> 	; 30/07/2022
  3029 00012B0F 72ED                <1> 	jc	short snd_dma_map_5
  3030 00012B11 A3[1C010300]        <1> 	mov	[u.r0], eax
  3031 00012B16 C3                  <1> 	retn
  3032                              <1> 
  3033                              <1> soundc_info:
  3034                              <1> 	; FUNCTION = 14 
  3035                              <1> 	; Get Audio Controller Info
  3036                              <1> 	; 30/07/2022
  3037                              <1> 	; 10/06/2017
  3038                              <1> 	; 05/06/2017
  3039 00012B17 20DB                <1> 	and	bl, bl ; 0
  3040 00012B19 7409                <1> 	jz	short sndc_info_0
  3041                              <1> 	; invalid parameter !
  3042                              <1> ; 30/07/2022
  3043                              <1> 	;mov	eax, ERR_INV_PARAMETER ; 23
  3044                              <1> ;sndc_inf_error:
  3045                              <1> ;	mov	[u.r0], eax
  3046                              <1> ;	mov	[u.error], eax
  3047                              <1> ;	jmp	error
  3048                              <1> 	; 30/07/2022
  3049 00012B1B 29C0                <1> 	sub	eax, eax
  3050 00012B1D B017                <1> 	mov	al, ERR_INV_PARAMETER ; 23
  3051 00012B1F E9C5FAFFFF          <1> 	jmp	sysaudio_err
  3052                              <1> 
  3053                              <1> sndc_info_0:
  3054 00012B24 E8CA000000          <1> 	call	snd_dev_check
  3055                              <1> 	;jc	soundc_dev_err
  3056                              <1> 	; 30/07/2022
  3057 00012B29 7305                <1> 	jnc	short sndc_info_3
  3058                              <1> snd_data_dev_err:
  3059 00012B2B E9A6FAFFFF          <1> 	jmp	soundc_dev_err
  3060                              <1> sndc_info_3:
  3061 00012B30 8B1D[BC890100]      <1> 	mov	ebx, [audio_vendor]
  3062 00012B36 8B0D[B8890100]      <1> 	mov	ecx, [audio_dev_id]
  3063                              <1> 	;mov	al,  [audio_device]
  3064 00012B3C 3C02                <1> 	cmp	al, 2 ; AC'97 (ICH)
  3065 00012B3E 7513                <1> 	jne	short sndc_info_1
  3066                              <1> 	; Intel AC97 (ICH) Audio Controller (=2)	
  3067 00012B40 668B15[EA890100]    <1> 	mov	dx, [NABMBAR]
  3068 00012B47 C1E210              <1> 	shl	edx, 16
  3069 00012B4A 668B15[E8890100]    <1> 	mov	dx, [NAMBAR]
  3070 00012B51 EB07                <1> 	jmp	short sndc_info_2
  3071                              <1> sndc_info_1:
  3072                              <1> 	; 05/06/2017
  3073                              <1> 	; Note: Intel HDA code (here) is not ready yet!
  3074                              <1> 	; !!! SB16 or VT8233 (VT8237R) !!!
  3075 00012B53 0FB715[B6890100]    <1> 	movzx	edx, word [audio_io_base]	
  3076                              <1> sndc_info_2:
  3077 00012B5A 88C4                <1> 	mov	ah, al ;  [audio_device]
  3078 00012B5C A0[B3890100]        <1> 	mov	al, [audio_intr] 
  3079                              <1> 
  3080                              <1> 	; EAX = IRQ Number in AL
  3081                              <1> 	;	Audio Device Number in AH 
  3082                              <1> 	; EBX = DEV/VENDOR ID
  3083                              <1> 	;	(DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
  3084                              <1> 	; ECX = BUS/DEV/FN 
  3085                              <1> 	;	(00000000BBBBBBBBDDDDDFFF00000000)
  3086                              <1> 	; EDX = NABMBAR/NAMBAR (for AC97)
  3087                              <1> 	;	(Low word, DX = NAMBAR address)
  3088                              <1> 	; EDX = Base IO Addr (DX) for SB16 & VT8233
  3089                              <1> 
  3090                              <1> 	; 10/06/2017
  3091 00012B61 A3[1C010300]        <1> 	mov	[u.r0], eax
  3092 00012B66 8B2D[18010300]      <1> 	mov	ebp, [u.usp]
  3093 00012B6C 895D10              <1> 	mov	[ebp+16], ebx  ; ebx
  3094 00012B6F 895514              <1> 	mov	[ebp+20], edx  ; edx
  3095 00012B72 894D18              <1> 	mov	[ebp+24], ecx  ; ecx
  3096                              <1>   			  		
  3097 00012B75 C3                  <1>  	retn
  3098                              <1> 
  3099                              <1> sound_data:
  3100                              <1> 	; FUNCTION = 15 
  3101                              <1> 	; Get Current Sound data for graphics
  3102                              <1> 	; 30/07/2022
  3103                              <1> 	; 22/06/2017
  3104                              <1> 	;
  3105 00012B76 E878000000          <1> 	call	snd_dev_check
  3106                              <1> 	;jc	soundc_dev_err ; Device not ready !
  3107                              <1> 	; 30/07/2022
  3108 00012B7B 72AE                <1> 	jc	short snd_data_dev_err
  3109                              <1> 
  3110 00012B7D 80FB00              <1> 	cmp	bl, 0
  3111 00012B80 760A                <1> 	jna	short sound_data_0
  3112                              <1> 
  3113                              <1> 	; Only PCM OUT buffer data is valid for now!
  3114 00012B82 B817000000          <1> 	mov	eax, ERR_INV_PARAMETER  ; 23
  3115 00012B87 E95DFAFFFF          <1> 	jmp	sysaudio_err
  3116                              <1> 
  3117                              <1> sound_data_0:
  3118 00012B8C A1[D0890100]        <1> 	mov	eax, [audio_dma_buff]
  3119 00012B91 09C0                <1> 	or	eax, eax
  3120                              <1> 	;jz	sound_buff_error
  3121                              <1> 	; 30/07/2022
  3122 00012B93 741A                <1> 	jz	short sound_data_5
  3123                              <1> 
  3124 00012B95 803D[B1890100]04    <1> 	cmp	byte [audio_device], 4 ; Intel HDA
  3125 00012B9C 744C                <1> 	je	short sound_data_4 ; temporary ! (22/06/2017)
  3126                              <1> 
  3127 00012B9E 21C9                <1> 	and	ecx, ecx
  3128                              <1> 	;jnz	short sound_data_1 ; sample tranfer
  3129                              <1> 	
  3130                              <1> 	; Return only DMA Buffer pointer/offset... 
  3131                              <1> 	; (If DMA Buffer has been mapped to user's
  3132                              <1> 	;  memory space; program can get graphics
  3133                              <1> 	;  data by using only this pointer value.)
  3134                              <1> 	   	
  3135                              <1> 	;call	get_dma_buffer_offset
  3136                              <1> 	;; eax = DMA buffer offset
  3137                              <1> 	;;	(!not half buffer offset!)
  3138                              <1> 	;mov	[u.r0], eax
  3139                              <1> 	;retn
  3140                              <1> 
  3141                              <1> 	;jz	get_dma_buffer_offset
  3142                              <1> 	; 30/07/2022
  3143 00012BA0 7505                <1> 	jnz	short sound_data_1
  3144 00012BA2 E9D11C0000          <1> 	jmp	get_dma_buffer_offset		
  3145                              <1> 	
  3146                              <1> sound_data_1:
  3147                              <1> 	;mov	eax, [audio_dmabuff_size]
  3148                              <1> 	;shr	eax, 1 ; half buffer size
  3149                              <1> 	;cmp	ecx, eax
  3150                              <1> 	;ja	short sound_buff_error	
  3151                              <1> 
  3152 00012BA7 3B0D[D4890100]      <1> 	cmp	ecx, [audio_dmabuff_size]
  3153                              <1> 	;ja	sound_buff_error
  3154                              <1> 	; 30/07/2022
  3155 00012BAD 7605                <1> 	jna	short sound_data_6
  3156                              <1> sound_data_5:
  3157 00012BAF E929FAFFFF          <1> 	jmp	sound_buff_error	
  3158                              <1> sound_data_6:
  3159 00012BB4 89D0                <1> 	mov	eax, edx
  3160 00012BB6 25FF0F0000          <1> 	and	eax, PAGE_OFF ; 4095 (0FFFh)
  3161 00012BBB 81F900100000        <1> 	cmp	ecx, 4096
  3162 00012BC1 7604                <1> 	jna	short sound_data_2
  3163                              <1> 	;mov	ecx, 4096 ; max. 1 page
  3164                              <1> 	; 30/07/2022
  3165 00012BC3 31C9                <1> 	xor	ecx, ecx
  3166 00012BC5 B510                <1> 	mov	ch, 16
  3167                              <1> 	; ecx = 4096
  3168                              <1> sound_data_2:
  3169 00012BC7 01C8                <1> 	add	eax, ecx
  3170 00012BC9 3D00100000          <1> 	cmp	eax, 4096
  3171 00012BCE 7606                <1> 	jna	short sound_data_3
  3172 00012BD0 6625FF0F            <1> 	and	ax, PAGE_OFF ; 4095 (0FFFh)
  3173 00012BD4 29C1                <1> 	sub	ecx, eax
  3174                              <1> 	; here, ECX has been adjusted to fit 
  3175                              <1> 	;	in page border..  (<= 4096, >0)
  3176                              <1> sound_data_3:
  3177 00012BD6 51                  <1> 	push	ecx
  3178 00012BD7 52                  <1> 	push	edx
  3179 00012BD8 89D3                <1> 	mov	ebx, edx 
  3180 00012BDA E8D82EFFFF          <1> 	call	get_physical_addr
  3181 00012BDF 5A                  <1> 	pop	edx
  3182 00012BE0 59                  <1> 	pop	ecx
  3183                              <1> 	;jc	sound_buff_error
  3184                              <1> 	; 30/07/2022
  3185 00012BE1 72CC                <1> 	jc	short sound_data_5	
  3186                              <1> 	
  3187                              <1> 	; eax = physical address of user's buffer
  3188 00012BE3 89C3                <1> 	mov	ebx, eax  
  3189                              <1> 	; ecx = byte (transfer) count
  3190                              <1> 	;call	get_current_sound_data
  3191                              <1> 	;retn
  3192 00012BE5 E9EC1B0000          <1> 	jmp	get_current_sound_data
  3193                              <1> 
  3194                              <1> sound_data_4:
  3195                              <1> 	; Intel HDA code is not ready yet !
  3196                              <1> 	; 22/06/2017
  3197 00012BEA 31C0                <1> 	xor	eax, eax
  3198 00012BEC 48                  <1> 	dec	eax
  3199 00012BED A3[1C010300]        <1> 	mov	[u.r0], eax ; 0FFFFFFFFh
  3200 00012BF2 C3                  <1> 	retn 
  3201                              <1> 
  3202                              <1> snd_dev_check:
  3203                              <1> 	; 10/06/2017
  3204                              <1> 	; 05/06/2017
  3205                              <1> 	; 24/05/2017
  3206                              <1> 	; 22/04/2017
  3207                              <1> 	; 21/04/2017
  3208                              <1> 	; ... device check at first
  3209 00012BF3 A0[B1890100]        <1> 	mov	al, [audio_device]
  3210 00012BF8 3C01                <1> 	cmp	al, 1 ; SB 16
  3211 00012BFA 7203                <1> 	jb	short snd_dev_chk_retn ; error !
  3212                              <1> 	;cmp	al, 4 ; Intel HDA
  3213                              <1> 	;ja	short snd_dbchk_stc ; invalid !
  3214                              <1> 	; 10/06/2017
  3215 00012BFC 3C05                <1> 	cmp	al, 5
  3216 00012BFE F5                  <1> 	cmc
  3217                              <1> snd_dev_chk_retn:
  3218 00012BFF C3                  <1> 	retn
  3219                              <1> 
  3220                              <1> snd_buf_check:
  3221                              <1> 	; 10/06/2017
  3222                              <1> 	; 22/04/2017
  3223                              <1> 	; 21/04/2017
  3224                              <1> 	; ... buffer & (buffer) owner check at second
  3225 00012C00 833D[C4890100]00    <1> 	cmp	dword [audio_buffer], 0
  3226 00012C07 760D                <1> 	jna	short snd_dbchk_stc
  3227                              <1> snd_user_check:
  3228 00012C09 A0[6D010300]        <1> 	mov	al, [u.uno]
  3229 00012C0E 3A05[D9890100]      <1> 	cmp	al, [audio_user]
  3230                              <1> 	;jne	short snd_dbchk_stc
  3231                              <1> 	;retn
  3232 00012C14 74E9                <1> 	je	short snd_dev_chk_retn
  3233                              <1> 
  3234                              <1> snd_dbchk_stc:
  3235 00012C16 F9                  <1> 	stc
  3236 00012C17 C3                  <1> 	retn
  3237                              <1> 
  3238                              <1> sound_update:
  3239                              <1> 	; FUNCTION = 16 
  3240                              <1> 	; bl = 
  3241                              <1> 	;    0 = automatic (sequental) update (with flag switch!)
  3242                              <1> 	;    1 = update dma half buffer 1 (without flag switch!)		
  3243                              <1> 	;    2 = update dma half buffer 2 (without flag switch!)
  3244                              <1> 	;  FFh = get current flag value	
  3245                              <1> 	;      0 = dma half buffer 1 (will be played next)
  3246                              <1> 	;      1 = dma half buffer 2 (will be played next)
  3247                              <1> 	
  3248                              <1> 	; 30/07/2022
  3249                              <1> 	; 10/10/2017
  3250                              <1> 	; ... device check at first
  3251 00012C18 A0[B1890100]        <1> 	mov	al, [audio_device]
  3252 00012C1D 08C0                <1> 	or	al, al ; 0 ; pc speaker or invalid 
  3253                              <1> 	;jz	soundc_dev_err
  3254                              <1> 	; 30/07/2022
  3255 00012C1F 7505                <1> 	jnz	short snd_update_4
  3256 00012C21 E9B0F9FFFF          <1> 	jmp	soundc_dev_err
  3257                              <1> snd_update_4:
  3258                              <1> 	; ... buffer & (buffer) owner check at second
  3259 00012C26 833D[C4890100]00    <1> 	cmp	dword [audio_buffer], 0
  3260                              <1> 	;jna	sound_buff_error
  3261                              <1> 	; 30/07/2022
  3262 00012C2D 761C                <1> 	jna	short snd_update_6 ; jmp sound_buff_error
  3263 00012C2F A0[6D010300]        <1> 	mov	al, [u.uno]
  3264 00012C34 3A05[D9890100]      <1> 	cmp	al, [audio_user]
  3265                              <1> 	;jne	sndc_owner_error
  3266                              <1> 	; 30/07/2022
  3267 00012C3A 7405                <1> 	je	short snd_update_5
  3268 00012C3C E9E9FAFFFF          <1> 	jmp	sndc_owner_error
  3269                              <1> snd_update_5:
  3270                              <1> 	; Transfer ring 3 (user's) audio buffer content to dma buffer
  3271 00012C41 8B3D[D0890100]      <1> 	mov	edi, [audio_dma_buff] ; dma buffer (ring 0)
  3272 00012C47 09FF                <1> 	or	edi, edi
  3273                              <1> 	;jz	sound_buff_error
  3274                              <1> 	; 30/07/2022
  3275 00012C49 7505                <1> 	jnz	short snd_update_7
  3276                              <1> snd_update_6:
  3277 00012C4B E98DF9FFFF          <1> 	jmp	sound_buff_error
  3278                              <1> snd_update_7:
  3279 00012C50 8B35[C8890100]      <1> 	mov	esi, [audio_p_buffer] ; physical address (ring 3)
  3280 00012C56 8B0D[CC890100]      <1> 	mov	ecx, [audio_buff_size]
  3281                              <1> 	
  3282                              <1> 	;movzx	eax, byte [audio_flag]
  3283 00012C5C A0[D8890100]        <1> 	mov	al, [audio_flag]
  3284                              <1> 
  3285 00012C61 FEC3                <1> 	inc	bl
  3286 00012C63 7426                <1> 	jz	short snd_update_3 ; bl = 0FFh
  3287 00012C65 FECB                <1> 	dec	bl 
  3288 00012C67 7410                <1> 	jz	short snd_update_0 ; bl = 0
  3289                              <1> 
  3290 00012C69 80FB02              <1> 	cmp	bl, 2
  3291 00012C6C 7416                <1> 	je	short snd_update_1 ; dma half buffer 2
  3292 00012C6E 7216                <1> 	jb	short snd_update_2 ; dma half buffer 1
  3293                              <1>  
  3294                              <1> 	; invalid parameter !
  3295                              <1> ; 30/07/2022
  3296                              <1> 	;mov	eax, ERR_INV_PARAMETER ; 23
  3297                              <1> ;	mov	[u.r0], eax
  3298                              <1> ;	mov	[u.error], eax
  3299                              <1> ;	jmp	error
  3300                              <1> 
  3301                              <1> 	; 30/07/2022
  3302 00012C70 29C0                <1> 	sub	eax, eax
  3303 00012C72 B017                <1> 	mov	al, ERR_INV_PARAMETER ; 23
  3304 00012C74 E970F9FFFF          <1> 	jmp	sysaudio_err
  3305                              <1> 	
  3306                              <1> snd_update_0:
  3307 00012C79 8035[D8890100]01    <1> 	xor	byte [audio_flag], 1 ; update flag !!!
  3308 00012C80 3C01                <1> 	cmp	al, 1
  3309 00012C82 7202                <1> 	jb	short snd_update_2 ; dma half buffer 1
  3310                              <1> snd_update_1:
  3311                              <1> 	; dma half buffer 2
  3312 00012C84 01CF                <1> 	add	edi, ecx
  3313                              <1> snd_update_2:
  3314                              <1> 	;rep	movsb
  3315 00012C86 C1E902              <1> 	shr	ecx, 2
  3316 00012C89 F3A5                <1> 	rep	movsd
  3317                              <1> snd_update_3:
  3318 00012C8B A3[1C010300]        <1> 	mov	[u.r0], eax
  3319                              <1> 
  3320 00012C90 C3                  <1> 	retn
  3321                              <1> 
  3322                              <1> set_irq_callback_service:
  3323                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
  3324                              <1> 	; 03/08/2020
  3325                              <1> 	; 10/06/2017
  3326                              <1> 	; 12/05/2017
  3327                              <1> 	; 24/04/2017
  3328                              <1> 	; 22/04/2017
  3329                              <1> 	; caller: 'syscalbac' or 'sysaudio' or ...
  3330                              <1> 	; 13/04/2017, 14/04/2017, 17/04/2017
  3331                              <1> 	; 24/02/2017, 26/02/2017, 28/02/2017
  3332                              <1> 	; 21/02/2017 - TRDOS 386 (TRDOS v2.0)
  3333                              <1> 	;
  3334                              <1> 	; Link or unlink IRQ callback service to/from user (ring 3)	
  3335                              <1> 	;
  3336                              <1> 	; INPUT ->
  3337                              <1> 	;	If AL = 0, the caller is 'syscalbac';
  3338                              <1> 	;	   otherwise, the caller is 'sysaudio' or ...
  3339                              <1> 	;	   (AL = user number) 
  3340                              <1> 	; 	 
  3341                              <1> 	;	BL = IRQ number (Hardware interrupt request number)
  3342                              <1> 	;	     (0 t0 15 but IRQ 0,1,2,6,8,14,15 are prohibited)
  3343                              <1> 	;	     IRQ numbers 3,4,5,7,9,10,11,12,13 are valid
  3344                              <1> 	;	     (numbers >15 are invalid)
  3345                              <1> 	;
  3346                              <1> 	;	BH = 0 = Unlink IRQ (in BL) from user (ring 3) service
  3347                              <1> 	;	     1 = Link IRQ by using Signal Response Byte method
  3348                              <1> 	;	     2 = Link IRQ by using Callback service method 		
  3349                              <1> 	;	     3 = Link IRQ by using Auto Increment S.R.B. method 	
  3350                              <1> 	;	    >3 = invalid 
  3351                              <1> 	;		 (syscallback version will return to user) 	
  3352                              <1> 	;	
  3353                              <1> 	;	CL = Signal Return/Response Byte value 
  3354                              <1> 	;
  3355                              <1> 	;	If BH = 3, kernel will put a counter value ; 03/08/2020
  3356                              <1> 	;	          (into the S.R.B. addr)
  3357                              <1> 	;		  between 0 to 255. (start value = CL+1)
  3358                              <1> 	;	
  3359                              <1> 	;	NOTE: counter value, for example: even and odd numbers
  3360                              <1> 	;	      may be used for -audio- DMA buffer switch 
  3361                              <1> 	;	      within double buffer method, etc. 		
  3362                              <1> 	;
  3363                              <1> 	;	EDX = Signal return (Response) byte address
  3364                              <1> 	;	       		  - or -
  3365                              <1> 	;	      Interrupt/Callback service/routine address
  3366                              <1> 	; 	
  3367                              <1> 	;	      (virtual address in user's memory space)
  3368                              <1> 	;
  3369                              <1> 	; OUTPUT ->
  3370                              <1> 	;	CF = 0 & EAX = 0 -> Successful setting
  3371                              <1> 	;	CF = 1 & EAX > 0 -> IRQ is prohibited or locked 
  3372                              <1> 	;			by another process
  3373                              <1> 	;		 eax = ERR_PERM_DENIED -> prohibited or locked
  3374                              <1> 	;		 eax = ERR_INV_PARAMETER -> 
  3375                              <1> 	;		       invalid parameter/option or bad address
  3376                              <1> 	;
  3377                              <1> 	; TRDOS 386 - IRQ CALLBACK structures (parameters):
  3378                              <1> 	;	
  3379                              <1> 	;	   [u.irqlock] = 1 word, IRQ flags (0-15) that indicates
  3380                              <1> 	;			which IRQs are locked by (that) user.
  3381                              <1> 	;		        Lock and unlock (by user) will change
  3382                              <1> 	;			these flags or 'terminate process' (sysexit)
  3383                              <1> 	;			will clear these flags and unlock those IRQs.
  3384                              <1> 	;			               
  3385                              <1> 	;		   	Bit 0 is for IRQ 0 and Bit 15 is for IRQ 15
  3386                              <1> 	;
  3387                              <1> 	;	   IRQ(x).owner	 : 1 byte, user, [u.uno], 0 = free (unlocked)	
  3388                              <1> 	;
  3389                              <1> 	;	   IRQ(x).method : 1 byte for callback method & status
  3390                              <1> 	;			   0 = Signal Response Byte method
  3391                              <1> 	;			   1 = Callback service method
  3392                              <1> 	;			   >1 = invalid for current 'syscalback'.
  3393                              <1> 	;			or(+) 80h = IRQ is in use by system (ring 0)
  3394                              <1> 	;			            function (audio etc.) or
  3395                              <1> 	;			   	    a device driver.	   	
  3396                              <1> 	;			(system function will ignore the lock/owner)
  3397                              <1> 	;
  3398                              <1> 	;	   IRQ(x).srb	: 1 byte, Signal Return/Response byte value
  3399                              <1> 	;			  (a fixed value by user or a counter value
  3400                              <1> 	;			 from 0 to 255, which is increased by every
  3401                              <1> 	;			 interrupt just before putting it into 
  3402                              <1> 	;			 the Signal Response byte address
  3403                              <1> 	;			 (This is not used in callback serv method)
  3404                              <1> 	;	    	  
  3405                              <1> 	;	   IRQ(x).addr	: 1 dword
  3406                              <1> 	;			  Signal Response Byte address (physical)
  3407                              <1> 	;			  		-or-
  3408                              <1> 	;			  Callback service address (virtual)
  3409                              <1> 	;
  3410                              <1> 	;	   IRQ(x).dev	: 1 byte
  3411                              <1> 	;			  0 = Default device or kernel function
  3412                              <1> 	;			  		-or-
  3413                              <1> 	;			  1-255 = Assigned device driver number
  3414                              <1> 	;
  3415                              <1> 	;	   (x) = 3,4,5,7,9,10,11,12,13
  3416                              <1> 	;
  3417                              <1> 	
  3418 00012C91 80FB0F              <1> 	cmp	bl, 15
  3419 00012C94 7728                <1> 	ja	short scbs_2
  3420                              <1> 	
  3421 00012C96 80FF03              <1> 	cmp	bh, 3
  3422 00012C99 7723                <1> 	ja	short scbs_2  ; invalid parameter
  3423                              <1> 
  3424 00012C9B 0FB6FB              <1> 	movzx	edi, bl ; save IRQ number
  3425                              <1> 
  3426                              <1> 		;  IRQ 0,1,2,6,8,14,15 are prohibited
  3427                              <1> 	;IRQenum: ; 'trdosk9.s'
  3428                              <1> 	;	db  0,0,0,1,2,3,0,4,0,5,6,7,8,9,0,0
  3429                              <1> 
  3430 00012C9E 0FB6B7[B4370100]    <1> 	movzx	esi, byte [edi+IRQenum] ; IRQ availability 
  3431                              <1> 					; enumeration/index
  3432                              <1> 	;dec	esi
  3433 00012CA5 664E                <1> 	dec	si
  3434 00012CA7 780F                <1> 	js	short scbs_1 ;  0 -> 0FFFFh  
  3435                              <1> 
  3436                              <1> 	; ESI = IRQ callback parameters index number (0 to 8)
  3437                              <1> 
  3438 00012CA9 08FF                <1> 	or	bh, bh
  3439 00012CAB 7417                <1> 	jz	short scbs_4 ; unlink the IRQ (in BL)
  3440                              <1> 
  3441 00012CAD FECF                <1> 	dec	bh
  3442                              <1> 	; bh = method (0 = signal response byte, 1 = callback)
  3443                              <1> 	;	      (2 = auto increment of signal response byte) 
  3444                              <1> 
  3445 00012CAF 80BE[60890100]00    <1> 	cmp	byte [esi+IRQ.owner], 0 ; locked ?
  3446 00012CB6 7635                <1> 	jna	short scbs_6	; no... OK...	
  3447                              <1> 
  3448                              <1> scbs_1:
  3449                              <1> 	; permission denied (prohibited IRQ)
  3450                              <1> 	;mov	eax, ERR_PERM_DENIED
  3451                              <1> 	; 30/07/2022
  3452 00012CB8 29C0                <1> 	sub	eax, eax
  3453 00012CBA B00B                <1> 	mov	al, ERR_PERM_DENIED
  3454 00012CBC F9                  <1> 	stc
  3455 00012CBD C3                  <1> 	retn
  3456                              <1> scbs_2:
  3457                              <1> 	;stc
  3458                              <1> scbs_3:
  3459                              <1> 	;mov	eax, ERR_INV_PARAMETER
  3460                              <1> 	; 30/07/2022
  3461 00012CBE 29C0                <1> 	sub	eax, eax
  3462 00012CC0 B017                <1> 	mov	al, ERR_INV_PARAMETER
  3463 00012CC2 F9                  <1> 	stc
  3464 00012CC3 C3                  <1> 	retn
  3465                              <1> 
  3466                              <1> scbs_4: ; unlink the requested IRQ (if it belongs to current user)
  3467                              <1> 	; 10/06/2017
  3468                              <1> 	; 22/04/2017
  3469                              <1> 	; 14/04/2017
  3470                              <1> 	; If AL = 0 -> The caller is 'syscalbac'
  3471 00012CC4 8AA6[60890100]      <1> 	mov	ah, [esi+IRQ.owner]
  3472 00012CCA 3A25[6D010300]      <1> 	cmp	ah, [u.uno]
  3473 00012CD0 75E6                <1> 	jne	short scbs_1
  3474                              <1> 
  3475 00012CD2 FE0D[92010300]      <1> 	dec	byte [u.irqc] ; decrease IRQ count (in use)
  3476                              <1> 
  3477                              <1> 	;sub	ah, ah
  3478                              <1> 	;mov	[esi+IRQ.owner], ah ; 0 ; free !!!
  3479                              <1> 	;and	byte [esi+IRQ.method], 80h
  3480                              <1> 	;mov	[esi+IRQ.srb], ah ; 0
  3481                              <1> 	;mov	[esi+IRQ.dev], ah ; 0
  3482                              <1> 	;mov	dword [esi+IRQ.addr], 0
  3483                              <1> 	;mov	dword [u.r0], 0
  3484                              <1> 
  3485                              <1> 	;mov	byte [esi+IRQ.owner], 0
  3486                              <1> 
  3487                              <1> 	; 22/04/2017
  3488 00012CD8 29C0                <1> 	sub	eax, eax
  3489 00012CDA 8886[60890100]      <1> 	mov	[esi+IRQ.owner], al ; 0
  3490                              <1> 	; 10/06/2017
  3491 00012CE0 8686[72890100]      <1> 	xchg	al, [esi+IRQ.method]
  3492 00012CE6 2480                <1> 	and	al, 80h
  3493 00012CE8 745E                <1> 	jz	short scbs_12 
  3494                              <1> 	; Audio device must be disabled -later- ! ([IRQ.medhod] = 80h)
  3495                              <1> 
  3496                              <1> ;	cmp	byte [esi+IRQ.method], 80h ; device drv or kernel extension ?
  3497                              <1> ;	jb	short scbs_12 ; bh = 0 reset to default IRQ handler
  3498                              <1> ;
  3499                              <1> ;	and	al, al
  3500                              <1> ;	jz	short scbs_5  ; the caller is 'syscalbac'
  3501                              <1> ;	; The caller is 'sysaudio' or ...
  3502 00012CEA 30C0                <1> 	xor	al, al
  3503                              <1> ;	mov	[esi+IRQ.method], al ; 0 ; reset kernel extension flag
  3504                              <1> ;scbs_5:
  3505                              <1> ;	sub	ah, ah
  3506                              <1> 	;mov	[u.r0], eax ; 0
  3507 00012CEC C3                  <1> 	retn	
  3508                              <1> 
  3509                              <1> scbs_6:
  3510                              <1> 	; 14/04/2017
  3511 00012CED 20C0                <1> 	and	al, al
  3512 00012CEF 7405                <1> 	jz	short scbs_7  ; the caller is 'syscalbac'
  3513                              <1> 	; AL = user number ([u.uno] or [audio.user] or ...)
  3514                              <1> 	; The caller is 'sysaudio' or ...
  3515                              <1> 	;	
  3516                              <1> 	; bh = method (0 = signal response byte, 1 = callback)
  3517                              <1> 	;	      (2 = auto increment of signal response byte) 
  3518                              <1> 
  3519 00012CF1 80CF80              <1> 	or	bh, 80h		; Kernel extension flag !
  3520 00012CF4 EB0A                <1> 	jmp	short scbs_8
  3521                              <1> scbs_7:	
  3522 00012CF6 8A86[72890100]      <1> 	mov	al, [esi+IRQ.method] ; >= 80h = kernel is using this IRQ
  3523 00012CFC 2480                <1> 	and	al, 80h ; use only bit 7 (kernel function flag)
  3524 00012CFE 08C7                <1> 	or	bh, al		 ; method 
  3525                              <1> 				 ; 0 = signal response byte, 1 = callback
  3526                              <1> 				 ; 2 = auto increment of s.r.b.
  3527                              <1> scbs_8:
  3528 00012D00 A0[6D010300]        <1> 	mov	al, [u.uno] ; user (process) number (1 to 16)
  3529 00012D05 8886[60890100]      <1> 	mov	[esi+IRQ.owner], al ; lock the IRQ for user
  3530 00012D0B 88BE[72890100]      <1> 	mov	[esi+IRQ.method], bh
  3531                              <1> 
  3532                              <1> ;	test	bh, 1
  3533                              <1> ;	jnz	short scbs_9 	 ; Callback method, CX will not be used 
  3534                              <1> ;			
  3535                              <1> ;	test	bh, 2		 ; use auto increment (counter) method
  3536                              <1> ;	jz	short scbs_10	 ; (count can be used for buffer switch)
  3537                              <1> ;scbs_9:
  3538                              <1> ;	xor	ecx, ecx ; 0
  3539                              <1> 
  3540                              <1> scbs_10:			      	
  3541                              <1> 	;mov	[esi+IRQ.method], bh
  3542 00012D11 888E[7B890100]      <1> 	mov	[esi+IRQ.srb], cl
  3543 00012D17 C686[69890100]00    <1> 	mov	byte [esi+IRQ.dev], 0 ; device number is always 0 
  3544                              <1> 				 ; for this system call
  3545                              <1> 	;test	bh, 1
  3546 00012D1E 80E701              <1> 	and	bh, 1 ; 17/04/2017
  3547 00012D21 7513                <1> 	jnz	short scbs_11	 ; callback method, use virtual address 
  3548                              <1> 
  3549 00012D23 53                  <1> 	push	ebx ; IRQ number (in BL)
  3550 00012D24 89D3                <1> 	mov	ebx, edx
  3551                              <1> 	; ebx = virtual address
  3552                              <1> 	; [u.pgdir] = page directory's physical address
  3553 00012D26 FE05[1E890100]      <1> 	inc	 byte [no_page_swap] ; 1 
  3554                              <1> 			; Do not add this page to swap queue
  3555                              <1> 			; and remove it from swap queue if it is
  3556                              <1> 			; on the queue.
  3557 00012D2C E8862DFFFF          <1> 	call	get_physical_addr
  3558 00012D31 5B                  <1> 	pop	ebx
  3559 00012D32 728A                <1> 	jc	short scbs_3 ; invalid address !
  3560                              <1> 	; eax = physical address of the virtual address in user's space
  3561 00012D34 89C2                <1> 	mov	edx, eax
  3562                              <1> scbs_11:
  3563 00012D36 66C1E602            <1> 	shl	si, 2		; byte (index) to dword (offset)
  3564 00012D3A 8996[84890100]      <1> 	mov	[esi+IRQ.addr], edx
  3565                              <1> 
  3566 00012D40 FE05[92010300]      <1> 	inc	byte [u.irqc]	; increase IRQ (in use) count
  3567                              <1> 
  3568 00012D46 FEC7                <1> 	inc	bh ; 17/04/2017
  3569                              <1> 	; bh > 0 -> set to requested IRQ handler (IRQ_u_list)
  3570                              <1> scbs_12:
  3571 00012D48 88D8                <1> 	mov	al, bl ; IRQ number
  3572 00012D4A 88FC                <1> 	mov	ah, bh ; 0 = reset, >0 = set
  3573 00012D4C E860F5FFFF          <1> 	call	set_hardware_int_vector
  3574                              <1> 
  3575 00012D51 31C0                <1> 	xor	eax, eax
  3576                              <1> 	;mov 	[u.r0], eax ; 0	
  3577                              <1> 
  3578 00012D53 C3                  <1> 	retn	; return with success (cf=0, eax=0)
  3579                              <1> 
  3580                              <1> 
  3581                              <1> sysdma: ; DMA FUNCTIONS
  3582                              <1> 	; 08/08/2022
  3583                              <1> 	; 30/07/2022 - TRDOS 386 Kernel v2.0.5
  3584                              <1> 	; 02/09/2017
  3585                              <1> 	; 28/08/2017
  3586                              <1> 	; 20/08/2017 - TRDOS 386 (TRDOS v2.0)
  3587                              <1> 	;
  3588                              <1> 	; Inputs:
  3589                              <1> 	;	BH = 0 -> Allocate DMA buffer
  3590                              <1> 	;	   BL = 0 -> Use the system's default DMA
  3591                              <1> 	;		     (SB16) Buffer
  3592                              <1> 	;	        Buffer Size (max.) = 65536 bytes
  3593                              <1> 	;	   BL > 0 -> Allocate (a new) DMA buffer
  3594                              <1>  	;	   ECX = DMA Buffer Size in bytes (<=128KB)
  3595                              <1> 	;	   EDX = Virtual Address of DMA buffer 	
  3596                              <1> 	;		
  3597                              <1> 	;	BH = 1 -> Initialize (Start) DMA service
  3598                              <1> 	;	     BL, bit 0 to 3 = Channel Number (0 to 7)	
  3599                              <1> 	;	     BL, bit 7 = Auto Initialized Mode 
  3600                              <1> 	;			(If bit 7 is set)
  3601                              <1> 	;		 bit 6 = Record (read) mode (0= playback)
  3602                              <1> 	;	     ECX = byte count (0 = use dma buffer size)
  3603                              <1> 	;	     EDX = physical buffer address
  3604                              <1> 	;	     	   (0 = use dma buffer -start- address)		
  3605                              <1> 	;
  3606                              <1> 	;	BH = 2 -> Get Current DMA Buffer Offset
  3607                              <1> 	;	     BL = DMA channel number	
  3608                              <1> 	;		
  3609                              <1> 	;	BH = 3 -> Get Current DMA count down value
  3610                              <1> 	;	     BL = DMA channel number (0 tO 7)	
  3611                              <1> 	;
  3612                              <1> 	;	BH = 4 -> Get Current DMA channel (in progress)
  3613                              <1> 	;
  3614                              <1> 	;	BH = 5 -> Get System's Default DMA Buffer Address
  3615                              <1> 	;
  3616                              <1> 	;	BH = 6 -> Get Current DMA Buffer Address	
  3617                              <1> 	;
  3618                              <1> 	;	BH = 7 -> Stop DMA service
  3619                              <1> 	;
  3620                              <1> 	; Outputs:
  3621                              <1> 	;
  3622                              <1> 	;	For BH = 0 ; Allocate DMA buffer
  3623                              <1> 	;	    EAX = Physical address of DMA buffer
  3624                              <1> 	;	    ECX = Allocated buffer size in bytes
  3625                              <1> 	;		  - page count * 4096 -
  3626                              <1> 	;		  (may be bigger than requested)	
  3627                              <1> 	;	    If BL input > 0,
  3628                              <1> 	;	       'sysalloc:' system call will be used with
  3629                              <1>   	;	       EBX (for 'sysalloc') = EDX (for 'sysdma')
  3630                              <1> 	;	       ECX is same, byte count (buffer size)
  3631                              <1> 	;	       EDX = 1024*1024*16 ; 16 MB upper limit	 		        	 
  3632                              <1> 	;	    If BL input = 0,
  3633                              <1> 	;	       Default DMA buffer (SB16 buffer) will be
  3634                              <1> 	;	       checked and if it is free, it's address
  3635                              <1> 	;	       will be returned in EAX and it's size
  3636                              <1> 	;	       will be returned in ECX (as 65536)
  3637                              <1> 	;
  3638                              <1> 	;	    If CF = 1, error code is in EAX
  3639                              <1> 	;	       EAX = -1 ; DMA buffer allocation error! 		
  3640                              <1> 	;	       EAX = 11 ; 'Permission Denied' error !
  3641                              <1> 	;
  3642                              <1> 	;	       Note: 'sysalloc' error return method
  3643                              <1> 	;		      will be applied if BL input > 0 !		
  3644                              <1> 	;
  3645                              <1> 	; 	 For BH = 1 ; Initialize (Start) DMA
  3646                              <1> 	;	     EAX = 0 (Successful)	
  3647                              <1> 	;	     If CF = 1, error code is in EAX
  3648                              <1> 	;
  3649                              <1> 	; 	 For BH = 2 ; Get Current DMA Buffer Offset
  3650                              <1> 	;	     EAX = DMA Buffer Offset (in bytes)
  3651                              <1> 	;	     ;
  3652                              <1> 	;	      AX = DMA buffer offset
  3653                              <1> 	;	     EAX bits 16 to 23 = Page register value
  3654                              <1> 	;		   	
  3655                              <1> 	; 	 For BH = 3 ; Get Current DMA count down value
  3656                              <1> 	;	     EAX = Count down value (remain bytes)
  3657                              <1> 	;	
  3658                              <1> 	;	 For BH = 4 ; Get Current DMA channel (in progress)
  3659                              <1> 	;	     EAX = DMA channel number (0 to 7)
  3660                              <1> 	;		AH = 0 if the owner is the caller process
  3661                              <1> 	;		AH > 0 if the dma channel is in use by
  3662                              <1> 	;		       another user/process
  3663                              <1> 	;	     EAX = -1 (0FFFFFFFFh) 
  3664                              <1> 	;		    if DMA service is not in use	    		
  3665                              <1> 	;	 	    (stopped or not initialized/started)	
  3666                              <1> 	;
  3667                              <1> 	;	 For BH = 5 ; Get System's Default DMA Buff Addr
  3668                              <1> 	;	     EAX = Default DMA Buffer Address (Physical)
  3669                              <1> 	;		 = offset 'sb16_dma_buffer:'	
  3670                              <1> 	;	     ECX = Buffer size
  3671                              <1> 	;		 = 65536 
  3672                              <1> 	;
  3673                              <1> 	;	 For BH = 6 ; Get Current DMA Buffer Address
  3674                              <1> 	;	     EAX = Current DMA buffer address (Physical)
  3675                              <1> 	;	     ECX = Current DMA buffer size (setting value)	   		  	 		
  3676                              <1> 	;	     Note: These values are for current dma channel
  3677                              <1> 	;		   settings for the user/process
  3678                              <1> 	;	     ** For now (for current TRDOS 386 version)
  3679                              <1> 	;		only one user/process can use only one
  3680                              <1> 	;		dma channel & one dma buffer at same time
  3681                              <1> 	;		(no multi tasking on DMA service) !!! **
  3682                              <1> 	;	     (Once, current DMA user must stop it's own DMA
  3683                              <1> 	;	      DMA service, than another user/program 
  3684                              <1> 	;	      can use DMA service with same dma channel 
  3685                              <1> 	;	      or with another DMA channel.)	 			      		
  3686                              <1> 	;
  3687                              <1> 	;	 For BH = 7 ; Stop DMA service (for current user
  3688                              <1> 	;	     and current DMA channel)	
  3689                              <1> 	;	     EAX = 0 ; successful
  3690                              <1> 	;	     CF = 1 & EAX > 0 (= -1) -> Error		
  3691                              <1> 
  3692 00012D54 80FF07              <1> 	cmp	bh, 7
  3693 00012D57 7612                <1> 	jna	short sysdma_0
  3694                              <1> 
  3695                              <1> sysdma_err:
  3696 00012D59 31C0                <1> 	xor	eax, eax
  3697 00012D5B 48                  <1> 	dec	eax ; -1
  3698                              <1> sysdma_perm_err:
  3699 00012D5C A3[1C010300]        <1> 	mov	[u.r0], eax
  3700 00012D61 A3[84010300]        <1> 	mov	[u.error], eax ; DMA service error !
  3701 00012D66 E9949FFFFF          <1> 	jmp	error
  3702                              <1> 
  3703                              <1> sysdma_0:
  3704 00012D6B 08FF                <1> 	or	bh, bh
  3705 00012D6D 7537                <1> 	jnz	short sysdma_1 ; 30/07/2022
  3706                              <1> 	
  3707 00012D6F 20DB                <1> 	and	bl, bl
  3708 00012D71 7416                <1> 	jz	short sysdma_01
  3709                              <1> 
  3710                              <1> 	; redirect system call to 'sysalloc'
  3711 00012D73 89D3                <1> 	mov	ebx, edx ; virtual address of DMA buffer
  3712                              <1> 	;ecx = Buffer size in bytes
  3713                              <1> 	; DMA buffer address <= 16MB upper limit
  3714 00012D75 BA00000001          <1> 	mov	edx, 1024*1024*16 ; 16MB limit for DMA buff
  3715                              <1> 
  3716 00012D7A C705[F48D0100]FFFF- <1> 	mov	dword [dma_addr], 0FFFFFFFFh ; -1
  3716 00012D82 FFFF                <1>
  3717                              <1> 
  3718 00012D84 E980E7FFFF          <1> 	jmp	sysalloc
  3719                              <1> 
  3720                              <1> sysdma_01:
  3721 00012D89 B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
  3722                              <1> 
  3723 00012D8E 803D[B1890100]01    <1> 	cmp	byte [audio_device], 1
  3724 00012D95 724A                <1> 	jb	short sysdma_03
  3725                              <1> 
  3726 00012D97 3B05[D0890100]      <1> 	cmp	eax, [audio_dma_buff]
  3727 00012D9D 7527                <1> 	jne	short sysdma_02
  3728                              <1> 
  3729                              <1> sysdma_0_err:
  3730 00012D9F B80B000000          <1> 	mov	eax, ERR_PERM_DENIED
  3731 00012DA4 EBB6                <1> 	jmp	short sysdma_perm_err
  3732                              <1> 
  3733                              <1> 	; 30/07/2022
  3734                              <1> sysdma_1:
  3735 00012DA6 80FF01              <1> 	cmp	bh, 1
  3736                              <1> 	;ja	sysdma_5
  3737                              <1> 	; 30/07/2022
  3738 00012DA9 7605                <1> 	jna	short sysdma_10
  3739 00012DAB E90C010000          <1> 	jmp	sysdma_5
  3740                              <1> 
  3741                              <1> sysdma_10:
  3742 00012DB0 F6C340              <1> 	test	bl, 40h	; record (read) mode -BL, bit 6-
  3743                              <1> 	;jnz	sysdma_err ; not ready yet!
  3744                              <1> 	; 30/07/2022
  3745 00012DB3 757C                <1> 	jnz	short sysdma_06 ; jmp sysdma_err
  3746                              <1> 
  3747 00012DB5 A1[F48D0100]        <1> 	mov	eax, [dma_addr] ; physical address of dma buffer
  3748 00012DBA 21C0                <1> 	and	eax, eax
  3749                              <1> 	;jz	sysdma_err
  3750                              <1> 	; 30/07/2022
  3751 00012DBC 7473                <1> 	jz	short sysdma_06 ; jmp sysdma_err
  3752                              <1> 
  3753 00012DBE 09D2                <1> 	or	edx, edx
  3754 00012DC0 7574                <1> 	jnz	short sysdma_11
  3755                              <1> 
  3756 00012DC2 89C2                <1> 	mov	edx, eax
  3757 00012DC4 EB74                <1> 	jmp	short sysdma_12	
  3758                              <1> 
  3759                              <1> sysdma_02:
  3760                              <1> 	; Only one user is permitted for audio/dma functions
  3761                              <1> 
  3762 00012DC6 833D[D0890100]00    <1> 	cmp	dword [audio_dma_buff], 0
  3763 00012DCD 7612                <1> 	jna	short sysdma_03
  3764                              <1> 
  3765 00012DCF 8A1D[D9890100]      <1> 	mov	bl, [audio_user]
  3766 00012DD5 08DB                <1> 	or	bl, bl
  3767 00012DD7 7408                <1> 	jz	short sysdma_03
  3768                              <1> 
  3769 00012DD9 3A1D[6D010300]      <1> 	cmp	bl, [u.uno]
  3770 00012DDF 75BE                <1> 	jne	short sysdma_0_err
  3771                              <1> 
  3772                              <1> sysdma_03: 
  3773 00012DE1 8A1D[F18D0100]      <1> 	mov	bl, [dma_user]
  3774 00012DE7 20DB                <1> 	and	bl, bl
  3775 00012DE9 750E                <1> 	jnz	short sysdma_04
  3776                              <1> 	
  3777 00012DEB 8A1D[6D010300]      <1> 	mov	bl, [u.uno]
  3778 00012DF1 881D[F18D0100]      <1> 	mov	[dma_user], bl
  3779                              <1> 
  3780 00012DF7 EB15                <1> 	jmp	short sysdma_05
  3781                              <1> 
  3782                              <1> sysdma_04:
  3783 00012DF9 8B35[F48D0100]      <1> 	mov	esi, [dma_addr]
  3784 00012DFF 21F6                <1> 	and	esi, esi
  3785 00012E01 740B                <1> 	jz	short sysdma_05
  3786                              <1> 
  3787 00012E03 46                  <1> 	inc	esi ; -1 -> 0
  3788 00012E04 7408                <1> 	jz	short sysdma_05
  3789                              <1> 
  3790 00012E06 3A1D[6D010300]      <1> 	cmp	bl, [u.uno]
  3791 00012E0C 7591                <1> 	jne	short sysdma_0_err
  3792                              <1> 	
  3793                              <1> sysdma_05:
  3794                              <1> 	; edx = virtual address (user's buffer address)
  3795                              <1> 	; 
  3796 00012E0E 81F900000100        <1> 	cmp	ecx, 65536   ; byte count (buffer size)
  3797                              <1> 	;ja	sysdma_err
  3798                              <1> 	; 30/07/2022
  3799 00012E14 771B                <1> 	ja	short sysdma_06 ; jmp sysdma_err
  3800                              <1> 	;
  3801 00012E16 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
  3802 00012E1C 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
  3803                              <1> 	;cmp	ecx, 65536
  3804                              <1> 	;ja	sysdma_err
  3805 00012E21 51                  <1> 	push	ecx	; buffer size (allocated pages * 4096) 
  3806 00012E22 50                  <1> 	push	eax	; offset sb16_dma_buffer
  3807 00012E23 89D3                <1> 	mov	ebx, edx
  3808 00012E25 C1E90C              <1> 	shr	ecx, 12 ; byte count to page count
  3809                              <1> 	; eax = physical address of (audio) dma buffer
  3810                              <1> 	; ebx = virtual address of (audio) dma buffer (user's pgdir) 
  3811                              <1> 	; ecx = page count (>0)
  3812 00012E28 E84B30FFFF          <1> 	call	direct_memory_access
  3813 00012E2D 58                  <1> 	pop	eax
  3814 00012E2E 59                  <1> 	pop	ecx
  3815                              <1> 	;jc	sysdma_err
  3816                              <1> 	; 30/07/2022
  3817 00012E2F 7315                <1> 	jnc	short sysdma_07
  3818                              <1> sysdma_06:
  3819 00012E31 E923FFFFFF          <1> 	jmp	sysdma_err
  3820                              <1> 
  3821                              <1> sysdma_11:
  3822 00012E36 39C2                <1> 	cmp	edx, eax
  3823                              <1> 	;jb	sysdma_err
  3824                              <1> 	; 30/07/2022
  3825 00012E38 72F7                <1> 	jb	short sysdma_06 ; jmp sysdma_err
  3826                              <1> sysdma_12:
  3827 00012E3A 21C9                <1> 	and	ecx, ecx
  3828 00012E3C 7515                <1> 	jnz	short sysdma_13
  3829                              <1> 
  3830 00012E3E 8B0D[F88D0100]      <1> 	mov	ecx, [dma_size]
  3831 00012E44 EB15                <1> 	jmp	short sysdma_14
  3832                              <1> 
  3833                              <1> sysdma_07:
  3834 00012E46 A3[F48D0100]        <1> 	mov	[dma_addr], eax
  3835 00012E4B 890D[F88D0100]      <1> 	mov	[dma_size], ecx ; dma buffer size (in bytes)
  3836                              <1> 
  3837                              <1> 	;mov	[u.r0], eax ; DMA Buffer Address (Physical)
  3838                              <1> 
  3839                              <1> 	;mov	ebp, [u.usp]  ; ebp points to user's registers
  3840                              <1> 	;mov	[ebp+24], ecx ; return to user with ecx value
  3841                              <1> 
  3842                              <1> 	;jmp	sysret
  3843                              <1> 
  3844                              <1> 	; 28/08/2017
  3845 00012E51 EB7A                <1> 	jmp	sysdma_51
  3846                              <1> 
  3847                              <1> sysdma_13:
  3848 00012E53 3B0D[F88D0100]      <1> 	cmp	ecx, [dma_size]
  3849                              <1> 	;ja	sysdma_err
  3850                              <1> 	; 30/07/2022
  3851 00012E59 77D6                <1> 	ja	short sysdma_06 ; jmp sysdma_err
  3852                              <1> sysdma_14:
  3853 00012E5B 89C6                <1> 	mov	esi, eax
  3854 00012E5D 0335[F88D0100]      <1> 	add	esi, [dma_size]
  3855                              <1> 
  3856 00012E63 89D0                <1> 	mov	eax, edx
  3857 00012E65 01C8                <1> 	add	eax, ecx
  3858                              <1> 	;jc	sysdma_err ; 02/09/2017
  3859                              <1> 	; 30/07/2022
  3860 00012E67 72C8                <1> 	jc	short sysdma_06 ; jmp sysdma_err	
  3861                              <1> 		
  3862 00012E69 39F0                <1> 	cmp	eax, esi
  3863                              <1> 	;ja	sysdma_err
  3864                              <1> 	; 30/07/2022
  3865 00012E6B 77C4                <1> 	ja	short sysdma_06 ; jmp sysdma_err
  3866                              <1> 
  3867 00012E6D 8B3D[D0890100]      <1> 	mov	edi, [audio_dma_buff]
  3868 00012E73 8B35[F48D0100]      <1> 	mov	esi, [dma_addr]
  3869                              <1> 
  3870 00012E79 09FF                <1> 	or	edi, edi
  3871 00012E7B 7425                <1> 	jz	short sysdma_16
  3872                              <1> 	
  3873 00012E7D 803D[B1890100]01    <1> 	cmp	byte [audio_device], 1
  3874 00012E84 7209                <1> 	jb	short sysdma_15
  3875                              <1> 
  3876                              <1> 	; Sound Blaster 16
  3877 00012E86 39FE                <1> 	cmp	esi, edi
  3878                              <1> 	;je	sysdma_0_err ; permmission denied !
  3879                              <1> 	; 30/07/2022
  3880 00012E88 7505                <1> 	jne	short sysdma_15
  3881 00012E8A E910FFFFFF          <1> 	jmp	sysdma_0_err
  3882                              <1> sysdma_15:
  3883 00012E8F C605[F38D0100]48    <1> 	mov	byte [dma_mode], 48h ; single mode playback	
  3884                              <1> 
  3885 00012E96 F6C380              <1> 	test	bl, 80h ; DMA mode - BL, bit 7, auto init -
  3886 00012E99 7407                <1> 	jz	short sysdma_16	
  3887                              <1> 	; Auto initialized playback (write) mode
  3888 00012E9B 8005[F38D0100]10    <1> 	add	byte [dma_mode], 10h ; = 58h
  3889                              <1> sysdma_16:
  3890 00012EA2 80E307              <1> 	and	bl, 07h
  3891 00012EA5 881D[F28D0100]      <1> 	mov	[dma_channel], bl
  3892 00012EAB 8915[FC8D0100]      <1> 	mov	[dma_start], edx
  3893 00012EB1 890D[008E0100]      <1> 	mov	[dma_count], ecx
  3894                              <1> 	 
  3895                              <1> 	; 28/08/2017
  3896                              <1> 	;call	dma_init
  3897                              <1> 	;jmp	sysret
  3898 00012EB7 E945010000          <1> 	jmp	dma_init
  3899                              <1> 
  3900                              <1> sysdma_5:
  3901 00012EBC 80FF05              <1> 	cmp	bh, 5
  3902 00012EBF 726D                <1> 	jb	short sysdma_3
  3903 00012EC1 7759                <1> 	ja	short sysdma_6
  3904                              <1> 
  3905                              <1> 	; Get the system's default dma buffer addr and size
  3906 00012EC3 B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
  3907 00012EC8 B900000100          <1> 	mov	ecx, 65536 ; Buffer size in bytes
  3908                              <1> 
  3909                              <1> sysdma_51:
  3910                              <1> 	; 0 = there is not a dma buffer (in use or available)
  3911 00012ECD A3[1C010300]        <1> 	mov	[u.r0], eax
  3912                              <1> 
  3913 00012ED2 8B2D[18010300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
  3914 00012ED8 894D18              <1> 	mov	[ebp+24], ecx ; return to user with ecx value
  3915                              <1> 
  3916 00012EDB E93F9EFFFF          <1> 	jmp	sysret
  3917                              <1> 
  3918                              <1> sysdma_2:
  3919                              <1> 	; Get current dma buffer offset (& page)
  3920                              <1> 	; 28/08/2017
  3921 00012EE0 0FB635[F28D0100]    <1> 	movzx	esi, byte [dma_channel]
  3922 00012EE7 0FB696[EC370100]    <1> 	movzx	edx, byte [dma_flip+esi]
  3923 00012EEE EE                  <1> 	out	dx, al			; flip-flop clear
  3924 00012EEF 8A96[C4370100]      <1> 	mov	dl, [dma_adr+esi]
  3925 00012EF5 EC                  <1> 	in	al, dx			; get dma position
  3926 00012EF6 0FB6D8              <1> 	movzx	ebx, al
  3927 00012EF9 EC                  <1> 	in	al, dx			
  3928 00012EFA 88C7                <1> 	mov	bh, al
  3929                              <1> 
  3930 00012EFC 6683FE04            <1> 	cmp	si, 4	; channel number ?
  3931 00012F00 7202                <1> 	jb	short sysdma_21 ; 8 bit dma channel
  3932                              <1> 
  3933 00012F02 D1E3                <1> 	shl	ebx, 1	; word offset to byte offset
  3934                              <1> 
  3935                              <1> sysdma_21:
  3936 00012F04 891D[1C010300]      <1> 	mov	[u.r0], ebx
  3937                              <1> 
  3938 00012F0A 8A96[D4370100]      <1> 	mov	dl, [dma_page+esi]
  3939 00012F10 EC                  <1> 	in	al, dx			; get dma page
  3940                              <1> 
  3941                              <1> 	;add	[u.ro+2], al
  3942 00012F11 0805[1E010300]      <1> 	or	[u.r0+2], al
  3943                              <1> 
  3944 00012F17 E9039EFFFF          <1> 	jmp	sysret
  3945                              <1> 
  3946                              <1> sysdma_6:
  3947 00012F1C 80FF06              <1> 	cmp	bh, 6
  3948 00012F1F 775C                <1> 	ja	short sysdma_7
  3949                              <1> 
  3950                              <1> 	; 28/08/2017
  3951                              <1> 	; Get current DMA buffer addr and size
  3952 00012F21 A1[F48D0100]        <1> 	mov	eax, [dma_addr] ; dma buffer address
  3953 00012F26 8B0D[F88D0100]      <1> 	mov	ecx, [dma_size] ; dma buffer size (in bytes)
  3954                              <1> 
  3955 00012F2C EB9F                <1> 	jmp	short sysdma_51
  3956                              <1> 
  3957                              <1> sysdma_3:
  3958 00012F2E 80FF03              <1> 	cmp	bh, 3
  3959 00012F31 72AD                <1> 	jb	short sysdma_2
  3960 00012F33 772F                <1> 	ja	short sysdma_4
  3961                              <1> 
  3962                              <1> 	; Get current dma count down value (remain bytes)
  3963                              <1> 	; 28/08/2017
  3964 00012F35 0FB635[F28D0100]    <1> 	movzx	esi, byte [dma_channel]
  3965 00012F3C 0FB696[EC370100]    <1> 	movzx	edx, byte [dma_flip+esi]
  3966 00012F43 EE                  <1> 	out	dx, al			; flip-flop clear
  3967 00012F44 8A96[CC370100]      <1> 	mov	dl, [dma_cnt+esi] ; dma count register addr
  3968 00012F4A EC                  <1> 	in	al, dx
  3969 00012F4B 0FB6D8              <1> 	movzx	ebx, al	
  3970 00012F4E EC                  <1> 	in	al, dx
  3971 00012F4F 88C7                <1> 	mov     bh, al
  3972                              <1> 	
  3973 00012F51 6683FE04            <1> 	cmp	si, 4	; channel number ?
  3974 00012F55 7202                <1> 	jb	short sysdma_31 ; 8 bit dma channel
  3975                              <1> 
  3976 00012F57 D1E3                <1> 	shl	ebx, 1	; word count to byte count
  3977                              <1> 
  3978                              <1> sysdma_31:
  3979 00012F59 891D[1C010300]      <1> 	mov	[u.r0], ebx
  3980                              <1> 
  3981 00012F5F E9BB9DFFFF          <1> 	jmp	sysret
  3982                              <1> 
  3983                              <1> sysdma_4:
  3984                              <1> 	; Get current DMA channel number
  3985                              <1> 	; 28/08/2017
  3986 00012F64 8A25[F18D0100]      <1> 	mov	ah, [dma_user]
  3987 00012F6A 20E4                <1> 	and	ah, ah
  3988 00012F6C 7539                <1> 	jnz	short sysdma_42
  3989                              <1> 
  3990                              <1> sysdma_41:	
  3991                              <1> 	; Not a valid dma channel (in use)
  3992 00012F6E C705[1C010300]FFFF- <1> 	mov	dword [u.r0], -1 ; 0FFFFFFFFh
  3992 00012F76 FFFF                <1>
  3993 00012F78 E9A29DFFFF          <1> 	jmp	sysret
  3994                              <1> 
  3995                              <1> sysdma_7:
  3996                              <1> 	; DMA service STOP
  3997 00012F7D A0[6D010300]        <1> 	mov	al, [u.uno]
  3998 00012F82 3A05[F18D0100]      <1> 	cmp	al, [dma_user]
  3999 00012F88 7543                <1> 	jne	short sysdma_72
  4000                              <1> 	
  4001 00012F8A 28C0                <1> 	sub	al, al ; 0
  4002                              <1> 
  4003 00012F8C A2[F18D0100]        <1> 	mov	[dma_user], al ; clear user
  4004                              <1> 
  4005 00012F91 8605[F38D0100]      <1> 	xchg	al, [dma_mode]
  4006 00012F97 20C0                <1> 	and	al, al
  4007                              <1> 	;jz	short sysdma_err
  4008 00012F99 754E                <1> 	jnz	short sysdma_73	
  4009                              <1> 
  4010                              <1> sysdma_71:
  4011 00012F9B 31C0                <1> 	xor	eax, eax
  4012 00012F9D A3[1C010300]        <1> 	mov	[u.r0], eax; 0
  4013 00012FA2 E9789DFFFF          <1> 	jmp	sysret
  4014                              <1> 
  4015                              <1> sysdma_42:
  4016 00012FA7 8B35[F48D0100]      <1> 	mov	esi, [dma_addr]
  4017 00012FAD 21F6                <1> 	and	esi, esi
  4018 00012FAF 74BD                <1> 	jz	short sysdma_41
  4019                              <1> 
  4020 00012FB1 46                  <1> 	inc	esi ; -1 -> 0
  4021 00012FB2 74BA                <1> 	jz	short sysdma_41
  4022                              <1> 
  4023 00012FB4 A0[F28D0100]        <1> 	mov	al, [dma_channel]
  4024                              <1> 
  4025 00012FB9 3A25[6D010300]      <1> 	cmp	ah, [u.uno]
  4026 00012FBF 7502                <1> 	jne	short sysdma_43
  4027                              <1> 
  4028 00012FC1 30E4                <1> 	xor	ah, ah ; DMA channel in use by current user
  4029                              <1> 
  4030                              <1> sysdma_43:
  4031 00012FC3 A3[1C010300]        <1> 	mov	[u.r0], eax ; AL = dma channel number
  4032                              <1> 			    ; AH > 0 if the the channel
  4033                              <1> 			    ; in use by another user/process
  4034 00012FC8 E9529DFFFF          <1> 	jmp	sysret
  4035                              <1> 
  4036                              <1> sysdma_72:
  4037                              <1> 	; 28/08/2017
  4038 00012FCD 803D[F18D0100]00    <1> 	cmp	byte [dma_user], 0
  4039 00012FD4 76C5                <1> 	jna	short sysdma_71 ; Nothing to do !
  4040                              <1> 
  4041 00012FD6 833D[F48D0100]00    <1> 	cmp	dword [dma_addr], 0
  4042                              <1> 	;ja	sysdma_0_err
  4043                              <1> 	; 30/07/2022
  4044 00012FDD 7605                <1> 	jna	short sysdma_74
  4045 00012FDF E9BBFDFFFF          <1> 	jmp	sysdma_0_err
  4046                              <1> 
  4047                              <1> sysdma_74:	
  4048 00012FE4 A2[F18D0100]        <1> 	mov	[dma_user], al ; reset to current user
  4049                              <1> 
  4050                              <1> sysdma_73:
  4051                              <1> 	; 28/08/2017
  4052 00012FE9 0FB635[F28D0100]    <1> 	movzx	esi, byte [dma_channel]
  4053 00012FF0 0FB696[DC370100]    <1> 	movzx	edx, byte [dma_mask+esi]
  4054 00012FF7 A0[F28D0100]        <1> 	mov	al, [dma_channel]
  4055 00012FFC 0C04                <1> 	or	al, 4
  4056 00012FFE EE                  <1> 	out	dx, al
  4057                              <1> 
  4058 00012FFF EB9A                <1> 	jmp	short sysdma_71
  4059                              <1> 
  4060                              <1> dma_init:
  4061                              <1> 	; 30/07/2022 (TRDOS 386 Kernel v2.0.5)
  4062                              <1> 	; 28/08/2017
  4063                              <1> 	; 20/08/2017
  4064                              <1> 	; DMA initialization
  4065                              <1> 	; 14/08/2017
  4066                              <1> 	; 03/08/2017, 06/08/2017, 08/08/2017
  4067                              <1> 	; 02/07/2017, 13/07/2017, 16/07/2017, 30/07/2017
  4068                              <1> 	; (Derived from 'DMA_INIT' procedure in SB16MOD.ASM)
  4069                              <1> 	; Modified for TRDOS 386 DMA buffer allocation & initialization !
  4070                              <1> 
  4071 00013001 8B1D[FC8D0100]      <1> 	mov	ebx, [dma_start]
  4072 00013007 8B0D[008E0100]      <1> 	mov	ecx, [dma_count]
  4073                              <1> 
  4074 0001300D 0FB635[F28D0100]    <1> 	movzx	esi, byte [dma_channel]
  4075                              <1> 
  4076 00013014 6683FE04            <1> 	cmp	si, 4
  4077 00013018 7204                <1> 	jb	short gdmi1
  4078                              <1> 	; 08/08/2017
  4079                              <1> 	;shr	cx, 1 ; word count
  4080                              <1> 	; 30/07/2022
  4081 0001301A D1E9                <1> 	shr	ecx, 1
  4082 0001301C D1EB                <1> 	shr	ebx, 1 ; convert byte offset to word offset
  4083                              <1> gdmi1:
  4084                              <1> 	;mov	[dma_poff], bx ; 08/08/2017
  4085                              <1> 	;dec	cx			; dma size = block size - 1
  4086                              <1> 	; 30/07/2022
  4087 0001301E 49                  <1> 	dec	ecx	
  4088                              <1> 
  4089 0001301F 0FB696[DC370100]    <1> 	movzx	edx, byte [dma_mask+esi] ; 30/07/2017
  4090 00013026 A0[F28D0100]        <1> 	mov	al, [dma_channel]
  4091 0001302B 0C04                <1> 	or	al, 4
  4092 0001302D EE                  <1> 	out	dx, al			; dma channel mask
  4093                              <1> 
  4094 0001302E 30C0                <1> 	xor	al, al ; 0 ; any value ! 08/08/2017
  4095 00013030 8A96[EC370100]      <1> 	mov	dl, [dma_flip+esi]
  4096 00013036 EE                  <1> 	out	dx, al			; flip-flop clear
  4097                              <1> 	
  4098 00013037 8A96[E4370100]      <1> 	mov	dl, [dma_mod+esi]
  4099 0001303D A0[F28D0100]        <1> 	mov	al, [dma_channel]  ; 13/07/2017
  4100 00013042 2403                <1> 	and	al, 3
  4101                              <1> 	; 08/08/2017
  4102 00013044 0A05[F38D0100]      <1> 	or	al, [dma_mode] ; 58h    ; dma mode for SB16
  4103 0001304A EE                  <1> 	out	dx, al			
  4104                              <1> 
  4105 0001304B 8A96[C4370100]      <1> 	mov	dl, [dma_adr+esi]	
  4106 00013051 88D8                <1> 	mov	al, bl			
  4107 00013053 EE                  <1> 	out	dx, al			; offset low
  4108                              <1> 
  4109 00013054 88F8                <1> 	mov	al, bh
  4110 00013056 EE                  <1> 	out	dx, al			; offset high
  4111                              <1> 
  4112 00013057 8A96[CC370100]      <1> 	mov	dl, [dma_cnt+esi]
  4113 0001305D 88C8                <1> 	mov	al, cl
  4114 0001305F EE                  <1> 	out	dx, al			; size low
  4115                              <1> 
  4116 00013060 88E8                <1> 	mov	al, ch
  4117 00013062 EE                  <1> 	out	dx, al			; size high
  4118                              <1> 
  4119 00013063 8A96[D4370100]      <1> 	mov	dl, [dma_page+esi]
  4120                              <1> 	; 14/08/2017 
  4121 00013069 6683FE04            <1> 	cmp	si, 4
  4122 0001306D 7305                <1> 	jnb	short gdmi2
  4123 0001306F C1EB10              <1> 	shr	ebx, 16
  4124 00013072 EB06                <1> 	jmp	short gdmi3
  4125                              <1> gdmi2:
  4126                              <1> 	; 09/08/2017
  4127 00013074 C1EB0F              <1> 	shr	ebx, 15	 ; complete 16 bit shift
  4128 00013077 80E3FE              <1> 	and	bl, 0FEh ; clear bit 0 (not necessary)
  4129                              <1> gdmi3:	
  4130 0001307A 88D8                <1> 	mov	al, bl
  4131 0001307C EE                  <1> 	out	dx, al			; page			
  4132                              <1> 	
  4133 0001307D 8A96[DC370100]      <1> 	mov	dl, [dma_mask+esi]
  4134 00013083 A0[F28D0100]        <1> 	mov	al, [dma_channel]  ; 13/07/2017
  4135 00013088 2403                <1> 	and	al, 3
  4136 0001308A EE                  <1> 	out	dx, al			; dma channel unmask
  4137                              <1> 
  4138                              <1> 	;retn
  4139                              <1> 	; 28/08/2017
  4140 0001308B E98F9CFFFF          <1> 	jmp	sysret
  4141                              <1> 
  4142                              <1> otty:
  4143                              <1> sret:
  4144                              <1> ocvt:
  4145                              <1> ctty:
  4146                              <1> cret:
  4147                              <1> ccvt:
  4148                              <1> rtty:
  4149                              <1> wtty:
  4150                              <1> rmem:
  4151                              <1> wmem:
  4152                              <1> rfd:
  4153                              <1> rhd:
  4154                              <1> wfd:
  4155                              <1> whd:
  4156                              <1> rlpt:
  4157                              <1> wlpt:
  4158                              <1> rcvt:
  4159                              <1> xmtt:
  4160 00013090 C3                  <1> 	retn
  3245                                  %include 'trdosk9.s' ; 04/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.7) - INITIALIZED DATA : trdosk9.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 20/10/2023 (Previous: 30/08/2022 - Kernel v2.0.6)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 04/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; ----------------------------------------------------------------------------
     9                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
    10                              <1> ; ----------------------------------------------------------------------------
    11                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    12                              <1> ; TRDOS2.ASM (09/11/2011)
    13                              <1> ; ****************************************************************************
    14                              <1> ; DRV_INIT.ASM [26/09/2009] Last Update: 07/08/2011
    15                              <1> ; MAINPROG.ASM [17/01/2004] Last Update: 09/11/2011
    16                              <1> ; CMD_INTR.ASM [29/01/2005] Last Update: 09/11/2011
    17                              <1> ; FILE.ASM [29/10/2009] Last Update: 09/10/2011
    18                              <1> 
    19                              <1> ; 12/02/2016
    20                              <1> Last_DOS_DiskNo: 
    21 00013091 01                  <1> 		db 1 ; A: = 0 & B: = 1
    22                              <1> 
    23                              <1> Restore_CDIR:	
    24 00013092 FF                  <1> 		db 0FFh ; Initial value -> any number except 0
    25                              <1> 
    26                              <1> msg_CRLF_temp:  
    27 00013093 070D0A00            <1> 		db 07h, 0Dh, 0Ah, 0
    28                              <1> 
    29                              <1> Magic_Bytes:
    30 00013097 04                  <1> 		db 4
    31 00013098 01                  <1> 		db 1
    32                              <1> mainprog_Version:
    33 00013099 07                  <1> 		db 7
    34 0001309A 5B5452444F535D204D- <1> 		db "[TRDOS] Main Program v2.0.7 (20/10/2023)"
    34 000130A3 61696E2050726F6772- <1>
    34 000130AC 616D2076322E302E37- <1>
    34 000130B5 202832302F31302F32- <1>
    34 000130BE 30323329            <1>
    35 000130C2 0D0A                <1> 		db 0Dh, 0Ah
    36 000130C4 286329204572646F67- <1> 		db "(c) Erdogan Tan 2005-2023"
    36 000130CD 616E2054616E203230- <1>
    36 000130D6 30352D32303233      <1>
    37 000130DD 0D0A00              <1> 		db 0Dh, 0Ah, 0
    38                              <1> 
    39                              <1> MainProgCfgFile: ; 14/04/2016
    40 000130E0 4D41494E50524F472E- <1> 		db "MAINPROG.CFG", 0
    40 000130E9 43464700            <1>
    41                              <1> 
    42                              <1> TRDOSPromptLabel:
    43 000130ED 5452444F53          <1> 		db "TRDOS"
    44 000130F2 00                  <1> 		db 0
    45 000130F3 00<rep 5h>          <1>                 times 5 db 0
    46 000130F8 00                  <1> 		db 0
    47                              <1> 
    48                              <1> ; INTERNAL COMMANDS
    49                              <1> Command_List:
    50 000130F9 44495200            <1> Cmd_Dir:	db "DIR", 0
    51 000130FD 434400              <1> Cmd_Cd:		db "CD", 0
    52 00013100 433A00              <1> Cmd_Drive:	db "C:", 0
    53 00013103 56455200            <1> Cmd_Ver:	db "VER", 0
    54 00013107 4558495400          <1> Cmd_Exit:	db "EXIT", 0
    55 0001310C 50524F4D505400      <1> Cmd_Prompt:	db "PROMPT", 0
    56 00013113 564F4C554D4500      <1> Cmd_Volume:	db "VOLUME", 0
    57 0001311A 4C4F4E474E414D4500  <1> Cmd_LongName:	db "LONGNAME", 0
    58 00013123 4441544500          <1> Cmd_Date:	db "DATE", 0
    59 00013128 54494D4500          <1> Cmd_Time:	db "TIME", 0
    60 0001312D 52554E00            <1> Cmd_Run:	db "RUN", 0
    61 00013131 53455400            <1> Cmd_Set:	db "SET", 0 
    62 00013135 434C5300            <1> Cmd_Cls:	db "CLS", 0
    63 00013139 53484F5700          <1> Cmd_Show:	db "SHOW", 0
    64 0001313E 44454C00            <1> Cmd_Del:	db "DEL", 0
    65 00013142 41545452494200      <1> Cmd_Attrib:	db "ATTRIB", 0
    66 00013149 52454E414D4500      <1> Cmd_Rename:	db "RENAME", 0
    67 00013150 524D44495200        <1> Cmd_Rmdir:	db "RMDIR", 0
    68 00013156 4D4B44495200        <1> Cmd_Mkdir:	db "MKDIR", 0
    69 0001315C 434F505900          <1> Cmd_Copy:	db "COPY", 0
    70 00013161 4D4F564500          <1> Cmd_Move:	db "MOVE", 0
    71 00013166 5041544800          <1> Cmd_Path:	db "PATH", 0
    72 0001316B 4D454D00            <1> Cmd_Mem:	db "MEM", 0
    73 0001316F 00                  <1> 		db 0
    74 00013170 46494E4400          <1> Cmd_Find:	db "FIND", 0
    75 00013175 4543484F00          <1> Cmd_Echo:	db "ECHO", 0
    76 0001317A 2A00                <1> Cmd_Remark:	db "*", 0
    77 0001317C 3F00                <1> Cmd_Help:	db "?", 0
    78 0001317E 44455649434500      <1> Cmd_Device:	db "DEVICE", 0
    79 00013185 4445564C49535400    <1> Cmd_DevList:	db "DEVLIST", 0
    80 0001318D 434844495200        <1> Cmd_Chdir:	db "CHDIR", 0
    81 00013193 4245455000          <1> Cmd_Beep:	db "BEEP", 0
    82                              <1> 		
    83 00013198 00                  <1> 		db 0
    84                              <1> 
    85                              <1> ; 15/02/2016 (FILE.ASM, 09/10/2011)
    86                              <1> invalid_fname_chars:
    87 00013199 222728292A2B2C2F    <1> 		db 22h, 27h, 28h, 29h, 2Ah, 2Bh, 2Ch, 2Fh
    88 000131A1 3A3B3C3D3E3F40      <1> 		db 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh, 40h
    89 000131A8 5B5C5D5E60          <1> 		db 5Bh, 5Ch, 5Dh, 5Eh, 60h
    90                              <1> sizeInvFnChars  equ ($ - invalid_fname_chars)                
    91                              <1> ;
    92                              <1> 
    93                              <1> Msg_Enter_Date:
    94 000131AD 456E746572206E6577- <1>                 db 'Enter new date (dd-mm-yy): '
    94 000131B6 206461746520286464- <1>
    94 000131BF 2D6D6D2D7979293A20  <1>
    95 000131C8 00                  <1>                 db 0
    96                              <1> Msg_Show_Date:
    97 000131C9 43757272656E742064- <1>                 db   'Current date is '
    97 000131D2 61746520697320      <1>
    98 000131D9 30                  <1> Day:            db   '0'
    99 000131DA 30                  <1> 		db   '0'
   100 000131DB 2F                  <1>                 db   '/'
   101 000131DC 30                  <1> Month:          db   '0'
   102 000131DD 30                  <1> 		db   '0'
   103 000131DE 2F                  <1>                 db   '/'
   104 000131DF 30                  <1> Century:        db   '0'
   105 000131E0 30                  <1>                 db   '0'
   106 000131E1 30                  <1> Year:           db   '0'
   107 000131E2 30                  <1> 		db   '0'
   108 000131E3 0D0A00              <1>                 db   0Dh, 0Ah, 0
   109                              <1> 
   110                              <1> Msg_Enter_Time:
   111 000131E6 456E746572206E6577- <1> 		db 'Enter new time: '
   111 000131EF 2074696D653A20      <1>
   112 000131F6 00                  <1> 		db 0
   113                              <1> Msg_Show_Time:
   114 000131F7 43757272656E742074- <1> 		db   'Current time is '
   114 00013200 696D6520697320      <1>
   115 00013207 30                  <1> Hour:           db   '0'
   116 00013208 30                  <1> 		db   '0'
   117 00013209 3A                  <1> 		db   ':'
   118 0001320A 30                  <1> Minute:         db   '0'
   119 0001320B 30                  <1> 		db   '0'
   120 0001320C 3A                  <1> 		db   ':'
   121 0001320D 30                  <1> Second:         db   '0'
   122 0001320E 30                  <1> 		db   '0'
   123 0001320F 0D0A00              <1> 		db   0Dh, 0Ah, 0
   124                              <1> 
   125                              <1> ;VolSize_Unit1:   dd 0
   126                              <1> ;VolSize_Unit2:   dd 0
   127                              <1> 
   128                              <1> VolSize_KiloBytes:
   129 00013212 206B696C6F62797465- <1> 		db " kilobytes", 0Dh, 0Ah, 0
   129 0001321B 730D0A00            <1>
   130                              <1> VolSize_Bytes:
   131 0001321F 2062797465730D0A00  <1> 		db " bytes", 0Dh, 0Ah, 0
   132                              <1> Volume_in_drive:
   133 00013228 0D0A                <1> 		db 0Dh, 0Ah
   134                              <1> Vol_FS_Name:
   135 0001322A 54522046533120      <1> 		db "TR FS1 "
   136 00013231 566F6C756D6520696E- <1> 		db "Volume in drive "
   136 0001323A 20647269766520      <1>
   137 00013241 30                  <1> Vol_Drv_Name:   db 30h
   138 00013242 3A                  <1> 		db ":"
   139 00013243 20697320            <1> 		db " is "
   140 00013247 0D0A00              <1> 		db 0Dh, 0Ah, 0
   141                              <1> Dir_Drive_Str:
   142 0001324A 54522D444F53204472- <1>                 db "TR-DOS Drive "
   142 00013253 69766520            <1>
   143                              <1> Dir_Drive_Name:
   144 00013257 303A                <1>                 db "0:"
   145 00013259 0D0A                <1>                 db  0Dh, 0Ah
   146                              <1> Vol_Str_Header:
   147 0001325B 566F6C756D65204E61- <1>                 db "Volume Name: "
   147 00013264 6D653A20            <1>
   148                              <1> Vol_Name:
   149 00013268 00<rep 40h>         <1> 		times 64 db 0
   150 000132A8 00                  <1> 		db 0
   151                              <1> Vol_Serial_Header:
   152 000132A9 0D0A                <1> 		db 0Dh, 0Ah
   153 000132AB 566F6C756D65205365- <1> 		db "Volume Serial No: "
   153 000132B4 7269616C204E6F3A20  <1>
   154                              <1> Vol_Serial1:
   155 000132BD 30303030            <1> 		db "0000"
   156 000132C1 2D                  <1> 		db "-"
   157                              <1> Vol_Serial2:
   158 000132C2 30303030            <1> 		db "0000"
   159 000132C6 0D0A00              <1> 		db 0Dh, 0Ah, 0
   160                              <1> 
   161                              <1> ;Vol_Tot_Sec_Str_Start:
   162                              <1> ;		dd 0
   163                              <1> Vol_Total_Sector_Header:
   164 000132C9 0D0A                <1> 		db 0Dh, 0Ah
   165 000132CB 566F6C756D65205369- <1> 		db "Volume Size : ", 0
   165 000132D4 7A65203A2000        <1>
   166                              <1> ;Vol_Tot_Sec_Str: 
   167                              <1> ;		db "0000000000"
   168                              <1> ;Vol_Tot_Sec_Str_End:
   169                              <1> ;		db 0
   170                              <1> ;Vol_Free_Sectors_Str_Start:
   171                              <1> ;		dd 0
   172                              <1> Vol_Free_Sectors_Header:
   173 000132DA 467265652053706163- <1> 		db "Free Space  : ", 0
   173 000132E3 6520203A2000        <1>
   174                              <1> ;Vol_Free_Sectors_Str:
   175                              <1> ;		db "0000000000"
   176                              <1> ;Vol_Free_Sectors_Str_End:
   177                              <1> ;		db 0
   178                              <1> 
   179                              <1> Dir_Str_Header:
   180 000132E9 4469726563746F7279- <1>                 db "Directory: "
   180 000132F2 3A20                <1>
   181 000132F4 2F                  <1> Dir_Str_Root:   db "/"
   182 000132F5 00<rep 40h>         <1> Dir_Str:        times 64 db 0
   183 00013335 00000000            <1>                 dd 0
   184 00013339 00                  <1>                 db 0
   185                              <1> 
   186                              <1> Msg_Bad_Command:
   187 0001333A 42616420636F6D6D61- <1>                 db "Bad command or file name!"
   187 00013343 6E64206F722066696C- <1>
   187 0001334C 65206E616D6521      <1>
   188 00013353 0D0A00              <1>                 db 0Dh, 0Ah, 0
   189                              <1> 
   190                              <1> msgl_drv_not_ready: 
   191 00013356 070D0A              <1> 		db 07h, 0Dh, 0Ah
   192                              <1> 
   193                              <1> ; CMD_INTR.ASM - 09/11/2011 - Messages
   194                              <1> 
   195                              <1> Msg_Not_Ready_Read_Err:
   196 00013359 4472697665206E6F74- <1>                 db "Drive not ready or read error!"
   196 00013362 207265616479206F72- <1>
   196 0001336B 207265616420657272- <1>
   196 00013374 6F7221              <1>
   197 00013377 0D0A00              <1>                 db 0Dh, 0Ah, 0
   198                              <1> 
   199                              <1> Msg_Not_Ready_Write_Err:
   200 0001337A 4472697665206E6F74- <1>                 db "Drive not ready or write error!"
   200 00013383 207265616479206F72- <1>
   200 0001338C 207772697465206572- <1>
   200 00013395 726F7221            <1>
   201 00013399 0D0A00              <1>                 db 0Dh, 0Ah, 0
   202                              <1> 
   203                              <1> Msg_Dir_Not_Found:
   204 0001339C 4469726563746F7279- <1>                 db "Directory not found!"
   204 000133A5 206E6F7420666F756E- <1>
   204 000133AE 6421                <1>
   205 000133B0 0D0A00              <1>                 db 0Dh, 0Ah, 0
   206                              <1> 
   207                              <1> Msg_File_Not_Found:
   208 000133B3 46696C65206E6F7420- <1>                 db "File not found!"
   208 000133BC 666F756E6421        <1>
   209 000133C2 0D0A00              <1>                 db 0Dh, 0Ah, 0
   210                              <1> 
   211                              <1> Msg_File_Directory_Not_Found:
   212 000133C5 46696C65206F722064- <1>                 db "File or directory not found!"
   212 000133CE 69726563746F727920- <1>
   212 000133D7 6E6F7420666F756E64- <1>
   212 000133E0 21                  <1>
   213 000133E1 0D0A00              <1>                 db 0Dh, 0Ah, 0
   214                              <1> 
   215                              <1> Msg_LongName_Not_Found:
   216 000133E4 4C6F6E67206E616D65- <1>                 db "Long name not found!"
   216 000133ED 206E6F7420666F756E- <1>
   216 000133F6 6421                <1>
   217 000133F8 0D0A00              <1>                 db 0Dh, 0Ah, 0
   218                              <1> 
   219                              <1> beep_Insufficient_Memory: ; 20/02/2017
   220 000133FB 0D0A                <1> 		db 0Dh, 0Ah
   221 000133FD 07                  <1> 		db 07h
   222                              <1> Msg_Insufficient_Memory:
   223 000133FE 496E73756666696369- <1>                 db "Insufficient memory!"
   223 00013407 656E74206D656D6F72- <1>
   223 00013410 7921                <1>
   224 00013412 0D0A00              <1>                 db 0Dh, 0Ah, 0
   225                              <1> 
   226                              <1> Msg_Error_Code:
   227 00013415 436F6D6D616E642066- <1>                 db 'Command failed! Error code : '
   227 0001341E 61696C656421204572- <1>
   227 00013427 726F7220636F646520- <1>
   227 00013430 3A20                <1>
   228 00013432 303068              <1> error_code_hex: db '00h'
   229 00013435 0A0A00              <1>                 db 0Ah, 0Ah, 0
   230                              <1> 
   231                              <1> align 2
   232                              <1> 
   233                              <1> ; 10/02/2016
   234                              <1> ; DIR.ASM - 09/10/2011
   235                              <1> 
   236 00013438 3C4449523E20202020- <1> Type_Dir:       db '<DIR>     ' ; 10 bytes
   236 00013441 20                  <1>
   237                              <1> 
   238                              <1> File_Name:
   239 00013442 20<rep Ch>          <1>                 times 12 db 20h
   240 0001344E 20                  <1> 		db 20h
   241                              <1> Dir_Or_FileSize:
   242 0001344F 20<rep Ah>          <1>                 times 10 db 20h
   243 00013459 20                  <1> 		db 20h
   244                              <1> File_Attribute:
   245 0001345A 20202020            <1> 		dd 20202020h
   246 0001345E 20                  <1> 		db 20h
   247                              <1> File_Day:
   248 0001345F 3030                <1>                 db '0','0'
   249 00013461 2F                  <1> 		db '/'
   250                              <1> File_Month:
   251 00013462 3030                <1>                 db '0','0'
   252 00013464 2F                  <1> 		db '/'
   253                              <1> File_Year:
   254 00013465 30303030            <1>                 db '0','0','0','0'
   255 00013469 20                  <1> 		db 20h
   256                              <1> File_Hour:
   257 0001346A 3030                <1>                 db '0','0'
   258 0001346C 3A                  <1> 		db ':'
   259                              <1> File_Minute:
   260 0001346D 3030                <1>                 db '0','0'
   261 0001346F 00                  <1> 		db 0
   262                              <1> 
   263                              <1> Decimal_File_Count_Header:
   264 00013470 0D0A                <1> 		db 0Dh, 0Ah
   265                              <1> Decimal_File_Count:
   266 00013472 00<rep 6h>          <1> 		times 6 db 0
   267                              <1> 
   268 00013478 2066696C6528732920- <1> str_files:	db " file(s) & "
   268 00013481 2620                <1>
   269                              <1> Decimal_Dir_Count: 
   270 00013483 00<rep 6h>          <1> 		times 6 db 0
   271                              <1> str_dirs:       
   272 00013489 206469726563746F72- <1> 		db " directory(s) "
   272 00013492 7928732920          <1>
   273 00013497 0D0A00              <1> 		db 0Dh, 0Ah, 0
   274                              <1> 
   275 0001349A 206279746528732920- <1> str_bytes:	db " byte(s) in file(s)"
   275 000134A3 696E2066696C652873- <1>
   275 000134AC 29                  <1>
   276 000134AD 0D0A00              <1> 		db 0Dh, 0Ah, 0
   277                              <1> 
   278                              <1> ; CMD_INTR.ASM - 09/11/2011
   279                              <1> ; 07/10/2010
   280                              <1> Msg_invalid_name_chars:
   281 000134B0 496E76616C69642066- <1>                 db "Invalid file or directory name characters!"
   281 000134B9 696C65206F72206469- <1>
   281 000134C2 726563746F7279206E- <1>
   281 000134CB 616D65206368617261- <1>
   281 000134D4 637465727321        <1>
   282 000134DA 0D0A00              <1>         	db 0Dh, 0Ah, 0
   283                              <1> ; 21/02/2016
   284 000134DD 46696C65206F722064- <1> Msg_Name_Exists: db "File or directory name exists!"
   284 000134E6 69726563746F727920- <1>
   284 000134EF 6E616D652065786973- <1>
   284 000134F8 747321              <1>
   285 000134FB 0D0A00              <1>                 db 0Dh, 0Ah, 0
   286                              <1> Msg_DoYouWantMkdir:
   287 000134FE 446F20796F75207761- <1>                 db "Do you want to make directory ", 0
   287 00013507 6E7420746F206D616B- <1>
   287 00013510 65206469726563746F- <1>
   287 00013519 72792000            <1>
   288 0001351D 2028592F4E29203F20- <1> Msg_YesNo:      db " (Y/N) ? ", 0  
   288 00013526 00                  <1>
   289 00013527 000D0A00            <1> Y_N_nextline:	db 0, 0Dh, 0Ah, 0 
   290 0001352B 4F4B2E0D0A00        <1> Msg_OK:		db "OK.", 0Dh, 0Ah, 0
   291                              <1> 
   292                              <1> ; 27/02/2016
   293                              <1> Msg_DoYouWantRmDir:
   294 00013531 446F20796F75207761- <1>                 db "Do you want to delete directory ", 0
   294 0001353A 6E7420746F2064656C- <1>
   294 00013543 657465206469726563- <1>
   294 0001354C 746F72792000        <1>
   295                              <1> Msg_Dir_Not_Empty:
   296 00013552 4469726563746F7279- <1>                 db "Directory not empty!"
   296 0001355B 206E6F7420656D7074- <1>
   296 00013564 7921                <1>
   297 00013566 0D0A00              <1>                 db 0Dh, 0Ah, 0
   298                              <1> 
   299                              <1> Msg_DoYouWantDelete:
   300 00013569 446F20796F75207761- <1>                 db "Do you want to delete file ",0
   300 00013572 6E7420746F2064656C- <1>
   300 0001357B 6574652066696C6520- <1>
   300 00013584 00                  <1>
   301                              <1> 
   302 00013585 44656C657465642E2E- <1> Msg_Deleted:    db "Deleted...", 0Dh, 0Ah, 0
   302 0001358E 2E0D0A00            <1>
   303                              <1> 
   304                              <1> Msg_Permission_Denied:
   305 00013592 07                  <1>                 db 7
   306 00013593 5065726D697373696F- <1>                 db "Permission denied!", 0Dh, 0Ah, 0
   306 0001359C 6E2064656E69656421- <1>
   306 000135A5 0D0A00              <1>
   307                              <1> 
   308                              <1> ; 04/03/2016
   309 000135A8 4E657720            <1> Msg_New:        db "New "
   310 000135AC 00                  <1>                 db 0
   311                              <1> Str_Attributes:
   312 000135AD 417474726962757465- <1>                 db "Attributes : "
   312 000135B6 73203A20            <1>
   313 000135BA 4E4F524D414C        <1> Attr_Chars:     db "NORMAL"
   314 000135C0 00                  <1>                 db 0
   315                              <1> 
   316                              <1> ; 06/03/2016
   317                              <1> ; CMD_INTR.ASM - 16/11/2010 
   318                              <1> Msg_DoYouWantRename:
   319 000135C1 446F20796F75207761- <1>                 db "Do you want to rename ", 0
   319 000135CA 6E7420746F2072656E- <1>
   319 000135D3 616D652000          <1>
   320 000135D8 66696C652000        <1> Rename_File:    db "file ", 0
   321 000135DE 6469726563746F7279- <1> Rename_Directory: db "directory ", 0
   321 000135E7 2000                <1>
   322 000135E9 00<rep Dh>          <1> Rename_OldName: times 13 db 0
   323 000135F6 20617320            <1> Msg_File_rename_as: db " as "
   324 000135FA 00<rep Dh>          <1> Rename_NewName: times 13 db 0
   325                              <1> 
   326                              <1> ; 08/03/2016
   327                              <1> ; CMD_INTR.ASM - 01/08/2010 - 23/04/2011
   328                              <1> msg_not_same_drv:
   329 00013607 4E6F742073616D6520- <1>                 db "Not same drive!" 
   329 00013610 647269766521        <1>
   330 00013616 0D0A00              <1>                 db 0Dh, 0Ah, 0 
   331                              <1> 
   332                              <1> Msg_DoYouWantMoveFile:
   333 00013619 446F20796F75207761- <1>                 db "Do you want to move file", 0
   333 00013622 6E7420746F206D6F76- <1>
   333 0001362B 652066696C6500      <1>
   334                              <1> 
   335                              <1> msg_insufficient_disk_space:
   336 00013632 496E73756666696369- <1>                 db "Insufficient disk space!" 
   336 0001363B 656E74206469736B20- <1>
   336 00013644 737061636521        <1>
   337 0001364A 0D0A00              <1>                 db 0Dh, 0Ah, 0
   338                              <1> 
   339                              <1> ; 01/08/2010
   340                              <1> msg_source_file: 
   341 0001364D 0D0A536F7572636520- <1> 		db 0Dh, 0Ah, "Source file name      :   "
   341 00013656 66696C65206E616D65- <1>
   341 0001365F 2020202020203A2020- <1>
   341 00013668 20                  <1>
   342                              <1> msg_source_file_drv: 
   343 00013669 203A00              <1> 		db " :", 0
   344                              <1> msg_destination_file: 
   345 0001366C 0D0A44657374696E61- <1> 		db 0Dh, 0Ah, "Destination file name :   "
   345 00013675 74696F6E2066696C65- <1>
   345 0001367E 206E616D65203A2020- <1>
   345 00013687 20                  <1>
   346                              <1> msg_destination_file_drv: 
   347 00013688 203A00              <1> 		db " :", 0
   348                              <1> msg_copy_nextline: 
   349 0001368B 0D0A00              <1> 		db 0Dh, 0Ah, 0
   350                              <1> 
   351                              <1> ; 15/03/2016
   352                              <1> ; CMD_INTR.ASM
   353                              <1> 
   354                              <1> Msg_DoYouWantOverWriteFile:
   355 0001368E 446F20796F75207761- <1>                 db "Do you want to overwrite file ",0
   355 00013697 6E7420746F206F7665- <1>
   355 000136A0 727772697465206669- <1>
   355 000136A9 6C652000            <1>
   356                              <1>   
   357                              <1> Msg_DoYouWantCopyFile:
   358 000136AD 446F20796F75207761- <1>                 db "Do you want to copy file",0
   358 000136B6 6E7420746F20636F70- <1>
   358 000136BF 792066696C6500      <1>
   359                              <1> 
   360                              <1> Msg_read_file_error_before_EOF:
   361 000136C6 46696C652072656164- <1> 		db "File reading error! (before EOF)"
   361 000136CF 696E67206572726F72- <1>
   361 000136D8 2120286265666F7265- <1>
   361 000136E1 20454F4629          <1>
   362 000136E6 0A0A00              <1> 		db 0Ah, 0Ah, 0
   363                              <1> 
   364                              <1> ; 18/03/2016
   365                              <1> ; TRDOS 386 (v2.0) mainprog copy procedure
   366                              <1> msg_reading:
   367 000136E9 52656164696E672E2E- <1> 		db "Reading... ", 0
   367 000136F2 2E2000              <1>
   368                              <1> msg_writing:
   369 000136F5 57726974696E672E2E- <1> 		db "Writing... ", 0
   369 000136FE 2E2000              <1>
   370                              <1> percentagestr:
   371 00013701 2020202500          <1> 		db "   %", 0  ; "  0%" .. "100%"
   372                              <1> ; 11/04/2016
   373                              <1> Msg_No_Set_Space:
   374 00013706 496E73756666696369- <1>                 db "Insufficient environment space!"
   374 0001370F 656E7420656E766972- <1>
   374 00013718 6F6E6D656E74207370- <1>
   374 00013721 61636521            <1>
   375 00013725 0D0A00              <1>                 db 0Dh, 0Ah, 0
   376                              <1> ; 18/04/2016
   377                              <1> isc_msg:	
   378 00013728 0D0A                <1> 		db 0Dh, 0Ah
   379 0001372A 494E56414C49442053- <1> 		db "INVALID SYSTEM CALL", 0
   379 00013733 595354454D2043414C- <1>
   379 0001373C 4C00                <1>
   380                              <1> usi_msg:
   381 0001373E 0D0A                <1> 		db 0Dh, 0Ah
   382 00013740 554E444546494E4544- <1> 		db "UNDEFINED SOFTWARE INTERRUPT", 0
   382 00013749 20534F465457415245- <1>
   382 00013752 20494E544552525550- <1>
   382 0001375B 5400                <1>
   383                              <1> ifc_msg:
   384 0001375D 0D0A                <1> 		db 0Dh, 0Ah
   385 0001375F 494E56414C49442046- <1> 		db "INVALID FUNCTION CALL"
   385 00013768 554E4354494F4E2043- <1>
   385 00013771 414C4C              <1>
   386                              <1> inv_msg_for_trdos_v2:
   387 00013774 20                  <1> 		db 20h
   388 00013775 666F72205452444F53- <1> 		db "for TRDOS v2!"
   388 0001377E 20763221            <1>
   389 00013782 07                  <1> 		db 07h
   390 00013783 0D0A                <1> 		db 0Dh, 0Ah
   391 00013785 0D0A                <1> 		db 0Dh, 0Ah
   392 00013787 494E5420            <1> 		db "INT "
   393 0001378B 303068              <1> int_num_str:	db "00h"
   394 0001378E 0D0A                <1> 		db 0Dh, 0Ah
   395 00013790 454158203A20        <1> 		db "EAX : "
   396 00013796 303030303030303068- <1> eax_str:	db "00000000h", 0Dh, 0Ah
   396 0001379F 0D0A                <1>
   397 000137A1 454950203A20        <1> 		db "EIP : "
   398 000137A7 303030303030303068- <1> eip_str:	db "00000000h", 0Dh, 0Ah, 0
   398 000137B0 0D0A00              <1>
   399                              <1> 
   400                              <1> ; 17/04/2021
   401                              <1> ; ('KDEV' device parameters are disabled as temporary)
   402                              <1> 
   403                              <1> ; 07/10/2016
   404                              <1> ; Device names & parameters (for kernel devices)
   405                              <1> 
   406 000137B3 90                  <1> align 2
   407                              <1> ;KDEV_NAME:
   408                              <1> ;		db 'TTY',0,0,0,0,0 ; 1
   409                              <1> ;		db 'MEM',0,0,0,0,0 ; 2
   410                              <1> ;		db 'FD0',0,0,0,0,0 ; 3
   411                              <1> ;		db 'FD1',0,0,0,0,0 ; 4
   412                              <1> ;		db 'HD0',0,0,0,0,0 ; 5
   413                              <1> ;		db 'HD1',0,0,0,0,0 ; 6
   414                              <1> ;		db 'HD2',0,0,0,0,0 ; 7
   415                              <1> ;		db 'HD3',0,0,0,0,0 ; 8
   416                              <1> ;		db 'LPT',0,0,0,0,0 ; 9
   417                              <1> ;		db 'TTY0',0,0,0,0 ; 10
   418                              <1> ;		db 'TTY1',0,0,0,0 ; 11
   419                              <1> ;		db 'TTY2',0,0,0,0 ; 12
   420                              <1> ;		db 'TTY3',0,0,0,0 ; 13
   421                              <1> ;		db 'TTY4',0,0,0,0 ; 14
   422                              <1> ;		db 'TTY5',0,0,0,0 ; 15
   423                              <1> ;		db 'TTY6',0,0,0,0 ; 16
   424                              <1> ;		db 'TTY7',0,0,0,0 ; 17
   425                              <1> ;		db 'TTY8',0,0,0,0 ; 18
   426                              <1> ;		db 'TTY9',0,0,0,0 ; 19
   427                              <1> ;		db 'COM1',0,0,0,0 ; 18
   428                              <1> ;		db 'COM2',0,0,0,0 ; 19
   429                              <1> ;		;db 'CONSOLE',0	  ; 1
   430                              <1> ;		;db 'PRINTER',0   ; 9
   431                              <1> ;		;db 'CDROM'	  ; 20
   432                              <1> ;		;db 'CDROM0'	  ; 20
   433                              <1> ;		;db 'CDROM1'	  ; 21		
   434                              <1> ;		;db 'DVD'	  ; 22
   435                              <1> ;		;db 'DVD0'	  ; 22
   436                              <1> ;		;db 'DVD1'	  ; 23		
   437                              <1> ;		;db 'USB'	  ; 24
   438                              <1> ;		;db 'USB0'	  ; 24
   439                              <1> ;		;db 'USB1'	  ; 25
   440                              <1> ;		;db 'USB2'	  ; 26
   441                              <1> ;		;db 'USB3'        ; 27
   442                              <1> ;		;db 'KEYBOARD'	  ; 1	
   443                              <1> ;		;db 'MOUSE'	  ; 28
   444                              <1> ;		;db 'SOUND'	  ; 29
   445                              <1> ;		;db 'VGA',0,0,0,0 ; 30
   446                              <1> ;		;db 'CGA',0,0,0,0 ; 31
   447                              <1> ;		;db 'AUDIO',0,0,0 ; 29
   448                              <1> ;		;db 'VIDEO',0,0,0 ; 32
   449                              <1> ;		;db 'MUSIC',0,0,0 ; 33
   450                              <1> ;		;db 'ETHERNET'	  ; 34 		
   451                              <1> ;		;db 'SD0',0,0,0,0,0 ; 35
   452                              <1> ;		;db 'SD1',0,0,0,0,0 ; 36
   453                              <1> ;		;db 'SD2',0,0,0,0,0 ; 37
   454                              <1> ;		;db 'SD3',0,0,0,0,0 ; 38
   455                              <1> ;		;db 'SATA0'	  ; 35
   456                              <1> ;		;db 'SATA1'	  ; 36
   457                              <1> ;		;db 'SATA2'        ; 37
   458                              <1> ;		;db 'SATA3'        ; 38
   459                              <1> ;		;db 'PATA0',0,0,0  ; 5
   460                              <1> ;		;db 'PATA1',0,0,0  ; 6
   461                              <1> ;		;db 'PATA2',0,0,0  ; 7
   462                              <1> ;		;db 'PATA3',0,0,0  ; 8
   463                              <1> ;		;db 'WIRELESS'	  ; 39
   464                              <1> ;		;db 'HDMI',0,0,0,0 ; 40
   465                              <1> ;		db 'NULL',0,0,0,0 ; 0
   466                              <1> 
   467                              <1> ;NumOfKernelDevNames equ ($-KDEV_NAME) / 8 ; 20 (07/10/2016)
   468                              <1> 
   469                              <1> ;KDEV_NUMBER:
   470                              <1> ;		db 1,2,3,4,5,6,7,8,9
   471                              <1> ;		db 10,11,12,13,14,15,16,17,18,19
   472                              <1> ;		db 18,19,0
   473                              <1> 
   474                              <1> ;NumOfKernelDevices equ $ - KDEV_NUMBER
   475                              <1> 
   476                              <1> ;KDEV_OADDR:
   477                              <1> ;		dd otty ;tty  ; 1
   478                              <1> ;		dd sret ;mem  ; 2
   479                              <1> ; 		dd sret ;fd0  ; 3
   480                              <1> ; 		dd sret ;fd1  ; 4
   481                              <1> ;		dd sret ;hd0  ; 5
   482                              <1> ;		dd sret ;hd1  ; 6
   483                              <1> ;		dd sret ;hd2  ; 7
   484                              <1> ;		dd sret ;hd3  ; 8
   485                              <1> ;		dd sret ;lpt  ; 9
   486                              <1> ;		dd ocvt ;tty0 ; 10
   487                              <1> ;		dd ocvt ;tty1 ; 11
   488                              <1> ;		dd ocvt ;tty2 ; 12
   489                              <1> ;		dd ocvt ;tty3 ; 13
   490                              <1> ;		dd ocvt ;tty4 ; 14
   491                              <1> ;		dd ocvt ;tty5 ; 15
   492                              <1> ;		dd ocvt ;tty6 ; 16
   493                              <1> ;		dd ocvt ;tty7 ; 17
   494                              <1> ;		dd ocvt ;tty8 ; 18
   495                              <1> ;		dd ocvt ;tty9 ; 19
   496                              <1> ;		;dd ocvt ;com1 ; 18
   497                              <1> ;		;dd ocvt ;com2 ; 19
   498                              <1> ;		dd sret ;null ; 20  
   499                              <1> ;KDEV_CADDR:
   500                              <1> ;		dd ctty ;tty  ; 1
   501                              <1> ;		dd cret ;mem  ; 2
   502                              <1> ; 		dd cret ;fd0  ; 3
   503                              <1> ; 		dd cret ;fd1  ; 4
   504                              <1> ;		dd cret ;hd0  ; 5
   505                              <1> ;		dd cret ;hd1  ; 6
   506                              <1> ; 		dd cret ;hd2  ; 7
   507                              <1> ;		dd cret ;hd3  ; 8
   508                              <1> ; 		dd cret ;lpt  ; 9
   509                              <1> ;		dd ocvt ;tty0 ; 10
   510                              <1> ;		dd ccvt ;tty1 ; 11
   511                              <1> ;		dd ccvt ;tty2 ; 12
   512                              <1> ; 		dd ccvt ;tty3 ; 13
   513                              <1> ; 		dd ccvt ;tty4 ; 14
   514                              <1> ; 		dd ccvt ;tty5 ; 15
   515                              <1> ; 		dd ccvt ;tty6 ; 16
   516                              <1> ; 		dd ccvt ;tty7 ; 17
   517                              <1> ; 		dd ccvt ;tty8 ; 18
   518                              <1> ; 		dd ccvt ;tty9 ; 19
   519                              <1> ; 		;dd ccvt ;com1 ; 18
   520                              <1> ; 		;dd ccvt ;com2 ; 19
   521                              <1> ;		dd cret ;null ; 20
   522                              <1> ;
   523                              <1> ;KDEV_RADDR:
   524                              <1> ;		dd rtty ;tty  ; 1
   525                              <1> ;		dd rmem ;mem  ; 2
   526                              <1> ;		dd rfd  ;fd0  ; 3
   527                              <1> ; 		dd rfd  ;fd1  ; 4
   528                              <1> ; 		dd rhd  ;hd0  ; 5
   529                              <1> ; 		dd rhd  ;hd1  ; 6
   530                              <1> ; 		dd rhd  ;hd2  ; 7
   531                              <1> ; 		dd rhd  ;hd3  ; 8
   532                              <1> ; 		dd rlpt ;lpt  ; 9
   533                              <1> ; 		dd rcvt ;tty0 ; 10
   534                              <1> ;		dd rcvt ;tty1 ; 11
   535                              <1> ; 		dd rcvt ;tty2 ; 12
   536                              <1> ; 		dd rcvt ;tty3 ; 13
   537                              <1> ; 		dd rcvt ;tty4 ; 14
   538                              <1> ; 		dd rcvt ;tty5 ; 15
   539                              <1> ; 		dd rcvt ;tty6 ; 16
   540                              <1> ; 		dd rcvt ;tty7 ; 17
   541                              <1> ; 		dd rcvt ;tty8 ; 18
   542                              <1> ; 		dd rcvt ;tty9 ; 19
   543                              <1> ; 		;dd rcvt ;com1 ; 18
   544                              <1> ; 		;dd rcvt ;com2 ; 19
   545                              <1> ;		dd rnull ;null ; 20  
   546                              <1> ;KDEV_WADDR:
   547                              <1> ;		dd wtty ;tty  ; 1
   548                              <1> ;		dd wmem ;mem  ; 2
   549                              <1> ;		dd wfd  ;fd0  ; 3
   550                              <1> ; 		dd wfd  ;fd1  ; 4
   551                              <1> ; 		dd whd  ;hd0  ; 5
   552                              <1> ; 		dd whd  ;hd1  ; 6
   553                              <1> ; 		dd whd  ;hd2  ; 7
   554                              <1> ; 		dd whd  ;hd3  ; 8
   555                              <1> ; 		dd wlpt ;lpt  ; 9
   556                              <1> ; 		dd xmtt ;tty0 ; 10
   557                              <1> ;		dd xmtt ;tty1 ; 11
   558                              <1> ; 		dd xmtt ;tty2 ; 12
   559                              <1> ; 		dd xmtt ;tty3 ; 13
   560                              <1> ; 		dd xmtt ;tty4 ; 14
   561                              <1> ; 		dd xmtt ;tty5 ; 15
   562                              <1> ; 		dd xmtt ;tty6 ; 16
   563                              <1> ; 		dd xmtt ;tty7 ; 17
   564                              <1> ; 		dd xmtt ;tty8 ; 18
   565                              <1> ; 		dd xmtt ;tty9 ; 19
   566                              <1> ; 		;dd xmtt ;com1 ; 18
   567                              <1> ; 		;dd xmtt ;com2 ; 19
   568                              <1> ;		dd wnull ;null ; 20  
   569                              <1> 
   570                              <1> ; DEV_ACCESS bits:
   571                              <1> 	; bit 0 = accessable by normal users
   572                              <1> 	; bit 1 = read access permission
   573                              <1> 	; bit 2 = write access permission
   574                              <1> 	; bit 3 = IOCTL permission to users
   575                              <1> 	; bit 4 = block device if it is set
   576                              <1> 	; bit 5 = 16 bit or 1024 byte data
   577                              <1> 	; bit 6 = 32 bit or 2048 byte data
   578                              <1> 	; bit 7 = installable device driver	
   579                              <1> 
   580                              <1> ;KDEV_ACCESS: ; 08/10/2016
   581                              <1> ;		db  00000111b	; tty, 1
   582                              <1> ;		db  00000111b	; mem, 2	
   583                              <1> ;		db  10001111b	; fd0, 3	
   584                              <1> ;		db  10001111b	; fd1, 4
   585                              <1> ;		db  10001111b	; hd0, 5
   586                              <1> ;		db  10001111b	; hd1, 6
   587                              <1> ;		db  10001111b	; hd2, 7
   588                              <1> ;		db  10001111b	; hd3, 8
   589                              <1> ;		db  00000111b   ; lpt, 9
   590                              <1> ;		db  00000111b	; tty0, 10
   591                              <1> ;		db  00000111b	; tty1, 11
   592                              <1> ;		db  00000111b	; tty2, 12
   593                              <1> ;		db  00000111b	; tty3, 13
   594                              <1> ;		db  00000111b	; tty4, 14
   595                              <1> ;		db  00000111b	; tty5, 15
   596                              <1> ;		db  00000111b	; tty6, 16
   597                              <1> ;		db  00000111b	; tty7, 17
   598                              <1> ;		db  00000111b	; tty8, 18
   599                              <1> ;		db  00000111b	; tty9, 19
   600                              <1> ;		;db 00000111b	; com1, 18
   601                              <1> ;		;db 00000111b	; com2, 19
   602                              <1> ;		db  00000000b   ; null, 0
   603                              <1> 
   604                              <1> ; 07/10/2016
   605                              <1> ;NumOfInstallableDevices equ 8
   606                              <1> ;NUMIDEV	equ NumOfInstallableDevices ; 8
   607                              <1> ;NUMOFDEVICES	equ NumOfKernelDevices + NumOfInstallableDevices
   608                              <1> 
   609                              <1> ; 26/02/2017
   610                              <1> ; IRQ Callback (& Signal Response Byte) service availibity
   611                              <1> ; 'syscalbac'
   612                              <1> ; ***************************************************
   613                              <1> ; IRQ 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
   614                              <1> ; --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
   615                              <1> ; --- 00 00 00 01 02 03 00 04 00 05 06 07 08 09 00 00
   616                              <1> ; ***************************************************
   617                              <1> IRQenum:
   618 000137B4 000000010203000400- <1> 	db  0,0,0,1,2,3,0,4,0,5,6,7,8,9,0,0
   618 000137BD 05060708090000      <1>
   619                              <1> 
   620                              <1> ; 28/08/2017
   621                              <1> ; 20/08/2017
   622                              <1> ; DMA Registers (for 'sysdma')
   623                              <1> ; 02/07/2017 (sb16mod.s)
   624 000137C4 00020406C0C4C8CC    <1> dma_adr:	db 0,2,4,6,0C0h,0C4h,0C8h,0CCh
   625 000137CC 01030507C2C6CACE    <1> dma_cnt:	db 1,3,5,7,0C2h,0C6h,0CAh,0CEh
   626 000137D4 878381828F8B898A    <1> dma_page:	db 87h,83h,81h,82h,8Fh,8Bh,89h,8Ah ; 03/08/2017
   627 000137DC 0A0A0A0AD4D4D4D4    <1> dma_mask:	db 0Ah,0Ah,0Ah,0Ah,0D4h,0D4h,0D4h,0D4h
   628 000137E4 0B0B0B0BD6D6D6D6    <1> dma_mod:	db 0Bh,0Bh,0Bh,0Bh,0D6h,0D6h,0D6h,0D6h
   629 000137EC 0C0C0C0CD8D8D8D8    <1> dma_flip:	db 0Ch,0Ch,0Ch,0Ch,0D8h,0D8h,0D8h,0D8h	
  3246                                  
  3247                                  ; 27/08/2014
  3248                                  scr_row:
  3249 000137F4 E0810B00                	dd 0B8000h + 0A0h + 0A0h + 0A0h ; Row 3
  3250                                  scr_col:
  3251 000137F8 00000000                	dd 0
  3252                                  
  3253                                  Align 4
  3254                                  	; 15/04/2016
  3255                                  	; TRDOS 386 (TRDOS v2.0)
  3256                                  
  3257                                  	; 21/08/2014
  3258                                  ilist:
  3259                                  	;times 	32 dd cpu_except ; INT 0 to INT 1Fh
  3260                                  	;
  3261                                  	; Exception list
  3262                                  	; 25/08/2014	
  3263 000137FC [080C0000]              	dd	exc0	; 0h,  Divide-by-zero Error
  3264 00013800 [0F0C0000]              	dd	exc1	
  3265 00013804 [160C0000]              	dd 	exc2	
  3266 00013808 [1D0C0000]              	dd	exc3	
  3267 0001380C [210C0000]              	dd	exc4	
  3268 00013810 [250C0000]              	dd	exc5	
  3269 00013814 [290C0000]              	dd 	exc6	; 06h,  Invalid Opcode
  3270 00013818 [2D0C0000]              	dd	exc7	
  3271 0001381C [310C0000]              	dd	exc8	
  3272 00013820 [350C0000]              	dd	exc9	
  3273 00013824 [390C0000]              	dd 	exc10	
  3274 00013828 [3D0C0000]              	dd	exc11
  3275 0001382C [410C0000]              	dd	exc12
  3276 00013830 [450C0000]              	dd	exc13	; 0Dh, General Protection Fault
  3277 00013834 [490C0000]              	dd 	exc14	; 0Eh, Page Fault
  3278 00013838 [4D0C0000]              	dd	exc15
  3279 0001383C [510C0000]              	dd	exc16
  3280 00013840 [550C0000]              	dd	exc17
  3281 00013844 [590C0000]              	dd 	exc18
  3282 00013848 [5D0C0000]              	dd	exc19
  3283 0001384C [610C0000]              	dd 	exc20
  3284 00013850 [650C0000]              	dd	exc21
  3285 00013854 [690C0000]              	dd	exc22
  3286 00013858 [6D0C0000]              	dd	exc23
  3287 0001385C [710C0000]              	dd 	exc24
  3288 00013860 [750C0000]              	dd	exc25
  3289 00013864 [790C0000]              	dd	exc26
  3290 00013868 [7D0C0000]              	dd	exc27
  3291 0001386C [810C0000]              	dd 	exc28
  3292 00013870 [850C0000]              	dd	exc29
  3293 00013874 [890C0000]              	dd 	exc30
  3294 00013878 [8D0C0000]              	dd	exc31
  3295                                  IRQ_list: ; 28/02/2017 ('syscalbac')
  3296                                  	; Interrupt list
  3297 0001387C [7B090000]              	dd	timer_int	; INT 20h
  3298                                  		;dd	irq0	
  3299 00013880 [D9100000]              	dd	kb_int		; 24/01/2016
  3300                                  		;dd	irq1
  3301 00013884 [5E0B0000]              	dd	irq2
  3302                                  		; COM2 int
  3303 00013888 [620B0000]              	dd	irq3
  3304                                  		; COM1 int
  3305 0001388C [6D0B0000]              	dd	irq4
  3306 00013890 [780B0000]              	dd	irq5
  3307                                  ;DISKETTE_INT: ;06/02/2015
  3308 00013894 [0C4E0000]              	dd	fdc_int		; 16/02/2015, IRQ 6 handler	
  3309                                  		;dd	irq6
  3310                                  ; Default IRQ 7 handler against spurious IRQs (from master PIC)
  3311                                  ; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  3312 00013898 [E60E0000]              	dd	default_irq7	; 25/02/2015
  3313                                  		;dd	irq7
  3314                                  ; Real Time Clock Interrupt
  3315 0001389C [E60A0000]              	dd	rtc_int		; 23/02/2015, IRQ 8 handler
  3316                                  		;dd	irq8	; INT 28h
  3317 000138A0 [880B0000]              	dd	irq9
  3318 000138A4 [8C0B0000]              	dd	irq10
  3319 000138A8 [900B0000]              	dd	irq11
  3320 000138AC [940B0000]              	dd	irq12
  3321 000138B0 [980B0000]              	dd	irq13
  3322                                  ;HDISK_INT1:  ;06/02/2015 	
  3323 000138B4 [8E560000]              	dd	hdc1_int 	; 21/02/2015, IRQ 14 handler		
  3324                                  		;dd	irq14
  3325                                  ;HDISK_INT2:  ;06/02/2015
  3326 000138B8 [B1560000]              	dd	hdc2_int 	; 21/02/2015, IRQ 15 handler		
  3327                                  		;dd	irq15	; INT 2Fh
  3328                                  		; 14/08/2015
  3329                                  	;dd	sysent		; INT 30h (system calls)
  3330                                  
  3331                                  	; 15/04/2016
  3332                                  	; TRDOS 386(TRDOS v2.0) Software Interrupts
  3333                                  
  3334 000138BC [19390100]              	dd	int30h		; Reserved for
  3335                                  				; !!! Retro UNIX (RUNIX) !!!
  3336                                  				; !!! SINGLIX !!! System Calls
  3337 000138C0 [68170000]              	dd	int31h		; Video BIOS (IBM PC/AT, Int 10h)
  3338 000138C4 [350F0000]              	dd	int32h		; Keyboard Functions (IBM PC/AT, Int 16h)
  3339 000138C8 [AE4E0000]              	dd	int33h		; DISK I/O (IBM PC/AT, Int 13h)
  3340 000138CC [E41E0100]              	dd	int34h		; #IOCTL# (I/O port access support for ring 3)
  3341 000138D0 [94610000]              	dd	int35h		; Time/Date Functions (IBM PC/AT, Int 1Ah)
  3342 000138D4 [9A0D0000]              	dd	ignore_int	; INT 36h : Timer Functions	
  3343 000138D8 [9A0D0000]              	dd	ignore_int	; INT 37h	
  3344 000138DC [9A0D0000]              	dd	ignore_int	; INT 38h
  3345 000138E0 [9A0D0000]              	dd	ignore_int	; INT 39h
  3346 000138E4 [9A0D0000]              	dd	ignore_int	; INT 3Ah	
  3347 000138E8 [9A0D0000]              	dd	ignore_int	; INT 3Bh
  3348 000138EC [9A0D0000]              	dd	ignore_int	; INT 3Ch
  3349 000138F0 [9A0D0000]              	dd	ignore_int	; INT 3Dh	
  3350 000138F4 [9A0D0000]              	dd	ignore_int	; INT 3Eh
  3351 000138F8 [9A0D0000]              	dd	ignore_int	; INT 3Fh
  3352 000138FC [6BCB0000]              	dd	sysent		; INT 40h : !!! TRDOS 386 System Calls !!!
  3353                                  	;dd	ignore_int
  3354 00013900 00000000                	dd	0
  3355                                  
  3356                                  ; 20/08/2014
  3357                                    ; /* This is the default interrupt "handler" :-) */ 
  3358                                    ; Linux v0.12 (head.s)
  3359                                  int_msg:
  3360 00013904 556E6B6E6F776E2069-     	db "Unknown interrupt ! ", 0
  3360 0001390D 6E7465727275707420-
  3360 00013916 212000             
  3361                                  
  3362                                  ; 15/04/2016
  3363                                  ; TRDOS 386 (TRDOS v2.0)
  3364                                  
  3365                                  ; 29/04/2016
  3366                                  int30h:
  3367                                  trdos_isc_routine:
  3368                                  	; 02/05/2016
  3369                                  	; 01/05/2016
  3370                                  	; 29/04/2016
  3371                                  	; 18/04/2016
  3372                                  	; 15/04/2016 (TRDOS 386 = TRDOS v2.0)
  3373                                  	; 17/04/2011 (TRDOS v1.0, 'IFC.ASM')
  3374                                  	; 03/02/2011 ('trdos_ifc_routine')
  3375                                  	;
  3376 00013919 8B1C24                  	mov	ebx, [esp] ; EIP (next)
  3377 0001391C 83EB02                  	sub	ebx, 2 ; EIP (CD ##h)
  3378                                  
  3379 0001391F 89C1                    	mov	ecx, eax
  3380 00013921 8A4301                  	mov	al, [ebx+1] ; CDh ##h
  3381                                  
  3382 00013924 66BA1000                	mov	dx, KDATA
  3383 00013928 8EDA                    	mov	ds, dx
  3384 0001392A 8EC2                    	mov	es, dx
  3385                                  
  3386 0001392C FC                      	cld
  3387 0001392D 8B15[88770100]          	mov	edx, [k_page_dir]
  3388 00013933 0F22DA                  	mov	cr3, edx
  3389                                  
  3390 00013936 E8F807FFFF              	call	bytetohex
  3391 0001393B 66A3[8B370100]          	mov	[int_num_str], ax
  3392                                  
  3393 00013941 89D8                    	mov	eax, ebx ; EIP
  3394 00013943 E82B08FFFF              	call	dwordtohex
  3395 00013948 8915[A7370100]          	mov	[eip_str], edx
  3396 0001394E A3[AB370100]            	mov	[eip_str+4], eax
  3397                                  
  3398 00013953 89C8                    	mov	eax, ecx
  3399 00013955 E81908FFFF              	call	dwordtohex
  3400 0001395A 8915[96370100]          	mov	[eax_str], edx
  3401 00013960 A3[9A370100]            	mov	[eax_str+4], eax 	
  3402                                  
  3403 00013965 43                      	inc	ebx
  3404 00013966 8A03                    	mov	al, [ebx] ; Interrupt number
  3405                                  
  3406                                  trdos_isc_handler:
  3407 00013968 80FE30                  	cmp	dh, 30h ; Retro UNIX, SINGLIX System calls
  3408 0001396B 7507                    	jne	short trdos_usi_handler
  3409 0001396D BE[28370100]            	mov	esi, isc_msg
  3410 00013972 EB05                    	jmp	short loc_write_inv_system_call_msg
  3411                                  
  3412                                  trdos_usi_handler:
  3413 00013974 BE[3E370100]            	mov	esi, usi_msg
  3414                                  
  3415                                  loc_write_inv_system_call_msg:
  3416 00013979 E8DC32FFFF              	call	print_msg
  3417                                  	; 29/04/2016
  3418 0001397E BE[74370100]            	mov	esi, inv_msg_for_trdos_v2
  3419 00013983 E8D232FFFF              	call	print_msg
  3420                                  
  3421                                  loc_ifc_terminate_process:
  3422                                  	; u.uno = process number
  3423                                  	; 29/04/2016
  3424                                  
  3425                                  	; 02/05/2016
  3426 00013988 FE05[10010300]          	inc	byte [sysflg] ; 0FFh -> 0
  3427                                  
  3428 0001398E B801000000              	mov	eax, 1
  3429 00013993 E9C494FFFF              	jmp	sysexit
  3430                                  
  3431                                  ; 07/03/2015
  3432                                  ; Temporary Code
  3433                                  display_disks:
  3434 00013998 803D[2C650000]00        	cmp 	byte [fd0_type], 0
  3435 0001399F 7605                    	jna 	short ddsks1
  3436 000139A1 E87D000000              	call	pdskm
  3437                                  ddsks1:
  3438 000139A6 803D[2D650000]00        	cmp	byte [fd1_type], 0
  3439 000139AD 760C                    	jna	short ddsks2
  3440 000139AF C605[F33A0100]31        	mov	byte [dskx], '1'
  3441 000139B6 E868000000              	call	pdskm
  3442                                  ddsks2:
  3443 000139BB 803D[2E650000]00        	cmp	byte [hd0_type], 0
  3444 000139C2 7654                    	jna	short ddsk6
  3445 000139C4 66C705[F13A0100]68-     	mov	word [dsktype], 'hd'
  3445 000139CC 64                 
  3446 000139CD C605[F33A0100]30        	mov	byte [dskx], '0'
  3447 000139D4 E84A000000              	call	pdskm
  3448                                  ddsks3:
  3449 000139D9 803D[2F650000]00        	cmp	byte [hd1_type], 0
  3450 000139E0 7636                    	jna	short ddsk6
  3451 000139E2 C605[F33A0100]31        	mov	byte [dskx], '1'
  3452 000139E9 E835000000              	call	pdskm
  3453                                  ddsks4:
  3454 000139EE 803D[30650000]00        	cmp	byte [hd2_type], 0
  3455 000139F5 7621                    	jna	short ddsk6
  3456 000139F7 C605[F33A0100]32        	mov	byte [dskx], '2'
  3457 000139FE E820000000              	call	pdskm
  3458                                  ddsks5:
  3459 00013A03 803D[31650000]00        	cmp	byte [hd3_type], 0
  3460 00013A0A 760C                    	jna	short ddsk6
  3461 00013A0C C605[F33A0100]33        	mov	byte [dskx], '3'
  3462 00013A13 E80B000000              	call	pdskm
  3463                                  ddsk6:
  3464 00013A18 BE[1B3B0100]            	mov	esi, nextline
  3465 00013A1D E806000000              	call	pdskml
  3466                                  pdskm_ok:
  3467 00013A22 C3                      	retn
  3468                                  pdskm:
  3469 00013A23 BE[EF3A0100]            	mov	esi, dsk_ready_msg
  3470                                  pdskml:	
  3471 00013A28 AC                      	lodsb
  3472 00013A29 08C0                    	or	al, al
  3473 00013A2B 74F5                    	jz	short pdskm_ok
  3474 00013A2D 56                      	push	esi
  3475                                  	; 13/05/2016
  3476 00013A2E BB07000000                      mov     ebx, 7  ; Black background, 
  3477                                  			; light gray forecolor
  3478                                  			; Video page 0 (bh=0)
  3479 00013A33 E820E8FEFF              	call	_write_tty
  3480 00013A38 5E                      	pop	esi
  3481 00013A39 EBED                    	jmp	short pdskml
  3482                                  
  3483 00013A3B 90                      Align 2
  3484                                  	; 21/08/2014
  3485                                  exc_msg:
  3486 00013A3C 435055206578636570-     	db "CPU exception ! "
  3486 00013A45 74696F6E202120     
  3487                                  excnstr: 		; 25/08/2014
  3488 00013A4C 3F3F68202045495020-     	db "??h", "  EIP : "
  3488 00013A55 3A20               
  3489                                  EIPstr: ; 29/08/2014
  3490 00013A57 00<rep Ch>              	times 12 db 0
  3491                                  
  3492                                  	; 23/02/2015
  3493                                  	; 25/08/2014
  3494                                  ;scounter:
  3495                                  ;	db 5
  3496                                  ;	db 19
  3497                                  
  3498                                  ; 06/11/2014
  3499                                  ; Memory Information message
  3500                                  ; 14/08/2015
  3501                                  msg_memory_info:
  3502 00013A63 07                      	db	07h
  3503 00013A64 0D0A                    	db	0Dh, 0Ah
  3504                                  	;db 	"MEMORY ALLOCATION INFO", 0Dh, 0Ah, 0Dh, 0Ah
  3505 00013A66 546F74616C206D656D-     	db	"Total memory : "
  3505 00013A6F 6F7279203A20       
  3506                                  mem_total_b_str: ; 10 digits
  3507 00013A75 303030303030303030-     	db	"0000000000 bytes", 0Dh, 0Ah
  3507 00013A7E 302062797465730D0A 
  3508 00013A87 202020202020202020-     	db	"               ", 20h, 20h, 20h
  3508 00013A90 202020202020202020 
  3509                                  mem_total_p_str: ; 7 digits
  3510 00013A99 303030303030302070-     	db	"0000000 pages", 0Dh, 0Ah
  3510 00013AA2 616765730D0A       
  3511 00013AA8 0D0A                    	db 	0Dh, 0Ah
  3512 00013AAA 46726565206D656D6F-     	db	"Free memory  : "
  3512 00013AB3 727920203A20       
  3513                                  free_mem_b_str:  ; 10 digits
  3514 00013AB9 3F3F3F3F3F3F3F3F3F-     	db	"?????????? bytes", 0Dh, 0Ah
  3514 00013AC2 3F2062797465730D0A 
  3515 00013ACB 202020202020202020-     	db	"               ", 20h, 20h, 20h
  3515 00013AD4 202020202020202020 
  3516                                  free_mem_p_str:  ; 7 digits
  3517 00013ADD 3F3F3F3F3F3F3F2070-     	db	"??????? pages", 0Dh, 0Ah
  3517 00013AE6 616765730D0A       
  3518 00013AEC 0D0A00                  	db	0Dh, 0Ah, 0
  3519                                  
  3520                                  dsk_ready_msg:
  3521 00013AEF 0D0A                    	db 	0Dh, 0Ah
  3522                                  dsktype:
  3523 00013AF1 6664                    	db	'fd'
  3524                                  dskx:
  3525 00013AF3 30                      	db	'0'
  3526 00013AF4 20                      	db	20h
  3527 00013AF5 697320524541445920-     	db 	'is READY ...'
  3527 00013AFE 2E2E2E             
  3528 00013B01 00                      	db 	0
  3529                                  
  3530                                  setup_error_msg:
  3531 00013B02 0D0A                    	db	0Dh, 0Ah
  3532 00013B04 4469736B2053657475-     	db	'Disk Setup Error !' 
  3532 00013B0D 70204572726F722021 
  3533 00013B16 0D0A00                  	db	0Dh, 0Ah,0
  3534                                  
  3535                                  next2line: ; 08/02/2016
  3536 00013B19 0D0A                    	db	0Dh, 0Ah
  3537                                  nextline:
  3538 00013B1B 0D0A00                  	db 	0Dh, 0Ah, 0
  3539                                  
  3540                                  ; temporary
  3541                                  ; 19/12/2020
  3542                                  msg_lfb_addr:
  3543                                  	;db	0Dh, 0Ah
  3544 00013B1E 4C696E656172206672-     	db	"Linear frame buffer at "
  3544 00013B27 616D65206275666665-
  3544 00013B30 7220617420         
  3545                                  lfb_addr_str: ; 8 (hex) digits
  3546 00013B35 303030303030303068-     	db	"00000000h", 0Dh, 0Ah
  3546 00013B3E 0D0A               
  3547 00013B40 0D0A00                  	db	0Dh, 0Ah, 0
  3548                                  
  3549                                  ; KERNEL - SYSINIT Messages
  3550                                  ; 24/08/2015
  3551                                  ; 13/04/2015 - (Retro UNIX 386 v1 Beginning)
  3552                                  ; 14/07/2013
  3553                                  ;kernel_init_err_msg:
  3554                                  ;	db 0Dh, 0Ah
  3555                                  ;	db 07h
  3556                                  ;	db 'Kernel initialization ERROR !'
  3557                                  ;	db 0Dh, 0Ah, 0 
  3558                                  
  3559                                  ;welcome_msg: 
  3560                                  ;	db 0Dh, 0Ah
  3561                                  ;	db 07h
  3562                                  ;	db 'Welcome to TRDOS 386 Operating System !'
  3563                                  ;	db 0Dh, 0Ah
  3564                                  ;	db 'by Erdogan Tan - 31/12/2017 (v2.0.0)'
  3565                                  ;	db 0Dh, 0Ah, 0
  3566                                  
  3567                                  panic_msg:
  3568 00013B43 0D0A07                  	db 0Dh, 0Ah, 07h
  3569 00013B46 4552524F523A204B65-     	db 'ERROR: Kernel Panic !'
  3569 00013B4F 726E656C2050616E69-
  3569 00013B58 632021             
  3570 00013B5B 0D0A00                  	db 0Dh, 0Ah, 0
  3571                                  
  3572                                  ;msgl_drv_not_ready: 
  3573                                  ;	db 07h, 0Dh, 0Ah
  3574                                  ;       db 'Drive not ready or read error !'
  3575                                  ;       db 0Dh, 0Ah, 0
  3576                                  
  3577                                  starting_msg:
  3578                                  	;;;db "Turkish Rational DOS v2.0 [18/04/2021] ...", 0
  3579                                  	;;db "Turkish Rational DOS v2.0 [11/08/2022] ...", 0
  3580                                  	;db "Turkish Rational DOS v2.0 [30/08/2023] ...", 0
  3581 00013B5E 5475726B6973682052-     	db "Turkish Rational DOS v2.0 [20/10/2023] ...", 0
  3581 00013B67 6174696F6E616C2044-
  3581 00013B70 4F532076322E30205B-
  3581 00013B79 32302F31302F323032-
  3581 00013B82 335D202E2E2E00     
  3582                                  
  3583                                  NextLine:
  3584 00013B89 0D0A00                  	db 0Dh, 0Ah, 0
  3585                                  
  3586                                  %include 'audio.s' ; 03/04/2017
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - audio.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 06/08/2022  (Previous: 01/09/2020 - Kernel v2.0.4)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 03/04/2017
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ****************************************************************************
    10                              <1> 
    11                              <1> ; AUDIO CONTROLLER & CODEC DEFINITIONS & CODE FOR TRDOS 386
    12                              <1> 
    13                              <1> ;=============================================================================
    14                              <1> ;               EQUATES
    15                              <1> ;=============================================================================
    16                              <1> 
    17                              <1> ; PCI EQUATES
    18                              <1> 
    19                              <1> BIT0  EQU 1
    20                              <1> BIT1  EQU 2
    21                              <1> BIT2  EQU 4
    22                              <1> BIT3  EQU 8
    23                              <1> BIT4  EQU 10h
    24                              <1> BIT5  EQU 20h
    25                              <1> BIT6  EQU 40h
    26                              <1> BIT7  EQU 80h
    27                              <1> BIT8  EQU 100h
    28                              <1> BIT9  EQU 200h
    29                              <1> BIT10 EQU 400h
    30                              <1> BIT11 EQU 800h
    31                              <1> BIT12 EQU 1000h
    32                              <1> BIT13 EQU 2000h
    33                              <1> BIT14 EQU 4000h
    34                              <1> BIT15 EQU 8000h
    35                              <1> BIT16 EQU 10000h
    36                              <1> BIT17 EQU 20000h
    37                              <1> BIT18 EQU 40000h
    38                              <1> BIT19 EQU 80000h
    39                              <1> BIT20 EQU 100000h
    40                              <1> BIT21 EQU 200000h
    41                              <1> BIT22 EQU 400000h
    42                              <1> BIT23 EQU 800000h
    43                              <1> BIT24 EQU 1000000h
    44                              <1> BIT25 EQU 2000000h
    45                              <1> BIT26 EQU 4000000h
    46                              <1> BIT27 EQU 8000000h
    47                              <1> BIT28 EQU 10000000h
    48                              <1> BIT29 EQU 20000000h
    49                              <1> BIT30 EQU 40000000h
    50                              <1> BIT31 EQU 80000000h
    51                              <1> NOT_BIT31 EQU 7FFFFFFFh
    52                              <1> 
    53                              <1> ; PCI equates
    54                              <1> ; PCI function address (PFA)
    55                              <1> ; bit 31 = 1
    56                              <1> ; bit 23:16 = bus number     (0-255)
    57                              <1> ; bit 15:11 = device number  (0-31)
    58                              <1> ; bit 10:8 = function number (0-7)
    59                              <1> ; bit 7:0 = register number  (0-255)
    60                              <1> 
    61                              <1> IO_ADDR_MASK    EQU     0FFFEh	; mask off bit 0 for reading BARs
    62                              <1> PCI_INDEX_PORT  EQU     0CF8h
    63                              <1> PCI_DATA_PORT   EQU     0CFCh
    64                              <1> PCI32           EQU     BIT31	; bitflag to signal 32bit access
    65                              <1> PCI16           EQU     BIT30	; bitflag for 16bit access
    66                              <1> NOT_PCI32_PCI16	EQU	03FFFFFFFh ; NOT BIT31+BIT30 ; 19/03/2017
    67                              <1> 
    68                              <1> PCI_FN0         EQU     0 << 8
    69                              <1> PCI_FN1         EQU     1 << 8
    70                              <1> PCI_FN2         EQU     2 << 8
    71                              <1> PCI_FN3         EQU     3 << 8
    72                              <1> PCI_FN4         EQU     4 << 8
    73                              <1> PCI_FN5         EQU     5 << 8
    74                              <1> PCI_FN6         EQU     6 << 8
    75                              <1> PCI_FN7         EQU     7 << 8
    76                              <1> 
    77                              <1> PCI_CMD_REG	EQU	04h	; reg 04, command reg
    78                              <1> IO_ENA		EQU	BIT0	; i/o decode enable
    79                              <1> MEM_ENA		EQU	BIT1	; memory decode enable
    80                              <1> BM_ENA		EQU     BIT2	; bus master enable
    81                              <1> 
    82                              <1> ; VIA VT8233 EQUATES
    83                              <1> 
    84                              <1> VIA_VID		equ 1106h	; VIA's PCI vendor ID
    85                              <1> VT8233_DID      equ 3059h	; VT8233 (VT8235) device ID
    86                              <1> 		
    87                              <1> PCI_IO_BASE          equ 10h
    88                              <1> AC97_INT_LINE        equ 3Ch
    89                              <1> VIA_ACLINK_CTRL      equ 41h
    90                              <1> VIA_ACLINK_STAT      equ 40h
    91                              <1> VIA_ACLINK_C00_READY equ 01h ; primary codec ready
    92                              <1> 	
    93                              <1> VIA_REG_AC97	     equ 80h ; dword
    94                              <1> 
    95                              <1> VIA_ACLINK_CTRL_ENABLE	equ   80h ; 0: disable, 1: enable
    96                              <1> VIA_ACLINK_CTRL_RESET	equ   40h ; 0: assert, 1: de-assert
    97                              <1> VIA_ACLINK_CTRL_SYNC	equ   20h ; 0: release SYNC, 1: force SYNC hi
    98                              <1> VIA_ACLINK_CTRL_VRA	equ   08h ; 0: disable VRA, 1: enable VRA
    99                              <1> VIA_ACLINK_CTRL_PCM	equ   04h ; 0: disable PCM, 1: enable PCM
   100                              <1> 					; 3D Audio Channel slots 3/4
   101                              <1> VIA_ACLINK_CTRL_INIT	equ  (VIA_ACLINK_CTRL_ENABLE +                               VIA_ACLINK_CTRL_RESET +                               VIA_ACLINK_CTRL_PCM +                               VIA_ACLINK_CTRL_VRA)
   105                              <1> 
   106                              <1> CODEC_AUX_VOL		equ   04h
   107                              <1> VIA_REG_AC97_BUSY	equ   01000000h ;(1<<24) 
   108                              <1> VIA_REG_AC97_CMD_SHIFT	equ   10h ; 16
   109                              <1> VIA_REG_AC97_PRIMARY_VALID equ 02000000h ;(1<<25)
   110                              <1> VIA_REG_AC97_READ	equ   00800000h ;(1<<23)
   111                              <1> VIA_REG_AC97_CODEC_ID_SHIFT   equ  1Eh ; 30
   112                              <1> VIA_REG_AC97_CODEC_ID_PRIMARY equ  0
   113                              <1> VIA_REG_AC97_DATA_SHIFT equ   0
   114                              <1> VIADEV_PLAYBACK         equ   0
   115                              <1> VIA_REG_OFFSET_STATUS   equ   0    ;; byte - channel status
   116                              <1> VIA_REG_OFFSET_CONTROL  equ   01h  ;; byte - channel control
   117                              <1> VIA_REG_CTRL_START	equ   80h  ;; WO
   118                              <1> VIA_REG_CTRL_TERMINATE  equ   40h  ;; WO
   119                              <1> VIA_REG_CTRL_PAUSE      equ   08h  ;; RW
   120                              <1> VIA_REG_CTRL_RESET      equ   01h  ;; RW - probably reset? undocumented
   121                              <1> VIA_REG_OFFSET_STOP_IDX equ   08h  ;; dword - stop index, channel type, sample rate
   122                              <1> VIA8233_REG_TYPE_16BIT  equ   200000h ;; RW
   123                              <1> VIA8233_REG_TYPE_STEREO equ   100000h ;; RW
   124                              <1> VIA_REG_OFFSET_CURR_INDEX equ 0Fh ;; byte - channel current index (for via8233 only)
   125                              <1> VIA_REG_OFFSET_TABLE_PTR equ  04h  ;; dword - channel table pointer
   126                              <1> VIA_REG_OFFSET_CURR_PTR equ   04h  ;; dword - channel current pointer
   127                              <1> VIA_REG_OFS_PLAYBACK_VOLUME_L equ  02h ;; byte
   128                              <1> VIA_REG_OFS_PLAYBACK_VOLUME_R equ  03h ;; byte
   129                              <1> VIA_REG_CTRL_AUTOSTART	equ   20h
   130                              <1> VIA_REG_CTRL_INT_EOL	equ   02h
   131                              <1> VIA_REG_CTRL_INT_FLAG	equ   01h
   132                              <1> VIA_REG_CTRL_INT	equ  (VIA_REG_CTRL_INT_FLAG +                               VIA_REG_CTRL_INT_EOL +                               VIA_REG_CTRL_AUTOSTART)
   135                              <1> 
   136                              <1> VIA_REG_STAT_STOP_IDX	equ   10h    ;; RO ; 27/07/2020
   137                              <1> 				     ; current index = stop index
   138                              <1> VIA_REG_STAT_STOPPED	equ   04h    ;; RWC
   139                              <1> VIA_REG_STAT_EOL	equ   02h    ;; RWC
   140                              <1> VIA_REG_STAT_FLAG	equ   01h    ;; RWC
   141                              <1> VIA_REG_STAT_ACTIVE	equ   80h    ;; RO
   142                              <1> ; 28/11/2016
   143                              <1> VIA_REG_STAT_LAST	equ   40h    ;; RO
   144                              <1> VIA_REG_STAT_TRIGGER_QUEUED equ 08h  ;; RO
   145                              <1> VIA_REG_CTRL_INT_STOP	equ   04h  ; Interrupt on Current Index = Stop Index
   146                              <1> 		   		   ; and End of Block
   147                              <1> 
   148                              <1> VIA_REG_OFFSET_CURR_COUNT equ 0Ch ;; dword - channel current count, index
   149                              <1> 
   150                              <1> PORTB		EQU	061h
   151                              <1> REFRESH_STATUS	EQU	010h	; Refresh signal status
   152                              <1> 
   153                              <1> ; AC97 Codec registers.
   154                              <1> 
   155                              <1> ; 22/07/2020
   156                              <1> ; REALTEK ALC655 and ADI SOUNDMAX AD1980 CODEC MIXER REGISTERS
   157                              <1> 
   158                              <1> ; each codec/mixer register is 16bits
   159                              <1> 
   160                              <1> CODEC_RESET_REG                 equ     00h	; reset codec
   161                              <1> CODEC_MASTER_VOL_REG            equ     02h	; master volume
   162                              <1> CODEC_HP_VOL_REG                equ     04h	; headphone volume ; AD1980
   163                              <1> CODEC_MASTER_MONO_VOL_REG       equ     06h	; master mono volume (mono-out)
   164                              <1> ;CODEC_MASTER_TONE_REG          equ     08h	; master tone (R+L) ; (not used)
   165                              <1> CODEC_PCBEEP_VOL_REG            equ     0Ah	; PC beep volume ; ALC655
   166                              <1> CODEC_PHONE_VOL_REG             equ     0Ch	; phone volume
   167                              <1> CODEC_MIC_VOL_REG               equ     0Eh	; mic volume
   168                              <1> CODEC_LINE_IN_VOL_REG           equ     10h	; line in volume
   169                              <1> CODEC_CD_VOL_REG                equ     12h	; CD volume
   170                              <1> ;CODEC_VID_VOL_REG              equ     14h	; video volume ; (not used)
   171                              <1> CODEC_AUX_VOL_REG               equ     16h	; aux volume
   172                              <1> CODEC_PCM_OUT_REG               equ     18h	; PCM out volume
   173                              <1> CODEC_RECORD_SELECT_REG         equ     1Ah	; record select
   174                              <1> CODEC_RECORD_VOL_REG            equ     1Ch	; record volume (record gain)
   175                              <1> ;CODEC_RECORD_MIC_VOL_REG       equ     1Eh	; record mic volume ; (not used)
   176                              <1> CODEC_GP_REG                    equ     20h	; general purpose
   177                              <1> ;CODEC_3D_CONTROL_REG           equ     22h	; 3D control
   178                              <1> ;;CODEC_AUDIO_INT_PAGING_REG    equ	24h	; audio int & paging ; (not used) 
   179                              <1> CODEC_POWER_CTRL_REG            equ     26h	; power down control
   180                              <1> CODEC_EXT_AUDIO_REG             equ     28h	; extended audio ID
   181                              <1> CODEC_EXT_AUDIO_CTRL_REG        equ     2Ah	; extended audio status/control
   182                              <1> CODEC_PCM_FRONT_DACRATE_REG     equ     2Ch	; PCM front sample rate
   183                              <1> CODEC_PCM_SURND_DACRATE_REG     equ     2Eh	; PCM surround sample rate
   184                              <1> CODEC_PCM_LFE_DACRATE_REG       equ     30h	; PCM Center/LFE sample rate
   185                              <1> CODEC_LR_ADCRATE_REG            equ     32h	; PCM input sample rate
   186                              <1> CODEC_MIC_ADCRATE_REG           equ     34h	; mic in sample rate  ; AD1980
   187                              <1> CODEC_PCM_LFE_VOL_REG           equ     36h	; PCM Center/LFE volume
   188                              <1> CODEC_PCM_SURND_VOL_REG         equ     38h	; PCM surround volume
   189                              <1> ;CODEC_SPDIF_CTRL_REG           equ     3Ah	; S/PDIF control
   190                              <1> ; 22/07/2020
   191                              <1> CODEC_MISC_CRTL_BITS_REG	equ	76h	; misc control bits ; AD1980
   192                              <1> ;	
   193                              <1> CODEC_VENDOR_ID1		equ	7Ch	; REALTEK: 414Ch, ADI: 4144h	
   194                              <1> CODEC_VENDOR_ID2		equ	7Eh	; REALTEK: 4760h, ADI: 5370h	
   195                              <1> 
   196                              <1> ; VT8233 SGD bits (21/04/2017)
   197                              <1> FLAG	EQU BIT30
   198                              <1> EOL	EQU BIT31
   199                              <1> 
   200                              <1> ; INTEL ICH EQUATES
   201                              <1> ; 28/05/2017
   202                              <1> INTEL_VID	equ	8086h	; Intel's PCI vendor ID
   203                              <1> ICH_DID		equ	2415h	; ICH (82801AA) device ID
   204                              <1> NAMBAR_REG      equ	10h	; native audio mixer Base Address Register
   205                              <1> NABMBAR_REG     equ	14h	; native audio bus mastering Base Addr Reg
   206                              <1> 
   207                              <1> PI_CR_REG       equ     0Bh     ; PCM in Control Register
   208                              <1> PO_CR_REG	equ     1Bh     ; PCM out Control Register
   209                              <1> MC_CR_REG	equ     2Bh     ; MIC in Control Register
   210                              <1> 
   211                              <1> PI_SR_REG	equ     6       ; PCM in Status register
   212                              <1> PO_SR_REG	equ     16h     ; PCM out Status register
   213                              <1> MC_SR_REG	equ     26h     ; MIC in Status register
   214                              <1> 
   215                              <1> IOCE 		equ     BIT4    ; interrupt on complete enable.
   216                              <1> FEIFE		equ     BIT3    ; set if you want an interrupt to fire
   217                              <1> LVBIE		equ     BIT2    ; last valid buffer interrupt enable.
   218                              <1> RR 		equ     BIT1    ; reset registers. Nukes all regs
   219                              <1>                                 ; except bits 4:2 of this register.
   220                              <1>                                 ; Only set this bit if BIT 0 is 0
   221                              <1> RPBM		equ     BIT0    ; Run/Pause
   222                              <1> 				; set this bit to start the codec!
   223                              <1> 
   224                              <1> PI_BDBAR_REG	equ     0       ; PCM in buffer descriptor BAR
   225                              <1> PO_BDBAR_REG	equ     10h     ; PCM out buffer descriptor BAR
   226                              <1> MC_BDBAR_REG	equ     20h     ; MIC in buffer descriptor BAR
   227                              <1> 
   228                              <1> PI_CIV_REG	equ     4       ; PCM in current Index value (RO)
   229                              <1> PO_CIV_REG	equ     14h     ; PCM out current Index value (RO)
   230                              <1> MC_CIV_REG 	equ     24h     ; MIC in current Index value (RO)
   231                              <1> 
   232                              <1> PI_LVI_REG	equ     5       ; PCM in Last Valid Index
   233                              <1> PO_LVI_REG	equ     15h     ; PCM out Last Valid Index
   234                              <1> MC_LVI_REG	equ     25h     ; MIC in Last Valid Index
   235                              <1> 
   236                              <1> IOC		equ     BIT31	; Fire an interrupt whenever this
   237                              <1>                 		; buffer is complete.
   238                              <1> BUP		equ     BIT30	; Buffer Underrun Policy.
   239                              <1> 
   240                              <1> GLOB_CNT_REG	equ     2Ch     ; Global Control Register
   241                              <1> GLOB_STS_REG	equ     30h     ; Global Status register (RO)
   242                              <1> 
   243                              <1> CTRL_ST_CREADY	equ   BIT8+BIT9+BIT28 ; Primary Codec Ready
   244                              <1> 
   245                              <1> CODEC_REG_POWERDOWN   equ 26h
   246                              <1> CODEC_REG_ST          equ 26h
   247                              <1> 
   248                              <1> ; 22/06/2017
   249                              <1> PO_PICB_REG	equ 18h	; PCM Out Position In Current Buffer Register
   250                              <1> 
   251                              <1> ;=============================================================================
   252                              <1> ;               CODE
   253                              <1> ;=============================================================================
   254                              <1> 
   255                              <1> ; CODE for INTEL ICH AC'97 AUDIO CONTROLLER
   256                              <1> 
   257                              <1> DetectICH:
   258                              <1> 	; 10/06/2017
   259                              <1> 	; 05/06/2017
   260                              <1> 	; 29/05/2017
   261                              <1> 	; 28/05/2017
   262 00013B8C B886801524          <1> 	mov     eax, (ICH_DID << 16) + INTEL_VID
   263 00013B91 E86E000000          <1>         call    pciFindDevice
   264 00013B96 730D                <1>         jnc     short d_ac97_1
   265                              <1> d_ac97_0:
   266                              <1> ; couldn't find the audio device!
   267 00013B98 C3                  <1> 	retn
   268                              <1> 
   269                              <1> ; CODE for VIA VT8233 AUDIO CONTROLLER
   270                              <1> 
   271                              <1> DetectVT8233:
   272                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
   273                              <1> 	; 10/06/2017
   274                              <1> 	; 05/06/2017
   275                              <1> 	; 29/05/2017
   276                              <1> 	; 03/04/2017
   277 00013B99 B806115930          <1> 	mov     eax, (VT8233_DID << 16) + VIA_VID
   278 00013B9E E861000000          <1>         call    pciFindDevice
   279                              <1> ;       jnc     short d_vt8233_0
   280                              <1> ; couldn't find the audio device!
   281                              <1> ;	retn
   282 00013BA3 72F3                <1> 	jc	short d_ac97_0  ; 28/05/2017
   283                              <1> d_vt8233_0:
   284                              <1> 	; 24/03/2017 ('player.asm')
   285                              <1> 	; 12/11/2016 
   286                              <1> 	; Erdogan Tan - 8/11/2016
   287                              <1> 	; References: Kolibrios - vt823x.asm (2016)
   288                              <1> 	;	      VIA VT8235 V-Link South Bridge (VT8235-VIA.PDF)(2002)
   289                              <1> 	;	      lowlevel.eu - AC97 (2016)
   290                              <1> 	;	      .wav player for DOS by Jeff Leyda (2002) -this file-
   291                              <1> 	;	      Linux kernel - via82xx.c (2016)
   292                              <1> d_ac97_1:
   293                              <1> 	; eax = BUS/DEV/FN
   294                              <1> 	;	00000000BBBBBBBBDDDDDFFF00000000
   295                              <1> 	; edx = DEV/VENDOR
   296                              <1> 	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
   297                              <1> 
   298 00013BA5 A3[B8890100]        <1> 	mov	[audio_dev_id], eax
   299 00013BAA 8915[BC890100]      <1> 	mov	[audio_vendor], edx
   300                              <1> 
   301                              <1> 	; init controller
   302 00013BB0 B004                <1> 	mov	al, PCI_CMD_REG ; command register (04h)
   303 00013BB2 E8DA000000          <1> 	call	pciRegRead32
   304                              <1> 
   305                              <1> 	; eax = BUS/DEV/FN/REG
   306                              <1> 	; edx = STATUS/COMMAND
   307                              <1> 	; 	SSSSSSSSSSSSSSSSCCCCCCCCCCCCCCCC
   308 00013BB7 8915[C0890100]      <1> 	mov	[audio_stats_cmd], edx
   309                              <1> 
   310 00013BBD B010                <1> 	mov	al, PCI_IO_BASE ; IO base address register (10h)
   311                              <1> 	;mov	al, NAMBAR_REG	; Native Audio Mixer BAR (10h)
   312 00013BBF E8CD000000          <1> 	call	pciRegRead32
   313                              <1> 
   314 00013BC4 66813D[BC890100]86- <1> 	cmp	word [audio_vendor], 8086h ; AC'97 ?
   314 00013BCC 80                  <1>
   315 00013BCD 751D                <1> 	jne	short d_vt8233_1
   316                              <1> 
   317                              <1> 	;and	dx, 0FFFEh ; Audio Codec IO_ADDR_MASK
   318                              <1> 	; 06/08/2022
   319 00013BCF 80E2FE              <1> 	and	dl, 0FEh
   320 00013BD2 668915[E8890100]    <1> 	mov	[NAMBAR], dx
   321                              <1> 
   322 00013BD9 B014                <1> 	mov	al, NABMBAR_REG ; Native Audio Bus Mastering BAR (14h)
   323 00013BDB E8B1000000          <1> 	call	pciRegRead32	
   324                              <1> 
   325                              <1> 	;and	dx, 0FFC0h ; Audio Controller IO_ADDR_MASK
   326                              <1> 	; 06/08/2022
   327 00013BE0 80E2C0              <1> 	and	dl, 0C0h
   328 00013BE3 668915[EA890100]    <1> 	mov	[NABMBAR], dx
   329                              <1>         ;mov	[audio_io_base], dx
   330                              <1> 	
   331 00013BEA EB0A                <1> 	jmp	short d_ac97_2
   332                              <1> 
   333                              <1> d_vt8233_1:
   334                              <1> 	;and	dx, 0FFC0h ; Audio Controller IO_ADDR_MASK 
   335                              <1> 	; 06/08/2022
   336 00013BEC 80E2C0              <1> 	and	dl, 0C0h
   337 00013BEF 668915[B6890100]    <1>         mov     [audio_io_base], dx
   338                              <1> 
   339                              <1> d_ac97_2:
   340                              <1> 	; 10/06/2017
   341 00013BF6 B03C                <1> 	mov	al, AC97_INT_LINE ; Interrupt Line Register (3Ch)
   342                              <1> 	;call	pciRegRead32
   343 00013BF8 E881000000          <1> 	call	pciRegRead8
   344                              <1> 
   345                              <1> 	;;and 	edx, 0FFh
   346                              <1> 	; 06/08/2022
   347                              <1> 	;and	dx, 0FFh
   348                              <1> 
   349 00013BFD 8815[B3890100]      <1>   	mov     [audio_intr], dl
   350                              <1> 
   351 00013C03 C3                  <1> 	retn
   352                              <1> 
   353                              <1> 	;; (Note: Interrupts are already enabled by TRDOS 386 kernel!)
   354                              <1> 	;mov	cx, dx
   355                              <1> 	
   356                              <1> 	;in	al, 0A1h ; irq 8-15
   357                              <1> 	;mov	ah, al
   358                              <1> 	;in	al, 21h  ; irq 0-7 
   359                              <1> 	;btr	ax, dx	 ; unmask ; 17/03/2017
   360                              <1> 	;;bts	ax, dx   ; MASK interrupt ; 10/06/2017 
   361                              <1> 	;out	21h, al  ; irq <= 7
   362                              <1> 	;mov	al, ah
   363                              <1> 	;out	0A1h, al ; irq > 7
   364                              <1> 	;
   365                              <1> 	
   366                              <1> 	; 10/06/2017
   367                              <1> 	; === Intel ICH I/O Controller Hub Datasheet, Section 8.1.16 ===
   368                              <1> 	; PRQ[n]_ROUT Register (61h, PRQB) Bit 7:
   369                              <1> 	; Interrupt Routing Enable (IRQEN).
   370                              <1> 	; 0 = The corresponding PIRQ is routed to one of the ISA-compatible
   371                              <1> 	;     interrupts specified in bits[3:0].
   372                              <1> 	; 1 = The PIRQ is not routed to the 8259.
   373                              <1> 	; Note: If the PIRQ is intended to cause an interrupt to the ICHs 
   374                              <1> 	;	integrated I/O APIC, then this bit should be set to 0 and 
   375                              <1> 	;	the APIC_EN bit should be set to 1. 
   376                              <1> 	;	The IRQEN must be set to 0 and the PIRQ routed to 
   377                              <1> 	;	an 8259 interrupt via the IRQ Routing filed (bits[3:0).
   378                              <1> 	;	The corresponding 8259 interrupt must be masked via the 
   379                              <1> 	;	appropriated bit in the 8259s OCW1 (Interrupt Mask)
   380                              <1> 	;	register. The IOAPIC must then be enabled by setting 
   381                              <1> 	;	the APIC_EN bit in the GEN_CNTL register.
   382                              <1> 
   383                              <1> 	;mov	eax, 0F861h  ; D31:F0
   384                              <1> 		;AL=61h : PIRQ[B] Routing Control Reg, LPC interface
   385                              <1> 	;;mov	dl, [audio_intr]
   386                              <1> 	;call	pciRegWrite8
   387                              <1> 	;;mov	al, 0D0h ; General Control Register (GEN_CTL)
   388                              <1> 	;;call	pciRegRead32
   389                              <1> 	;;or	edx, 100h ; Bit 8, APIC_EN (Enable I/O APIC) 
   390                              <1> 	;;;call	pciRegWrite32
   391                              <1> 	;;and	edx, ~100h
   392                              <1> 	;;call	pciRegWrite32 ; ; Bit 8, APIC_EN (Disable I/O APIC) 
   393                              <1> 	;
   394                              <1> 
   395                              <1> 	;mov	dx, 4D1h	; 8259 ELCR2
   396                              <1>     	;in	al, dx
   397                              <1> 	;mov	ah, al
   398                              <1> 	;;mov	dx, 4D0h 	; 8259 ELCR1
   399                              <1> 	;dec	dl
   400                              <1> 	;in	al, dx
   401                              <1> 	;bts	ax, cx
   402                              <1> 	;;mov	dx, 4D0h
   403                              <1> 	;out	dx, al		; set level-triggered mode
   404                              <1> 	;mov	al, ah ; 29/05/2017
   405                              <1> 	;;mov	dx, 4D1h
   406                              <1> 	;inc	dl
   407                              <1> 	;out	dx, al		; set level-triggered mode
   408                              <1> 
   409                              <1> 	;xor	eax, eax ; 0
   410                              <1> 
   411                              <1> 	;retn
   412                              <1> 
   413                              <1> ; CODE for PCI
   414                              <1> 
   415                              <1> pciFindDevice:
   416                              <1> 	; 03/04/2017 ('pci.asm', 20/03/2017)
   417                              <1> 	;
   418                              <1> 	; scan through PCI space looking for a device+vendor ID
   419                              <1> 	;
   420                              <1> 	; Entry: EAX=Device+Vendor ID
   421                              <1> 	;
   422                              <1> 	; Exit: EAX=PCI address if device found
   423                              <1> 	;	 EDX=Device+Vendor ID
   424                              <1> 	;        CY clear if found, set if not found. EAX invalid if CY set.
   425                              <1> 	;
   426                              <1> 	; Destroys: ebx, esi, edi, cl
   427                              <1> 	;
   428                              <1> 
   429                              <1> 	;push	ecx
   430 00013C04 50                  <1> 	push	eax
   431                              <1> 	;push	esi
   432                              <1> 	;push	edi
   433                              <1> 
   434 00013C05 89C6                <1>         mov     esi, eax                ; save off vend+device ID
   435 00013C07 BF00FFFF7F          <1>         mov     edi, (80000000h - 100h) ; start with bus 0, dev 0 func 0
   436                              <1> 
   437                              <1> nextPCIdevice:
   438 00013C0C 81C700010000        <1>         add     edi, 100h
   439 00013C12 81FF00F8FF80        <1>         cmp     edi, 80FFF800h		; scanned all devices?
   440 00013C18 F9                  <1>         stc
   441 00013C19 740C                <1>         je      short PCIScanExit       ; not found
   442                              <1> 
   443 00013C1B 89F8                <1>         mov     eax, edi                ; read PCI registers
   444 00013C1D E86F000000          <1>         call    pciRegRead32
   445 00013C22 39F2                <1>         cmp     edx, esi                ; found device?
   446 00013C24 75E6                <1>         jne     short nextPCIdevice
   447 00013C26 F8                  <1>         clc
   448                              <1> 
   449                              <1> PCIScanExit:
   450 00013C27 9C                  <1> 	pushf
   451 00013C28 B8FFFFFF7F          <1> 	mov	eax, NOT_BIT31 	; 19/03/2017
   452 00013C2D 21F8                <1> 	and	eax, edi	; return only bus/dev/fn #
   453 00013C2F 9D                  <1> 	popf
   454                              <1> 
   455                              <1> 	;pop	edi
   456                              <1> 	;pop	esi
   457 00013C30 5A                  <1> 	pop	edx
   458                              <1> 	;pop	ecx
   459 00013C31 C3                  <1> 	retn
   460                              <1> 
   461                              <1> pciRegRead:
   462                              <1> 	; 03/04/2017 ('pci.asm', 20/03/2017)
   463                              <1> 	;
   464                              <1> 	; 8/16/32bit PCI reader
   465                              <1> 	;
   466                              <1> 	; Entry: EAX=PCI Bus/Device/fn/register number
   467                              <1> 	;           BIT30 set if 32 bit access requested
   468                              <1> 	;           BIT29 set if 16 bit access requested
   469                              <1> 	;           otherwise defaults to 8 bit read
   470                              <1> 	;
   471                              <1> 	; Exit:  DL,DX,EDX register data depending on requested read size
   472                              <1> 	;
   473                              <1> 	; Note1: this routine is meant to be called via pciRegRead8,
   474                              <1> 	;	 pciRegread16 or pciRegRead32, listed below.
   475                              <1> 	;
   476                              <1> 	; Note2: don't attempt to read 32 bits of data from a non dword
   477                              <1> 	;	 aligned reg number. Likewise, don't do 16 bit reads from
   478                              <1> 	;	 non word aligned reg #
   479                              <1> 	
   480 00013C32 53                  <1> 	push	ebx
   481 00013C33 51                  <1> 	push	ecx
   482 00013C34 89C3                <1>         mov     ebx, eax		; save eax, dh
   483 00013C36 88F1                <1>         mov     cl, dh
   484                              <1> 
   485 00013C38 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
   486 00013C3D 0D00000080          <1>         or      eax, BIT31		; make a PCI access request
   487 00013C42 24FC                <1>         and     al, ~3 ; NOT 3		; force index to be dword
   488                              <1> 
   489 00013C44 66BAF80C            <1>         mov     dx, PCI_INDEX_PORT
   490 00013C48 EF                  <1>         out	dx, eax			; write PCI selector
   491                              <1> 	
   492 00013C49 66BAFC0C            <1>         mov     dx, PCI_DATA_PORT
   493 00013C4D 88D8                <1>         mov     al, bl
   494 00013C4F 2403                <1>         and     al, 3			; figure out which port to
   495 00013C51 00C2                <1>         add     dl, al			; read to
   496                              <1> 
   497 00013C53 F7C3000000C0        <1> 	test    ebx, PCI32+PCI16
   498 00013C59 7507                <1>         jnz     short _pregr0
   499 00013C5B EC                  <1> 	in	al, dx			; return 8 bits of data
   500 00013C5C 88C2                <1>         mov	dl, al
   501 00013C5E 88CE                <1> 	mov     dh, cl			; restore dh for 8 bit read
   502 00013C60 EB12                <1> 	jmp	short _pregr2
   503                              <1> _pregr0:	
   504 00013C62 F7C300000080        <1> 	test    ebx, PCI32
   505 00013C68 7507                <1>         jnz	short _pregr1
   506 00013C6A 66ED                <1> 	in	ax, dx
   507 00013C6C 6689C2              <1>         mov     dx, ax			; return 16 bits of data
   508 00013C6F EB03                <1> 	jmp	short _pregr2
   509                              <1> _pregr1:
   510 00013C71 ED                  <1> 	in	eax, dx			; return 32 bits of data
   511 00013C72 89C2                <1> 	mov	edx, eax
   512                              <1> _pregr2:
   513 00013C74 89D8                <1> 	mov     eax, ebx		; restore eax
   514 00013C76 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
   515 00013C7B 59                  <1> 	pop	ecx
   516 00013C7C 5B                  <1> 	pop	ebx
   517 00013C7D C3                  <1> 	retn
   518                              <1> 
   519                              <1> pciRegRead8:
   520 00013C7E 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 8 bit read size
   521 00013C83 EBAD                <1>         jmp     short pciRegRead	; call generic PCI access
   522                              <1> 
   523                              <1> pciRegRead16:
   524 00013C85 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 16 bit read size
   525 00013C8A 0D00000040          <1>         or      eax, PCI16		; call generic PCI access
   526 00013C8F EBA1                <1>         jmp     short pciRegRead
   527                              <1> 
   528                              <1> pciRegRead32:
   529 00013C91 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 32 bit read size
   530 00013C96 0D00000080          <1>         or      eax, PCI32		; call generic PCI access
   531 00013C9B EB95                <1>         jmp     pciRegRead
   532                              <1> 
   533                              <1> pciRegWrite:
   534                              <1> 	; 03/04/2017 ('pci.asm', 29/11/2016)
   535                              <1> 	;
   536                              <1> 	; 8/16/32bit PCI writer
   537                              <1> 	;
   538                              <1> 	; Entry: EAX=PCI Bus/Device/fn/register number
   539                              <1> 	;           BIT31 set if 32 bit access requested
   540                              <1> 	;           BIT30 set if 16 bit access requested
   541                              <1> 	;           otherwise defaults to 8bit read
   542                              <1> 	;        DL/DX/EDX data to write depending on size
   543                              <1> 	;
   544                              <1> 	; Note1: this routine is meant to be called via pciRegWrite8, 
   545                              <1> 	;	 pciRegWrite16 or pciRegWrite32 as detailed below.
   546                              <1> 	;
   547                              <1> 	; Note2: don't attempt to write 32bits of data from a non dword
   548                              <1> 	;	 aligned reg number. Likewise, don't do 16 bit writes from
   549                              <1> 	;	 non word aligned reg #
   550                              <1> 
   551 00013C9D 53                  <1> 	push	ebx
   552 00013C9E 51                  <1> 	push	ecx
   553 00013C9F 89C3                <1>         mov     ebx, eax		; save eax, edx
   554 00013CA1 89D1                <1>         mov     ecx, edx
   555 00013CA3 25FFFFFF3F          <1> 	and     eax, NOT_PCI32_PCI16	; clear out data size request
   556 00013CA8 0D00000080          <1>         or      eax, BIT31		; make a PCI access request
   557 00013CAD 24FC                <1>         and     al, ~3 ; NOT 3		; force index to be dword
   558                              <1> 
   559 00013CAF 66BAF80C            <1>         mov     dx, PCI_INDEX_PORT
   560 00013CB3 EF                  <1>         out	dx, eax			; write PCI selector
   561                              <1> 	
   562 00013CB4 66BAFC0C            <1>         mov     dx, PCI_DATA_PORT
   563 00013CB8 88D8                <1>         mov     al, bl
   564 00013CBA 2403                <1>         and     al, 3			; figure out which port to
   565 00013CBC 00C2                <1>         add     dl, al			; write to
   566                              <1> 
   567 00013CBE F7C3000000C0        <1> 	test    ebx, PCI32+PCI16
   568 00013CC4 7505                <1>         jnz     short _pregw0
   569 00013CC6 88C8                <1> 	mov	al, cl 			; put data into al
   570 00013CC8 EE                  <1> 	out	dx, al
   571 00013CC9 EB12                <1> 	jmp	short _pregw2
   572                              <1> _pregw0:
   573 00013CCB F7C300000080        <1> 	test    ebx, PCI32
   574 00013CD1 7507                <1>         jnz     short _pregw1
   575 00013CD3 6689C8              <1> 	mov	ax, cx			; put data into ax
   576 00013CD6 66EF                <1> 	out	dx, ax
   577 00013CD8 EB03                <1> 	jmp	short _pregw2
   578                              <1> _pregw1:
   579 00013CDA 89C8                <1> 	mov	eax, ecx		; put data into eax 		
   580 00013CDC EF                  <1> 	out	dx, eax
   581                              <1> _pregw2:
   582 00013CDD 89D8                <1>         mov     eax, ebx		; restore eax
   583 00013CDF 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
   584 00013CE4 89CA                <1>         mov     edx, ecx		; restore dx
   585 00013CE6 59                  <1> 	pop	ecx
   586 00013CE7 5B                  <1> 	pop	ebx
   587 00013CE8 C3                  <1> 	retn
   588                              <1> 
   589                              <1> pciRegWrite8:
   590 00013CE9 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 8 bit write size
   591 00013CEE EBAD                <1>         jmp	short pciRegWrite	; call generic PCI access
   592                              <1> 
   593                              <1> pciRegWrite16:
   594 00013CF0 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 16 bit write size
   595 00013CF5 0D00000040          <1>         or      eax, PCI16		; call generic PCI access
   596 00013CFA EBA1                <1>         jmp	short pciRegWrite
   597                              <1> 
   598                              <1> pciRegWrite32:
   599 00013CFC 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 32 bit write size
   600 00013D01 0D00000080          <1>         or      eax, PCI32		; call generic PCI access
   601 00013D06 EB95                <1>         jmp	pciRegWrite
   602                              <1> 
   603                              <1> init_codec:
   604                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
   605                              <1> 	; 05/06/2017
   606                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   607                              <1> 	;
   608 00013D08 A1[B8890100]        <1> 	mov	eax, [audio_dev_id]	
   609 00013D0D B041                <1> 	mov	al, VIA_ACLINK_CTRL
   610 00013D0F E86AFFFFFF          <1> 	call	pciRegRead8
   611                              <1> 	; ?
   612 00013D14 B040                <1> 	mov	al, VIA_ACLINK_STAT
   613 00013D16 E863FFFFFF          <1> 	call	pciRegRead8
   614 00013D1B F6C201              <1> 	test	dl, VIA_ACLINK_C00_READY
   615 00013D1E 7508                <1>         jnz     short _codec_ready_1
   616 00013D20 E80D000000          <1> 	call	reset_codec
   617 00013D25 7305                <1> 	jnc	short _codec_ready_2 ; eax = 1
   618 00013D27 C3                  <1> 	retn
   619                              <1> _codec_ready_1:
   620                              <1> 	;mov	eax, 1
   621                              <1> 	; 06/08/2022
   622 00013D28 29C0                <1> 	sub	eax, eax
   623 00013D2A FEC0                <1> 	inc	al
   624                              <1> 	; eax = 1
   625                              <1> _codec_ready_2:
   626 00013D2C E885000000          <1> 	call	codec_io_w16
   627                              <1> detect_codec:
   628 00013D31 C3                  <1> 	retn
   629                              <1> 
   630                              <1> reset_codec:
   631                              <1> 	; 16/04/2017
   632                              <1> 	; 23/03/2017 
   633                              <1> 	; ('codec.asm')
   634                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   635 00013D32 A1[B8890100]        <1> 	mov	eax, [audio_dev_id]
   636 00013D37 B041                <1>  	mov	al, VIA_ACLINK_CTRL
   637 00013D39 B2E0                <1>        	mov	dl, VIA_ACLINK_CTRL_ENABLE + VIA_ACLINK_CTRL_RESET + VIA_ACLINK_CTRL_SYNC
   638 00013D3B E8A9FFFFFF          <1> 	call	pciRegWrite8
   639                              <1> 
   640 00013D40 E848000000          <1> 	call	delay_100ms 	; wait 100 ms
   641                              <1> _rc_cold:
   642 00013D45 E814000000          <1>         call    cold_reset
   643 00013D4A 7301                <1>         jnc     short _reset_codec_ok
   644                              <1> 	
   645                              <1> 	; 16/04/2017
   646                              <1>         ;xor	eax, eax	; timeout error
   647                              <1>        	;stc
   648 00013D4C C3                  <1> 	retn
   649                              <1> 
   650                              <1> _reset_codec_ok:
   651                              <1> 	; 01/09/2020
   652                              <1> 	; 15/08/2020
   653                              <1> 	; 27/07/2020
   654                              <1> 	; also reset codec by using index control register 0 of AD1980 or ALC655
   655                              <1> 	; (to fix line out -2 channels audio playing- problem on AD1980 codec)  
   656                              <1> 
   657 00013D4D 29C0                <1> 	sub	eax, eax
   658 00013D4F BA00000000          <1> 	mov	edx, CODEC_RESET_REG ; 00h ; Reset register
   659 00013D54 E8C0000000          <1> 	call	codec_write
   660                              <1> 
   661                              <1> 	;sub	eax, eax
   662                              <1> 	; 01/09/2020
   663                              <1> 	; 15/08/2020
   664                              <1> 	; AD1980 BugFix
   665                              <1> 	; (set HPSEL -headphone amp to be driven from mixer- and
   666                              <1> 	;      CLDIS - center and LFE disable- bits)	
   667                              <1> 	;mov	eax, 0C00h ; HPSEL = bit 10, CLDIS = bit 11 ; 01/09/2020
   668                              <1>  	;mov	edx, CODEC_MISC_CRTL_BITS_REG ; 76h ; Misc Ctrl Bits ; AD1980
   669                              <1> 	;call	codec_write
   670                              <1> 
   671 00013D59 31C0                <1>         xor     eax, eax
   672                              <1>         ;mov	al, VIA_ACLINK_C00_READY ; 1
   673 00013D5B FEC0                <1>         inc	al
   674 00013D5D C3                  <1> 	retn
   675                              <1> 
   676                              <1> cold_reset:
   677                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
   678                              <1> 	; 16/04/2017
   679                              <1> 	; 23/03/2017
   680                              <1> 	; ('codec.asm')
   681                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   682                              <1> 	;mov	eax, [audio_dev_id]
   683                              <1> 	;mov	al, VIA_ACLINK_CTRL
   684 00013D5E 30D2                <1> 	xor	dl, dl ; 0
   685 00013D60 E884FFFFFF          <1> 	call	pciRegWrite8
   686                              <1> 
   687 00013D65 E823000000          <1> 	call	delay_100ms	; wait 100 ms
   688                              <1> 
   689                              <1> 	;; ACLink on, deassert ACLink reset, VSR, SGD data out
   690                              <1>         ;; note - FM data out has trouble with non VRA codecs !!
   691                              <1>         
   692                              <1> 	;mov	eax, [audio_dev_id]
   693                              <1> 	;mov	al, VIA_ACLINK_CTRL
   694 00013D6A B2CC                <1> 	mov	dl, VIA_ACLINK_CTRL_INIT
   695 00013D6C E878FFFFFF          <1> 	call	pciRegWrite8
   696                              <1> 
   697                              <1> 	;mov	ecx, 16	; total 2s
   698                              <1> 	; 06/08/2022
   699 00013D71 29C9                <1> 	sub	ecx, ecx
   700 00013D73 B110                <1> 	mov	cl, 16
   701                              <1> _crst_wait:
   702                              <1> 	;mov	eax, [audio_dev_id]
   703 00013D75 B040                <1> 	mov	al, VIA_ACLINK_STAT
   704 00013D77 E802FFFFFF          <1> 	call	pciRegRead8	
   705                              <1> 
   706 00013D7C F6C201              <1>         test    dl, VIA_ACLINK_C00_READY
   707 00013D7F 750B                <1>         jnz     short _crst_ok
   708                              <1> 
   709 00013D81 51                  <1> 	push	ecx
   710 00013D82 E806000000          <1> 	call	delay_100ms
   711 00013D87 59                  <1> 	pop	ecx
   712                              <1> 
   713 00013D88 49                  <1>         dec     ecx
   714 00013D89 75EA                <1>         jnz     short _crst_wait
   715                              <1> 
   716                              <1> _crst_fail:
   717 00013D8B F9                  <1>         stc
   718                              <1> _crst_ok:
   719 00013D8C C3                  <1> 	retn
   720                              <1> 
   721                              <1> delay_100ms:
   722                              <1> 	; 29/05/2017
   723                              <1> 	; 24/03/2017 ('codec.asm')
   724                              <1> 	; wait 100 ms
   725 00013D8D B990010000          <1> 	mov	ecx, 400  ; 400*0.25ms
   726                              <1> _delay_x_ms:
   727 00013D92 E803000000          <1> 	call	delay1_4ms
   728 00013D97 E2F9                <1>         loop	_delay_x_ms
   729 00013D99 C3                  <1> 	retn
   730                              <1> 
   731                              <1> ;       delay1_4ms - Delay for 1/4 millisecond.
   732                              <1> ;	    1ms = 1000us
   733                              <1> ;       Entry:
   734                              <1> ;         None
   735                              <1> ;       Exit:
   736                              <1> ;	  None
   737                              <1> ;
   738                              <1> ;       Modified:
   739                              <1> ;         None
   740                              <1> ;
   741                              <1> 
   742                              <1> 	; 29/05/2017
   743                              <1> 	; 23/04/2017
   744                              <1> 	; 05/03/2017 (TRDOS 386)
   745                              <1> 	; ('UTILS.ASM')
   746                              <1> delay1_4ms:
   747 00013D9A 50                  <1>         push    eax 
   748 00013D9B 51                  <1>         push    ecx
   749 00013D9C B110                <1>         mov	cl, 16		; close enough.
   750                              <1> 
   751 00013D9E E461                <1> 	in	al, PORTB ; 61h
   752                              <1> 		
   753 00013DA0 2410                <1> 	and	al, REFRESH_STATUS ; 10h
   754 00013DA2 88C5                <1> 	mov	ch, al		; Start toggle state
   755                              <1> _d4ms1:	
   756 00013DA4 E461                <1> 	in	al, PORTB	; Read system control port
   757                              <1> 	
   758 00013DA6 2410                <1> 	and	al, REFRESH_STATUS ; Refresh toggles 15.085 microseconds
   759 00013DA8 38C5                <1> 	cmp	ch, al
   760 00013DAA 74F8                <1> 	je	short _d4ms1	; Wait for state change
   761                              <1> 
   762 00013DAC 88C5                <1> 	mov	ch, al		; Update with new state
   763 00013DAE FEC9                <1> 	dec	cl
   764 00013DB0 75F2                <1> 	jnz	short _d4ms1
   765                              <1> 
   766 00013DB2 F8                  <1> 	clc	; 29/05/2017
   767                              <1> 
   768 00013DB3 59                  <1>         pop     ecx
   769 00013DB4 58                  <1>         pop     eax
   770 00013DB5 C3                  <1>         retn
   771                              <1> 
   772                              <1> ; 10/04/2017 (TRDOS 386)
   773                              <1> ; 12/11/2016
   774                              <1> 
   775                              <1> codec_io_w16: ;w32
   776                              <1> 	; ('codec.asm')
   777 00013DB6 668B15[B6890100]    <1>         mov	dx, [audio_io_base]
   778 00013DBD 6681C28000          <1>         add     dx, VIA_REG_AC97
   779 00013DC2 EF                  <1> 	out	dx, eax
   780 00013DC3 C3                  <1>         retn
   781                              <1> 
   782                              <1> codec_io_r16: ;r32
   783                              <1> 	; ('codec.asm')
   784 00013DC4 668B15[B6890100]    <1>         mov     dx, [audio_io_base]
   785 00013DCB 6681C28000          <1>         add     dx, VIA_REG_AC97
   786 00013DD0 ED                  <1>         in	eax, dx
   787 00013DD1 C3                  <1>         retn
   788                              <1> 
   789                              <1> ctrl_io_w8:
   790                              <1> 	; ('codec.asm')
   791 00013DD2 660315[B6890100]    <1>         add     dx, [audio_io_base]
   792 00013DD9 EE                  <1>         out	dx, al
   793 00013DDA C3                  <1>         retn
   794                              <1> 
   795                              <1> ctrl_io_r8:
   796                              <1> 	; ('codec.asm')
   797 00013DDB 660315[B6890100]    <1>         add     dx, [audio_io_base]
   798 00013DE2 EC                  <1>         in	al, dx
   799 00013DE3 C3                  <1>         retn
   800                              <1> 
   801                              <1> ctrl_io_w32:
   802                              <1> 	; ('codec.asm')
   803 00013DE4 660315[B6890100]    <1>         add     dx, [audio_io_base]
   804 00013DEB EF                  <1>         out	dx, eax
   805 00013DEC C3                  <1>         retn
   806                              <1> 
   807                              <1> ctrl_io_r32:
   808                              <1> 	; ('codec.asm')
   809 00013DED 660315[B6890100]    <1>         add	dx, [audio_io_base]
   810 00013DF4 ED                  <1> 	in	eax, dx
   811                              <1> _cr_not_rdy:	; 06/08/2022
   812 00013DF5 C3                  <1>         retn
   813                              <1> 
   814                              <1> codec_read:
   815                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
   816                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   817                              <1>         ; Use only primary codec.
   818                              <1>         ; eax = register
   819 00013DF6 C1E010              <1>         shl     eax, VIA_REG_AC97_CMD_SHIFT
   820 00013DF9 0D00008002          <1>         or      eax, VIA_REG_AC97_PRIMARY_VALID + VIA_REG_AC97_READ
   821                              <1> 
   822 00013DFE E8B3FFFFFF          <1> 	call    codec_io_w16
   823                              <1> 
   824                              <1>       	; codec_valid
   825 00013E03 E828000000          <1> 	call	codec_check_ready
   826                              <1> 	;jnc	short _cr_ok
   827                              <1> 	;retn
   828                              <1> 	; 06/08/2022
   829 00013E08 72EB                <1> 	jc	short _cr_not_rdy
   830                              <1> 	; ecx <= 20
   831                              <1> _cr_ok:
   832                              <1> 	; wait 25 ms
   833                              <1> 	;mov	ecx, 80 ; (100*0.25 ms)
   834                              <1> 	; 06/08/2022
   835                              <1> 	;xor	ecx, ecx
   836 00013E0A B150                <1> 	mov	cl, 80
   837                              <1> 	; ecx = 80
   838                              <1> _cr_wloop:
   839 00013E0C E889FFFFFF          <1> 	call	delay1_4ms
   840 00013E11 E2F9                <1> 	loop	_cr_wloop
   841                              <1> 
   842 00013E13 E8ACFFFFFF          <1>         call    codec_io_r16
   843                              <1> 	; 06/08/2022
   844                              <1> 	;and	eax, 0FFFFh
   845 00013E18 C3                  <1>         retn
   846                              <1> 
   847                              <1> codec_write:
   848                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
   849                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   850                              <1>         ; Use only primary codec.
   851                              <1>         
   852                              <1> 	; eax = data (volume)
   853                              <1> 	; edx = register (mixer register)
   854                              <1> 	
   855 00013E19 C1E210              <1> 	shl     edx, VIA_REG_AC97_CMD_SHIFT
   856                              <1> 
   857 00013E1C C1E000              <1>         shl     eax, VIA_REG_AC97_DATA_SHIFT ; shl eax, 0
   858 00013E1F 09C2                <1>         or      edx, eax
   859                              <1> 
   860 00013E21 B800000000          <1>         mov     eax, VIA_REG_AC97_CODEC_ID_PRIMARY
   861 00013E26 C1E01E              <1>         shl     eax, VIA_REG_AC97_CODEC_ID_SHIFT
   862 00013E29 09D0                <1>         or      eax, edx
   863                              <1> 
   864 00013E2B E886FFFFFF          <1>         call    codec_io_w16
   865                              <1>         ;mov    [codec.regs+esi], ax
   866                              <1> 
   867                              <1>         ;call	codec_check_ready
   868                              <1>        	;retn
   869                              <1> 	;jmp	short _codec_check_ready	
   870                              <1> 
   871                              <1> codec_check_ready:
   872                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
   873                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   874                              <1> 
   875                              <1> _codec_check_ready:
   876                              <1> 	;mov	ecx, 20	; total 2s
   877                              <1> 	; 06/08/2022
   878 00013E30 29C9                <1> 	sub	ecx, ecx
   879 00013E32 B114                <1> 	mov	cl, 20
   880                              <1> _ccr_wait:
   881 00013E34 51                  <1> 	push	ecx
   882                              <1> 
   883 00013E35 E88AFFFFFF          <1>         call    codec_io_r16
   884 00013E3A A900000001          <1>         test    eax, VIA_REG_AC97_BUSY
   885 00013E3F 740B                <1>         jz      short _ccr_ok
   886                              <1> 
   887 00013E41 E847FFFFFF          <1> 	call	delay_100ms
   888                              <1> 
   889 00013E46 59                  <1> 	pop	ecx
   890                              <1> 
   891 00013E47 49                  <1> 	dec     ecx
   892 00013E48 75EA                <1>         jnz     short _ccr_wait
   893                              <1> 
   894 00013E4A F9                  <1>         stc
   895 00013E4B C3                  <1>         retn
   896                              <1> 
   897                              <1> _ccr_ok:
   898 00013E4C 59                  <1> 	pop	ecx
   899 00013E4D 25FFFF0000          <1> 	and     eax, 0FFFFh
   900 00013E52 C3                  <1>         retn
   901                              <1> 
   902                              <1> codec_config:
   903                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
   904                              <1> 	; 10/06/2017
   905                              <1> 	; 29/05/2017
   906                              <1> 	; 24/04/2017
   907                              <1> 	; 21/04/2017
   908                              <1> 	; 16/04/2017 (TRDOS 386 Kernel) 
   909                              <1> 	; 15/11/2016 ('codec.asm', 'player.com')
   910                              <1> 	; 14/11/2016
   911                              <1> 	; 12/11/2016 - Erdogan Tan
   912                              <1> 	;	     (Ref: KolibriOS, 'setup_codec', codec.inc)
   913                              <1> 
   914 00013E53 B802020000          <1> 	mov     eax, 0202h
   915 00013E58 66A3[E6890100]      <1> 	mov	[audio_master_volume], ax
   916 00013E5E 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
   917                              <1> 	;mov	edx, CODEC_MASTER_VOL_REG ; 02h ; Line Out
   918                              <1> 	; 06/08/2022
   919 00013E62 29D2                <1> 	sub	edx, edx
   920 00013E64 B202                <1> 	mov	dl, CODEC_MASTER_VOL_REG ; 02h ; Line Out
   921 00013E66 E8AEFFFFFF          <1> 	call	codec_write
   922                              <1> 	;jc	short cconfig_error
   923                              <1> 
   924                              <1>  	;mov    eax, 0202h
   925 00013E6B 66B80202            <1> 	mov     ax, 0202h
   926                              <1> 	;mov	edx, CODEC_PCM_OUT_REG ; 18h ; Wave Output (Stereo)
   927                              <1> 	; 06/08/2022
   928 00013E6F 29D2                <1> 	sub	edx, edx
   929 00013E71 B218                <1> 	mov	dl, CODEC_PCM_OUT_REG ; 18h ; Wave Output (Stereo)
   930 00013E73 E8A1FFFFFF          <1> 	call	codec_write
   931                              <1> 	;jc	short cconfig_error
   932                              <1>       
   933                              <1>  	;mov    eax, 0202h
   934 00013E78 66B80202            <1> 	mov	ax, 0202h
   935                              <1> 	;mov	edx, CODEC_AUX_VOL ; 04h ; CODEC_HP_VOL_REG ; HeadPhone
   936                              <1> 	; 06/08/2022
   937 00013E7C 29D2                <1> 	sub	edx, edx
   938 00013E7E B204                <1> 	mov	dl, CODEC_AUX_VOL ; 04h ; CODEC_HP_VOL_REG ; HeadPhone
   939 00013E80 E894FFFFFF          <1> 	call	codec_write
   940                              <1> 	;jc	short cconfig_error
   941                              <1> 
   942                              <1>  	;mov    eax, 08h
   943                              <1>         ;mov    ax, 08h
   944 00013E85 66B80880            <1> 	mov	ax, 8008h ; Mute
   945                              <1> 	;mov	edx, 0Ch  ; AC97_PHONE_VOL ; TAD Input (Mono)
   946                              <1> 	; 06/08/2022
   947 00013E89 29D2                <1> 	sub	edx, edx
   948 00013E8B B20C                <1> 	mov	dl, 0Ch	; AC97_PHONE_VOL ; TAD Input (Mono)
   949 00013E8D E887FFFFFF          <1> 	call	codec_write
   950                              <1> 	;jc	short cconfig_error
   951                              <1> 
   952                              <1>  	;mov    eax, 0808h
   953 00013E92 66B80808            <1> 	mov	ax, 0808h
   954                              <1> 	;mov	edx, CODEC_LINE_IN_VOL_REG ; 10h ; Line Input (Stereo)	
   955                              <1> 	; 06/08/2022
   956 00013E96 29D2                <1> 	sub	edx, edx
   957 00013E98 B210                <1> 	mov	dl, CODEC_LINE_IN_VOL_REG ; 10h ; Line Input (Stereo)	
   958 00013E9A E87AFFFFFF          <1> 	call	codec_write
   959                              <1> 	;jc	short cconfig_error
   960                              <1> 
   961                              <1>  	;mov    eax, 0808h
   962 00013E9F 66B80808            <1> 	mov	ax, 0808h
   963                              <1> 	;mov	edx, CODEC_CD_VOL_REG ; 12h ; CR Input (Stereo)
   964                              <1> 	; 06/08/2022
   965 00013EA3 B212                <1> 	mov	dl, CODEC_CD_VOL_REG ; 12h ; CR Input (Stereo)
   966 00013EA5 E86FFFFFFF          <1> 	call	codec_write
   967                              <1> 	;jc	short cconfig_error
   968                              <1> 
   969                              <1>  	;mov    eax, 0808h
   970 00013EAA 66B80808            <1> 	mov     ax, 0808h
   971                              <1>         ;mov	edx, CODEC_AUX_VOL_REG ; 16h ; Aux Input (Stereo)
   972                              <1> 	; 06/08/2022
   973 00013EAE 29D2                <1> 	sub	edx, edx
   974 00013EB0 B216                <1> 	mov	dl, CODEC_AUX_VOL_REG ; 16h ; Aux Input (Stereo)
   975                              <1> 	;call	codec_write
   976                              <1> 	;;jc	short cconfig_error
   977 00013EB2 E962FFFFFF          <1> 	jmp	codec_write ; 10/06/2017
   978                              <1> 
   979                              <1> ;	; Extended Audio Status (2Ah)
   980                              <1> ;	mov	eax, CODEC_EXT_AUDIO_CTRL_REG ; 2Ah 
   981                              <1> ;	call	codec_read
   982                              <1> ;	and     eax, 0FFFFh - 2		; clear DRA (BIT1)
   983                              <1> ;	;or     eax, 1			; set VRA (BIT0)
   984                              <1> ;	or	eax, 5  	; VRA (BIT0) & S/PDIF (BIT2) ; 14/11/2016
   985                              <1> ;	mov	edx, CODEC_EXT_AUDIO_CTRL_REG
   986                              <1> ;	call	codec_write
   987                              <1> ;	;jc	short cconfig_error
   988                              <1> ;
   989                              <1> ;set_sample_rate:
   990                              <1> ;	;movzx	eax, word [audio_freq]
   991                              <1> ;	mov	ax, [audio_freq]
   992                              <1> ;	mov	edx, CODEC_PCM_FRONT_DACRATE_REG ; 2Ch ; PCM Front DAC Rate
   993                              <1> ;	;call	codec_write
   994                              <1> ;	;retn
   995                              <1> ;	jmp	codec_write
   996                              <1> 	
   997                              <1> ;cconfig_error:
   998                              <1> ;	retn
   999                              <1> 
  1000                              <1> vt8233_int_handler:
  1001                              <1> 	; 27/07/2020
  1002                              <1> 	; 22/07/2020
  1003                              <1> 	; Interrupt Handler for VIA VT8237R Audio Controller
  1004                              <1> 	; Note: called by 'dev_IRQ_service'
  1005                              <1> 	; 14/10/2017 
  1006                              <1> 	; 09/10/2017, 10/10/2017, 12/10/2017
  1007                              <1> 	; 13/06/2017
  1008                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
  1009                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('player.asm') 
  1010                              <1> 
  1011                              <1> 	;push	eax ; * must be saved !
  1012                              <1> 	;push	edx
  1013                              <1> 	;push	ecx
  1014                              <1> 	;push	ebx ; * must be saved !
  1015                              <1> 	;push	esi
  1016                              <1> 	;push	edi
  1017                              <1> 
  1018                              <1> 	;cmp	byte [audio_busy], 1
  1019                              <1> 	;jnb	short _ih0 ; 09/10/2017
  1020                              <1> 
  1021                              <1> 	;mov	byte [audio_flag_eol], 0
  1022                              <1> 
  1023 00013EB7 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
  1024 00013EBB E81BFFFFFF          <1>         call    ctrl_io_r8
  1025                              <1> 
  1026 00013EC0 A880                <1> 	test    al, VIA_REG_STAT_ACTIVE
  1027 00013EC2 7417                <1>         jz      short _ih0 ; 09/10/2017
  1028                              <1> 
  1029 00013EC4 2407                <1>         and     al, VIA_REG_STAT_EOL + VIA_REG_STAT_FLAG + VIA_REG_STAT_STOPPED
  1030 00013EC6 A2[E5890100]        <1> 	mov	[audio_flag_eol], al
  1031 00013ECB 740E                <1>         jz	short _ih0 ; 09/10/2017
  1032                              <1> 
  1033                              <1> 	; 09/10/2017
  1034                              <1> 	;mov	byte [audio_busy], 1
  1035                              <1> 
  1036 00013ECD 803D[E4890100]01    <1> 	cmp	byte [audio_play_cmd], 1
  1037 00013ED4 7315                <1> 	jnb	short _ih1 ; 10/10/2017
  1038                              <1> 
  1039 00013ED6 E84A000000          <1> 	call	channel_reset
  1040                              <1> _ih0:
  1041                              <1> 	; 09/10/2017
  1042 00013EDB A0[E5890100]        <1>         mov     al, [audio_flag_eol]   ;; ack ;;
  1043 00013EE0 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
  1044 00013EE4 E8E9FEFFFF          <1>         call    ctrl_io_w8
  1045 00013EE9 EB39                <1> 	jmp	short _ih4
  1046                              <1> _ih1:
  1047                              <1> vt8233_tuneLoop:
  1048 00013EEB A0[E5890100]        <1>         mov     al, [audio_flag_eol]   ;; ack ;;
  1049 00013EF0 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
  1050 00013EF4 E8D9FEFFFF          <1>         call    ctrl_io_w8
  1051                              <1> 
  1052                              <1> 	; 22/07/2020
  1053                              <1> 	;; 12/10/2017
  1054                              <1> 	;mov	byte [audio_flag], 0 ; Reset	
  1055                              <1> 
  1056                              <1> 	; 10/10/2017
  1057                              <1> 	; 09/10/2017
  1058                              <1> 	;test	byte [audio_flag_eol], VIA_REG_STAT_FLAG
  1059                              <1> 	;jz	short _ih2 ; EOL
  1060                              <1> 
  1061                              <1> 	; 22/07/2020
  1062                              <1> 	; 14/10/2017
  1063                              <1> 	;test	byte [audio_flag_eol], VIA_REG_STAT_EOL
  1064                              <1> 	;jnz	short _ih2 ; EOL
  1065                              <1> 	;		   ; (Half Buffer 2 has been completed 
  1066                              <1> 	;		   ; and Half Buffer 1 will be played.)
  1067                              <1> 	
  1068                              <1> 	; FLAG  
  1069                              <1> 	; (Half Buffer 1 has been completed 
  1070                              <1> 	;  and Half Buffer 2 will be played.)
  1071                              <1> 
  1072                              <1> 	; 14/10/2017
  1073                              <1> 	;; (Continue to play.)
  1074                              <1> 	;mov	al, VIA_REG_CTRL_INT
  1075                              <1>        	;or	al, VIA_REG_CTRL_START
  1076                              <1>        	;mov	dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  1077                              <1>         ;call	ctrl_io_w8
  1078                              <1> 	; 12/10/2017
  1079                              <1> 	;mov	byte [audio_flag], 1 
  1080                              <1> 
  1081                              <1> 	; 22/07/2020
  1082                              <1> 	;inc	byte [audio_flag] ; = 1
  1083                              <1> _ih2: 
  1084                              <1> 	; 10/10/2017
  1085 00013EF9 8B3D[D0890100]      <1> 	mov	edi, [audio_dma_buff]
  1086 00013EFF 8B0D[D4890100]      <1> 	mov	ecx, [audio_dmabuff_size]
  1087 00013F05 D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
  1088                              <1> 	
  1089                              <1> 	; 22/07/2020
  1090                              <1> 	; 12/10/2017
  1091                              <1> 	;cmp	byte [audio_flag], 0
  1092                              <1> 	;ja	short _ih3 ; Playing Half Buffer 2 (Current: FLAG)
  1093                              <1> 	
  1094                              <1> 	; 27/07/2020
  1095                              <1> 	; 22/07/2020
  1096 00013F07 F605[D8890100]01    <1> 	test	byte [audio_flag], 1  ; Current flag value
  1097 00013F0E 7402                <1> 	jz	short _ih3 ; Half Buffer 1 must be filled
  1098                              <1> 
  1099                              <1> 	; Half Buffer 2 must be filled
  1100 00013F10 01CF                <1> 	add	edi, ecx
  1101                              <1> _ih3:
  1102                              <1> 	; Update half buffer 2 while playing half buffer 1
  1103                              <1> 	; Update half buffer 1 while playing half buffer 2
  1104                              <1> 
  1105 00013F12 8B35[C8890100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
  1106 00013F18 C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
  1107 00013F1B F3A5                <1> 	rep	movsd
  1108                              <1> 
  1109                              <1> 	; switch flag value ;
  1110 00013F1D 8035[D8890100]01    <1> 	xor	byte [audio_flag], 1
  1111                              <1> 	; 12/10/2017
  1112                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2
  1113                              <1> 			   ; Next buffer (to update) is dma half buff 1
  1114                              <1> 	; 	       = 1 : Playing dma half buffer 1
  1115                              <1> 			   ; Next buffer (to update) is dma half buff 2
  1116                              <1> _ih4:	
  1117                              <1> 	; 28/05/2017
  1118                              <1> 	;mov	byte [audio_busy], 0 ; 09/10/2017
  1119                              <1> 	;
  1120                              <1> 	;pop	edi
  1121                              <1> 	;pop	esi
  1122                              <1> 	;pop	ebx ; * must be restored !
  1123                              <1> 	;pop	ecx
  1124                              <1> 	;pop	edx
  1125                              <1> 	;pop	eax ; * must be restored !
  1126                              <1> 
  1127 00013F24 C3                  <1> 	retn
  1128                              <1> 
  1129                              <1> channel_reset:
  1130                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
  1131                              <1> 	; 24/06/2017
  1132                              <1> 	; 29/05/2017
  1133                              <1> 	; 23/03/2017
  1134                              <1> 	; 14/11/2016 - Erdogan Tan
  1135                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
  1136                              <1>         ;mov	edx, VIA_REG_OFFSET_CONTROL
  1137                              <1> 	; 06/08/2022
  1138 00013F25 29D2                <1> 	sub	edx, edx
  1139 00013F27 B201                <1> 	mov	dl, VIA_REG_OFFSET_CONTROL 
  1140                              <1> 	;mov	eax, VIA_REG_CTRL_PAUSE + VIA_REG_CTRL_TERMINATE + VIA_REG_CTRL_RESET
  1141 00013F29 B848000000          <1>         mov	eax, VIA_REG_CTRL_PAUSE + VIA_REG_CTRL_TERMINATE ; 24/06/2017       
  1142 00013F2E E89FFEFFFF          <1> 	call    ctrl_io_w8
  1143                              <1> 
  1144                              <1>         ;mov	edx, VIA_REG_OFFSET_CONTROL
  1145                              <1>         ;call   ctrl_io_r8
  1146                              <1> 
  1147                              <1> 	; wait for 50 ms
  1148                              <1> 	;mov	ecx, 160 ; (200*0.25 ms) ; 29/05/2017	
  1149                              <1> 	; 06/08/2022
  1150 00013F33 31C9                <1> 	xor	ecx, ecx
  1151 00013F35 B1A0                <1> 	mov	cl, 160
  1152                              <1> _ch_rst_wait:
  1153 00013F37 E85EFEFFFF          <1> 	call	delay1_4ms
  1154 00013F3C 49                  <1> 	dec	ecx
  1155 00013F3D 75F8                <1> 	jnz	short _ch_rst_wait     
  1156                              <1> 
  1157                              <1>         ; disable interrupts
  1158                              <1> 	;mov	edx, VIA_REG_OFFSET_CONTROL
  1159                              <1>         ; 06/08/2022
  1160 00013F3F 29D2                <1> 	sub	edx, edx
  1161 00013F41 B201                <1> 	mov	dl, VIA_REG_OFFSET_CONTROL
  1162 00013F43 31C0                <1>  	xor     eax, eax
  1163 00013F45 E888FEFFFF          <1>         call    ctrl_io_w8
  1164                              <1> 
  1165                              <1>         ; clear interrupts
  1166                              <1>         ;mov	edx, VIA_REG_OFFSET_STATUS
  1167                              <1> 	; 06/08/2022
  1168 00013F4A 29D2                <1> 	sub	edx, edx
  1169                              <1> 	;mov	dl, VIA_REG_OFFSET_STATUS ; 0
  1170                              <1> 	; edx = 0
  1171                              <1> 	;mov	eax, 3
  1172                              <1>         ; 06/08/2022
  1173 00013F4C 29C0                <1> 	sub	eax, eax
  1174 00013F4E B003                <1> 	mov	al, 3
  1175                              <1> 	; eax = 3
  1176 00013F50 E87DFEFFFF          <1> 	call	ctrl_io_w8
  1177                              <1> 
  1178                              <1> 	;mov	edx, VIA_REG_OFFSET_CURR_PTR
  1179                              <1> 	;xor	eax, eax
  1180                              <1> 	;call	ctrl_io_w32
  1181                              <1> 
  1182 00013F55 C3                  <1>         retn	
  1183                              <1> 
  1184                              <1> vt8233_stop: ; 22/04/2017
  1185 00013F56 C605[E4890100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  1186                              <1> _tlp2:
  1187                              <1> 	; 24/06/2017
  1188                              <1>         ; finished with song, stop everything
  1189                              <1> 	;mov	al, VIA_REG_CTRL_INT
  1190                              <1>         ;or	al, VIA_REG_CTRL_TERMINATE
  1191                              <1> 	;mov	dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  1192                              <1>         ;call	ctrl_io_w8
  1193                              <1> 
  1194                              <1>         ;call	channel_reset
  1195                              <1> 	;retn
  1196                              <1> 
  1197 00013F5D EBC6                <1> 	jmp	short channel_reset
  1198                              <1> 
  1199                              <1> set_vt8233_bdl: ; Set VT8237R Buffer Descriptor List
  1200                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  1201                              <1> 	; 22/07/2020 - TRDOS 386 v2.0.2
  1202                              <1> 	; 28/05/2017
  1203                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
  1204                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
  1205                              <1> 	
  1206                              <1> 	; eax = dma buffer address = [audio_DMA_buff]
  1207                              <1> 	; ecx = dma buffer buffer size = [audio_dmabuff_size]
  1208                              <1> 
  1209 00013F5F D1E9                <1> 	shr	ecx, 1 ; dma half buffer size
  1210 00013F61 89CE                <1> 	mov	esi, ecx
  1211                              <1> 
  1212 00013F63 BF[EC890100]        <1>         mov     edi, audio_bdl_buff	; get BDL address
  1213                              <1> 	;mov	ecx, 32 / 2		; make 32 entries in BDL
  1214                              <1> 	; 06/08/2022
  1215 00013F68 29C9                <1> 	sub	ecx, ecx
  1216 00013F6A B110                <1> 	mov	cl, 16
  1217                              <1> 
  1218 00013F6C EB05                <1> 	jmp	short s_vt8233_bdl1 
  1219                              <1> 
  1220                              <1> s_vt8233_bdl0:
  1221                              <1> 	; set buffer descriptor 0 to start of data file in memory
  1222                              <1> 
  1223 00013F6E A1[D0890100]        <1>  	mov	eax, [audio_dma_buff]	; Physical address of DMA buffer
  1224                              <1>  
  1225                              <1> s_vt8233_bdl1:
  1226 00013F73 AB                  <1> 	stosd				; store dmabuffer1 address
  1227                              <1> 
  1228 00013F74 89C2                <1> 	mov	edx, eax
  1229                              <1> 
  1230                              <1> ; VIA VT8235.PDF: (Page 110) (Erdogan Tan, 29/11/2016)
  1231                              <1> 	;
  1232                              <1> 	; 	Audio SGD Table Format
  1233                              <1> 	;	-------------------------------
  1234                              <1> 	;	63   62    61-56    55-32  31-0
  1235                              <1> 	;	--   --   --------  -----  ----
  1236                              <1> 	;	EOL FLAG -reserved- Base   Base
  1237                              <1> 	;		    	    Count  Address
  1238                              <1> 	;		            [23:0] [31:0]
  1239                              <1> 	;	EOL: End Of Link. 
  1240                              <1> 	;	     1 indicates this block is the last of the link.
  1241                              <1> 	;	     If the channel Interrupt on EOL bit is set, then
  1242                              <1> 	;	     an interrupt is generated at the end of the transfer.
  1243                              <1> 	;
  1244                              <1> 	;	FLAG: Block Flag. If set, transfer pauses at the end of this
  1245                              <1> 	;	      block. If the channel Interrupt on FLAG bit is set,
  1246                              <1> 	;	      then an interrupt is generated at the end of this block.
  1247                              <1> 
  1248 00013F76 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  1249 00013F78 01C2                <1> 	add	edx, eax
  1250 00013F7A 0D00000040          <1> 	or	eax, FLAG
  1251                              <1> 	;or	eax, EOL
  1252 00013F7F AB                  <1> 	stosd
  1253                              <1> 
  1254                              <1> ; 2nd buffer:
  1255                              <1> 
  1256 00013F80 89D0                <1>         mov	eax, edx ; Physical address of the 2nd half of DMA buffer	
  1257 00013F82 AB                  <1> 	stosd		 ; store dmabuffer2 address
  1258                              <1> 
  1259                              <1> ; set length to [audio_dmabuff_size]/2
  1260                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples
  1261                              <1> ; 
  1262 00013F83 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  1263                              <1> 	; 22/07/2020
  1264                              <1> 	;or	eax, EOL
  1265 00013F85 0D00000040          <1> 	or	eax, FLAG
  1266 00013F8A AB                  <1> 	stosd
  1267                              <1> 
  1268 00013F8B E2E1                <1> 	loop    s_vt8233_bdl0
  1269                              <1> 
  1270                              <1> 	; 22/07/2020
  1271 00013F8D 814FFC00000080      <1> 	or	dword [edi-4], EOL
  1272                              <1> 	
  1273 00013F94 C3                  <1> 	retn
  1274                              <1> 
  1275                              <1> vt8233_start_play:
  1276                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
  1277                              <1> 	; 01/09/2020 
  1278                              <1> 	; 22/07/2020 
  1279                              <1> 	; start to play audio data via VT8233 audio controller
  1280                              <1> 	; 13/06/2017
  1281                              <1> 	; 10/06/2017
  1282                              <1> 	; 24/04/2017 
  1283                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
  1284                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
  1285                              <1> 	; write buffer descriptor list address
  1286                              <1> 
  1287                              <1> 	; Extended Audio Status (2Ah)
  1288 00013F95 B82A000000          <1> 	mov	eax, CODEC_EXT_AUDIO_CTRL_REG ; 2Ah 
  1289 00013F9A E857FEFFFF          <1> 	call	codec_read
  1290 00013F9F 25FDFF0000          <1> 	and     eax, 0FFFFh - 2		; clear DRA (BIT1)
  1291                              <1> 	;or     eax, 1			; set VRA (BIT0)
  1292                              <1> 	;or	eax, 5  	; VRA (BIT0) & S/PDIF (BIT2) ; 14/11/2016
  1293 00013FA4 0C05                <1> 	or	al, 5
  1294                              <1> 	; 01/09/2020	
  1295                              <1> 	;or	eax, 3805h ; AD1980 (PRK, PRJ, PRI = 1 .. only front DAC)
  1296                              <1> 	; 01/09/2020
  1297                              <1> 	;mov	edx, CODEC_EXT_AUDIO_CTRL_REG
  1298                              <1> 	;cmp	word [audio_freq], 0BB80h ; 48 kHz
  1299                              <1> 	;jne	short set_extd_audio_status_1
  1300                              <1> 	;and	al, 0FEh ; disable VRA bit (set sample rate to 48000 Hz)
  1301                              <1> 	;jmp	short set_extd_audio_status_2
  1302                              <1> ;set_extd_audio_status_1:
  1303 00013FA6 BA2A000000          <1> 	mov	edx, CODEC_EXT_AUDIO_CTRL_REG
  1304 00013FAB E869FEFFFF          <1> 	call	codec_write
  1305                              <1> 	;jc	short cconfig_error
  1306                              <1> 
  1307                              <1> set_sample_rate:
  1308                              <1> 	;movzx	eax, word [audio_freq]
  1309 00013FB0 66A1[E2890100]      <1> 	mov	ax, [audio_freq]
  1310 00013FB6 BA2C000000          <1> 	mov	edx, CODEC_PCM_FRONT_DACRATE_REG ; 2Ch ; PCM Front DAC Rate
  1311                              <1> ;set_extd_audio_status_2:
  1312 00013FBB E859FEFFFF          <1> 	call	codec_write
  1313                              <1> 
  1314                              <1> 	; 01/09/2020
  1315                              <1> 	; set AD1980 MCB register (Index 76h) to 0C00h
  1316                              <1> 	; (CLDIS, HPSEL)
  1317                              <1> 	;mov	ax, 0C00h
  1318                              <1> 	;mov	edx, CODEC_MISC_CRTL_BITS_REG ; 76h 
  1319                              <1> 	;			; Miscellaneous Control Bit Register
  1320                              <1> 	;call	codec_write
  1321                              <1> 	;
  1322                              <1> 
  1323 00013FC0 B8[EC890100]        <1>         mov	eax, audio_bdl_buff
  1324                              <1>   
  1325                              <1> 	; 12/11/2016 - Erdogan Tan 
  1326                              <1> 	; (Ref: KolibriOS, vt823x.asm, 'create_primary_buff')
  1327                              <1> 	;mov	edx, VIADEV_PLAYBACK + VIA_REG_OFFSET_TABLE_PTR
  1328                              <1>         ; 06/08/2022
  1329 00013FC5 29D2                <1> 	sub	edx, edx
  1330                              <1> 	;mov	dl, VIADEV_PLAYBACK + VIA_REG_OFFSET_TABLE_PTR
  1331                              <1> 	; edx = 0
  1332 00013FC7 E818FEFFFF          <1> 	call	ctrl_io_w32
  1333                              <1> 
  1334                              <1> 	;call	codec_check_ready
  1335                              <1> 
  1336 00013FCC 66BA0200            <1>   	mov	dx, VIADEV_PLAYBACK + VIA_REG_OFS_PLAYBACK_VOLUME_L
  1337                              <1>         ;mov	eax, 2	; 31
  1338 00013FD0 B01F                <1> 	mov	al, 31
  1339 00013FD2 2A05[E6890100]      <1>         sub	al, [audio_master_volume_l]
  1340 00013FD8 E8F5FDFFFF          <1> 	call	ctrl_io_w8
  1341                              <1> 
  1342                              <1> 	;call	codec_check_ready
  1343                              <1> 
  1344 00013FDD 66BA0300            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFS_PLAYBACK_VOLUME_R
  1345                              <1>         ;mov	ax, 2	; 31
  1346 00013FE1 B01F                <1> 	mov	al, 31
  1347 00013FE3 2A05[E7890100]      <1>         sub	al, [audio_master_volume_r]
  1348 00013FE9 E8E4FDFFFF          <1> 	call    ctrl_io_w8
  1349                              <1> 
  1350                              <1> 	;call	codec_check_ready
  1351                              <1> ;
  1352                              <1> ;
  1353                              <1> ; All set. Let's play some music.
  1354                              <1> ;
  1355                              <1> ;
  1356                              <1>        	;mov    dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STOP_IDX
  1357                              <1>         ;mov    ax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000
  1358                              <1>         ;call   ctrl_io_w32
  1359                              <1> 
  1360                              <1> 	;call	codec_check_ready
  1361                              <1> 
  1362                              <1> 	; 08/12/2016
  1363                              <1> 	; 07/10/2016
  1364                              <1>         ;;mov    al, 1
  1365                              <1>         ;mov	al, 31
  1366                              <1> 	; 22/07/2020
  1367 00013FEE B0FF                <1> 	mov	al, 0FFh
  1368 00013FF0 E813000000          <1> 	call    set_VT8233_LastValidIndex
  1369                              <1> 
  1370 00013FF5 C605[E4890100]01    <1> 	mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
  1371                              <1> 
  1372                              <1> 	; 22/07/2020
  1373                              <1> 	;mov	byte [audio_flag], 0  ; clear half buffer flag
  1374                              <1> 
  1375                              <1> vt8233_play: ; continue to play
  1376                              <1> 	; 22/04/2017
  1377                              <1> 	;mov	al, VIA_REG_CTRL_INT
  1378                              <1>        	;or	al, VIA_REG_CTRL_START
  1379                              <1>         ;;mov	al, VIA_REG_CTRL_AUTOSTART + VIA_REG_CTRL_START
  1380                              <1> 	; 22/07/2020	
  1381 00013FFC B0A1                <1> 	mov	al, VIA_REG_CTRL_AUTOSTART + VIA_REG_CTRL_START + VIA_REG_CTRL_INT_FLAG
  1382                              <1> 
  1383 00013FFE 66BA0100            <1> 	mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  1384 00014002 E8CBFDFFFF          <1>         call    ctrl_io_w8
  1385                              <1> 	;call	codec_check_ready
  1386                              <1> 	;retn
  1387                              <1> 	;jmp	codec_check_ready
  1388 00014007 C3                  <1> 	retn
  1389                              <1> 
  1390                              <1> ;input AL = index # to stop on
  1391                              <1> set_VT8233_LastValidIndex:
  1392                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5
  1393                              <1> 	; 23/07/2020
  1394                              <1> 	; 10/06/2017
  1395                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
  1396                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
  1397                              <1> 	; 19/11/2016
  1398                              <1> 	; 14/11/2016 - Erdogan Tan (Ref: VIA VT8235.PDF, Page 110)
  1399                              <1> 	; 12/11/2016 - Erdogan Tan
  1400                              <1> 	; (Ref: KolibriOS, vt823x.asm, 'create_primary_buff')
  1401                              <1> 	;push	edx
  1402                              <1> 	;push	ax
  1403 00014008 50                  <1> 	push	eax ; 23/07/2020
  1404                              <1> 	;push	ecx
  1405 00014009 0FB705[E2890100]    <1> 	movzx	eax, word [audio_freq] ; Hertz
  1406 00014010 BA00001000          <1> 	mov	edx, 100000h ; 2^20 = 1048576
  1407 00014015 F7E2                <1> 	mul	edx
  1408 00014017 B980BB0000          <1> 	mov	ecx, 48000	
  1409 0001401C F7F1                <1> 	div	ecx
  1410                              <1> 	;and	eax, 0FFFFFh
  1411                              <1> 	;pop	ecx
  1412                              <1> 	;pop	dx 
  1413 0001401E 5A                  <1> 	pop	edx ; 23/07/2020
  1414 0001401F C1E218              <1> 	shl	edx, 24  ; STOP Index Setting: Bit 24 to 31
  1415 00014022 09D0                <1> 	or	eax, edx
  1416                              <1> 	; 19/11/2016
  1417 00014024 803D[E0890100]10    <1> 	cmp	byte [audio_bps], 16
  1418 0001402B 7505                <1> 	jne	short sLVI_1
  1419 0001402D 0D00002000          <1> 	or	eax, VIA8233_REG_TYPE_16BIT
  1420                              <1> sLVI_1:
  1421 00014032 803D[E1890100]02    <1> 	cmp	byte [audio_stmo], 2
  1422 00014039 7505                <1> 	jne	short sLVI_2
  1423 0001403B 0D00001000          <1> 	or	eax, VIA8233_REG_TYPE_STEREO
  1424                              <1> sLVI_2:
  1425                              <1> 	;mov	edx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STOP_IDX
  1426                              <1> 	; 06/08/2022
  1427 00014040 29D2                <1> 	sub	edx, edx
  1428 00014042 B208                <1> 	mov	dl, VIADEV_PLAYBACK + VIA_REG_OFFSET_STOP_IDX
  1429 00014044 E89BFDFFFF          <1> 	call    ctrl_io_w32
  1430                              <1> 	;call	codec_check_ready
  1431                              <1> 	;pop	edx
  1432 00014049 C3                  <1> 	retn
  1433                              <1> 
  1434                              <1> vt8233_pause: ; pause
  1435                              <1> 	; 10/06/2017
  1436                              <1> 	; 22/04/2017
  1437                              <1> 	;mov	al, VIA_REG_CTRL_INT
  1438                              <1>         ;or	al, VIA_REG_CTRL_PAUSE
  1439                              <1> 	; 23/07/2020
  1440 0001404A B029                <1> 	mov	al, VIA_REG_CTRL_PAUSE+VIA_REG_CTRL_INT_FLAG+VIA_REG_CTRL_AUTOSTART
  1441                              <1> 	
  1442 0001404C 66BA0100            <1> 	mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  1443 00014050 E87DFDFFFF          <1>         call    ctrl_io_w8
  1444                              <1> 	;call	codec_check_ready
  1445                              <1> 	;retn
  1446                              <1> 	;jmp	codec_check_ready
  1447 00014055 C3                  <1> 	retn
  1448                              <1> 
  1449                              <1> vt8233_reset: 
  1450                              <1> 	; 22/04/2017
  1451                              <1> 	; reset VT8237R (vt8233) Audio Controller
  1452                              <1> 	;cmp	byte [audio_play_cmd], 1
  1453                              <1> 	;jna	short vt8233_rst_0
  1454 00014056 C605[E4890100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  1455                              <1> vt8233_rst_0:
  1456 0001405D E8D0FCFFFF          <1> 	call	reset_codec
  1457 00014062 720A                <1> 	jc	short vt8233_rst_1 ; codec error !
  1458                              <1> 	; eax = 1
  1459 00014064 E84DFDFFFF          <1> 	call	codec_io_w16 ; w32
  1460 00014069 E8B7FEFFFF          <1> 	call	channel_reset
  1461                              <1> vt8233_rst_1:
  1462                              <1> vt8233_vol_1:	; 06/08/2022
  1463 0001406E C3                  <1> 	retn
  1464                              <1> 
  1465                              <1> vt8233_volume:
  1466                              <1> 	; set VT8237R (vt8233) sound volume level
  1467                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  1468                              <1> 	; 24/04/2017
  1469                              <1> 	; 22/04/2017
  1470                              <1> 	; bl = component (0 = master/playback/lineout volume)
  1471                              <1> 	; cl = left channel volume level (0 to 31)
  1472                              <1> 	; ch = right channel volume level (0 to 31)
  1473                              <1> 
  1474 0001406F 08DB                <1> 	or	bl, bl
  1475 00014071 75FB                <1> 	jnz	short vt8233_vol_1 ; temporary !
  1476 00014073 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
  1477 00014077 38C1                <1> 	cmp	cl, al
  1478 00014079 77F3                <1> 	ja	short vt8233_vol_1 ; temporary !
  1479 0001407B 38E5                <1> 	cmp	ch, ah
  1480 0001407D 77EF                <1> 	ja	short vt8233_vol_1 ; temporary !
  1481 0001407F 66890D[E6890100]    <1> 	mov	[audio_master_volume], cx
  1482 00014086 6629C8              <1> 	sub	ax, cx
  1483                              <1> 	;mov	edx, CODEC_MASTER_VOL_REG ; 02h ; Line Out
  1484                              <1> 	; 06/08/2022
  1485 00014089 29D2                <1> 	sub	edx, edx
  1486 0001408B B202                <1> 	mov	dl, CODEC_MASTER_VOL_REG ; 02h ; Line Out
  1487                              <1> 	; 06/08/2022
  1488 0001408D E987FDFFFF          <1> 	jmp	codec_write
  1489                              <1> 	;call	codec_write
  1490                              <1> ;vt8233_vol_1:
  1491                              <1> 	;retn
  1492                              <1> 
  1493                              <1> ; CODE for SOUND BLASTER 16
  1494                              <1> 
  1495                              <1> DetectSB:
  1496                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  1497                              <1> 	; 24/04/2017
  1498                              <1> 	;pushad
  1499                              <1> ScanPort:
  1500                              <1> 	; 06/08/2022
  1501 00014092 66BB1002            <1> 	mov	bx, 0210h	; start scanning ports
  1502                              <1> 				; 210h, 220h, .. 260h
  1503                              <1> 	; 06/08/2022
  1504 00014096 31C9                <1> 	xor	ecx, ecx
  1505 00014098 88FE                <1> 	mov	dh, bh
  1506                              <1> ResetDSP:       
  1507                              <1> 	;mov	dx, bx		; try to reset the DSP.
  1508                              <1> 	;add	dx, 06h
  1509                              <1> 	; 06/08/2022
  1510 0001409A 88DA                <1> 	mov	dl, bl
  1511 0001409C 80C206              <1> 	add	dl, 06h
  1512                              <1> 
  1513 0001409F B001                <1> 	mov	al, 1
  1514 000140A1 EE                  <1> 	out	dx, al
  1515                              <1> 
  1516 000140A2 EC                  <1> 	in	al, dx
  1517 000140A3 EC                  <1> 	in	al, dx
  1518 000140A4 EC                  <1> 	in	al, dx
  1519 000140A5 EC                  <1> 	in	al, dx
  1520                              <1> 
  1521 000140A6 30C0                <1> 	xor     al, al
  1522 000140A8 EE                  <1> 	out	dx, al
  1523                              <1> 
  1524                              <1> 	;add	dx, 08h
  1525                              <1> 	; 06/08/2022
  1526 000140A9 80C208              <1> 	add	dl, 08h
  1527                              <1> 	;mov	cx, 100
  1528 000140AC B164                <1> 	mov	cl, 100
  1529                              <1> WaitID:
  1530 000140AE EC                  <1> 	in	al, dx
  1531 000140AF 08C0                <1> 	or      al, al
  1532 000140B1 7804                <1> 	js      short GetID
  1533 000140B3 E2F9                <1> 	loop    WaitID
  1534 000140B5 EB0D                <1> 	jmp     short NextPort
  1535                              <1> GetID:          
  1536                              <1> 	;sub	dx, 04h
  1537                              <1> 	; 06/08/2022
  1538 000140B7 80EA04              <1> 	sub	dl, 04h
  1539 000140BA EC                  <1> 	in	al, dx
  1540 000140BB 3CAA                <1> 	cmp     al, 0AAh
  1541 000140BD 740F                <1> 	je      short Found
  1542                              <1> 	;add	dx, 04h
  1543                              <1> 	; 06/08/2022
  1544 000140BF 80C204              <1> 	add	dl, 04h
  1545 000140C2 E2EA                <1> 	loop    WaitID
  1546                              <1> NextPort:
  1547                              <1> 	;add	bx, 10h		; if not response,
  1548                              <1> 	; 06/08/2022
  1549 000140C4 80C310              <1> 	add	bl, 10h
  1550                              <1> 	;cmp	bx, 260h	; try the next port.
  1551 000140C7 80FB60              <1> 	cmp	bl, 60h
  1552 000140CA 76CE                <1> 	jbe     short ResetDSP
  1553 000140CC F9                  <1> 	stc
  1554 000140CD C3                  <1> 	retn
  1555                              <1> Found:
  1556 000140CE 66891D[B6890100]    <1> 	mov     [audio_io_base], bx	; SB Port Address Found!
  1557                              <1> ScanIRQ:
  1558                              <1> SetIrqs:
  1559 000140D5 28C0                <1> 	sub 	al, al ; 0
  1560 000140D7 A2[AC890100]        <1> 	mov 	[IRQnum], al ; reset
  1561 000140DC A2[B3890100]        <1> 	mov	[audio_intr], al ; reset
  1562                              <1> 
  1563                              <1> 	; ah > 0 -> set IRQ vector
  1564                              <1> 	; al = IRQ number
  1565                              <1> 	;mov	ax, 103h ; IRQ 3
  1566                              <1> 	;call	set_hardware_int_vector
  1567                              <1> 	;mov	ax, 104h ; IRQ 4
  1568                              <1> 	;call	set_hardware_int_vector
  1569 000140E1 66B80501            <1> 	mov	ax, 105h ; IRQ 5
  1570 000140E5 E8C7E1FFFF          <1> 	call	set_hardware_int_vector
  1571 000140EA 66B80701            <1> 	mov	ax, 107h ; IRQ 7
  1572 000140EE E8BEE1FFFF          <1> 	call	set_hardware_int_vector
  1573                              <1> 
  1574 000140F3 668B15[B6890100]    <1> 	mov     dx, [audio_io_base] ; tells to the SB to
  1575                              <1> 	;add	dx, 0Ch		    ; generate a IRQ!
  1576                              <1> 	; 06/08/2022
  1577 000140FA 80C20C              <1> 	add	dl, 0Ch
  1578                              <1> WaitSb:
  1579 000140FD EC                  <1> 	in	al, dx
  1580 000140FE 08C0                <1> 	or      al, al
  1581 00014100 78FB                <1> 	js      short WaitSb
  1582 00014102 B0F2                <1> 	mov     al, 0F2h
  1583 00014104 EE                  <1> 	out	dx, al
  1584                              <1> 
  1585 00014105 31C9                <1> 	xor     ecx, ecx	; wait until IRQ level
  1586                              <1> WaitIRQ: 
  1587 00014107 A0[AC890100]        <1> 	mov	al, [IRQnum]
  1588 0001410C 3C00                <1> 	cmp     al, 0 ; is changed or timeout.
  1589 0001410E 7706                <1> 	ja	short IrqOk
  1590 00014110 6649                <1> 	dec	cx
  1591 00014112 75F3                <1> 	jnz	short WaitIRQ
  1592 00014114 EB14                <1> 	jmp	short RestoreIrqs
  1593                              <1> IrqOk:
  1594 00014116 A2[B3890100]        <1> 	mov	[audio_intr], al ; set   
  1595 0001411B 668B15[B6890100]    <1> 	mov     dx, [audio_io_base]
  1596                              <1> 	;add	dx, 0Eh
  1597                              <1> 	; 06/08/2022
  1598 00014122 80C20E              <1> 	add	dl, 0Eh
  1599 00014125 EC                  <1> 	in	al, dx	; SB acknowledge.
  1600 00014126 B020                <1> 	mov	al, 20h
  1601 00014128 E620                <1> 	out	20h, al	; Hardware acknowledge.
  1602                              <1> 
  1603                              <1> RestoreIrqs:
  1604                              <1> 	; ah = 0 -> reset IRQ vector
  1605                              <1> 	; al = IRQ number
  1606                              <1> 	;mov	ax, 3 ; IRQ 3
  1607                              <1> 	;call	set_hardware_int_vector
  1608                              <1> 	;mov	ax, 4 ; IRQ 4
  1609                              <1> 	;call	set_hardware_int_vector
  1610 0001412A 66B80500            <1> 	mov	ax, 5 ; IRQ 5
  1611 0001412E E87EE1FFFF          <1> 	call	set_hardware_int_vector
  1612 00014133 66B80700            <1> 	mov	ax, 7 ; IRQ 7
  1613 00014137 E875E1FFFF          <1> 	call	set_hardware_int_vector
  1614                              <1> 
  1615 0001413C 31D2                <1> 	xor	edx, edx
  1616 0001413E 8915[B8890100]      <1> 	mov	[audio_dev_id], edx ; 0
  1617 00014144 8915[BC890100]      <1> 	mov	[audio_vendor], edx ; 0
  1618 0001414A 8915[C0890100]      <1> 	mov	[audio_stats_cmd], edx ; 0
  1619                              <1> 
  1620                              <1> 	;popad
  1621                              <1> 
  1622 00014150 803D[B3890100]01    <1> 	cmp     byte [audio_intr], 1 ; IRQ level was changed?
  1623                              <1> 	
  1624 00014157 C3                  <1> 	retn
  1625                              <1> 
  1626                              <1> %macro	SbOut	1
  1627                              <1> %%Wait:
  1628                              <1> 	in	al, dx
  1629                              <1> 	or	al, al
  1630                              <1> 	js	short %%Wait
  1631                              <1> 	mov	al, %1
  1632                              <1> 	out	dx, al
  1633                              <1> %endmacro
  1634                              <1> 
  1635                              <1> SbInit_play:
  1636                              <1> 	; 06/08/2022 - TRDOS 386 Kernel v2.0.5 
  1637                              <1> 	; 22/10/2017
  1638                              <1> 	; 20/10/2017
  1639                              <1> 	; 06/10/2017
  1640                              <1> 	; 13/07/2017 - 09/08/2017
  1641                              <1> 	; 24/04/2017 - 15/05/2017 - 24/06/2017
  1642                              <1> 	;pushad
  1643                              <1> SetBuffer:
  1644                              <1> 	;mov	byte [DmaFlag], 0
  1645                              <1> 
  1646 00014158 8B1D[D0890100]      <1> 	mov	ebx, [audio_dma_buff] ; physical addr of DMA buff
  1647 0001415E 89DF                <1> 	mov	edi, ebx
  1648 00014160 8B0D[D4890100]      <1> 	mov     ecx, [audio_dmabuff_size]
  1649                              <1> 
  1650 00014166 803D[E0890100]10    <1> 	cmp	byte [audio_bps], 16
  1651 0001416D 7531                <1> 	jne	short sbInit_0 ; set 8 bit DMA buffer
  1652                              <1> 	
  1653                              <1> 	; 09/08/2017
  1654                              <1> 	; convert byte count to word count
  1655 0001416F D1E9                <1> 	shr	ecx, 1
  1656 00014171 49                  <1> 	dec	ecx ; word count - 1
  1657                              <1> 	; convert byte offset to word offset
  1658 00014172 D1EB                <1> 	shr	ebx, 1
  1659                              <1> 
  1660                              <1> 	; 16 bit DMA buffer setting (DMA channel 5)
  1661 00014174 B005                <1> 	mov     al, 05h  ; set mask bit for channel 5  (4+1)
  1662 00014176 E6D4                <1> 	out	0D4h, al
  1663                              <1> 	
  1664 00014178 30C0                <1> 	xor     al, al   ; stops all DMA processes on selected channel
  1665 0001417A E6D8                <1> 	out	0D8h, al ; clear selected channel register
  1666                              <1> 
  1667 0001417C 88D8                <1> 	mov     al, bl	 ; byte 0 of DMA buffer offset in words (physical) 
  1668 0001417E E6C4                <1> 	out	0C4h, al ; DMA channel 5 port number
  1669                              <1> 
  1670 00014180 88F8                <1> 	mov     al, bh   ; byte 1 of DMA buffer offset in words (physical)   
  1671 00014182 E6C4                <1> 	out	0C4h, al
  1672                              <1> 	
  1673                              <1> 	; 09/08/2017
  1674 00014184 C1EB0F              <1> 	shr	ebx, 15	 ; complete 16 bit shift
  1675 00014187 80E3FE              <1> 	and	bl, 0FEh ; clear bit 0 (not necessary, it will be ignored)
  1676                              <1> 
  1677 0001418A 88D8                <1> 	mov     al, bl   ; byte 2 of DMA buffer address (physical) 
  1678 0001418C E68B                <1> 	out	8Bh, al  ; page register port addr for channel 5 ; 13/07/2017
  1679                              <1> 
  1680 0001418E 88C8                <1> 	mov     al, cl   ; low byte of DMA count - 1
  1681 00014190 E6C6                <1> 	out	0C6h, al ; count register port addr for channel 1
  1682                              <1> 
  1683 00014192 88E8                <1> 	mov     al, ch   ; high byte of DMA count - 1
  1684 00014194 E6C6                <1> 	out	0C6h, al
  1685                              <1> 
  1686                              <1> 	; channel 5, read, autoinitialized, single mode
  1687                              <1> 	;mov	al, 49h
  1688 00014196 B059                <1> 	mov	al, 59h  ; 06/10/2017 
  1689 00014198 E6D6                <1> 	out	0D6h, al ; DMA mode register port address
  1690                              <1> 
  1691 0001419A B001                <1> 	mov     al, 01h  ; clear mask bit for channel 1
  1692 0001419C E6D4                <1> 	out	0D4h, al ; DMA mask register port address
  1693                              <1> 
  1694 0001419E EB28                <1> 	jmp	short ClearBuffer
  1695                              <1> 
  1696                              <1> sbInit_0:    
  1697 000141A0 49                  <1> 	dec     ecx	; 09/08/2017
  1698                              <1> 
  1699                              <1> 	; 8 bit DMA buffer setting (DMA channel 1)
  1700 000141A1 B005                <1> 	mov     al, 05h ; set mask bit for channel 1  (4+1)
  1701 000141A3 E60A                <1> 	out	0Ah, al ; DMA mask register
  1702                              <1> 
  1703 000141A5 30C0                <1> 	xor     al, al  ; stops all DMA processes on selected channel
  1704 000141A7 E60C                <1> 	out	0Ch, al ; clear selected channel register
  1705                              <1> 
  1706 000141A9 88D8                <1> 	mov     al, bl	; byte 0 of DMA buffer address (physical)   
  1707 000141AB E602                <1> 	out	02h, al ; DMA channel 1 port number
  1708                              <1> 
  1709 000141AD 88F8                <1> 	mov     al, bh  ; byte 1 of DMA buffer address (physical)   
  1710 000141AF E602                <1> 	out	02h, al
  1711                              <1> 
  1712 000141B1 C1EB10              <1> 	shr	ebx, 16
  1713                              <1> 
  1714 000141B4 88D8                <1> 	mov     al, bl  ; byte 2 of DMA buffer address (physical)   
  1715 000141B6 E683                <1> 	out	83h, al ; page register port addr for channel 1
  1716                              <1> 
  1717 000141B8 88C8                <1> 	mov     al, cl  ; low byte of DMA count - 1
  1718 000141BA E603                <1> 	out	03h, al ; count register port addr for channel 1
  1719                              <1> 
  1720 000141BC 88E8                <1> 	mov     al, ch  ; high byte of DMA count - 1
  1721 000141BE E603                <1> 	out	03h, al
  1722                              <1> 
  1723                              <1> 	; channel 1, read, autoinitialized, single mode
  1724                              <1> 	;mov	al, 49h
  1725 000141C0 B059                <1> 	mov	al, 59h ; 06/10/2017 
  1726 000141C2 E60B                <1> 	out	0Bh, al ; DMA mode register port address
  1727                              <1> 
  1728 000141C4 B001                <1> 	mov     al, 01h ; clear mask bit for channel 1
  1729 000141C6 E60A                <1> 	out	0Ah, al ; DMA mask register port address
  1730                              <1> 
  1731                              <1> ClearBuffer:
  1732                              <1> 	;;mov	edi, [audio_dma_buff]
  1733                              <1> 	;;mov	ecx, [audio_dmabuff_size]
  1734                              <1> 	;inc	ecx
  1735                              <1> 	;mov	al, 80h
  1736                              <1> 	;;cld
  1737                              <1> 	;rep	stosb
  1738                              <1> SetIrq:
  1739                              <1> 	;mov	ebx, SbIrqhandler
  1740                              <1> 	;mov	al, [audio_intr] ; IRQ number	
  1741                              <1> 	;call	set_dev_IRQ_service
  1742                              <1> 	;; SETUP (audio) INTERRUPT CALLBACK SERVICE
  1743                              <1> 	;mov	bl, [audio_intr] ; IRQ number
  1744                              <1> 	;mov	bh, [audio_cb_mode]
  1745                              <1> 	;inc	bh  ; 1 = Signal Response Byte method (fixed value)
  1746                              <1> 	;	    ; 2 = Callback service method
  1747                              <1> 	;	    ; 3 = Auto Increment S.R.B. method 	
  1748                              <1> 	;mov	cl, [audio_srb]
  1749                              <1> 	;mov	edx, [audio_cb_addr]
  1750                              <1> 	;mov	al, [audio_user]
  1751                              <1>  	;call	set_irq_callback_service
  1752                              <1> ResetDsp:
  1753 000141C8 668B15[B6890100]    <1> 	mov     dx, [audio_io_base]
  1754                              <1> 	;add	dx, 06h
  1755                              <1> 	; 06/08/2022
  1756 000141CF 80C206              <1> 	add	dl, 06h
  1757 000141D2 B001                <1> 	mov     al, 1
  1758 000141D4 EE                  <1> 	out	dx, al
  1759                              <1> 
  1760 000141D5 EC                  <1> 	in	al, dx
  1761 000141D6 EC                  <1> 	in	al, dx
  1762 000141D7 EC                  <1> 	in	al, dx
  1763 000141D8 EC                  <1> 	in	al, dx
  1764                              <1> 
  1765 000141D9 30C0                <1> 	xor     al, al
  1766 000141DB EE                  <1> 	out	dx, al
  1767                              <1> 
  1768                              <1> 	;mov	cx, 100
  1769                              <1> 	; 06/08/2022
  1770 000141DC 29C9                <1> 	sub	ecx, ecx
  1771 000141DE B164                <1> 	mov	cl, 100
  1772 000141E0 28E4                <1> 	sub	ah, ah ; 0
  1773                              <1> WaitId:         
  1774 000141E2 668B15[B6890100]    <1> 	mov     dx, [audio_io_base]
  1775                              <1> 	;add	dx, 0Eh
  1776                              <1> 	; 06/08/2022
  1777 000141E9 80C20E              <1> 	add	dl, 0Eh
  1778 000141EC EC                  <1> 	in	al, dx
  1779 000141ED 08C0                <1> 	or      al, al
  1780 000141EF 7807                <1> 	js      short sb_GetId
  1781 000141F1 E2EF                <1> 	loop    WaitId
  1782 000141F3 E9B1000000          <1> 	jmp     sb_Exit
  1783                              <1> sb_GetId:
  1784 000141F8 668B15[B6890100]    <1> 	mov     dx, [audio_io_base]
  1785                              <1> 	;add	dx, 0Ah
  1786                              <1> 	; 06/08/2022
  1787 000141FF 80C20A              <1> 	add	dl, 0Ah
  1788 00014202 EC                  <1> 	in	al, dx
  1789 00014203 3CAA                <1> 	cmp     al, 0AAh
  1790 00014205 7407                <1> 	je      short SbOk
  1791 00014207 E2D9                <1> 	loop    WaitId
  1792 00014209 E99B000000          <1> 	jmp	sb_Exit
  1793                              <1> SbOk:
  1794 0001420E 668B15[B6890100]    <1> 	mov     dx, [audio_io_base]
  1795                              <1> 	;add	dx, 0Ch
  1796                              <1> 	; 06/08/2022
  1797 00014215 80C20C              <1> 	add	dl, 0Ch
  1798                              <1> 	SbOut   0D1h ; Turn on speaker
  1627                              <2> %%Wait:
  1628 00014218 EC                  <2>  in al, dx
  1629 00014219 08C0                <2>  or al, al
  1630 0001421B 78FB                <2>  js short %%Wait
  1631 0001421D B0D1                <2>  mov al, %1
  1632 0001421F EE                  <2>  out dx, al
  1799                              <1> 	SbOut   41h ; 8h bit or 16 bit transfer
  1627                              <2> %%Wait:
  1628 00014220 EC                  <2>  in al, dx
  1629 00014221 08C0                <2>  or al, al
  1630 00014223 78FB                <2>  js short %%Wait
  1631 00014225 B041                <2>  mov al, %1
  1632 00014227 EE                  <2>  out dx, al
  1800 00014228 668B1D[E2890100]    <1> 	mov	bx, [audio_freq] ; sampling rate (Hz)
  1801                              <1> 	SbOut	bh ; sampling rate high byte
  1627                              <2> %%Wait:
  1628 0001422F EC                  <2>  in al, dx
  1629 00014230 08C0                <2>  or al, al
  1630 00014232 78FB                <2>  js short %%Wait
  1631 00014234 88F8                <2>  mov al, %1
  1632 00014236 EE                  <2>  out dx, al
  1802                              <1> 	SbOut	bl ; sampling rate low byte
  1627                              <2> %%Wait:
  1628 00014237 EC                  <2>  in al, dx
  1629 00014238 08C0                <2>  or al, al
  1630 0001423A 78FB                <2>  js short %%Wait
  1631 0001423C 88D8                <2>  mov al, %1
  1632 0001423E EE                  <2>  out dx, al
  1803                              <1> 
  1804                              <1> 	; 22/05/2017
  1805 0001423F E8BF000000          <1> 	call	sb16_volume_initial ; 15/05/2017
  1806                              <1> 	; 20/05/2017
  1807                              <1> 	;call	sb16_volume
  1808                              <1> 
  1809                              <1> StartDma: 
  1810                              <1> 	; autoinitialized mode
  1811 00014244 803D[E0890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  1812 0001424B 7411                <1> 	je	short sb_play_1
  1813                              <1> 	; 8 bit samples
  1814 0001424D 66BBC600            <1> 	mov	bx, 0C6h ; 8 bit output (0C6h)
  1815 00014251 803D[E1890100]02    <1> 	cmp	byte [audio_stmo], 2 ; 1 = mono, 2 = stereo
  1816 00014258 7214                <1> 	jb	short sb_play_2
  1817 0001425A B720                <1> 	mov	bh, 20h	; 8 bit stereo (20h)
  1818 0001425C EB10                <1> 	jmp	short sb_play_2
  1819                              <1> sb_play_1:
  1820                              <1> 	; 16 bit samples
  1821 0001425E 66BBB610            <1> 	mov	bx, 10B6h ; 16 bit output (0B6h)
  1822 00014262 803D[E1890100]02    <1> 	cmp	byte [audio_stmo], 2 ; 1 = mono, 2 = stereo
  1823 00014269 7203                <1> 	jb	short sb_play_2
  1824 0001426B 80C720              <1> 	add	bh, 20h	; 16 bit stereo (30h)
  1825                              <1> sb_play_2:     
  1826                              <1> 	; PCM output (8/16 bit mono autoinitialized transfer)
  1827                              <1> 	SbOut   bl ; bCommand
  1627                              <2> %%Wait:
  1628 0001426E EC                  <2>  in al, dx
  1629 0001426F 08C0                <2>  or al, al
  1630 00014271 78FB                <2>  js short %%Wait
  1631 00014273 88D8                <2>  mov al, %1
  1632 00014275 EE                  <2>  out dx, al
  1828                              <1> 	SbOut	bh ; bMode
  1627                              <2> %%Wait:
  1628 00014276 EC                  <2>  in al, dx
  1629 00014277 08C0                <2>  or al, al
  1630 00014279 78FB                <2>  js short %%Wait
  1631 0001427B 88F8                <2>  mov al, %1
  1632 0001427D EE                  <2>  out dx, al
  1829 0001427E 8B1D[D4890100]      <1> 	mov	ebx, [audio_dmabuff_size]  ; 15/05/2017
  1830 00014284 D1EB                <1> 	shr	ebx, 1 ; half buffer size
  1831                              <1> 	; 20/10/2017	
  1832 00014286 803D[E0890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit DMA
  1833 0001428D 7502                <1> 	jne	short sb_play_3
  1834 0001428F D1EB                <1> 	shr	ebx, 1 ; byte count to word count
  1835                              <1> sb_play_3: 
  1836                              <1> 	;dec	bx  ; wBlkSize is one less than the actual size 
  1837                              <1> 	; 06/08/2022
  1838 00014291 4B                  <1> 	dec	ebx
  1839                              <1> 	SbOut   bl
  1627                              <2> %%Wait:
  1628 00014292 EC                  <2>  in al, dx
  1629 00014293 08C0                <2>  or al, al
  1630 00014295 78FB                <2>  js short %%Wait
  1631 00014297 88D8                <2>  mov al, %1
  1632 00014299 EE                  <2>  out dx, al
  1840                              <1> 	SbOut   bh
  1627                              <2> %%Wait:
  1628 0001429A EC                  <2>  in al, dx
  1629 0001429B 08C0                <2>  or al, al
  1630 0001429D 78FB                <2>  js short %%Wait
  1631 0001429F 88F8                <2>  mov al, %1
  1632 000142A1 EE                  <2>  out dx, al
  1841                              <1> 
  1842 000142A2 C605[E4890100]01    <1> 	mov	byte [audio_play_cmd], 1 ; playing !
  1843                              <1> 
  1844                              <1> 	;; Set Voice and master volumes
  1845                              <1> 	;mov	dx, [audio_io_base]
  1846                              <1> 	;add	dl, 4 ; Mixer chip Register Address Port
  1847                              <1> 	;SbOut	30h   ; select Master Volume Register (L)
  1848                              <1> 	;inc	dl    ; Mixer chip Register Data Port
  1849                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
  1850                              <1> 	;dec	dl
  1851                              <1> 	;SbOut	31h   ; select Master Volume Register (R)
  1852                              <1> 	;inc	dl
  1853                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
  1854                              <1> 	;dec	dl
  1855                              <1> 	;SbOut	32h   ; select Voice Volume Register (L)
  1856                              <1> 	;inc	dl
  1857                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
  1858                              <1> 	;dec	dl
  1859                              <1> 	;SbOut	33h   ; select Voice Volume Register (R)
  1860                              <1> 	;inc	dl
  1861                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)	
  1862                              <1> 	;;
  1863                              <1> 	;dec	dl
  1864                              <1> 	;SbOut	44h   ; select Treble Register (L)
  1865                              <1> 	;inc	dl
  1866                              <1> 	;SbOut	0F0h  ; Max. Treble value is 15 (15*16)
  1867                              <1> 	;dec	dl
  1868                              <1> 	;SbOut	45h   ; select Treble Register (R)
  1869                              <1> 	;inc	dl
  1870                              <1> 	;SbOut	0F0h  ; Max. Treble value is 15 (15*16)
  1871                              <1> 	;dec	dl
  1872                              <1> 	;SbOut	46h   ; select Bass Register (L)
  1873                              <1> 	;inc	dl
  1874                              <1> 	;SbOut	0F0h  ; Max. Bass value is 15 (15*16)
  1875                              <1> 	;dec	dl
  1876                              <1> 	;SbOut	47h   ; select Bass Register (R)
  1877                              <1> 	;inc	dl
  1878                              <1> 	;SbOut	0F0h  ; Max. Bass value is 15 (15*16)	
  1879                              <1> 
  1880                              <1> sb_Exit:           
  1881                              <1> 	;popad
  1882 000142A9 C3                  <1> 	retn
  1883                              <1> 
  1884                              <1> sb16_int_handler:
  1885                              <1> 	; Interrupt Handler for Sound Blaster 16 Audio Card
  1886                              <1> 	; Note: called by 'dev_IRQ_service'
  1887                              <1> 	; 20/10/2017
  1888                              <1> 	; 12/10/2017
  1889                              <1> 	; 10/10/2017 
  1890                              <1> 	; 12/05/2017, 09/10/2017
  1891                              <1> 	; 24/04/2017 (TRDOS 386 kernel, 'audio.s')
  1892                              <1> 	; 10/03/2017 - 'PLAYWAV.PRG' ('playwav.s') 
  1893                              <1> 
  1894                              <1> 	;push	eax ; * must be saved !
  1895                              <1> 	;push	ebx ; * must be saved !
  1896                              <1> 	;push	ecx
  1897                              <1> 	;push	edx
  1898                              <1> 	;push	esi
  1899                              <1> 	;push	edi
  1900                              <1> 
  1901 000142AA 668B15[B6890100]    <1> 	mov     dx, [audio_io_base]
  1902                              <1> 	; 20/10/2017
  1903 000142B1 80C20F              <1> 	add     dl, 0Fh ; 2xFh (DSP 16 bit intr ack)
  1904 000142B4 803D[E0890100]10    <1> 	cmp	byte [audio_bps], 16
  1905 000142BB 7402                <1> 	je	short sb_irq_16bit_ack
  1906                              <1> sb_irq_8bit_ack:
  1907 000142BD FECA                <1> 	dec	dl  ; 2xEh (DSP 8 bit intr ack)
  1908                              <1> sb_irq_16bit_ack:
  1909 000142BF EC                  <1> 	in	al, dx
  1910                              <1> 
  1911                              <1> 	;cmp	byte [audio_busy], 0
  1912                              <1> 	;ja	short sb_irq_h3
  1913                              <1> 
  1914                              <1> 	;mov	byte [audio_busy], 1
  1915                              <1> 
  1916 000142C0 803D[E4890100]01    <1> 	cmp	byte [audio_play_cmd], 1
  1917 000142C7 7307                <1> 	jnb	short sb_irq_h1
  1918                              <1> sb_irq_h0:
  1919 000142C9 E8A3000000          <1> 	call	sb16_stop
  1920 000142CE EB2B                <1> 	jmp	short sb_irq_h3
  1921                              <1> sb_irq_h1:
  1922                              <1> 	;call	sb16_tuneloop
  1923                              <1> 	; 09/10/2017
  1924                              <1> sb16_tuneloop:
  1925 000142D0 8B3D[D0890100]      <1> 	mov	edi, [audio_dma_buff]
  1926 000142D6 8B0D[D4890100]      <1> 	mov	ecx, [audio_dmabuff_size]
  1927 000142DC D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
  1928                              <1> 
  1929                              <1> 	; 22/05/2017
  1930 000142DE F605[D8890100]01    <1> 	test	byte [audio_flag], 1  ; Current flag value
  1931 000142E5 7402                <1> 	jz	short sb_tlp1 ; EOL (Half Buffer 1 must be filled)
  1932                              <1> 	; FLAG (Half Buffer 2 must be filled)
  1933 000142E7 01CF                <1> 	add	edi, ecx
  1934                              <1> 	; 15/05/2017
  1935                              <1> sb_tlp1: 
  1936 000142E9 8B35[C8890100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
  1937                              <1> 	;rep	movsb
  1938 000142EF C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
  1939 000142F2 F3A5                <1> 	rep	movsd 
  1940                              <1> 	;retn
  1941                              <1> 
  1942                              <1> 	; 10/10/2017
  1943                              <1> 	; switch flag value
  1944 000142F4 8035[D8890100]01    <1> 	xor	byte [audio_flag], 1
  1945                              <1> 
  1946                              <1> 	; 12/10/2017
  1947                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2 (odd intr count)
  1948                              <1> 			   ; Next buffer (to update) is dma half buff 1
  1949                              <1> 	; 	       = 1 : Playing dma half buffer 1 (even intr count)
  1950                              <1> 			   ; Next buffer (to update) is dma half buff 2
  1951                              <1> 
  1952                              <1> sb_irq_h3:
  1953                              <1> 	;mov	byte [audio_busy], 0
  1954                              <1> 
  1955                              <1> 	;pop	edi
  1956                              <1> 	;pop	esi
  1957                              <1> 	;pop	edx
  1958                              <1> 	;pop	ecx
  1959                              <1> 	;pop	ebx ; * must be restored !
  1960                              <1> 	;pop	eax ; * must be restored !
  1961                              <1> 	
  1962 000142FB C3                  <1> 	retn
  1963                              <1> 
  1964                              <1> sb16_volume:
  1965                              <1> 	; 06/08/2022 (TRDOS 386 v2.0.5)
  1966                              <1> 	; 22/10/2017
  1967                              <1> 	; mov [audio_master_volume_l], cl 
  1968                              <1> 	; mov [audio_master_volume_h], ch 
  1969 000142FC 66890D[E6890100]    <1> 	mov	[audio_master_volume], cx
  1970                              <1> sb16_volume_initial:
  1971                              <1> 	;push	dx ; DX (port address) must be saved
  1972                              <1> 	; 06/08/2022
  1973 00014303 52                  <1> 	push	edx
  1974 00014304 668B15[B6890100]    <1> 	mov	dx, [audio_io_base]
  1975                              <1> 	;add	dx, 4 ; Mixer chip address port
  1976                              <1> 	; 06/08/2022
  1977 0001430B 80C204              <1> 	add	dl, 4
  1978 0001430E B022                <1> 	mov	al, 22h ; master volume
  1979 00014310 EE                  <1> 	out	dx, al
  1980                              <1> 	;inc	dx
  1981                              <1> 	; 06/08/2022
  1982 00014311 42                  <1> 	inc	edx
  1983 00014312 8A25[E6890100]      <1> 	mov	ah, [audio_master_volume_l]
  1984 00014318 C0EC02              <1> 	shr	ah, 2 ; 32 -> 8 level
  1985 0001431B C0E405              <1> 	shl	ah, 5 ; bit 5 to 7
  1986 0001431E A0[E7890100]        <1> 	mov	al, [audio_master_volume_r]	
  1987 00014323 C0E802              <1> 	shr	al, 2 ; 32 -> 8 level
  1988                              <1> 	;and	al, 0Fh
  1989 00014326 D0E0                <1> 	shl	al, 1 ; bit 1 to 3
  1990 00014328 08E0                <1> 	or	al, ah
  1991 0001432A EE                  <1> 	out	dx, al
  1992                              <1> 	;pop	dx ; DX (port address) must be restored
  1993                              <1> 	; 06/08/2022
  1994 0001432B 5A                  <1> 	pop	edx
  1995 0001432C C3                  <1> 	retn
  1996                              <1> 
  1997                              <1> sb16_pause:
  1998                              <1> 	; 06/08/2022 (TRDOS 386 v2.0.5)
  1999 0001432D 668B15[B6890100]    <1> 	mov	dx, [audio_io_base]
  2000                              <1> 	;add	dx, 0Ch ; Command & Data Port
  2001                              <1> 	; 06/08/2022
  2002 00014334 80C20C              <1> 	add	dl, 0Ch
  2003 00014337 803D[E0890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  2004 0001433E 7404                <1> 	je	short sb_pause_1
  2005                              <1> 	; 8 bit samples
  2006 00014340 B3D0                <1> 	mov	bl, 0D0h ; 8 bit DMA mode
  2007 00014342 EB02                <1> 	jmp	short sb_pause_2
  2008                              <1> sb_pause_1:
  2009                              <1> 	; 16 bit samples
  2010 00014344 B3D5                <1> 	mov	bl, 0D5h ; 16 bit DMA mode
  2011                              <1> sb_pause_2:     
  2012                              <1> 	SbOut   bl ; bCommand
  1627                              <2> %%Wait:
  1628 00014346 EC                  <2>  in al, dx
  1629 00014347 08C0                <2>  or al, al
  1630 00014349 78FB                <2>  js short %%Wait
  1631 0001434B 88D8                <2>  mov al, %1
  1632 0001434D EE                  <2>  out dx, al
  2013                              <1> sb_pause_3:
  2014 0001434E C3                  <1> 	retn
  2015                              <1> 
  2016                              <1> sb16_continue:
  2017                              <1> 	; 06/08/2022 (TRDOS 386 v2.0.5)
  2018 0001434F 668B15[B6890100]    <1> 	mov	dx, [audio_io_base]
  2019                              <1> 	;add	dx, 0Ch ; Command & Data Port
  2020                              <1> 	; 06/08/2022
  2021 00014356 80C20C              <1> 	add	dl, 0Ch
  2022 00014359 803D[E0890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  2023 00014360 7404                <1> 	je	short sb_cont_1
  2024                              <1> 	; 8 bit samples
  2025 00014362 B3D4                <1> 	mov	bl, 0D4h ; 8 bit DMA mode
  2026 00014364 EB02                <1> 	jmp	short sb_cont_2
  2027                              <1> sb_cont_1:
  2028                              <1> 	; 16 bit samples
  2029 00014366 B3D6                <1> 	mov	bl, 0D6h ; 16 bit DMA mode
  2030                              <1> sb_cont_2:     
  2031                              <1> 	SbOut   bl ; bCommand
  1627                              <2> %%Wait:
  1628 00014368 EC                  <2>  in al, dx
  1629 00014369 08C0                <2>  or al, al
  1630 0001436B 78FB                <2>  js short %%Wait
  1631 0001436D 88D8                <2>  mov al, %1
  1632 0001436F EE                  <2>  out dx, al
  2032                              <1> sb_cont_3:
  2033 00014370 C3                  <1> 	retn
  2034                              <1> 
  2035                              <1> sb16_stop:
  2036                              <1> 	; 06/08/2022 (TRDOS 386 v2.0.5)
  2037                              <1> 	; 24/04/2017
  2038 00014371 803D[E4890100]00    <1> 	cmp	byte [audio_play_cmd], 0
  2039 00014378 7647                <1> 	jna	short sb16_stop_4
  2040                              <1> 
  2041                              <1> 	; 22/05/2017
  2042 0001437A 668B15[B6890100]    <1> 	mov	dx, [audio_io_base]
  2043                              <1> 	;add	dx, 0Ch
  2044                              <1> 	; 06/08/2022
  2045 00014381 80C20C              <1> 	add	dl, 0Ch
  2046                              <1> 
  2047 00014384 B3D9                <1> 	mov	bl, 0D9h ; exit auto-initialize 16 bit transfer
  2048                              <1> 	; stop  autoinitialized DMA transfer mode 
  2049 00014386 803D[E0890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  2050 0001438D 7402                <1> 	je	short sb16_stop_1
  2051                              <1> 	;mov	bl, 0DAh ; exit auto-initialize 8 bit transfer
  2052 0001438F FEC3                <1> 	inc	bl
  2053                              <1> sb16_stop_1:
  2054                              <1> 	SbOut	bl ; exit auto-initialize transfer command
  1627                              <2> %%Wait:
  1628 00014391 EC                  <2>  in al, dx
  1629 00014392 08C0                <2>  or al, al
  1630 00014394 78FB                <2>  js short %%Wait
  1631 00014396 88D8                <2>  mov al, %1
  1632 00014398 EE                  <2>  out dx, al
  2055                              <1> 
  2056 00014399 30C0                <1> 	xor     al, al ; stops all DMA processes on selected channel
  2057                              <1> 
  2058 0001439B 803D[E0890100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  2059 000143A2 7404                <1> 	je	short sb16_stop_2
  2060 000143A4 E60C                <1> 	out	0Ch, al ; clear selected channel register
  2061 000143A6 EB02                <1> 	jmp	short sb16_stop_3
  2062                              <1> 
  2063                              <1> sb16_stop_2:
  2064 000143A8 E6D8                <1> 	out	0D8h, al ; clear selected channel register
  2065                              <1> 
  2066                              <1> sb16_stop_3:
  2067 000143AA C605[E4890100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  2068                              <1> SbDone:
  2069                              <1> 	;mov	dx, [audio_io_base]
  2070                              <1> 	;add	dx, 0Ch
  2071                              <1> 	SbOut   0D0h
  1627                              <2> %%Wait:
  1628 000143B1 EC                  <2>  in al, dx
  1629 000143B2 08C0                <2>  or al, al
  1630 000143B4 78FB                <2>  js short %%Wait
  1631 000143B6 B0D0                <2>  mov al, %1
  1632 000143B8 EE                  <2>  out dx, al
  2072                              <1> 	SbOut   0D3h
  1627                              <2> %%Wait:
  1628 000143B9 EC                  <2>  in al, dx
  1629 000143BA 08C0                <2>  or al, al
  1630 000143BC 78FB                <2>  js short %%Wait
  1631 000143BE B0D3                <2>  mov al, %1
  1632 000143C0 EE                  <2>  out dx, al
  2073                              <1> sb16_stop_4:
  2074 000143C1 C3                  <1> 	retn
  2075                              <1> 
  2076                              <1> sb16_reset:
  2077                              <1> 	; 06/08/2022 (TRDOS 386 v2.0.5)
  2078                              <1> 	; 24/04/2017
  2079 000143C2 668B15[B6890100]    <1> 	mov     dx, [audio_io_base] ; try to reset the DSP.
  2080                              <1> 	;add	dx, 06h
  2081                              <1> 	; 06/08/2022
  2082 000143C9 80C206              <1> 	add	dl, 06h
  2083 000143CC B001                <1> 	mov	al, 1
  2084 000143CE EE                  <1> 	out	dx, al
  2085                              <1> 
  2086 000143CF EC                  <1> 	in	al, dx
  2087 000143D0 EC                  <1> 	in	al, dx
  2088 000143D1 EC                  <1> 	in	al, dx
  2089 000143D2 EC                  <1> 	in	al, dx
  2090                              <1> 
  2091 000143D3 30C0                <1> 	xor     al, al
  2092 000143D5 EE                  <1> 	out	dx, al
  2093                              <1> 
  2094                              <1> 	;add	dx, 08h
  2095                              <1> 	; 06/08/2022
  2096 000143D6 80C208              <1> 	add	dl, 08h
  2097                              <1> 	;mov	cx, 100
  2098 000143D9 29C9                <1> 	sub	ecx, ecx
  2099 000143DB B164                <1> 	mov	cl, 100
  2100                              <1> sbrstWaitID:
  2101 000143DD EC                  <1> 	in	al, dx
  2102 000143DE 08C0                <1> 	or      al, al
  2103 000143E0 7804                <1> 	js      short sbrstGetID
  2104 000143E2 E2F9                <1> 	loop    sbrstWaitID
  2105 000143E4 F9                  <1> 	stc
  2106 000143E5 C3                  <1> 	retn
  2107                              <1> sbrstGetID:          
  2108                              <1> 	;sub	dx, 04h
  2109                              <1> 	; 06/08/2022
  2110 000143E6 80EA04              <1> 	sub	dl, 04h
  2111 000143E9 EC                  <1> 	in	al, dx
  2112 000143EA 3CAA                <1> 	cmp     al, 0AAh
  2113 000143EC 7405                <1> 	je      short sb_rst_retn
  2114                              <1> 	;add	dx, 04h
  2115                              <1> 	; 06/08/2022
  2116 000143EE 80C204              <1> 	add	dl, 04h
  2117 000143F1 E2EA                <1> 	loop    sbrstWaitID
  2118                              <1> sb_rst_retn:
  2119 000143F3 C3                  <1> 	retn
  2120                              <1> 
  2121                              <1> ac97_codec_config:
  2122                              <1> 	; 10/06/2017
  2123                              <1> 	; 05/06/2017
  2124                              <1> 	; 29/05/2017
  2125                              <1> 	; 28/05/2017 (TRDOS 386, 'audio.s')
  2126                              <1> 	; 07/11/2016 (Erdogan Tan)
  2127                              <1> 	; Derived from 'codecConfig' procedure in 'CODEC.ASM'
  2128                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
  2129                              <1> 
  2130                              <1> 	;; 'PLAYER.ASM'
  2131                              <1> 	;; get ICH base address regs for mixer and bus master
  2132                              <1> 
  2133                              <1> init_ac97_controller: ; 10/06/2017
  2134 000143F4 A1[B8890100]        <1> 	mov	eax, [audio_dev_id]
  2135                              <1>         ;mov	al, NAMBAR_REG
  2136                              <1>         ;;call  pciRegRead16			; read PCI registers 10-11
  2137                              <1>         ;call	pciRegRead32
  2138                              <1> 	;and	dx, IO_ADDR_MASK 		; mask off BIT0
  2139                              <1> 	;;and	edx, IO_ADDR_MASK 
  2140                              <1> 
  2141                              <1>         ;mov	[NAMBAR], dx			; save audio mixer base addr
  2142                              <1> 
  2143                              <1>         ;mov    al, NABMBAR_REG
  2144                              <1>         ;;call	pciRegRead16
  2145                              <1>         ;call	pciRegRead32
  2146                              <1> 	;and	dx, 0FFC0h ; IO_ADDR_MASK
  2147                              <1> 	;;and	edx, 0FFC0h
  2148                              <1> 
  2149                              <1>         ;mov    [NABMBAR], dx			; save bus master base addr
  2150                              <1> 
  2151                              <1> 	;mov	eax, [audio_dev_id]
  2152 000143F9 B004                <1>         mov     al, PCI_CMD_REG
  2153                              <1>         ;call	pciRegRead8			; read PCI command register
  2154 000143FB E885F8FFFF          <1>         call	pciRegRead16
  2155 00014400 80CA05              <1> 	or      dl, IO_ENA+BM_ENA               ; enable IO and bus master
  2156                              <1>         ;call 	pciRegWrite8
  2157 00014403 E8E8F8FFFF          <1> 	call	pciRegWrite16
  2158                              <1> 
  2159                              <1> 	; 'CODEC.ASM'
  2160                              <1> 
  2161                              <1> 	; enable codec, unmute stuff, set output rate
  2162                              <1> ;	; entry: [audio_freq] = desired sample rate
  2163                              <1> 		
  2164                              <1> ;	mov    	dx, [NAMBAR]               	
  2165                              <1> ;	add    	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah  	  
  2166                              <1> ;	in     	ax, dx
  2167                              <1> ;	or	ax, 1
  2168                              <1> ;	out	dx, ax 				; Enable variable rate audio
  2169                              <1> 
  2170                              <1> ;       ;call    delay1_4ms
  2171                              <1> ;       ;call    delay1_4ms
  2172                              <1> ;       ;call    delay1_4ms
  2173                              <1> ;       ;call    delay1_4ms
  2174                              <1> 
  2175                              <1> ;	mov	ax, [audio_freq]		; sample rate
  2176                              <1> 
  2177                              <1> ;	mov    	dx, [NAMBAR]               	
  2178                              <1> ;	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
  2179                              <1> ;	out	dx, ax 				; out sample rate
  2180                              <1> 		
  2181                              <1> ;       ;call	delay1_4ms
  2182                              <1> ;       ;call	delay1_4ms
  2183                              <1> ;       ;call	delay1_4ms
  2184                              <1> ;       ;call	delay1_4ms
  2185                              <1> 
  2186                              <1> 	;mov	dx, [NAMBAR]			; mixer base address
  2187                              <1>         ;add	dx, CODEC_RESET_REG  		; reset register
  2188                              <1>         ;mov	ax, 42
  2189                              <1> 	;out	dx, ax                          ; reset
  2190                              <1> 
  2191                              <1> 	;mov    dx, [NABMBAR]			; bus master base address
  2192                              <1>         ;add	dx, GLOB_STS_REG
  2193                              <1>         ;mov	ax, 2
  2194                              <1> 	;out	dx, ax                         
  2195                              <1> 
  2196 00014408 E880F9FFFF          <1>         call    delay_100ms ; 29/05/2017
  2197                              <1> 
  2198                              <1> init_ac97_codec:
  2199                              <1> 	; 10/06/2017
  2200                              <1> 	; 29/05/2017
  2201                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2202                              <1> 	;	
  2203 0001440D 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  2204 00014411 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2205 00014418 ED                  <1> 	in	eax, dx
  2206                              <1> 	; ?
  2207 00014419 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
  2208 0001441D 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2209 00014424 ED                  <1> 	in	eax, dx
  2210                              <1> 
  2211 00014425 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; -1
  2212 00014428 744B                <1> 	je	short init_ac97_codec_err1
  2213                              <1> 
  2214 0001442A A900030010          <1> 	test	eax, CTRL_ST_CREADY
  2215 0001442F 7507                <1> 	jnz	short _ac97_codec_ready
  2216                              <1> 
  2217 00014431 E8DB020000          <1> 	call	reset_ac97_codec
  2218 00014436 723E                <1> 	jc	short init_ac97_codec_err2
  2219                              <1> 
  2220                              <1> _ac97_codec_ready:
  2221 00014438 668B15[E8890100]    <1> 	mov	dx, [NAMBAR]
  2222                              <1> 	;add	dx, 0 ; ac_reg_0 ; reset register
  2223 0001443F 66EF                <1> 	out	dx, ax
  2224                              <1> 
  2225 00014441 31C0                <1> 	xor	eax, eax ; 0
  2226 00014443 668B15[E8890100]    <1> 	mov	dx, [NAMBAR]
  2227 0001444A 6683C226            <1> 	add	dx, CODEC_REG_POWERDOWN	
  2228 0001444E 66EF                <1> 	out	dx, ax
  2229                              <1> 
  2230                              <1> 	; 10/06/2017
  2231                              <1> 	; 29/05/2017
  2232                              <1> 	; wait for 1 second
  2233 00014450 B9E8030000          <1> 	mov	ecx, 1000 ; 1000*0.25ms = 1s
  2234                              <1> _ac97_codec_rloop:
  2235 00014455 E840F9FFFF          <1> 	call	delay1_4ms
  2236 0001445A E83BF9FFFF          <1> 	call	delay1_4ms
  2237 0001445F E836F9FFFF          <1> 	call	delay1_4ms
  2238 00014464 E831F9FFFF          <1> 	call	delay1_4ms
  2239                              <1> 	;mov	dx, [NAMBAR]
  2240                              <1> 	;add	dx, CODEC_REG_POWERDOWN
  2241 00014469 66ED                <1> 	in	ax, dx	
  2242 0001446B 6683E00F            <1> 	and	ax, 0Fh
  2243 0001446F 3C0F                <1> 	cmp	al, 0Fh
  2244 00014471 7404                <1> 	je	short _ac97_codec_init_ok
  2245 00014473 E2E0                <1> 	loop	_ac97_codec_rloop 
  2246                              <1> 
  2247                              <1> init_ac97_codec_err1:
  2248 00014475 F9                  <1> 	stc
  2249                              <1> init_ac97_codec_err2:
  2250 00014476 C3                  <1> 	retn
  2251                              <1> 
  2252                              <1> _ac97_codec_init_ok:
  2253 00014477 B002                <1>         mov     al, 2 ; force set 16-bit 2-channel PCM
  2254 00014479 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  2255 0001447D 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2256 00014484 EF                  <1> 	out	dx, eax
  2257                              <1> 
  2258                              <1> 	;call	delay1_4ms
  2259                              <1> 
  2260                              <1> 	; 10/06/2017
  2261 00014485 E835020000          <1> 	call 	reset_ac97_controller
  2262                              <1> 
  2263                              <1> ;	call 	setup_ac97_codec
  2264                              <1> ;
  2265                              <1> ;detect_ac97_codec:
  2266                              <1> ;	retn
  2267                              <1> 
  2268                              <1> setup_ac97_codec:
  2269                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2270                              <1> 	; 22/07/2020
  2271                              <1> 	; 10/06/2017
  2272                              <1> 	; 29/05/2017
  2273 0001448A B802020000          <1> 	mov     eax, 0202h
  2274 0001448F 66A3[E6890100]      <1> 	mov	[audio_master_volume], ax
  2275 00014495 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31, 31
  2276                              <1> 	
  2277 00014499 668B15[E8890100]    <1>   	mov     dx, [NAMBAR]
  2278 000144A0 6683C202            <1>   	add     dx, CODEC_MASTER_VOL_REG	;02h 
  2279                              <1> 	;xor	ax, ax 	; volume attenuation = 0 (max. volume)
  2280                              <1> 	; 06/08/2022
  2281 000144A4 31C0                <1> 	xor	eax, eax
  2282 000144A6 66EF                <1> 	out     dx, ax
  2283                              <1>  
  2284 000144A8 668B15[E8890100]    <1>   	mov     dx, [NAMBAR]
  2285 000144AF 6683C206            <1>   	add     dx, CODEC_MASTER_MONO_VOL_REG	;06h 
  2286                              <1> 	;xor	ax, ax
  2287 000144B3 66EF                <1>   	out     dx, ax
  2288                              <1> 
  2289 000144B5 668B15[E8890100]    <1>   	mov     dx, [NAMBAR]
  2290 000144BC 6683C20A            <1>   	add     dx, CODEC_PCBEEP_VOL_REG	;0Ah 
  2291                              <1>   	;xor    ax, ax
  2292 000144C0 66EF                <1>   	out     dx, ax
  2293                              <1> 
  2294 000144C2 668B15[E8890100]    <1>   	mov     dx, [NAMBAR]
  2295 000144C9 6683C218            <1>   	add     dx, CODEC_PCM_OUT_REG		;18h 
  2296                              <1>   	;xor    ax, ax
  2297 000144CD 66EF                <1>   	out     dx, ax
  2298                              <1> 
  2299 000144CF 66B80880            <1> 	mov     ax, 8008h ; Mute
  2300 000144D3 668B15[E8890100]    <1>   	mov     dx, [NAMBAR]
  2301                              <1> 	; 22/07/2020
  2302 000144DA 6683C20C            <1> 	add	dx, CODEC_PHONE_VOL_REG		;0Ch
  2303                              <1> 				 ; AC97_PHONE_VOL ; TAD Input (Mono)
  2304 000144DE 66EF                <1>   	out     dx, ax
  2305                              <1> 
  2306 000144E0 66B80808            <1>         mov	ax, 0808h
  2307 000144E4 668B15[E8890100]    <1>   	mov     dx, [NAMBAR]
  2308 000144EB 6683C210            <1>         add	dx, CODEC_LINE_IN_VOL_REG ;10h ; Line Input (Stereo)	
  2309 000144EF 66EF                <1>   	out     dx, ax
  2310                              <1> 
  2311                              <1> 	;mov	ax, 0808h
  2312 000144F1 668B15[E8890100]    <1>   	mov     dx, [NAMBAR]
  2313 000144F8 6683C212            <1>         add	dx, CODEC_CD_VOL_REG ;12h ; CR Input (Stereo)
  2314 000144FC 66EF                <1>   	out     dx, ax
  2315                              <1> 
  2316                              <1> 	;mov	ax, 0808h
  2317 000144FE 668B15[E8890100]    <1>   	mov     dx, [NAMBAR]
  2318 00014505 6683C216            <1>         add	dx, CODEC_AUX_VOL_REG ;16h ; Aux Input (Stereo)
  2319 00014509 66EF                <1>   	out     dx, ax
  2320                              <1> 
  2321                              <1>         ;call    delay1_4ms
  2322                              <1>         ;call    delay1_4ms
  2323                              <1>         ;call    delay1_4ms
  2324                              <1>         ;call    delay1_4ms
  2325                              <1> 
  2326                              <1> detect_ac97_codec:
  2327 0001450B C3                  <1>         retn
  2328                              <1> 
  2329                              <1> set_ac97_bdl: ; Set AC97 (ICH) Buffer Descriptor List
  2330                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2331                              <1> 	; 17/06/2017
  2332                              <1> 	; 11/06/2017
  2333                              <1> 	; 28/05/2017
  2334                              <1> 	; eax = dma buffer address = [audio_DMA_buff]
  2335                              <1> 	; ecx = dma buffer buffer size = [audio_dmabuff_size]
  2336                              <1> 
  2337 0001450C D1E9                <1> 	shr	ecx, 1 ; dma half buffer size
  2338 0001450E 89CE                <1> 	mov	esi, ecx
  2339                              <1> 
  2340 00014510 BF[EC890100]        <1>         mov     edi, audio_bdl_buff	; get BDL address
  2341                              <1> 	;mov	ecx, 32 / 2		; make 32 entries in BDL
  2342                              <1> 	; 06/08/2022
  2343 00014515 29C9                <1> 	sub	ecx, ecx
  2344 00014517 B110                <1> 	mov	cl, 16
  2345                              <1> 
  2346 00014519 EB05                <1> 	jmp	short s_ac97_bdl1 
  2347                              <1> 
  2348                              <1> s_ac97_bdl0:
  2349                              <1> 	; set buffer descriptor 0 to start of data file in memory
  2350                              <1> 
  2351 0001451B A1[D0890100]        <1>  	mov	eax, [audio_dma_buff]	; Physical address of DMA buffer
  2352                              <1>  
  2353                              <1> s_ac97_bdl1:
  2354 00014520 AB                  <1> 	stosd				; store dmabuffer1 address
  2355                              <1> 
  2356 00014521 89C2                <1> 	mov	edx, eax
  2357                              <1> 
  2358                              <1> ;
  2359                              <1> ; Buffer Descriptors List
  2360                              <1> ; As stated earlier, each buffer descriptor list is a set of (up to) 32 
  2361                              <1> ; descriptors, each 8 bytes in length. Bytes 0-3 of a descriptor entry point
  2362                              <1> ; to a chunk of memory to either play from or record to. Bytes 4-7 of an
  2363                              <1> ; entry describe various control things detailed below.
  2364                              <1> ; 
  2365                              <1> ; Buffer pointers must always be aligned on a Dword boundry.
  2366                              <1> ;
  2367                              <1> ;
  2368                              <1> 
  2369                              <1> ;IOC                     equ     BIT31	; Fire an interrupt whenever this
  2370                              <1>                                         ; buffer is complete.
  2371                              <1> 
  2372                              <1> ;BUP                     equ     BIT30  ; Buffer Underrun Policy.
  2373                              <1>                                         ; if this buffer is the last buffer
  2374                              <1>                                         ; in a playback, fill the remaining
  2375                              <1>                                         ; samples with 0 (silence) or not.
  2376                              <1>                                         ; It's a good idea to set this to 1
  2377                              <1>                                         ; for the last buffer in playback,
  2378                              <1>                                         ; otherwise you're likely to get a lot
  2379                              <1>                                         ; of noise at the end of the sound.
  2380                              <1> 
  2381                              <1> ;
  2382                              <1> ; Bits 15:0 contain the length of the buffer, in number of samples, which
  2383                              <1> ; are 16 bits each, coupled in left and right pairs, or 32bits each.
  2384                              <1> ; Luckily for us, that's the same format as .wav files.
  2385                              <1> ;
  2386                              <1> ; A value of FFFF is 65536 samples. Running at 44.1Khz, that's just about
  2387                              <1> ; 1.5 seconds of sample time. FFFF * 32bits is 1FFFFh bytes or 128k of data.
  2388                              <1> ;
  2389                              <1> ; A value of 0 in these bits means play no samples.
  2390                              <1> ;
  2391                              <1> 
  2392 00014523 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  2393 00014525 01C2                <1> 	add	edx, eax
  2394 00014527 D1E8                <1> 	shr	eax, 1 ; count of 16 bit samples
  2395                              <1> 	;or	eax, IOC+BUP
  2396 00014529 0D00000080          <1> 	or	eax, IOC ; 11/06/2017
  2397 0001452E AB                  <1> 	stosd
  2398                              <1> 
  2399                              <1> ; 2nd buffer:
  2400                              <1> 
  2401 0001452F 89D0                <1>         mov	eax, edx ; Physical address of the 2nd half of DMA buffer	
  2402 00014531 AB                  <1> 	stosd		 ; store dmabuffer2 address
  2403                              <1> 
  2404                              <1> ; set length to [audio_dmabuff_size]/2
  2405                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples
  2406                              <1> ; 
  2407 00014532 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  2408 00014534 D1E8                <1> 	shr	eax, 1 ; count of 16 bit samples
  2409                              <1> 	;or	eax, IOC+BUP
  2410 00014536 0D00000080          <1> 	or	eax, IOC ; 11/06/2017
  2411 0001453B AB                  <1> 	stosd
  2412                              <1> 
  2413 0001453C E2DD                <1> 	loop    s_ac97_bdl0
  2414                              <1> 	
  2415 0001453E C3                  <1> 	retn
  2416                              <1> 
  2417                              <1> ac97_start_play:  
  2418                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2419                              <1> 	; 28/05/2017
  2420                              <1> 	; Derived from 'playWav' procedure in 'ICHWAV.ASM'
  2421                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
  2422                              <1> 
  2423                              <1> 	; set output rate
  2424                              <1> 	; entry: [audio_freq] = desired sample rate
  2425                              <1> 		
  2426 0001453F 668B15[E8890100]    <1> 	mov    	dx, [NAMBAR]               	
  2427 00014546 6683C22A            <1> 	add    	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah  	  
  2428 0001454A 66ED                <1> 	in     	ax, dx
  2429                              <1> 	;or	ax, 1
  2430                              <1> 	; 06/08/2022
  2431 0001454C 0C01                <1> 	or	al, 1
  2432 0001454E 66EF                <1> 	out	dx, ax 				; Enable variable rate audio
  2433                              <1> 
  2434                              <1>        ;call    delay1_4ms
  2435                              <1>        ;call    delay1_4ms
  2436                              <1>        ;call    delay1_4ms
  2437                              <1>        ;call    delay1_4ms
  2438                              <1> 
  2439 00014550 66A1[E2890100]      <1> 	mov	ax, [audio_freq]		; sample rate
  2440                              <1> 
  2441 00014556 668B15[E8890100]    <1> 	mov    	dx, [NAMBAR]               	
  2442 0001455D 6683C22C            <1> 	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
  2443 00014561 66EF                <1> 	out	dx, ax 				; out sample rate
  2444                              <1> 		
  2445                              <1>        ;call    delay1_4ms
  2446                              <1>        ;call    delay1_4ms
  2447                              <1>        ;call    delay1_4ms
  2448                              <1>        ;call    delay1_4ms
  2449                              <1> 
  2450                              <1> ;
  2451                              <1> ; register reset the DMA engine. This may cause a pop noise on the output
  2452                              <1> ; lines when the device is reset. Prolly a better idea to mute output, then
  2453                              <1> ; reset.
  2454                              <1> ;
  2455 00014563 668B15[EA890100]    <1>         mov     dx, [NABMBAR]
  2456 0001456A 6683C21B            <1>         add     dx, PO_CR_REG                  ; set pointer to Cntl reg
  2457 0001456E B002                <1>         mov     al, RR                         ; set reset
  2458 00014570 EE                  <1>         out     dx, al                         ; self clearing bit
  2459                              <1> ;
  2460                              <1> ;	mov	edi, audio_bdl_buff
  2461                              <1> ;	mov	edx, [audio_dmabuff_size]
  2462                              <1> ;	shr	edx, 1
  2463                              <1> ;	mov	ecx, 32/2
  2464                              <1> ;ac97_set_bdl_buffer:
  2465                              <1> ;	; 1st half of DMA buffer
  2466                              <1> ;	mov	eax, [audio_dma_buff]
  2467                              <1> ;	push	eax
  2468                              <1> ;	stosd
  2469                              <1> ;	mov	eax, edx ; dma buffer size / 2
  2470                              <1> ;	or	eax, IOC+BUP
  2471                              <1> ;	stosd
  2472                              <1> ;	pop	eax
  2473                              <1> ;	; 2nd half of DMA buffer
  2474                              <1> ;	add	eax, edx
  2475                              <1> ;	stosd
  2476                              <1> ;	mov	eax, edx ; dma buffer size / 2
  2477                              <1> ;	or	eax, IOC+BUP
  2478                              <1> ;	stosd
  2479                              <1> ;	loop	ac97_set_bdl_buffer
  2480                              <1>  	
  2481                              <1> ; tell the DMA engine where to find our list of Buffer Descriptors.
  2482                              <1> ; this 32bit value is a flat mode memory offset (ie no segment:offset)
  2483                              <1> ;
  2484                              <1> ; write NABMBAR+10h with offset of buffer descriptor list
  2485                              <1> ;
  2486 00014571 B8[EC890100]        <1>         mov	eax, audio_bdl_buff
  2487 00014576 668B15[EA890100]    <1> 	mov	dx, [NABMBAR]
  2488 0001457D 6683C210            <1> 	add	dx, PO_BDBAR_REG
  2489 00014581 EF                  <1> 	out	dx, eax
  2490                              <1> ;
  2491                              <1> ; All set. Let's play some music.
  2492                              <1> ;
  2493                              <1> ;
  2494                              <1> 	;mov	eax, 31
  2495                              <1> 	; 06/08/2022
  2496 00014582 29C0                <1> 	sub	eax, eax
  2497 00014584 B01F                <1> 	mov	al, 31
  2498 00014586 E816000000          <1> 	call    set_ac97_LastValidIndex
  2499                              <1> 
  2500 0001458B C605[E4890100]01    <1> 	mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
  2501                              <1> 
  2502                              <1> ac97_play: ; continue to play (after pause)
  2503                              <1> 	; 11/06/2017
  2504                              <1> 	; 29/05/2017
  2505                              <1> 	; 28/05/2017
  2506 00014592 668B15[EA890100]    <1>         mov     dx, [NABMBAR]
  2507 00014599 6683C21B            <1>         add     dx, PO_CR_REG		; PCM out control register
  2508 0001459D B011                <1>         mov	al, IOCE+RPBM ; 29/05/2017
  2509                              <1>         ;mov	al, 1Dh ; (Ref: KolibriOS, intelac97.asm, 'play:')
  2510 0001459F EE                  <1> 	out     dx, al			; set start!
  2511                              <1> 
  2512                              <1> 	;mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
  2513                              <1> 
  2514 000145A0 C3                  <1> 	retn
  2515                              <1> 
  2516                              <1> ;input AL = index # to stop on
  2517                              <1> set_ac97_LastValidIndex:
  2518                              <1> 	; 28/05/2017
  2519                              <1> 	; Derived from 'setLastValidIndex' procedure in 'ICHWAV.ASM'
  2520                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
  2521 000145A1 668B15[EA890100]    <1> 	mov	dx, [NABMBAR]
  2522 000145A8 6683C215            <1> 	add	dx, PO_LVI_REG
  2523 000145AC EE                  <1>         out     dx, al
  2524                              <1> 	;mov	[audio_lvi], al ; for ac97_int_handler
  2525 000145AD C3                  <1> 	retn
  2526                              <1> 
  2527                              <1> ac97_volume:
  2528                              <1> 	; 28/05/2017
  2529                              <1> 	; bl = component (0 = master/playback/lineout volume)
  2530                              <1> 	; cl = left channel volume level (0 to 31)
  2531                              <1> 	; ch = right channel volume level (0 to 31)
  2532                              <1> 
  2533 000145AE 08DB                <1> 	or	bl, bl
  2534 000145B0 7523                <1> 	jnz	short ac97_vol_1 ; temporary !
  2535 000145B2 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
  2536 000145B6 38C1                <1> 	cmp	cl, al
  2537 000145B8 771B                <1> 	ja	short ac97_vol_1 ; temporary !
  2538 000145BA 38E5                <1> 	cmp	ch, ah
  2539 000145BC 7717                <1> 	ja	short ac97_vol_1 ; temporary !
  2540 000145BE 66890D[E6890100]    <1> 	mov	[audio_master_volume], cx
  2541 000145C5 6629C8              <1> 	sub	ax, cx
  2542 000145C8 668B15[E8890100]    <1>   	mov     dx, [NAMBAR]
  2543 000145CF 6683C202            <1>   	add     dx, CODEC_MASTER_VOL_REG  ; 02h ; Line Out 
  2544 000145D3 66EF                <1>   	out     dx, ax
  2545                              <1> ac97_vol_1:
  2546                              <1> _ac97_ih5:	; 06/08/2022
  2547 000145D5 C3                  <1> 	retn
  2548                              <1> 
  2549                              <1> ac97_int_handler:
  2550                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2551                              <1> 	; 12/10/2017
  2552                              <1> 	; 10/10/2017
  2553                              <1> 	; 09/10/2017
  2554                              <1> 	; 13/06/2017, 13/06/2017
  2555                              <1> 	; 10/06/2017, 11/06/2017
  2556                              <1> 	; Interrupt Handler for AC97 (ICH) Audio Controller
  2557                              <1> 	; Note: called by 'dev_IRQ_service' 
  2558                              <1> 	; 28/05/2017
  2559                              <1> 
  2560                              <1> 	;push	eax ; * must be saved !
  2561                              <1> 	;push	edx
  2562                              <1> 	;push	ecx
  2563                              <1> 	;push	ebx ; * must be saved !
  2564                              <1> 	;push	esi
  2565                              <1> 	;push	edi
  2566                              <1> 
  2567                              <1> 	;cmp	byte [audio_busy], 1
  2568                              <1> 	;jnb	_ac97_ih2 ; busy !
  2569                              <1> 
  2570 000145D6 66BA3000            <1>         mov     dx, GLOB_STS_REG
  2571 000145DA 660315[EA890100]    <1>         add	dx, [NABMBAR]
  2572 000145E1 ED                  <1> 	in	eax, dx
  2573                              <1> 
  2574 000145E2 83F8FF              <1>         cmp     eax, 0FFFFFFFFh ; -1
  2575                              <1> 	;je	_ac97_ih3 ; exit
  2576                              <1> 	; 06/08/2022
  2577 000145E5 74EE                <1> 	je	short _ac97_ih5
  2578                              <1> 
  2579                              <1>         ;test	eax, 40h ; PCM Out Interrupt
  2580                              <1> 	; 06/08/2022
  2581 000145E7 A840                <1> 	test	al, 40h
  2582 000145E9 7506                <1> 	jnz     short _ac97_ih0
  2583                              <1> 
  2584 000145EB 85C0                <1> 	test	eax, eax
  2585                              <1> 	;jz	_ac97_ih3 ; exit
  2586                              <1> 	; 06/08/2022
  2587 000145ED 74E6                <1> 	jz	short _ac97_ih5
  2588                              <1> 
  2589                              <1>  	;mov	dx, GLOB_STS_REG
  2590                              <1>         ;add	dx, [NABMBAR]
  2591 000145EF EF                  <1> 	out	dx, eax
  2592                              <1> 
  2593                              <1> 	;jmp	_ac97_ih3 ; exit
  2594                              <1> 	; 06/08/2022
  2595 000145F0 C3                  <1> 	retn
  2596                              <1> 
  2597                              <1> _ac97_ih0:
  2598 000145F1 50                  <1> 	push	eax
  2599                              <1> 	; 09/10/2017
  2600 000145F2 803D[E4890100]01    <1> 	cmp	byte [audio_play_cmd], 1
  2601 000145F9 727C                <1> 	jb	short _ac97_ih4 ; stop command !
  2602                              <1> 
  2603                              <1> 	;mov	byte [audio_busy], 1
  2604                              <1> 
  2605                              <1> 	;mov	al, 10h
  2606                              <1> 	;mov	dx, PO_CR_REG
  2607                              <1>         ;add	dx, [NABMBAR]
  2608                              <1> 	;out	dx, al
  2609                              <1> 
  2610 000145FB 66B81C00            <1> 	mov	ax, 1Ch ; FIFOE(=16)+BCIS(=8)+LVBCI(=4)
  2611 000145FF 66BA1600            <1> 	mov	dx, PO_SR_REG
  2612 00014603 660315[EA890100]    <1>         add	dx, [NABMBAR]
  2613 0001460A 66EF                <1> 	out	dx, ax
  2614                              <1> 
  2615 0001460C 66BA1400            <1> 	mov	dx, PO_CIV_REG
  2616 00014610 660315[EA890100]    <1>         add	dx, [NABMBAR]
  2617 00014617 EC                  <1> 	in	al, dx
  2618                              <1> 
  2619                              <1> 	;cmp	al, [audio_civ] ; [audio_flag]
  2620                              <1> 	;je	short _ac97_ih2
  2621                              <1> 
  2622 00014618 A2[E5890100]        <1> 	mov	[audio_civ], al
  2623 0001461D FEC8                <1> 	dec	al
  2624                              <1> 	;inc	al ; 11/06/2017
  2625 0001461F 241F                <1> 	and	al, 1Fh
  2626                              <1> 
  2627 00014621 66BA1500            <1>         mov     dx, PO_LVI_REG
  2628 00014625 660315[EA890100]    <1>         add	dx, [NABMBAR]
  2629 0001462C EE                  <1>         out	dx, al
  2630                              <1> 
  2631                              <1> 	; 12/10/2017
  2632 0001462D A0[E5890100]        <1> 	mov	al, [audio_civ]
  2633 00014632 FEC0                <1> 	inc	al
  2634 00014634 2401                <1> 	and	al, 1
  2635 00014636 A2[D8890100]        <1> 	mov	[audio_flag], al 
  2636                              <1> 	;; [audio_flag] : 0 = Buffer 1, 1 = Buffer 2
  2637                              <1> 	;
  2638 0001463B 58                  <1> 	pop	eax
  2639                              <1> 	;
  2640 0001463C 83E040              <1> 	and     eax, 40h
  2641 0001463F 668B15[EA890100]    <1>         mov	dx, [NABMBAR]
  2642 00014646 6683C230            <1> 	add	dx, GLOB_STS_REG
  2643 0001464A EF                  <1> 	out	dx, eax
  2644                              <1> 
  2645                              <1> 	;; 13/06/2017
  2646                              <1> 	;mov	al, 11h ; IOCE + RPBM
  2647                              <1> 	;mov	dx, PO_CR_REG
  2648                              <1>         ;add	dx, [NABMBAR]
  2649                              <1> 	;out	dx, al
  2650                              <1> 
  2651                              <1> ac97_tuneloop:
  2652                              <1> 	; 09/10/2017
  2653 0001464B 8B3D[D0890100]      <1> 	mov	edi, [audio_dma_buff]
  2654 00014651 8B0D[D4890100]      <1> 	mov	ecx, [audio_dmabuff_size]
  2655 00014657 D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
  2656                              <1> 
  2657                              <1> 	; 12/10/2017
  2658 00014659 803D[D8890100]00    <1> 	cmp 	byte [audio_flag], 0
  2659 00014660 7702                <1> 	ja	short _ac97_ih1  ; Playing Half Buffer 2 (Current: FLAG)
  2660                              <1> 	; Playing Half Buffer 1 (Current: EOL)	
  2661 00014662 01CF                <1> 	add	edi, ecx
  2662                              <1> _ac97_ih1: 
  2663                              <1> 	; Update half buffer 2 while playing half buffer 1 (next: FLAG)
  2664                              <1> 	; Update half buffer 1 while playing half buffer 2 (next: EOL)
  2665                              <1> 
  2666 00014664 8B35[C8890100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
  2667 0001466A C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
  2668 0001466D F3A5                <1> 	rep	movsd 
  2669                              <1> 
  2670                              <1> 	; 10/10/2017
  2671                              <1> 	; switch flag value
  2672 0001466F 8035[D8890100]01    <1> 	xor	byte [audio_flag], 1
  2673                              <1> 	; 12/10/2017
  2674                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2 (even index value)
  2675                              <1> 			   ; Next buffer (to update) is dma half buff 1
  2676                              <1> 	; 	       = 1 : Playing dma half buffer 1 (odd index value)
  2677                              <1> 			   ; Next buffer (to update) is dma half buff 2
  2678                              <1> _ac97_ih2:
  2679                              <1> 	;mov	byte [audio_busy], 0
  2680                              <1> _ac97_ih3:
  2681                              <1> 	;pop	edi
  2682                              <1> 	;pop	esi
  2683                              <1> 	;pop	ebx ; * must be restored !
  2684                              <1> 	;pop	ecx
  2685                              <1> 	;pop	edx
  2686                              <1> 	;pop	eax ; * must be restored !
  2687                              <1> 
  2688 00014676 C3                  <1> 	retn
  2689                              <1> 
  2690                              <1> _ac97_ih4:
  2691                              <1> 	; 09/10/2017
  2692 00014677 E818000000          <1> 	call	_ac97_stop
  2693                              <1> 	;
  2694 0001467C 58                  <1> 	pop	eax
  2695                              <1> 	;
  2696 0001467D 83E040              <1> 	and     eax, 40h
  2697 00014680 668B15[EA890100]    <1>         mov	dx, [NABMBAR]
  2698 00014687 6683C230            <1> 	add	dx, GLOB_STS_REG
  2699 0001468B EF                  <1> 	out	dx, eax
  2700                              <1> 
  2701                              <1> 	;; 13/06/2017
  2702                              <1> 	;mov	al, 11h ; IOCE + RPBM
  2703                              <1> 	;mov	dx, PO_CR_REG
  2704                              <1>         ;add	dx, [NABMBAR]
  2705                              <1> 	;out	dx, al
  2706                              <1> 
  2707                              <1> 	; 10/10/2017
  2708                              <1> 	;jmp	short _ac97_ih3  ; exit
  2709 0001468C C3                  <1> 	retn
  2710                              <1> 
  2711                              <1> ac97_stop: 
  2712                              <1> 	; 28/05/2017
  2713 0001468D C605[E4890100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  2714                              <1> _ac97_stop: ; 09/10/2017
  2715                              <1> 	; 29/05/2017
  2716                              <1> 	;mov	dx, [NABMBAR]
  2717                              <1> 	;add	dx, PO_CR_REG
  2718                              <1> 	;mov	al, 0
  2719                              <1> 	;out	dx, al
  2720                              <1> 
  2721                              <1> 	; 11/06/2017
  2722 00014694 30C0                <1> 	xor	al, al ; 0
  2723 00014696 E813000000          <1> 	call	ac97_po_cmd
  2724                              <1> 
  2725                              <1> 	; (Ref: KolibriOS, intelac97.asm, 'stop:')
  2726                              <1> 	; Clear FIFOE, BCIS, LVBCI (Ref: Intel ICH hub manual)
  2727 0001469B 66B81C00            <1> 	mov     ax, 1Ch
  2728 0001469F 668B15[EA890100]    <1> 	mov     dx, [NABMBAR]
  2729 000146A6 6683C216            <1> 	add     dx, PO_SR_REG
  2730 000146AA 66EF                <1> 	out     dx, ax
  2731                              <1> 
  2732                              <1> 	;retn
  2733                              <1> 
  2734                              <1> 	; 11/06/2017
  2735 000146AC B002                <1> 	mov     al, RR
  2736                              <1> ac97_po_cmd:
  2737                              <1> 	 ;11/06/2017
  2738                              <1> 	; 29/05/2017
  2739 000146AE 668B15[EA890100]    <1> 	mov     dx, [NABMBAR]
  2740 000146B5 6683C21B            <1>         add     dx, PO_CR_REG		; PCM out control register
  2741 000146B9 EE                  <1> 	out	dx, al
  2742 000146BA C3                  <1> 	retn
  2743                              <1> 
  2744                              <1> ac97_pause:
  2745                              <1> 	; 11/06/2017
  2746                              <1> 	; 29/05/2017
  2747 000146BB B010                <1> 	mov 	al, IOCE
  2748 000146BD EBEF                <1> 	jmp	short ac97_po_cmd
  2749                              <1> 
  2750                              <1> reset_ac97_controller:
  2751                              <1> 	; 10/06/2017
  2752                              <1> 	; 29/05/2017
  2753                              <1> 	; 28/05/2017
  2754                              <1> 	; reset AC97 audio controller registers
  2755 000146BF 31C0                <1> 	xor     eax, eax
  2756 000146C1 66BA0B00            <1>         mov	dx, PI_CR_REG
  2757 000146C5 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2758 000146CC EE                  <1> 	out     dx, al
  2759                              <1> 
  2760 000146CD 66BA1B00            <1>         mov     dx, PO_CR_REG
  2761 000146D1 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2762 000146D8 EE                  <1> 	out     dx, al
  2763                              <1> 
  2764 000146D9 66BA2B00            <1>         mov     dx, MC_CR_REG
  2765 000146DD 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2766 000146E4 EE                  <1> 	out     dx, al
  2767                              <1> 
  2768 000146E5 B002                <1>         mov     al, RR
  2769 000146E7 66BA0B00            <1>         mov     dx, PI_CR_REG
  2770 000146EB 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2771 000146F2 EE                  <1> 	out     dx, al
  2772                              <1> 
  2773 000146F3 66BA1B00            <1>         mov     dx, PO_CR_REG
  2774 000146F7 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2775 000146FE EE                  <1> 	out     dx, al
  2776                              <1> 
  2777 000146FF 66BA2B00            <1>         mov     dx, MC_CR_REG
  2778 00014703 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2779 0001470A EE                  <1> 	out     dx, al
  2780                              <1> 
  2781 0001470B C3                  <1> 	retn
  2782                              <1> 
  2783                              <1> ac97_reset:
  2784                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2785                              <1> 	; 10/06/2017
  2786                              <1> 	; 29/05/2017
  2787                              <1> 	; 28/05/2017
  2788 0001470C E8AEFFFFFF          <1> 	call	reset_ac97_controller
  2789                              <1> 	; 29/05/2017
  2790                              <1> 	;jmp	reset_ac97_codec
  2791                              <1> reset_ac97_codec:
  2792                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2793 00014711 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  2794 00014715 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2795 0001471C ED                  <1> 	in	eax, dx
  2796                              <1> 
  2797                              <1> 	;test	eax, 2
  2798                              <1> 	; 06/08/2022
  2799 0001471D A802                <1> 	test	al, 2
  2800 0001471F 7407                <1> 	jz	short _r_ac97codec_cold	
  2801                              <1> 
  2802 00014721 E80F000000          <1> 	call	warm_ac97codec_reset
  2803 00014726 7308                <1> 	jnc	short _r_ac97codec_ok
  2804                              <1> _r_ac97codec_cold:
  2805 00014728 E83B000000          <1>         call    cold_ac97codec_reset
  2806 0001472D 7301                <1>         jnc     short _r_ac97codec_ok
  2807                              <1> 	
  2808                              <1> 	; 16/04/2017
  2809                              <1>         ;xor	eax, eax	; timeout error
  2810                              <1>        	;stc
  2811 0001472F C3                  <1> 	retn
  2812                              <1> 
  2813                              <1> _r_ac97codec_ok:
  2814 00014730 31C0                <1>         xor     eax, eax
  2815                              <1>         ;mov	al, VIA_ACLINK_C00_READY ; 1
  2816 00014732 FEC0                <1>         inc	al
  2817 00014734 C3                  <1> 	retn
  2818                              <1> 
  2819                              <1> warm_ac97codec_reset:
  2820                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2821                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2822                              <1>         ;mov	eax, 6
  2823                              <1> 	; 06/08/2022
  2824 00014735 29C0                <1> 	sub	eax, eax
  2825 00014737 B006                <1> 	mov	al, 6
  2826 00014739 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  2827 0001473D 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2828 00014744 EF                  <1> 	out	dx, eax
  2829                              <1> 
  2830                              <1> 	;mov	ecx, 10	; total 1s
  2831                              <1> 	; 06/08/2022
  2832 00014745 31C9                <1> 	xor	ecx, ecx
  2833 00014747 B10A                <1> 	mov	cl, 10
  2834                              <1> _warm_ac97c_rst_wait:
  2835 00014749 51                  <1> 	push	ecx
  2836 0001474A E83EF6FFFF          <1> 	call	delay_100ms
  2837 0001474F 59                  <1> 	pop	ecx
  2838                              <1> 
  2839 00014750 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
  2840 00014754 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2841 0001475B ED                  <1> 	in	eax, dx
  2842                              <1> 
  2843 0001475C A900030010          <1> 	test	eax, CTRL_ST_CREADY
  2844 00014761 7504                <1> 	jnz	short _warm_ac97c_rst_ok
  2845                              <1> 
  2846 00014763 49                  <1>         dec     ecx
  2847 00014764 75E3                <1>         jnz     short _warm_ac97c_rst_wait
  2848                              <1> 
  2849                              <1> _warm_ac97c_rst_fail:
  2850 00014766 F9                  <1>         stc
  2851                              <1> _warm_ac97c_rst_ok:
  2852 00014767 C3                  <1> 	retn
  2853                              <1> 
  2854                              <1> cold_ac97codec_reset:
  2855                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2856                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2857                              <1>         ;mov	eax, 2
  2858                              <1> 	; 06/08/2022
  2859 00014768 31C0                <1> 	xor	eax, eax
  2860 0001476A B002                <1> 	mov	al, 2
  2861 0001476C 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  2862 00014770 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2863 00014777 EF                  <1> 	out	dx, eax
  2864                              <1> 
  2865 00014778 E810F6FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  2866 0001477D E80BF6FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  2867 00014782 E806F6FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  2868 00014787 E801F6FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  2869                              <1> 
  2870                              <1> 	;mov	ecx, 16	; total 20*100 ms = 2s
  2871                              <1> 	; 06/08/2022
  2872 0001478C 31C9                <1> 	xor	ecx, ecx
  2873 0001478E B110                <1> 	mov	cl, 16
  2874                              <1> _cold_ac97c_rst_wait:
  2875 00014790 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
  2876 00014794 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  2877 0001479B ED                  <1> 	in	eax, dx
  2878                              <1> 
  2879 0001479C A900030010          <1> 	test	eax, CTRL_ST_CREADY
  2880 000147A1 750B                <1> 	jnz	short _cold_ac97c_rst_ok
  2881                              <1> 
  2882 000147A3 51                  <1> 	push	ecx
  2883 000147A4 E8E4F5FFFF          <1> 	call	delay_100ms
  2884 000147A9 59                  <1> 	pop	ecx
  2885                              <1> 
  2886 000147AA 49                  <1>         dec     ecx
  2887 000147AB 75E3                <1>         jnz     short _cold_ac97c_rst_wait
  2888                              <1> 
  2889                              <1> _cold_ac97c_rst_fail:
  2890 000147AD F9                  <1>         stc
  2891                              <1> _cold_ac97c_rst_ok:
  2892 000147AE C3                  <1> 	retn
  2893                              <1> 
  2894                              <1> sb16_current_sound_data:
  2895                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2896                              <1> 	; 20/08/2017
  2897                              <1> 	; 24/06/2017
  2898                              <1> 	; 22/06/2017
  2899                              <1> 	; get current sound (PCM out) data for graphics
  2900                              <1> 	; (for Sound Blaster 16)
  2901                              <1> 	; ebx = Physical address (on page boundary)
  2902                              <1> 	; ecx = Byte count
  2903                              <1> 	; [audio_buff_size]
  2904                              <1> 
  2905                              <1> 	;;mov	edi, [audio_buff_size]
  2906                              <1> 	;mov	edi, [audio_dmabuff_size]
  2907                              <1> 	;mov	esi, [audio_dma_buff]
  2908 000147AF 39CF                <1> 	cmp	edi, ecx
  2909 000147B1 7302                <1> 	jnb	short sb16_gcd_0
  2910 000147B3 89F9                <1> 	mov	ecx, edi
  2911                              <1> sb16_gcd_0:
  2912                              <1> 	; 06/08/2022
  2913 000147B5 31C0                <1> 	xor	eax, eax
  2914                              <1> 	; 20/08/2017
  2915 000147B7 803D[E0890100]10    <1> 	cmp	byte [audio_bps], 16
  2916 000147BE 750C                <1> 	jne	short sb16_gcd_1 ; 8 bit DMA channel
  2917 000147C0 E4C6                <1> 	in	al, 0C6h ; DMA channel 5 count register
  2918                              <1> 	;mov	dl, al
  2919                              <1> 	; 06/08/2022
  2920 000147C2 88C4                <1> 	mov	ah, al
  2921 000147C4 E4C6                <1> 	in	al, 0C6h
  2922                              <1> 	;mov	dh, al
  2923                              <1> 	;movzx	eax, dx
  2924                              <1> 	; 06/08/2022
  2925 000147C6 86E0                <1> 	xchg	ah, al
  2926 000147C8 D1E0                <1> 	shl	eax, 1 ; word count -> byte count
  2927 000147CA EB4A                <1> 	jmp	short sb16_gcd_2	
  2928                              <1> sb16_gcd_1:
  2929 000147CC E403                <1> 	in	al, 03h ; DMA channel 1 count register
  2930                              <1> 	;mov	dl, al
  2931                              <1> 	; 06/08/2022
  2932 000147CE 88C4                <1> 	mov	ah, al
  2933 000147D0 E403                <1> 	in	al, 03h
  2934                              <1> 	;mov	dh, al
  2935                              <1> 	;movzx	eax, dx
  2936                              <1> 	; 06/08/2022
  2937 000147D2 86E0                <1> 	xchg	ah, al
  2938 000147D4 EB40                <1> 	jmp	short sb16_gcd_2
  2939                              <1> ;sb16_gcd_2:	
  2940                              <1> ;	cmp	eax, ecx
  2941                              <1> ;	jnb	short sb16_gcd_3 
  2942                              <1> ;	; remain count < graphics bytes
  2943                              <1> ;	mov	eax, ecx ; fix remain count to data size
  2944                              <1> ;sb16_gcd_3:	
  2945                              <1> ;	sub	edi, eax
  2946                              <1> ;	jna	short sb16_gcd_4
  2947                              <1> ;	add	esi, edi ; dma buffer offset
  2948                              <1> ;sb16_gcd_4:
  2949                              <1> ;	mov	edi, ebx ; buffer address (for graphics) 
  2950                              <1> ;	mov	[u.r0], ecx
  2951                              <1> ;	rep	movsb
  2952                              <1> ;	retn
  2953                              <1> 
  2954                              <1> get_current_sound_data:
  2955                              <1> 	; 24/06/2017
  2956                              <1> 	; 22/06/2017
  2957                              <1> 	; get current sound (PCM out) data for graphics
  2958                              <1> 	;
  2959                              <1> 	; ebx = Physical address (on page boundary)
  2960                              <1> 	; ecx = Byte count
  2961                              <1> 	; [audio_buff_size]
  2962                              <1> 
  2963                              <1> 	;mov	edi, [audio_buff_size]
  2964 000147D6 8B3D[D4890100]      <1> 	mov	edi, [audio_dmabuff_size]
  2965 000147DC 8B35[D0890100]      <1> 	mov	esi, [audio_dma_buff]
  2966 000147E2 803D[B1890100]02    <1> 	cmp	byte [audio_device], 2
  2967 000147E9 72C4                <1> 	jb	short sb16_current_sound_data ; = 1
  2968 000147EB D1EF                <1> 	shr	edi, 1
  2969 000147ED 39CF                <1> 	cmp	edi, ecx
  2970 000147EF 7302                <1> 	jnb	short gcd_0
  2971 000147F1 89F9                <1> 	mov	ecx, edi
  2972                              <1> gcd_0:
  2973 000147F3 803D[B1890100]03    <1> 	cmp	byte [audio_device], 3
  2974 000147FA 7231                <1> 	jb	short ac97_current_sound_data ; = 2
  2975                              <1> 	; = 3
  2976                              <1> vt8233_current_sound_data:
  2977                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  2978                              <1> 	; 22/06/2017
  2979                              <1> 	; 21/06/2017
  2980                              <1> 	; get current sound (PCM out) data for graphics
  2981                              <1> 	; (for VT 8233, VT 8237R)
  2982                              <1> 	; ebx = Physical address (on page boundary)
  2983                              <1> 	; ecx = Byte count
  2984                              <1> 	; [audio_buff_size]
  2985                              <1> 	
  2986                              <1> 	;;mov	edi, [audio_buff_size]
  2987                              <1> 	;mov	edi, [audio_dmabuff_size]
  2988                              <1> 	;mov	esi, [audio_dma_buff]
  2989                              <1> 	;shr	edi, 1
  2990                              <1> 	;cmp	edi, ecx
  2991                              <1> 	;jnb	short vt8233_gcd_1
  2992                              <1> 	;mov	ecx, edi
  2993                              <1> vt8233_gcd_1:
  2994                              <1> 	;mov	edx, VIA_REG_OFFSET_CURR_COUNT
  2995                              <1> 	; 06/08/2022
  2996 000147FC 31D2                <1> 	xor	edx, edx
  2997 000147FE B20C                <1> 	mov	dl, VIA_REG_OFFSET_CURR_COUNT
  2998 00014800 E8E8F5FFFF          <1> 	call	ctrl_io_r32
  2999 00014805 89C2                <1> 	mov	edx, eax ; remain count (bits 23-0),
  3000                              <1> 			 ; SGD index (bits 31-24) 
  3001 00014807 81E200000001        <1> 	and	edx, 1000000h ; SGD index (0 = 1st half)
  3002 0001480D 7402                <1> 	jz	short vt8233_gcd_2
  3003                              <1> 	; the second half of DMA buffer
  3004 0001480F 01FE                <1> 	add	esi, edi 
  3005                              <1> vt8233_gcd_2:	
  3006 00014811 25FFFFFF00          <1> 	and	eax, 0FFFFFFh ; bits 23-0
  3007                              <1> ac97_gcd_2:
  3008                              <1> sb16_gcd_2:
  3009 00014816 39C8                <1> 	cmp	eax, ecx
  3010 00014818 7302                <1> 	jnb	short vt8233_gcd_3 
  3011                              <1> 	; remain count < graphics bytes
  3012 0001481A 89C8                <1> 	mov	eax, ecx ; fix remain count to data size
  3013                              <1> vt8233_gcd_3:
  3014 0001481C 29C7                <1> 	sub	edi, eax
  3015 0001481E 7602                <1> 	jna	short vt8233_gcd_4
  3016 00014820 01FE                <1> 	add	esi, edi ; dma buffer offset
  3017                              <1> vt8233_gcd_4:
  3018 00014822 89DF                <1> 	mov	edi, ebx ; buffer address (for graphics) 
  3019 00014824 890D[1C010300]      <1> 	mov	[u.r0], ecx
  3020 0001482A F3A4                <1> 	rep	movsb
  3021                              <1> vt8233_gcd_5:
  3022 0001482C C3                  <1> 	retn
  3023                              <1> 
  3024                              <1> ac97_current_sound_data:
  3025                              <1> 	; 23/06/2017
  3026                              <1> 	; 22/06/2017
  3027                              <1> 	; get current sound (PCM out) data for graphics
  3028                              <1> 	; (for AC'97, ICH)
  3029                              <1> 	; ebx = Physical address (on page boundary)
  3030                              <1> 	; ecx = Byte count
  3031                              <1> 	; [audio_buff_size]
  3032                              <1> 	
  3033                              <1> 	;;mov	edi, [audio_buff_size]
  3034                              <1> 	;mov	edi, [audio_dmabuff_size]
  3035                              <1> 	;mov	esi, [audio_dma_buff]
  3036                              <1> 	;shr	edi, 1
  3037                              <1> 	;cmp	edi, ecx
  3038                              <1> 	;jnb	short ac97_gcd_0
  3039                              <1> 	;mov	ecx, edi
  3040                              <1> ac97_gcd_0:
  3041 0001482D 66BA1400            <1> 	mov	dx, PO_CIV_REG ; Position In Current Buff Reg
  3042 00014831 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  3043 00014838 EC                  <1> 	in	al, dx ; current index value
  3044 00014839 A801                <1> 	test	al, 1
  3045 0001483B 7402                <1> 	jz	short ac97_gcd_1
  3046 0001483D 01FE                <1> 	add	esi, edi
  3047                              <1> ac97_gcd_1:
  3048 0001483F 31C0                <1> 	xor	eax, eax
  3049 00014841 66BA1800            <1> 	mov	dx, PO_PICB_REG ; Position In Current Buff Reg
  3050 00014845 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  3051 0001484C 66ED                <1> 	in	ax, dx ; remain dwords
  3052 0001484E C1E002              <1> 	shl	eax, 2 ; remain bytes ; 23/06/2017 
  3053 00014851 EBC3                <1> 	jmp	short ac97_gcd_2
  3054                              <1> ;	cmp	eax, ecx
  3055                              <1> ;	jnb	short ac97_gcd_2 
  3056                              <1> ;	; remain count < graphics bytes
  3057                              <1> ;	mov	eax, ecx ; fix remain count to data size
  3058                              <1> ;ac97_gcd_2:	
  3059                              <1> ;	sub	edi, eax
  3060                              <1> ;	jna	short ac97_gcd_3
  3061                              <1> ;	add	esi, edi ; dma buffer offset
  3062                              <1> ;ac97_gcd_3:
  3063                              <1> ;	mov	edi, ebx ; buffer address (for graphics) 
  3064                              <1> ;	mov	[u.r0], ecx
  3065                              <1> ;	rep	movsb
  3066                              <1> ;	retn
  3067                              <1> 
  3068                              <1> sb16_get_dma_buff_off:
  3069                              <1> 	; 28/10/2017
  3070                              <1> 	; 24/06/2017
  3071                              <1> 	; 22/06/2017
  3072                              <1> 	; get current (PCM OUT DMA buffer) pointer
  3073                              <1> 	; (for Sound Blaster 16)
  3074                              <1> 
  3075                              <1> 	;mov	ecx, [audio_dmabuff_size]
  3076                              <1> 	;xor	ebx, ebx
  3077                              <1> 	;shr	ecx, 1
  3078                              <1> sb16_gdmabo_0:
  3079                              <1> 	; 28/10/2017
  3080 00014853 803D[E0890100]10    <1> 	cmp	byte [audio_bps], 16
  3081 0001485A 750F                <1> 	jne	short sb16_gdmabo_1 ; 8 bit DMA channel
  3082                              <1> 	; 16 bit DMA channel
  3083 0001485C E4C6                <1> 	in	al, 0C6h ; DMA channel 5 count register
  3084 0001485E 88C2                <1> 	mov	dl, al	
  3085 00014860 E4C6                <1> 	in	al, 0C6h
  3086 00014862 88C6                <1> 	mov     dh, al
  3087 00014864 0FB7C2              <1> 	movzx	eax, dx
  3088 00014867 D1E0                <1> 	shl	eax, 1 ; word count -> byte count
  3089 00014869 EB3C                <1> 	jmp	short sb16_gdmabo_2	
  3090                              <1> sb16_gdmabo_1:
  3091 0001486B E403                <1> 	in	al, 03h ; DMA channel 1 count register
  3092 0001486D 88C2                <1> 	mov	dl, al	
  3093 0001486F E403                <1> 	in	al, 03h
  3094 00014871 88C6                <1> 	mov     dh, al
  3095 00014873 0FB7C2              <1> 	movzx	eax, dx
  3096 00014876 EB2F                <1> 	jmp	short sb16_gdmabo_2
  3097                              <1> 
  3098                              <1> get_dma_buffer_offset:
  3099                              <1> 	; 24/06/2017
  3100                              <1> 	; 22/06/2017
  3101                              <1> 	; get current sound (PCM out) data for graphics
  3102                              <1> 	;
  3103                              <1> 	; ebx = Physical address (on page boundary)
  3104                              <1> 	; ecx = Byte count
  3105                              <1> 	; [audio_buff_size]
  3106                              <1> 
  3107 00014878 8B0D[D4890100]      <1> 	mov	ecx, [audio_dmabuff_size]
  3108 0001487E 31DB                <1> 	xor	ebx, ebx
  3109                              <1> gdmabo_0:
  3110 00014880 803D[B1890100]02    <1> 	cmp	byte [audio_device], 2
  3111 00014887 72CA                <1> 	jb	short sb16_get_dma_buff_off
  3112 00014889 7429                <1> 	je	short ac97_get_dma_buff_off
  3113                              <1> 
  3114                              <1> vt8233_get_dma_buff_off:
  3115                              <1> 	; 06/08/2022 - TRDOS 386 v2.0.5
  3116                              <1> 	; 24/06/2017
  3117                              <1> 	; 22/06/2017
  3118                              <1> 	; get current (PCM OUT DMA buffer) pointer
  3119                              <1> 	; (for VT 8233, VT 8237R)
  3120                              <1> 	
  3121                              <1> 	;mov	ecx, [audio_dmabuff_size]
  3122                              <1> 	;xor	ebx, ebx
  3123 0001488B D1E9                <1> 	shr	ecx, 1
  3124                              <1> vt8233_gdmabo_0:
  3125                              <1> 	;mov	edx, VIA_REG_OFFSET_CURR_COUNT
  3126                              <1> 	; 06/08/2022
  3127 0001488D 31D2                <1> 	xor	edx, edx
  3128 0001488F B20C                <1> 	mov	dl, VIA_REG_OFFSET_CURR_COUNT
  3129 00014891 E857F5FFFF          <1> 	call	ctrl_io_r32
  3130 00014896 89C2                <1> 	mov	edx, eax ; remain count (bits 23-0),
  3131                              <1> 			 ; SGD index (bits 31-24) 
  3132 00014898 81E200000001        <1> 	and	edx, 1000000h ; SGD index (0 = 1st half)
  3133 0001489E 7402                <1> 	jz	short vt8233_gdmabo_1
  3134                              <1> 	; the second half of DMA buffer
  3135 000148A0 89CB                <1> 	mov	ebx, ecx 
  3136                              <1> vt8233_gdmabo_1:	
  3137 000148A2 25FFFFFF00          <1> 	and	eax, 0FFFFFFh ; bits 23-0
  3138                              <1> sb16_gdmabo_2:
  3139                              <1> ac97_gdmabo_2:
  3140 000148A7 29C1                <1> 	sub	ecx, eax
  3141 000148A9 7602                <1> 	jna	short vt8233_gdmabo_2
  3142 000148AB 01CB                <1> 	add	ebx, ecx ; dma buffer offset
  3143                              <1> vt8233_gdmabo_2:
  3144 000148AD 891D[1C010300]      <1> 	mov	[u.r0], ebx
  3145 000148B3 C3                  <1> 	retn
  3146                              <1> 
  3147                              <1> ac97_get_dma_buff_off:
  3148                              <1> 	; 24/06/2017
  3149                              <1> 	; 22/06/2017
  3150                              <1> 	; get current (PCM OUT DMA buffer) pointer
  3151                              <1> 	; (for AC'97, ICH)
  3152                              <1> 	; ebx = Physical address (on page boundary)
  3153                              <1> 	; ecx = Byte count
  3154                              <1> 	; [audio_buff_size]
  3155                              <1> 	
  3156                              <1> 	;mov	ecx, [audio_dmabuff_size]
  3157                              <1> 	;xor	ebx, ebx
  3158 000148B4 D1E9                <1> 	shr	ecx, 1
  3159                              <1> ac97_gdmabo_0:
  3160 000148B6 66BA1400            <1> 	mov	dx, PO_CIV_REG ; Position In Current Buff Reg
  3161 000148BA 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  3162 000148C1 EC                  <1> 	in	al, dx ; current index value
  3163 000148C2 A801                <1> 	test	al, 1
  3164 000148C4 7402                <1> 	jz	short ac97_gdmabo_1
  3165 000148C6 89CB                <1> 	mov	ebx, ecx
  3166                              <1> ac97_gdmabo_1:
  3167 000148C8 31C0                <1> 	xor	eax, eax
  3168 000148CA 66BA1800            <1> 	mov	dx, PO_PICB_REG ; Position In Current Buff Reg
  3169 000148CE 660315[EA890100]    <1> 	add	dx, [NABMBAR]
  3170 000148D5 66ED                <1> 	in	ax, dx ; remain dwords
  3171 000148D7 EBCE                <1> 	jmp	short ac97_gdmabo_2
  3587                                  
  3588 000148D9 90<rep 3h>              align 4
  3589                                  
  3590                                  %include 'vgadata.s' ; 04/07/2016
     1                              <1> ; ****************************************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3 - vgadata.s  (palette and font data)
     3                              <1> ; -----------------------------------------------------------------------------
     4                              <1> ; Last Update: 01/01/2021
     5                              <1> ; -----------------------------------------------------------------------------
     6                              <1> ; Beginning: 16/01/2016
     7                              <1> ; -----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; -----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Plex86/Bochs VGABios' source code, vgabios-0.7a (2011)
    14                              <1> ; by the LGPL VGABios Developers Team (2001-2008), 'vgatables.h'
    15                              <1> ;
    16                              <1> ; Oracle VirtualBox 5.0.24 VGABios Source Code 
    17                              <1> ; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
    18                              <1> ;
    19                              <1> ; Palette and font data in assembly language format:
    20                              <1> ; 'VBoxVgaBiosAlternative.asm'
    21                              <1> 
    22                              <1> ; ****************************************************************************************************
    23                              <1> 
    24                              <1> ; 25/11/2020 (TRDOS 386 v2.0.3)
    25                              <1> ; ('vgatables.h' - 30/12/2019 - vruppert)
    26                              <1>  
    27                              <1> ; 04/07/2016
    28                              <1> ; COLOR DATA
    29                              <1> 
    30                              <1> palette0: ; (63+1)*3
    31 000148DC 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
    31 000148E5 00000000000000      <1>
    32 000148EC 00000000000000002A- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    32 000148F5 2A2A2A2A2A2A2A      <1>
    33 000148FC 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    33 00014905 2A2A2A2A2A2A2A      <1>
    34 0001490C 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    34 00014915 2A2A2A2A2A2A2A      <1>
    35 0001491C 2A2A2A2A2A2A2A2A3F- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    35 00014925 3F3F3F3F3F3F3F      <1>
    36 0001492C 3F3F3F3F3F3F3F3F3F- <1>     db  03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    36 00014935 3F3F3F3F3F3F3F      <1>
    37 0001493C 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
    37 00014945 00000000000000      <1>
    38 0001494C 00000000000000002A- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    38 00014955 2A2A2A2A2A2A2A      <1>
    39 0001495C 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    39 00014965 2A2A2A2A2A2A2A      <1>
    40 0001496C 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    40 00014975 2A2A2A2A2A2A2A      <1>
    41 0001497C 2A2A2A2A2A2A2A2A3F- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    41 00014985 3F3F3F3F3F3F3F      <1>
    42 0001498C 3F3F3F3F3F3F3F3F3F- <1>     db  03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    42 00014995 3F3F3F3F3F3F3F      <1>
    43                              <1> palette1: ; (63+1)*3	
    44 0001499C 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    44 000149A5 002A2A2A00002A      <1>
    45 000149AC 002A2A15002A2A2A00- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah
    45 000149B5 000000002A002A      <1>
    46 000149BC 00002A2A2A00002A00- <1>     db  000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah, 000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah
    46 000149C5 2A2A15002A2A2A      <1>
    47 000149CC 15151515153F153F15- <1>     db  015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh, 015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh
    47 000149D5 153F3F3F15153F      <1>
    48 000149DC 153F3F3F153F3F3F15- <1>     db  015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    48 000149E5 151515153F153F      <1>
    49 000149EC 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    49 000149F5 3F3F3F153F3F3F      <1>
    50 000149FC 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    50 00014A05 002A2A2A00002A      <1>
    51 00014A0C 002A2A15002A2A2A00- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah
    51 00014A15 000000002A002A      <1>
    52 00014A1C 00002A2A2A00002A00- <1>     db  000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah, 000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah
    52 00014A25 2A2A15002A2A2A      <1>
    53 00014A2C 15151515153F153F15- <1>     db  015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh, 015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh
    53 00014A35 153F3F3F15153F      <1>
    54 00014A3C 153F3F3F153F3F3F15- <1>     db  015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    54 00014A45 151515153F153F      <1>
    55 00014A4C 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    55 00014A55 3F3F3F153F3F3F      <1>
    56                              <1> palette2: ; (63+1)*3
    57 00014A5C 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    57 00014A65 002A2A2A00002A      <1>
    58 00014A6C 002A2A2A002A2A2A00- <1>     db  000h, 02ah, 02ah, 02ah, 000h, 02ah, 02ah, 02ah, 000h, 000h, 015h, 000h, 000h, 03fh, 000h, 02ah
    58 00014A75 001500003F002A      <1>
    59 00014A7C 15002A3F2A00152A00- <1>     db  015h, 000h, 02ah, 03fh, 02ah, 000h, 015h, 02ah, 000h, 03fh, 02ah, 02ah, 015h, 02ah, 02ah, 03fh
    59 00014A85 3F2A2A152A2A3F      <1>
    60 00014A8C 00150000152A003F00- <1>     db  000h, 015h, 000h, 000h, 015h, 02ah, 000h, 03fh, 000h, 000h, 03fh, 02ah, 02ah, 015h, 000h, 02ah
    60 00014A95 003F2A2A15002A      <1>
    61 00014A9C 152A2A3F002A3F2A00- <1>     db  015h, 02ah, 02ah, 03fh, 000h, 02ah, 03fh, 02ah, 000h, 015h, 015h, 000h, 015h, 03fh, 000h, 03fh
    61 00014AA5 151500153F003F      <1>
    62 00014AAC 15003F3F2A15152A15- <1>     db  015h, 000h, 03fh, 03fh, 02ah, 015h, 015h, 02ah, 015h, 03fh, 02ah, 03fh, 015h, 02ah, 03fh, 03fh
    62 00014AB5 3F2A3F152A3F3F      <1>
    63 00014ABC 15000015002A152A00- <1>     db  015h, 000h, 000h, 015h, 000h, 02ah, 015h, 02ah, 000h, 015h, 02ah, 02ah, 03fh, 000h, 000h, 03fh
    63 00014AC5 152A2A3F00003F      <1>
    64 00014ACC 002A3F2A003F2A2A15- <1>     db  000h, 02ah, 03fh, 02ah, 000h, 03fh, 02ah, 02ah, 015h, 000h, 015h, 015h, 000h, 03fh, 015h, 02ah
    64 00014AD5 001515003F152A      <1>
    65 00014ADC 15152A3F3F00153F00- <1>     db  015h, 015h, 02ah, 03fh, 03fh, 000h, 015h, 03fh, 000h, 03fh, 03fh, 02ah, 015h, 03fh, 02ah, 03fh
    65 00014AE5 3F3F2A153F2A3F      <1>
    66 00014AEC 15150015152A153F00- <1>     db  015h, 015h, 000h, 015h, 015h, 02ah, 015h, 03fh, 000h, 015h, 03fh, 02ah, 03fh, 015h, 000h, 03fh
    66 00014AF5 153F2A3F15003F      <1>
    67 00014AFC 152A3F3F003F3F2A15- <1>     db  015h, 02ah, 03fh, 03fh, 000h, 03fh, 03fh, 02ah, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    67 00014B05 151515153F153F      <1>
    68 00014B0C 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    68 00014B15 3F3F3F153F3F3F      <1>
    69                              <1> palette3: ; 256*3
    70 00014B1C 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    70 00014B25 002A2A2A00002A      <1>
    71 00014B2C 002A2A15002A2A2A15- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    71 00014B35 151515153F153F      <1>
    72 00014B3C 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    72 00014B45 3F3F3F153F3F3F      <1>
    73 00014B4C 000000050505080808- <1>     db  000h, 000h, 000h, 005h, 005h, 005h, 008h, 008h, 008h, 00bh, 00bh, 00bh, 00eh, 00eh, 00eh, 011h
    73 00014B55 0B0B0B0E0E0E11      <1>
    74 00014B5C 11111414141818181C- <1>     db  011h, 011h, 014h, 014h, 014h, 018h, 018h, 018h, 01ch, 01ch, 01ch, 020h, 020h, 020h, 024h, 024h
    74 00014B65 1C1C2020202424      <1>
    75 00014B6C 242828282D2D2D3232- <1>     db  024h, 028h, 028h, 028h, 02dh, 02dh, 02dh, 032h, 032h, 032h, 038h, 038h, 038h, 03fh, 03fh, 03fh
    75 00014B75 323838383F3F3F      <1>
    76 00014B7C 00003F10003F1F003F- <1>     db  000h, 000h, 03fh, 010h, 000h, 03fh, 01fh, 000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h, 03fh, 03fh
    76 00014B85 2F003F3F003F3F      <1>
    77 00014B8C 002F3F001F3F00103F- <1>     db  000h, 02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 000h, 000h, 03fh, 010h, 000h, 03fh, 01fh
    77 00014B95 00003F10003F1F      <1>
    78 00014B9C 003F2F003F3F002F3F- <1>     db  000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h, 02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 000h
    78 00014BA5 001F3F00103F00      <1>
    79 00014BAC 003F00003F10003F1F- <1>     db  000h, 03fh, 000h, 000h, 03fh, 010h, 000h, 03fh, 01fh, 000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h
    79 00014BB5 003F2F003F3F00      <1>
    80 00014BBC 2F3F001F3F00103F1F- <1>     db  02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh, 02fh, 01fh
    80 00014BC5 1F3F271F3F2F1F      <1>
    81 00014BCC 3F371F3F3F1F3F3F1F- <1>     db  03fh, 037h, 01fh, 03fh, 03fh, 01fh, 03fh, 03fh, 01fh, 037h, 03fh, 01fh, 02fh, 03fh, 01fh, 027h
    81 00014BD5 373F1F2F3F1F27      <1>
    82 00014BDC 3F1F1F3F271F3F2F1F- <1>     db  03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh, 02fh, 01fh, 03fh, 037h, 01fh, 03fh, 03fh, 01fh, 037h
    82 00014BE5 3F371F3F3F1F37      <1>
    83 00014BEC 3F1F2F3F1F273F1F1F- <1>     db  03fh, 01fh, 02fh, 03fh, 01fh, 027h, 03fh, 01fh, 01fh, 03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh
    83 00014BF5 3F1F1F3F271F3F      <1>
    84 00014BFC 2F1F3F371F3F3F1F37- <1>     db  02fh, 01fh, 03fh, 037h, 01fh, 03fh, 03fh, 01fh, 037h, 03fh, 01fh, 02fh, 03fh, 01fh, 027h, 03fh
    84 00014C05 3F1F2F3F1F273F      <1>
    85 00014C0C 2D2D3F312D3F362D3F- <1>     db  02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h, 02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh, 03fh, 03fh
    85 00014C15 3A2D3F3F2D3F3F      <1>
    86 00014C1C 2D3A3F2D363F2D313F- <1>     db  02dh, 03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h
    86 00014C25 2D2D3F312D3F36      <1>
    87 00014C2C 2D3F3A2D3F3F2D3A3F- <1>     db  02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh, 03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 02dh
    87 00014C35 2D363F2D313F2D      <1>
    88 00014C3C 2D3F2D2D3F312D3F36- <1>     db  02dh, 03fh, 02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h, 02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh
    88 00014C45 2D3F3A2D3F3F2D      <1>
    89 00014C4C 3A3F2D363F2D313F00- <1>     db  03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 000h, 000h, 01ch, 007h, 000h, 01ch, 00eh, 000h
    89 00014C55 001C07001C0E00      <1>
    90 00014C5C 1C15001C1C001C1C00- <1>     db  01ch, 015h, 000h, 01ch, 01ch, 000h, 01ch, 01ch, 000h, 015h, 01ch, 000h, 00eh, 01ch, 000h, 007h
    90 00014C65 151C000E1C0007      <1>
    91 00014C6C 1C00001C07001C0E00- <1>     db  01ch, 000h, 000h, 01ch, 007h, 000h, 01ch, 00eh, 000h, 01ch, 015h, 000h, 01ch, 01ch, 000h, 015h
    91 00014C75 1C15001C1C0015      <1>
    92 00014C7C 1C000E1C00071C0000- <1>     db  01ch, 000h, 00eh, 01ch, 000h, 007h, 01ch, 000h, 000h, 01ch, 000h, 000h, 01ch, 007h, 000h, 01ch
    92 00014C85 1C00001C07001C      <1>
    93 00014C8C 0E001C15001C1C0015- <1>     db  00eh, 000h, 01ch, 015h, 000h, 01ch, 01ch, 000h, 015h, 01ch, 000h, 00eh, 01ch, 000h, 007h, 01ch
    93 00014C95 1C000E1C00071C      <1>
    94 00014C9C 0E0E1C110E1C150E1C- <1>     db  00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h, 00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh, 01ch, 01ch
    94 00014CA5 180E1C1C0E1C1C      <1>
    95 00014CAC 0E181C0E151C0E111C- <1>     db  00eh, 018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h
    95 00014CB5 0E0E1C110E1C15      <1>
    96 00014CBC 0E1C180E1C1C0E181C- <1>     db  00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh, 018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 00eh
    96 00014CC5 0E151C0E111C0E      <1>
    97 00014CCC 0E1C0E0E1C110E1C15- <1>     db  00eh, 01ch, 00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h, 00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh
    97 00014CD5 0E1C180E1C1C0E      <1>
    98 00014CDC 181C0E151C0E111C14- <1>     db  018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 014h, 014h, 01ch, 016h, 014h, 01ch, 018h, 014h
    98 00014CE5 141C16141C1814      <1>
    99 00014CEC 1C1A141C1C141C1C14- <1>     db  01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ch, 01ch, 014h, 01ah, 01ch, 014h, 018h, 01ch, 014h, 016h
    99 00014CF5 1A1C14181C1416      <1>
   100 00014CFC 1C14141C16141C1814- <1>     db  01ch, 014h, 014h, 01ch, 016h, 014h, 01ch, 018h, 014h, 01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ah
   100 00014D05 1C1A141C1C141A      <1>
   101 00014D0C 1C14181C14161C1414- <1>     db  01ch, 014h, 018h, 01ch, 014h, 016h, 01ch, 014h, 014h, 01ch, 014h, 014h, 01ch, 016h, 014h, 01ch
   101 00014D15 1C14141C16141C      <1>
   102 00014D1C 18141C1A141C1C141A- <1>     db  018h, 014h, 01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ah, 01ch, 014h, 018h, 01ch, 014h, 016h, 01ch
   102 00014D25 1C14181C14161C      <1>
   103 00014D2C 000010040010080010- <1>     db  000h, 000h, 010h, 004h, 000h, 010h, 008h, 000h, 010h, 00ch, 000h, 010h, 010h, 000h, 010h, 010h
   103 00014D35 0C001010001010      <1>
   104 00014D3C 000C10000810000410- <1>     db  000h, 00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 000h, 000h, 010h, 004h, 000h, 010h, 008h
   104 00014D45 00001004001008      <1>
   105 00014D4C 00100C001010000C10- <1>     db  000h, 010h, 00ch, 000h, 010h, 010h, 000h, 00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 000h
   105 00014D55 00081000041000      <1>
   106 00014D5C 001000001004001008- <1>     db  000h, 010h, 000h, 000h, 010h, 004h, 000h, 010h, 008h, 000h, 010h, 00ch, 000h, 010h, 010h, 000h
   106 00014D65 00100C00101000      <1>
   107 00014D6C 0C1000081000041008- <1>     db  00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 008h, 008h, 010h, 00ah, 008h, 010h, 00ch, 008h
   107 00014D75 08100A08100C08      <1>
   108 00014D7C 100E08101008101008- <1>     db  010h, 00eh, 008h, 010h, 010h, 008h, 010h, 010h, 008h, 00eh, 010h, 008h, 00ch, 010h, 008h, 00ah
   108 00014D85 0E10080C10080A      <1>
   109 00014D8C 100808100A08100C08- <1>     db  010h, 008h, 008h, 010h, 00ah, 008h, 010h, 00ch, 008h, 010h, 00eh, 008h, 010h, 010h, 008h, 00eh
   109 00014D95 100E081010080E      <1>
   110 00014D9C 10080C10080A100808- <1>     db  010h, 008h, 00ch, 010h, 008h, 00ah, 010h, 008h, 008h, 010h, 008h, 008h, 010h, 00ah, 008h, 010h
   110 00014DA5 100808100A0810      <1>
   111 00014DAC 0C08100E081010080E- <1>     db  00ch, 008h, 010h, 00eh, 008h, 010h, 010h, 008h, 00eh, 010h, 008h, 00ch, 010h, 008h, 00ah, 010h
   111 00014DB5 10080C10080A10      <1>
   112 00014DBC 0B0B100C0B100D0B10- <1>     db  00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh, 00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh, 010h, 010h
   112 00014DC5 0F0B10100B1010      <1>
   113 00014DCC 0B0F100B0D100B0C10- <1>     db  00bh, 00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh
   113 00014DD5 0B0B100C0B100D      <1>
   114 00014DDC 0B100F0B10100B0F10- <1>     db  00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh, 00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 00bh
   114 00014DE5 0B0D100B0C100B      <1>
   115 00014DEC 0B100B0B100C0B100D- <1>     db  00bh, 010h, 00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh, 00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh
   115 00014DF5 0B100F0B10100B      <1>
   116 00014DFC 0F100B0D100B0C1000- <1>     db  00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   116 00014E05 00000000000000      <1>
   117 00014E0C 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   117 00014E15 00000000000000      <1>
   118                              <1> 
   119                              <1> 
   120                              <1> ; 04/07/2016
   121                              <1> ; FONT DATA
   122                              <1> 
   123                              <1> CRT_CHAR_GEN:
   124                              <1> vgafont8: 
   125 00014E1C 00000000000000007E- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 081h, 0a5h, 081h, 0bdh, 099h, 081h, 07eh
   125 00014E25 81A581BD99817E      <1>
   126 00014E2C 7EFFDBFFC3E7FF7E6C- <1>     db  07eh, 0ffh, 0dbh, 0ffh, 0c3h, 0e7h, 0ffh, 07eh, 06ch, 0feh, 0feh, 0feh, 07ch, 038h, 010h, 000h
   126 00014E35 FEFEFE7C381000      <1>
   127 00014E3C 10387CFE7C38100038- <1>     db  010h, 038h, 07ch, 0feh, 07ch, 038h, 010h, 000h, 038h, 07ch, 038h, 0feh, 0feh, 07ch, 038h, 07ch
   127 00014E45 7C38FEFE7C387C      <1>
   128 00014E4C 1010387CFE7C387C00- <1>     db  010h, 010h, 038h, 07ch, 0feh, 07ch, 038h, 07ch, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h
   128 00014E55 00183C3C180000      <1>
   129 00014E5C FFFFE7C3C3E7FFFF00- <1>     db  0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h
   129 00014E65 3C664242663C00      <1>
   130 00014E6C FFC399BDBD99C3FF0F- <1>     db  0ffh, 0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 00fh, 007h, 00fh, 07dh, 0cch, 0cch, 0cch, 078h
   130 00014E75 070F7DCCCCCC78      <1>
   131 00014E7C 3C6666663C187E183F- <1>     db  03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 018h, 03fh, 033h, 03fh, 030h, 030h, 070h, 0f0h, 0e0h
   131 00014E85 333F303070F0E0      <1>
   132 00014E8C 7F637F636367E6C099- <1>     db  07fh, 063h, 07fh, 063h, 063h, 067h, 0e6h, 0c0h, 099h, 05ah, 03ch, 0e7h, 0e7h, 03ch, 05ah, 099h
   132 00014E95 5A3CE7E73C5A99      <1>
   133 00014E9C 80E0F8FEF8E0800002- <1>     db  080h, 0e0h, 0f8h, 0feh, 0f8h, 0e0h, 080h, 000h, 002h, 00eh, 03eh, 0feh, 03eh, 00eh, 002h, 000h
   133 00014EA5 0E3EFE3E0E0200      <1>
   134 00014EAC 183C7E18187E3C1866- <1>     db  018h, 03ch, 07eh, 018h, 018h, 07eh, 03ch, 018h, 066h, 066h, 066h, 066h, 066h, 000h, 066h, 000h
   134 00014EB5 66666666006600      <1>
   135 00014EBC 7FDBDB7B1B1B1B003E- <1>     db  07fh, 0dbh, 0dbh, 07bh, 01bh, 01bh, 01bh, 000h, 03eh, 063h, 038h, 06ch, 06ch, 038h, 0cch, 078h
   135 00014EC5 63386C6C38CC78      <1>
   136 00014ECC 000000007E7E7E0018- <1>     db  000h, 000h, 000h, 000h, 07eh, 07eh, 07eh, 000h, 018h, 03ch, 07eh, 018h, 07eh, 03ch, 018h, 0ffh
   136 00014ED5 3C7E187E3C18FF      <1>
   137 00014EDC 183C7E181818180018- <1>     db  018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h
   137 00014EE5 1818187E3C1800      <1>
   138 00014EEC 00180CFE0C18000000- <1>     db  000h, 018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 030h, 060h, 0feh, 060h, 030h, 000h, 000h
   138 00014EF5 3060FE60300000      <1>
   139 00014EFC 0000C0C0C0FE000000- <1>     db  000h, 000h, 0c0h, 0c0h, 0c0h, 0feh, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h
   139 00014F05 2466FF66240000      <1>
   140 00014F0C 00183C7EFFFF000000- <1>     db  000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 000h, 000h, 000h, 0ffh, 0ffh, 07eh, 03ch, 018h, 000h, 000h
   140 00014F15 FFFF7E3C180000      <1>
   141 00014F1C 000000000000000030- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 030h, 078h, 078h, 030h, 030h, 000h, 030h, 000h
   141 00014F25 78783030003000      <1>
   142 00014F2C 6C6C6C00000000006C- <1>     db  06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch, 0feh, 06ch, 06ch, 000h
   142 00014F35 6CFE6CFE6C6C00      <1>
   143 00014F3C 307CC0780CF8300000- <1>     db  030h, 07ch, 0c0h, 078h, 00ch, 0f8h, 030h, 000h, 000h, 0c6h, 0cch, 018h, 030h, 066h, 0c6h, 000h
   143 00014F45 C6CC183066C600      <1>
   144 00014F4C 386C3876DCCC760060- <1>     db  038h, 06ch, 038h, 076h, 0dch, 0cch, 076h, 000h, 060h, 060h, 0c0h, 000h, 000h, 000h, 000h, 000h
   144 00014F55 60C00000000000      <1>
   145 00014F5C 183060606030180060- <1>     db  018h, 030h, 060h, 060h, 060h, 030h, 018h, 000h, 060h, 030h, 018h, 018h, 018h, 030h, 060h, 000h
   145 00014F65 30181818306000      <1>
   146 00014F6C 00663CFF3C66000000- <1>     db  000h, 066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 030h, 030h, 0fch, 030h, 030h, 000h, 000h
   146 00014F75 3030FC30300000      <1>
   147 00014F7C 000000000030306000- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 030h, 060h, 000h, 000h, 000h, 0fch, 000h, 000h, 000h, 000h
   147 00014F85 0000FC00000000      <1>
   148 00014F8C 000000000030300006- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 030h, 000h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h
   148 00014F95 0C183060C08000      <1>
   149 00014F9C 7CC6CEDEF6E67C0030- <1>     db  07ch, 0c6h, 0ceh, 0deh, 0f6h, 0e6h, 07ch, 000h, 030h, 070h, 030h, 030h, 030h, 030h, 0fch, 000h
   149 00014FA5 7030303030FC00      <1>
   150 00014FAC 78CC0C3860CCFC0078- <1>     db  078h, 0cch, 00ch, 038h, 060h, 0cch, 0fch, 000h, 078h, 0cch, 00ch, 038h, 00ch, 0cch, 078h, 000h
   150 00014FB5 CC0C380CCC7800      <1>
   151 00014FBC 1C3C6CCCFE0C1E00FC- <1>     db  01ch, 03ch, 06ch, 0cch, 0feh, 00ch, 01eh, 000h, 0fch, 0c0h, 0f8h, 00ch, 00ch, 0cch, 078h, 000h
   151 00014FC5 C0F80C0CCC7800      <1>
   152 00014FCC 3860C0F8CCCC7800FC- <1>     db  038h, 060h, 0c0h, 0f8h, 0cch, 0cch, 078h, 000h, 0fch, 0cch, 00ch, 018h, 030h, 030h, 030h, 000h
   152 00014FD5 CC0C1830303000      <1>
   153 00014FDC 78CCCC78CCCC780078- <1>     db  078h, 0cch, 0cch, 078h, 0cch, 0cch, 078h, 000h, 078h, 0cch, 0cch, 07ch, 00ch, 018h, 070h, 000h
   153 00014FE5 CCCC7C0C187000      <1>
   154 00014FEC 003030000030300000- <1>     db  000h, 030h, 030h, 000h, 000h, 030h, 030h, 000h, 000h, 030h, 030h, 000h, 000h, 030h, 030h, 060h
   154 00014FF5 30300000303060      <1>
   155 00014FFC 183060C06030180000- <1>     db  018h, 030h, 060h, 0c0h, 060h, 030h, 018h, 000h, 000h, 000h, 0fch, 000h, 000h, 0fch, 000h, 000h
   155 00015005 00FC0000FC0000      <1>
   156 0001500C 6030180C1830600078- <1>     db  060h, 030h, 018h, 00ch, 018h, 030h, 060h, 000h, 078h, 0cch, 00ch, 018h, 030h, 000h, 030h, 000h
   156 00015015 CC0C1830003000      <1>
   157 0001501C 7CC6DEDEDEC0780030- <1>     db  07ch, 0c6h, 0deh, 0deh, 0deh, 0c0h, 078h, 000h, 030h, 078h, 0cch, 0cch, 0fch, 0cch, 0cch, 000h
   157 00015025 78CCCCFCCCCC00      <1>
   158 0001502C FC66667C6666FC003C- <1>     db  0fch, 066h, 066h, 07ch, 066h, 066h, 0fch, 000h, 03ch, 066h, 0c0h, 0c0h, 0c0h, 066h, 03ch, 000h
   158 00015035 66C0C0C0663C00      <1>
   159 0001503C F86C6666666CF800FE- <1>     db  0f8h, 06ch, 066h, 066h, 066h, 06ch, 0f8h, 000h, 0feh, 062h, 068h, 078h, 068h, 062h, 0feh, 000h
   159 00015045 6268786862FE00      <1>
   160 0001504C FE6268786860F0003C- <1>     db  0feh, 062h, 068h, 078h, 068h, 060h, 0f0h, 000h, 03ch, 066h, 0c0h, 0c0h, 0ceh, 066h, 03eh, 000h
   160 00015055 66C0C0CE663E00      <1>
   161 0001505C CCCCCCFCCCCCCC0078- <1>     db  0cch, 0cch, 0cch, 0fch, 0cch, 0cch, 0cch, 000h, 078h, 030h, 030h, 030h, 030h, 030h, 078h, 000h
   161 00015065 30303030307800      <1>
   162 0001506C 1E0C0C0CCCCC7800E6- <1>     db  01eh, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 000h, 0e6h, 066h, 06ch, 078h, 06ch, 066h, 0e6h, 000h
   162 00015075 666C786C66E600      <1>
   163 0001507C F06060606266FE00C6- <1>     db  0f0h, 060h, 060h, 060h, 062h, 066h, 0feh, 000h, 0c6h, 0eeh, 0feh, 0feh, 0d6h, 0c6h, 0c6h, 000h
   163 00015085 EEFEFED6C6C600      <1>
   164 0001508C C6E6F6DECEC6C60038- <1>     db  0c6h, 0e6h, 0f6h, 0deh, 0ceh, 0c6h, 0c6h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h
   164 00015095 6CC6C6C66C3800      <1>
   165 0001509C FC66667C6060F00078- <1>     db  0fch, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h, 078h, 0cch, 0cch, 0cch, 0dch, 078h, 01ch, 000h
   165 000150A5 CCCCCCDC781C00      <1>
   166 000150AC FC66667C6C66E60078- <1>     db  0fch, 066h, 066h, 07ch, 06ch, 066h, 0e6h, 000h, 078h, 0cch, 0e0h, 070h, 01ch, 0cch, 078h, 000h
   166 000150B5 CCE0701CCC7800      <1>
   167 000150BC FCB4303030307800CC- <1>     db  0fch, 0b4h, 030h, 030h, 030h, 030h, 078h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 0fch, 000h
   167 000150C5 CCCCCCCCCCFC00      <1>
   168 000150CC CCCCCCCCCC783000C6- <1>     db  0cch, 0cch, 0cch, 0cch, 0cch, 078h, 030h, 000h, 0c6h, 0c6h, 0c6h, 0d6h, 0feh, 0eeh, 0c6h, 000h
   168 000150D5 C6C6D6FEEEC600      <1>
   169 000150DC C6C66C38386CC600CC- <1>     db  0c6h, 0c6h, 06ch, 038h, 038h, 06ch, 0c6h, 000h, 0cch, 0cch, 0cch, 078h, 030h, 030h, 078h, 000h
   169 000150E5 CCCC7830307800      <1>
   170 000150EC FEC68C183266FE0078- <1>     db  0feh, 0c6h, 08ch, 018h, 032h, 066h, 0feh, 000h, 078h, 060h, 060h, 060h, 060h, 060h, 078h, 000h
   170 000150F5 60606060607800      <1>
   171 000150FC C06030180C06020078- <1>     db  0c0h, 060h, 030h, 018h, 00ch, 006h, 002h, 000h, 078h, 018h, 018h, 018h, 018h, 018h, 078h, 000h
   171 00015105 18181818187800      <1>
   172 0001510C 10386CC60000000000- <1>     db  010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   172 00015115 000000000000FF      <1>
   173 0001511C 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 076h, 000h
   173 00015125 00780C7CCC7600      <1>
   174 0001512C E060607C6666DC0000- <1>     db  0e0h, 060h, 060h, 07ch, 066h, 066h, 0dch, 000h, 000h, 000h, 078h, 0cch, 0c0h, 0cch, 078h, 000h
   174 00015135 0078CCC0CC7800      <1>
   175 0001513C 1C0C0C7CCCCC760000- <1>     db  01ch, 00ch, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h
   175 00015145 0078CCFCC07800      <1>
   176 0001514C 386C60F06060F00000- <1>     db  038h, 06ch, 060h, 0f0h, 060h, 060h, 0f0h, 000h, 000h, 000h, 076h, 0cch, 0cch, 07ch, 00ch, 0f8h
   176 00015155 0076CCCC7C0CF8      <1>
   177 0001515C E0606C766666E60030- <1>     db  0e0h, 060h, 06ch, 076h, 066h, 066h, 0e6h, 000h, 030h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   177 00015165 00703030307800      <1>
   178 0001516C 0C000C0C0CCCCC78E0- <1>     db  00ch, 000h, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 0e0h, 060h, 066h, 06ch, 078h, 06ch, 0e6h, 000h
   178 00015175 60666C786CE600      <1>
   179 0001517C 703030303030780000- <1>     db  070h, 030h, 030h, 030h, 030h, 030h, 078h, 000h, 000h, 000h, 0cch, 0feh, 0feh, 0d6h, 0c6h, 000h
   179 00015185 00CCFEFED6C600      <1>
   180 0001518C 0000F8CCCCCCCC0000- <1>     db  000h, 000h, 0f8h, 0cch, 0cch, 0cch, 0cch, 000h, 000h, 000h, 078h, 0cch, 0cch, 0cch, 078h, 000h
   180 00015195 0078CCCCCC7800      <1>
   181 0001519C 0000DC66667C60F000- <1>     db  000h, 000h, 0dch, 066h, 066h, 07ch, 060h, 0f0h, 000h, 000h, 076h, 0cch, 0cch, 07ch, 00ch, 01eh
   181 000151A5 0076CCCC7C0C1E      <1>
   182 000151AC 0000DC766660F00000- <1>     db  000h, 000h, 0dch, 076h, 066h, 060h, 0f0h, 000h, 000h, 000h, 07ch, 0c0h, 078h, 00ch, 0f8h, 000h
   182 000151B5 007CC0780CF800      <1>
   183 000151BC 10307C303034180000- <1>     db  010h, 030h, 07ch, 030h, 030h, 034h, 018h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 076h, 000h
   183 000151C5 00CCCCCCCC7600      <1>
   184 000151CC 0000CCCCCC78300000- <1>     db  000h, 000h, 0cch, 0cch, 0cch, 078h, 030h, 000h, 000h, 000h, 0c6h, 0d6h, 0feh, 0feh, 06ch, 000h
   184 000151D5 00C6D6FEFE6C00      <1>
   185 000151DC 0000C66C386CC60000- <1>     db  000h, 000h, 0c6h, 06ch, 038h, 06ch, 0c6h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 07ch, 00ch, 0f8h
   185 000151E5 00CCCCCC7C0CF8      <1>
   186 000151EC 0000FC983064FC001C- <1>     db  000h, 000h, 0fch, 098h, 030h, 064h, 0fch, 000h, 01ch, 030h, 030h, 0e0h, 030h, 030h, 01ch, 000h
   186 000151F5 3030E030301C00      <1>
   187 000151FC 1818180018181800E0- <1>     db  018h, 018h, 018h, 000h, 018h, 018h, 018h, 000h, 0e0h, 030h, 030h, 01ch, 030h, 030h, 0e0h, 000h
   187 00015205 30301C3030E000      <1>
   188 0001520C 76DC00000000000000- <1>     db  076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 000h
   188 00015215 10386CC6C6FE00      <1>
   189 0001521C 78CCC0CC78180C7800- <1>     db  078h, 0cch, 0c0h, 0cch, 078h, 018h, 00ch, 078h, 000h, 0cch, 000h, 0cch, 0cch, 0cch, 07eh, 000h
   189 00015225 CC00CCCCCC7E00      <1>
   190 0001522C 1C0078CCFCC078007E- <1>     db  01ch, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h, 07eh, 0c3h, 03ch, 006h, 03eh, 066h, 03fh, 000h
   190 00015235 C33C063E663F00      <1>
   191 0001523C CC00780C7CCC7E00E0- <1>     db  0cch, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 0e0h, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h
   191 00015245 00780C7CCC7E00      <1>
   192 0001524C 3030780C7CCC7E0000- <1>     db  030h, 030h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 000h, 000h, 078h, 0c0h, 0c0h, 078h, 00ch, 038h
   192 00015255 0078C0C0780C38      <1>
   193 0001525C 7EC33C667E603C00CC- <1>     db  07eh, 0c3h, 03ch, 066h, 07eh, 060h, 03ch, 000h, 0cch, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h
   193 00015265 0078CCFCC07800      <1>
   194 0001526C E00078CCFCC07800CC- <1>     db  0e0h, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h, 0cch, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   194 00015275 00703030307800      <1>
   195 0001527C 7CC6381818183C00E0- <1>     db  07ch, 0c6h, 038h, 018h, 018h, 018h, 03ch, 000h, 0e0h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   195 00015285 00703030307800      <1>
   196 0001528C C6386CC6FEC6C60030- <1>     db  0c6h, 038h, 06ch, 0c6h, 0feh, 0c6h, 0c6h, 000h, 030h, 030h, 000h, 078h, 0cch, 0fch, 0cch, 000h
   196 00015295 300078CCFCCC00      <1>
   197 0001529C 1C00FC607860FC0000- <1>     db  01ch, 000h, 0fch, 060h, 078h, 060h, 0fch, 000h, 000h, 000h, 07fh, 00ch, 07fh, 0cch, 07fh, 000h
   197 000152A5 007F0C7FCC7F00      <1>
   198 000152AC 3E6CCCFECCCCCE0078- <1>     db  03eh, 06ch, 0cch, 0feh, 0cch, 0cch, 0ceh, 000h, 078h, 0cch, 000h, 078h, 0cch, 0cch, 078h, 000h
   198 000152B5 CC0078CCCC7800      <1>
   199 000152BC 00CC0078CCCC780000- <1>     db  000h, 0cch, 000h, 078h, 0cch, 0cch, 078h, 000h, 000h, 0e0h, 000h, 078h, 0cch, 0cch, 078h, 000h
   199 000152C5 E00078CCCC7800      <1>
   200 000152CC 78CC00CCCCCC7E0000- <1>     db  078h, 0cch, 000h, 0cch, 0cch, 0cch, 07eh, 000h, 000h, 0e0h, 000h, 0cch, 0cch, 0cch, 07eh, 000h
   200 000152D5 E000CCCCCC7E00      <1>
   201 000152DC 00CC00CCCC7C0CF8C3- <1>     db  000h, 0cch, 000h, 0cch, 0cch, 07ch, 00ch, 0f8h, 0c3h, 018h, 03ch, 066h, 066h, 03ch, 018h, 000h
   201 000152E5 183C66663C1800      <1>
   202 000152EC CC00CCCCCCCC780018- <1>     db  0cch, 000h, 0cch, 0cch, 0cch, 0cch, 078h, 000h, 018h, 018h, 07eh, 0c0h, 0c0h, 07eh, 018h, 018h
   202 000152F5 187EC0C07E1818      <1>
   203 000152FC 386C64F060E6FC00CC- <1>     db  038h, 06ch, 064h, 0f0h, 060h, 0e6h, 0fch, 000h, 0cch, 0cch, 078h, 0fch, 030h, 0fch, 030h, 030h
   203 00015305 CC78FC30FC3030      <1>
   204 0001530C F8CCCCFAC6CFC6C70E- <1>     db  0f8h, 0cch, 0cch, 0fah, 0c6h, 0cfh, 0c6h, 0c7h, 00eh, 01bh, 018h, 03ch, 018h, 018h, 0d8h, 070h
   204 00015315 1B183C1818D870      <1>
   205 0001531C 1C00780C7CCC7E0038- <1>     db  01ch, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 038h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   205 00015325 00703030307800      <1>
   206 0001532C 001C0078CCCC780000- <1>     db  000h, 01ch, 000h, 078h, 0cch, 0cch, 078h, 000h, 000h, 01ch, 000h, 0cch, 0cch, 0cch, 07eh, 000h
   206 00015335 1C00CCCCCC7E00      <1>
   207 0001533C 00F800F8CCCCCC00FC- <1>     db  000h, 0f8h, 000h, 0f8h, 0cch, 0cch, 0cch, 000h, 0fch, 000h, 0cch, 0ech, 0fch, 0dch, 0cch, 000h
   207 00015345 00CCECFCDCCC00      <1>
   208 0001534C 3C6C6C3E007E000038- <1>     db  03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h
   208 00015355 6C6C38007C0000      <1>
   209 0001535C 30003060C0CC780000- <1>     db  030h, 000h, 030h, 060h, 0c0h, 0cch, 078h, 000h, 000h, 000h, 000h, 0fch, 0c0h, 0c0h, 000h, 000h
   209 00015365 0000FCC0C00000      <1>
   210 0001536C 000000FC0C0C0000C3- <1>     db  000h, 000h, 000h, 0fch, 00ch, 00ch, 000h, 000h, 0c3h, 0c6h, 0cch, 0deh, 033h, 066h, 0cch, 00fh
   210 00015375 C6CCDE3366CC0F      <1>
   211 0001537C C3C6CCDB376FCF0318- <1>     db  0c3h, 0c6h, 0cch, 0dbh, 037h, 06fh, 0cfh, 003h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 000h
   211 00015385 18001818181800      <1>
   212 0001538C 003366CC6633000000- <1>     db  000h, 033h, 066h, 0cch, 066h, 033h, 000h, 000h, 000h, 0cch, 066h, 033h, 066h, 0cch, 000h, 000h
   212 00015395 CC663366CC0000      <1>
   213 0001539C 228822882288228855- <1>     db  022h, 088h, 022h, 088h, 022h, 088h, 022h, 088h, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah
   213 000153A5 AA55AA55AA55AA      <1>
   214 000153AC DB77DBEEDB77DBEE18- <1>     db  0dbh, 077h, 0dbh, 0eeh, 0dbh, 077h, 0dbh, 0eeh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   214 000153B5 18181818181818      <1>
   215 000153BC 18181818F818181818- <1>     db  018h, 018h, 018h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h, 018h
   215 000153C5 18F818F8181818      <1>
   216 000153CC 36363636F636363600- <1>     db  036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h
   216 000153D5 000000FE363636      <1>
   217 000153DC 0000F818F818181836- <1>     db  000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h
   217 000153E5 36F606F6363636      <1>
   218 000153EC 363636363636363600- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 0feh, 006h, 0f6h, 036h, 036h, 036h
   218 000153F5 00FE06F6363636      <1>
   219 000153FC 3636F606FE00000036- <1>     db  036h, 036h, 0f6h, 006h, 0feh, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h, 000h
   219 00015405 363636FE000000      <1>
   220 0001540C 1818F818F800000000- <1>     db  018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h
   220 00015415 000000F8181818      <1>
   221 0001541C 181818181F00000018- <1>     db  018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h
   221 00015425 181818FF000000      <1>
   222 0001542C 00000000FF18181818- <1>     db  000h, 000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 018h, 018h
   222 00015435 1818181F181818      <1>
   223 0001543C 00000000FF00000018- <1>     db  000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h
   223 00015445 181818FF181818      <1>
   224 0001544C 18181F181F18181836- <1>     db  018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h
   224 00015455 36363637363636      <1>
   225 0001545C 363637303F00000000- <1>     db  036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h
   225 00015465 003F3037363636      <1>
   226 0001546C 3636F700FF00000000- <1>     db  036h, 036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0f7h, 036h, 036h, 036h
   226 00015475 00FF00F7363636      <1>
   227 0001547C 363637303736363600- <1>     db  036h, 036h, 037h, 030h, 037h, 036h, 036h, 036h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h, 000h
   227 00015485 00FF00FF000000      <1>
   228 0001548C 3636F700F736363618- <1>     db  036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h
   228 00015495 18FF00FF000000      <1>
   229 0001549C 36363636FF00000000- <1>     db  036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h
   229 000154A5 00FF00FF181818      <1>
   230 000154AC 00000000FF36363636- <1>     db  000h, 000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 03fh, 000h, 000h, 000h
   230 000154B5 3636363F000000      <1>
   231 000154BC 18181F181F00000000- <1>     db  018h, 018h, 01fh, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h, 018h
   231 000154C5 001F181F181818      <1>
   232 000154CC 000000003F36363636- <1>     db  000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h
   232 000154D5 363636FF363636      <1>
   233 000154DC 1818FF18FF18181818- <1>     db  018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h
   233 000154E5 181818F8000000      <1>
   234 000154EC 000000001F181818FF- <1>     db  000h, 000h, 000h, 000h, 01fh, 018h, 018h, 018h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   234 000154F5 FFFFFFFFFFFFFF      <1>
   235 000154FC 00000000FFFFFFFFF0- <1>     db  000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
   235 00015505 F0F0F0F0F0F0F0      <1>
   236 0001550C 0F0F0F0F0F0F0F0FFF- <1>     db  00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h
   236 00015515 FFFFFF00000000      <1>
   237 0001551C 000076DCC8DC760000- <1>     db  000h, 000h, 076h, 0dch, 0c8h, 0dch, 076h, 000h, 000h, 078h, 0cch, 0f8h, 0cch, 0f8h, 0c0h, 0c0h
   237 00015525 78CCF8CCF8C0C0      <1>
   238 0001552C 00FCCCC0C0C0C00000- <1>     db  000h, 0fch, 0cch, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 0feh, 06ch, 06ch, 06ch, 06ch, 06ch, 000h
   238 00015535 FE6C6C6C6C6C00      <1>
   239 0001553C FCCC603060CCFC0000- <1>     db  0fch, 0cch, 060h, 030h, 060h, 0cch, 0fch, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 070h, 000h
   239 00015545 007ED8D8D87000      <1>
   240 0001554C 00666666667C60C000- <1>     db  000h, 066h, 066h, 066h, 066h, 07ch, 060h, 0c0h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 000h
   240 00015555 76DC1818181800      <1>
   241 0001555C FC3078CCCC7830FC38- <1>     db  0fch, 030h, 078h, 0cch, 0cch, 078h, 030h, 0fch, 038h, 06ch, 0c6h, 0feh, 0c6h, 06ch, 038h, 000h
   241 00015565 6CC6FEC66C3800      <1>
   242 0001556C 386CC6C66C6CEE001C- <1>     db  038h, 06ch, 0c6h, 0c6h, 06ch, 06ch, 0eeh, 000h, 01ch, 030h, 018h, 07ch, 0cch, 0cch, 078h, 000h
   242 00015575 30187CCCCC7800      <1>
   243 0001557C 00007EDBDB7E000006- <1>     db  000h, 000h, 07eh, 0dbh, 0dbh, 07eh, 000h, 000h, 006h, 00ch, 07eh, 0dbh, 0dbh, 07eh, 060h, 0c0h
   243 00015585 0C7EDBDB7E60C0      <1>
   244 0001558C 3860C0F8C060380078- <1>     db  038h, 060h, 0c0h, 0f8h, 0c0h, 060h, 038h, 000h, 078h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 000h
   244 00015595 CCCCCCCCCCCC00      <1>
   245 0001559C 00FC00FC00FC000030- <1>     db  000h, 0fch, 000h, 0fch, 000h, 0fch, 000h, 000h, 030h, 030h, 0fch, 030h, 030h, 000h, 0fch, 000h
   245 000155A5 30FC303000FC00      <1>
   246 000155AC 603018306000FC0018- <1>     db  060h, 030h, 018h, 030h, 060h, 000h, 0fch, 000h, 018h, 030h, 060h, 030h, 018h, 000h, 0fch, 000h
   246 000155B5 3060301800FC00      <1>
   247 000155BC 0E1B1B181818181818- <1>     db  00eh, 01bh, 01bh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h, 070h
   247 000155C5 18181818D8D870      <1>
   248 000155CC 303000FC0030300000- <1>     db  030h, 030h, 000h, 0fch, 000h, 030h, 030h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h
   248 000155D5 76DC0076DC0000      <1>
   249 000155DC 386C6C380000000000- <1>     db  038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h
   249 000155E5 00001818000000      <1>
   250 000155EC 00000000180000000F- <1>     db  000h, 000h, 000h, 000h, 018h, 000h, 000h, 000h, 00fh, 00ch, 00ch, 00ch, 0ech, 06ch, 03ch, 01ch
   250 000155F5 0C0C0CEC6C3C1C      <1>
   251 000155FC 786C6C6C6C00000070- <1>     db  078h, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 070h, 018h, 030h, 060h, 078h, 000h, 000h, 000h
   251 00015605 18306078000000      <1>
   252 0001560C 00003C3C3C3C000000- <1>     db  000h, 000h, 03ch, 03ch, 03ch, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   252 00015615 00000000000000      <1>
   253                              <1> vgafont14:
   254 0001561C 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   254 00015625 00000000000000      <1>
   255 0001562C 7E81A58181BD99817E- <1>     db  07eh, 081h, 0a5h, 081h, 081h, 0bdh, 099h, 081h, 07eh, 000h, 000h, 000h, 000h, 000h, 07eh, 0ffh
   255 00015635 00000000007EFF      <1>
   256 0001563C DBFFFFC3E7FF7E0000- <1>     db  0dbh, 0ffh, 0ffh, 0c3h, 0e7h, 0ffh, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 06ch, 0feh, 0feh
   256 00015645 000000006CFEFE      <1>
   257 0001564C FEFE7C381000000000- <1>     db  0feh, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 07ch, 0feh, 07ch
   257 00015655 000010387CFE7C      <1>
   258 0001565C 381000000000000018- <1>     db  038h, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 0e7h, 0e7h, 0e7h, 018h, 018h
   258 00015665 3C3CE7E7E71818      <1>
   259 0001566C 3C0000000000183C7E- <1>     db  03ch, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 07eh, 018h, 018h, 03ch, 000h
   259 00015675 FFFF7E18183C00      <1>
   260 0001567C 00000000000000183C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h, 000h
   260 00015685 3C180000000000      <1>
   261 0001568C FFFFFFFFFFE7C3C3E7- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h
   261 00015695 FFFFFFFFFF0000      <1>
   262 0001569C 00003C664242663C00- <1>     db  000h, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh
   262 000156A5 000000FFFFFFFF      <1>
   263 000156AC C399BDBD99C3FFFFFF- <1>     db  0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 01eh, 00eh, 01ah, 032h
   263 000156B5 FF00001E0E1A32      <1>
   264 000156BC 78CCCCCC7800000000- <1>     db  078h, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 066h, 066h, 03ch, 018h
   264 000156C5 003C6666663C18      <1>
   265 000156CC 7E181800000000003F- <1>     db  07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 03fh, 033h, 03fh, 030h, 030h, 030h, 070h, 0f0h
   265 000156D5 333F30303070F0      <1>
   266 000156DC E000000000007F637F- <1>     db  0e0h, 000h, 000h, 000h, 000h, 000h, 07fh, 063h, 07fh, 063h, 063h, 063h, 067h, 0e7h, 0e6h, 0c0h
   266 000156E5 63636367E7E6C0      <1>
   267 000156EC 000000001818DB3CE7- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 0dbh, 03ch, 0e7h, 03ch, 0dbh, 018h, 018h, 000h, 000h, 000h
   267 000156F5 3CDB1818000000      <1>
   268 000156FC 000080C0E0F8FEF8E0- <1>     db  000h, 000h, 080h, 0c0h, 0e0h, 0f8h, 0feh, 0f8h, 0e0h, 0c0h, 080h, 000h, 000h, 000h, 000h, 000h
   268 00015705 C0800000000000      <1>
   269 0001570C 02060E3EFE3E0E0602- <1>     db  002h, 006h, 00eh, 03eh, 0feh, 03eh, 00eh, 006h, 002h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch
   269 00015715 0000000000183C      <1>
   270 0001571C 7E1818187E3C180000- <1>     db  07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h
   270 00015725 00000066666666      <1>
   271 0001572C 666600666600000000- <1>     db  066h, 066h, 000h, 066h, 066h, 000h, 000h, 000h, 000h, 000h, 07fh, 0dbh, 0dbh, 0dbh, 07bh, 01bh
   271 00015735 007FDBDBDB7B1B      <1>
   272 0001573C 1B1B1B000000007CC6- <1>     db  01bh, 01bh, 01bh, 000h, 000h, 000h, 000h, 07ch, 0c6h, 060h, 038h, 06ch, 0c6h, 0c6h, 06ch, 038h
   272 00015745 60386CC6C66C38      <1>
   273 0001574C 0CC67C000000000000- <1>     db  00ch, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 0feh, 000h
   273 00015755 000000FEFEFE00      <1>
   274 0001575C 00000000183C7E1818- <1>     db  000h, 000h, 000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 07eh, 000h, 000h
   274 00015765 187E3C187E0000      <1>
   275 0001576C 0000183C7E18181818- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
   275 00015775 18180000000000      <1>
   276 0001577C 1818181818187E3C18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   276 00015785 00000000000000      <1>
   277 0001578C 180CFE0C1800000000- <1>     db  018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 030h, 060h
   277 00015795 00000000003060      <1>
   278 0001579C FE6030000000000000- <1>     db  0feh, 060h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c0h
   278 000157A5 00000000C0C0C0      <1>
   279 000157AC FE0000000000000000- <1>     db  0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 028h, 06ch, 0feh, 06ch, 028h, 000h
   279 000157B5 00286CFE6C2800      <1>
   280 000157BC 000000000000001038- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 038h, 07ch, 07ch, 0feh, 0feh, 000h, 000h
   280 000157C5 387C7CFEFE0000      <1>
   281 000157CC 0000000000FEFE7C7C- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 07ch, 07ch, 038h, 038h, 010h, 000h, 000h, 000h, 000h
   281 000157D5 38381000000000      <1>
   282 000157DC 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   282 000157E5 00000000000000      <1>
   283 000157EC 183C3C3C1818001818- <1>     db  018h, 03ch, 03ch, 03ch, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 066h, 066h, 066h
   283 000157F5 00000000666666      <1>
   284 000157FC 240000000000000000- <1>     db  024h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch
   284 00015805 0000006C6CFE6C      <1>
   285 0001580C 6C6CFE6C6C00000018- <1>     db  06ch, 06ch, 0feh, 06ch, 06ch, 000h, 000h, 000h, 018h, 018h, 07ch, 0c6h, 0c2h, 0c0h, 07ch, 006h
   285 00015815 187CC6C2C07C06      <1>
   286 0001581C 86C67C181800000000- <1>     db  086h, 0c6h, 07ch, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 0c2h, 0c6h, 00ch, 018h, 030h, 066h
   286 00015825 00C2C60C183066      <1>
   287 0001582C C60000000000386C6C- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 038h, 06ch, 06ch, 038h, 076h, 0dch, 0cch, 0cch, 076h, 000h
   287 00015835 3876DCCCCC7600      <1>
   288 0001583C 000000303030600000- <1>     db  000h, 000h, 000h, 030h, 030h, 030h, 060h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   288 00015845 00000000000000      <1>
   289 0001584C 00000C183030303030- <1>     db  000h, 000h, 00ch, 018h, 030h, 030h, 030h, 030h, 030h, 018h, 00ch, 000h, 000h, 000h, 000h, 000h
   289 00015855 180C0000000000      <1>
   290 0001585C 30180C0C0C0C0C1830- <1>     db  030h, 018h, 00ch, 00ch, 00ch, 00ch, 00ch, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   290 00015865 00000000000000      <1>
   291 0001586C 663CFF3C6600000000- <1>     db  066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h
   291 00015875 00000000001818      <1>
   292 0001587C 7E1818000000000000- <1>     db  07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   292 00015885 00000000000000      <1>
   293 0001588C 181818300000000000- <1>     db  018h, 018h, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 000h, 000h, 000h
   293 00015895 000000FE000000      <1>
   294 0001589C 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h
   294 000158A5 00000000181800      <1>
   295 000158AC 0000000002060C1830- <1>     db  000h, 000h, 000h, 000h, 002h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h, 000h, 000h, 000h
   295 000158B5 60C08000000000      <1>
   296 000158BC 00007CC6CEDEF6E6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0ceh, 0deh, 0f6h, 0e6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   296 000158C5 C67C0000000000      <1>
   297 000158CC 18387818181818187E- <1>     db  018h, 038h, 078h, 018h, 018h, 018h, 018h, 018h, 07eh, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h
   297 000158D5 00000000007CC6      <1>
   298 000158DC 060C183060C6FE0000- <1>     db  006h, 00ch, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 006h, 006h
   298 000158E5 0000007CC60606      <1>
   299 000158EC 3C0606C67C00000000- <1>     db  03ch, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 00ch, 01ch, 03ch, 06ch, 0cch, 0feh
   299 000158F5 000C1C3C6CCCFE      <1>
   300 000158FC 0C0C1E0000000000FE- <1>     db  00ch, 00ch, 01eh, 000h, 000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0fch, 006h, 006h, 0c6h
   300 00015905 C0C0C0FC0606C6      <1>
   301 0001590C 7C00000000003860C0- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 038h, 060h, 0c0h, 0c0h, 0fch, 0c6h, 0c6h, 0c6h, 07ch, 000h
   301 00015915 C0FCC6C6C67C00      <1>
   302 0001591C 00000000FEC6060C18- <1>     db  000h, 000h, 000h, 000h, 0feh, 0c6h, 006h, 00ch, 018h, 030h, 030h, 030h, 030h, 000h, 000h, 000h
   302 00015925 30303030000000      <1>
   303 0001592C 00007CC6C6C67CC6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   303 00015935 C67C0000000000      <1>
   304 0001593C 7CC6C6C67E06060C78- <1>     db  07ch, 0c6h, 0c6h, 0c6h, 07eh, 006h, 006h, 00ch, 078h, 000h, 000h, 000h, 000h, 000h, 000h, 018h
   304 00015945 00000000000018      <1>
   305 0001594C 180000001818000000- <1>     db  018h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h
   305 00015955 00000000181800      <1>
   306 0001595C 000018183000000000- <1>     db  000h, 000h, 018h, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 006h, 00ch, 018h, 030h, 060h, 030h
   306 00015965 00060C18306030      <1>
   307 0001596C 180C06000000000000- <1>     db  018h, 00ch, 006h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 000h, 000h, 07eh, 000h
   307 00015975 00007E00007E00      <1>
   308 0001597C 000000000000603018- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 060h, 000h
   308 00015985 0C060C18306000      <1>
   309 0001598C 000000007CC6C60C18- <1>     db  000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 00ch, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h
   309 00015995 18001818000000      <1>
   310 0001599C 00007CC6C6DEDEDEDC- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0deh, 0deh, 0deh, 0dch, 0c0h, 07ch, 000h, 000h, 000h, 000h, 000h
   310 000159A5 C07C0000000000      <1>
   311 000159AC 10386CC6C6FEC6C6C6- <1>     db  010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h, 0fch, 066h
   311 000159B5 0000000000FC66      <1>
   312 000159BC 66667C666666FC0000- <1>     db  066h, 066h, 07ch, 066h, 066h, 066h, 0fch, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 0c2h, 0c0h
   312 000159C5 0000003C66C2C0      <1>
   313 000159CC C0C0C2663C00000000- <1>     db  0c0h, 0c0h, 0c2h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h, 0f8h, 06ch, 066h, 066h, 066h, 066h
   313 000159D5 00F86C66666666      <1>
   314 000159DC 666CF80000000000FE- <1>     db  066h, 06ch, 0f8h, 000h, 000h, 000h, 000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 062h, 066h
   314 000159E5 66626878686266      <1>
   315 000159EC FE0000000000FE6662- <1>     db  0feh, 000h, 000h, 000h, 000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 060h, 0f0h, 000h
   315 000159F5 6878686060F000      <1>
   316 000159FC 000000003C66C2C0C0- <1>     db  000h, 000h, 000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0deh, 0c6h, 066h, 03ah, 000h, 000h, 000h
   316 00015A05 DEC6663A000000      <1>
   317 00015A0C 0000C6C6C6C6FEC6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h
   317 00015A15 C6C60000000000      <1>
   318 00015A1C 3C181818181818183C- <1>     db  03ch, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 01eh, 00ch
   318 00015A25 00000000001E0C      <1>
   319 00015A2C 0C0C0C0CCCCC780000- <1>     db  00ch, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h, 000h, 0e6h, 066h, 06ch, 06ch
   319 00015A35 000000E6666C6C      <1>
   320 00015A3C 786C6C66E600000000- <1>     db  078h, 06ch, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 0f0h, 060h, 060h, 060h, 060h, 060h
   320 00015A45 00F06060606060      <1>
   321 00015A4C 6266FE0000000000C6- <1>     db  062h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h, 0c6h, 0eeh, 0feh, 0feh, 0d6h, 0c6h, 0c6h, 0c6h
   321 00015A55 EEFEFED6C6C6C6      <1>
   322 00015A5C C60000000000C6E6F6- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 000h
   322 00015A65 FEDECEC6C6C600      <1>
   323 00015A6C 00000000386CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h
   323 00015A75 C6C66C38000000      <1>
   324 00015A7C 0000FC6666667C6060- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h, 000h
   324 00015A85 60F00000000000      <1>
   325 00015A8C 7CC6C6C6C6D6DE7C0C- <1>     db  07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0deh, 07ch, 00ch, 00eh, 000h, 000h, 000h, 000h, 0fch, 066h
   325 00015A95 0E00000000FC66      <1>
   326 00015A9C 66667C6C6666E60000- <1>     db  066h, 066h, 07ch, 06ch, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 060h
   326 00015AA5 0000007CC6C660      <1>
   327 00015AAC 380CC6C67C00000000- <1>     db  038h, 00ch, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 07eh, 07eh, 05ah, 018h, 018h, 018h
   327 00015AB5 007E7E5A181818      <1>
   328 00015ABC 18183C0000000000C6- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h
   328 00015AC5 C6C6C6C6C6C6C6      <1>
   329 00015ACC 7C0000000000C6C6C6- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 010h, 000h
   329 00015AD5 C6C6C66C381000      <1>
   330 00015ADC 00000000C6C6C6C6D6- <1>     db  000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0d6h, 0feh, 07ch, 06ch, 000h, 000h, 000h
   330 00015AE5 D6FE7C6C000000      <1>
   331 00015AEC 0000C6C66C3838386C- <1>     db  000h, 000h, 0c6h, 0c6h, 06ch, 038h, 038h, 038h, 06ch, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h
   331 00015AF5 C6C60000000000      <1>
   332 00015AFC 666666663C1818183C- <1>     db  066h, 066h, 066h, 066h, 03ch, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 0feh, 0c6h
   332 00015B05 0000000000FEC6      <1>
   333 00015B0C 8C183060C2C6FE0000- <1>     db  08ch, 018h, 030h, 060h, 0c2h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 03ch, 030h, 030h, 030h
   333 00015B15 0000003C303030      <1>
   334 00015B1C 303030303C00000000- <1>     db  030h, 030h, 030h, 030h, 03ch, 000h, 000h, 000h, 000h, 000h, 080h, 0c0h, 0e0h, 070h, 038h, 01ch
   334 00015B25 0080C0E070381C      <1>
   335 00015B2C 0E060200000000003C- <1>     db  00eh, 006h, 002h, 000h, 000h, 000h, 000h, 000h, 03ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch
   335 00015B35 0C0C0C0C0C0C0C      <1>
   336 00015B3C 3C00000010386CC600- <1>     db  03ch, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   336 00015B45 00000000000000      <1>
   337 00015B4C 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h
   337 00015B55 0000000000FF00      <1>
   338 00015B5C 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   338 00015B65 00000000000000      <1>
   339 00015B6C 000000780C7CCCCC76- <1>     db  000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 0e0h, 060h
   339 00015B75 0000000000E060      <1>
   340 00015B7C 60786C6666667C0000- <1>     db  060h, 078h, 06ch, 066h, 066h, 066h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch
   340 00015B85 0000000000007C      <1>
   341 00015B8C C6C0C0C67C00000000- <1>     db  0c6h, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 01ch, 00ch, 00ch, 03ch, 06ch, 0cch
   341 00015B95 001C0C0C3C6CCC      <1>
   342 00015B9C CCCC76000000000000- <1>     db  0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h
   342 00015BA5 00007CC6FEC0C6      <1>
   343 00015BAC 7C0000000000386C64- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 0f0h, 000h
   343 00015BB5 60F0606060F000      <1>
   344 00015BBC 0000000000000076CC- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 07ch, 00ch, 0cch, 078h, 000h
   344 00015BC5 CCCC7C0CCC7800      <1>
   345 00015BCC 0000E060606C766666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 06ch, 076h, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h
   345 00015BD5 66E60000000000      <1>
   346 00015BDC 18180038181818183C- <1>     db  018h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 006h, 006h
   346 00015BE5 00000000000606      <1>
   347 00015BEC 000E0606060666663C- <1>     db  000h, 00eh, 006h, 006h, 006h, 006h, 066h, 066h, 03ch, 000h, 000h, 000h, 0e0h, 060h, 060h, 066h
   347 00015BF5 000000E0606066      <1>
   348 00015BFC 6C786C66E600000000- <1>     db  06ch, 078h, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h
   348 00015C05 00381818181818      <1>
   349 00015C0C 18183C000000000000- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ech, 0feh, 0d6h, 0d6h, 0d6h
   349 00015C15 0000ECFED6D6D6      <1>
   350 00015C1C C60000000000000000- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 000h
   350 00015C25 DC666666666600      <1>
   351 00015C2C 000000000000007CC6- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h
   351 00015C35 C6C6C67C000000      <1>
   352 00015C3C 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h, 000h, 000h
   352 00015C45 7C6060F0000000      <1>
   353 00015C4C 00000076CCCCCC7C0C- <1>     db  000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 07ch, 00ch, 00ch, 01eh, 000h, 000h, 000h, 000h, 000h
   353 00015C55 0C1E0000000000      <1>
   354 00015C5C 00DC76666060F00000- <1>     db  000h, 0dch, 076h, 066h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch
   354 00015C65 0000000000007C      <1>
   355 00015C6C C6701CC67C00000000- <1>     db  0c6h, 070h, 01ch, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 010h, 030h, 030h, 0fch, 030h, 030h
   355 00015C75 00103030FC3030      <1>
   356 00015C7C 30361C000000000000- <1>     db  030h, 036h, 01ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch
   356 00015C85 0000CCCCCCCCCC      <1>
   357 00015C8C 760000000000000000- <1>     db  076h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 03ch, 018h, 000h
   357 00015C95 666666663C1800      <1>
   358 00015C9C 00000000000000C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0d6h, 0d6h, 0feh, 06ch, 000h, 000h, 000h
   358 00015CA5 D6D6FE6C000000      <1>
   359 00015CAC 0000000000C66C3838- <1>     db  000h, 000h, 000h, 000h, 000h, 0c6h, 06ch, 038h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h
   359 00015CB5 6CC60000000000      <1>
   360 00015CBC 000000C6C6C6C67E06- <1>     db  000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 0f8h, 000h, 000h, 000h, 000h, 000h
   360 00015CC5 0CF80000000000      <1>
   361 00015CCC 00FECC183066FE0000- <1>     db  000h, 0feh, 0cch, 018h, 030h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h, 00eh, 018h, 018h, 018h
   361 00015CD5 0000000E181818      <1>
   362 00015CDC 701818180E00000000- <1>     db  070h, 018h, 018h, 018h, 00eh, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 000h, 018h
   362 00015CE5 00181818180018      <1>
   363 00015CEC 181818000000000070- <1>     db  018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 070h, 018h, 018h, 018h, 00eh, 018h, 018h, 018h
   363 00015CF5 1818180E181818      <1>
   364 00015CFC 70000000000076DC00- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   364 00015D05 00000000000000      <1>
   365 00015D0C 00000000000010386C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   365 00015D15 C6C6FE00000000      <1>
   366 00015D1C 00003C66C2C0C0C266- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 00ch, 006h, 07ch, 000h, 000h, 000h
   366 00015D25 3C0C067C000000      <1>
   367 00015D2C CCCC00CCCCCCCCCC76- <1>     db  0cch, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 00ch, 018h, 030h
   367 00015D35 000000000C1830      <1>
   368 00015D3C 007CC6FEC0C67C0000- <1>     db  000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 000h, 078h
   368 00015D45 000010386C0078      <1>
   369 00015D4C 0C7CCCCC7600000000- <1>     db  00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 000h, 078h, 00ch, 07ch
   369 00015D55 00CCCC00780C7C      <1>
   370 00015D5C CCCC76000000006030- <1>     db  0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 078h, 00ch, 07ch, 0cch, 0cch
   370 00015D65 1800780C7CCCCC      <1>
   371 00015D6C 7600000000386C3800- <1>     db  076h, 000h, 000h, 000h, 000h, 038h, 06ch, 038h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h
   371 00015D75 780C7CCCCC7600      <1>
   372 00015D7C 0000000000003C6660- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 060h, 066h, 03ch, 00ch, 006h, 03ch, 000h, 000h
   372 00015D85 663C0C063C0000      <1>
   373 00015D8C 0010386C007CC6FEC0- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   373 00015D95 C67C0000000000      <1>
   374 00015D9C CCCC007CC6FEC0C67C- <1>     db  0cch, 0cch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h
   374 00015DA5 00000000603018      <1>
   375 00015DAC 007CC6FEC0C67C0000- <1>     db  000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 000h, 038h
   375 00015DB5 00000066660038      <1>
   376 00015DBC 181818183C00000000- <1>     db  018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 018h, 03ch, 066h, 000h, 038h, 018h, 018h
   376 00015DC5 183C6600381818      <1>
   377 00015DCC 18183C000000006030- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 038h, 018h, 018h, 018h, 018h
   377 00015DD5 18003818181818      <1>
   378 00015DDC 3C00000000C6C61038- <1>     db  03ch, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 000h
   378 00015DE5 6CC6C6FEC6C600      <1>
   379 00015DEC 0000386C3800386CC6- <1>     db  000h, 000h, 038h, 06ch, 038h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 000h, 000h, 000h
   379 00015DF5 C6FEC6C6000000      <1>
   380 00015DFC 18306000FE66607C60- <1>     db  018h, 030h, 060h, 000h, 0feh, 066h, 060h, 07ch, 060h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h
   380 00015E05 66FE0000000000      <1>
   381 00015E0C 0000CC76367ED8D86E- <1>     db  000h, 000h, 0cch, 076h, 036h, 07eh, 0d8h, 0d8h, 06eh, 000h, 000h, 000h, 000h, 000h, 03eh, 06ch
   381 00015E15 00000000003E6C      <1>
   382 00015E1C CCCCFECCCCCCCE0000- <1>     db  0cch, 0cch, 0feh, 0cch, 0cch, 0cch, 0ceh, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 000h, 07ch
   382 00015E25 000010386C007C      <1>
   383 00015E2C C6C6C6C67C00000000- <1>     db  0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 000h, 07ch, 0c6h, 0c6h
   383 00015E35 00C6C6007CC6C6      <1>
   384 00015E3C C6C67C000000006030- <1>     db  0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h
   384 00015E45 18007CC6C6C6C6      <1>
   385 00015E4C 7C000000003078CC00- <1>     db  07ch, 000h, 000h, 000h, 000h, 030h, 078h, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h
   385 00015E55 CCCCCCCCCC7600      <1>
   386 00015E5C 00000060301800CCCC- <1>     db  000h, 000h, 000h, 060h, 030h, 018h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h
   386 00015E65 CCCCCC76000000      <1>
   387 00015E6C 0000C6C600C6C6C6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 078h, 000h, 000h, 0c6h
   387 00015E75 7E060C780000C6      <1>
   388 00015E7C C6386CC6C6C6C66C38- <1>     db  0c6h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 000h
   388 00015E85 00000000C6C600      <1>
   389 00015E8C C6C6C6C6C6C67C0000- <1>     db  0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 018h, 018h, 03ch, 066h, 060h
   389 00015E95 000018183C6660      <1>
   390 00015E9C 60663C181800000000- <1>     db  060h, 066h, 03ch, 018h, 018h, 000h, 000h, 000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h
   390 00015EA5 386C6460F06060      <1>
   391 00015EAC 60E6FC000000000066- <1>     db  060h, 0e6h, 0fch, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 03ch, 018h, 07eh, 018h, 07eh, 018h
   391 00015EB5 663C187E187E18      <1>
   392 00015EBC 1800000000F8CCCCF8- <1>     db  018h, 000h, 000h, 000h, 000h, 0f8h, 0cch, 0cch, 0f8h, 0c4h, 0cch, 0deh, 0cch, 0cch, 0c6h, 000h
   392 00015EC5 C4CCDECCCCC600      <1>
   393 00015ECC 0000000E1B1818187E- <1>     db  000h, 000h, 000h, 00eh, 01bh, 018h, 018h, 018h, 07eh, 018h, 018h, 018h, 018h, 0d8h, 070h, 000h
   393 00015ED5 18181818D87000      <1>
   394 00015EDC 0018306000780C7CCC- <1>     db  000h, 018h, 030h, 060h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 00ch
   394 00015EE5 CC76000000000C      <1>
   395 00015EEC 18300038181818183C- <1>     db  018h, 030h, 000h, 038h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 018h, 030h, 060h
   395 00015EF5 00000000183060      <1>
   396 00015EFC 007CC6C6C6C67C0000- <1>     db  000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 018h, 030h, 060h, 000h, 0cch
   396 00015F05 000018306000CC      <1>
   397 00015F0C CCCCCCCC7600000000- <1>     db  0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 0dch, 066h, 066h
   397 00015F15 0076DC00DC6666      <1>
   398 00015F1C 66666600000076DC00- <1>     db  066h, 066h, 066h, 000h, 000h, 000h, 076h, 0dch, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h
   398 00015F25 C6E6F6FEDECEC6      <1>
   399 00015F2C C6000000003C6C6C3E- <1>     db  0c6h, 000h, 000h, 000h, 000h, 03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 000h, 000h, 000h
   399 00015F35 007E0000000000      <1>
   400 00015F3C 000000386C6C38007C- <1>     db  000h, 000h, 000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   400 00015F45 00000000000000      <1>
   401 00015F4C 0000303000303060C6- <1>     db  000h, 000h, 030h, 030h, 000h, 030h, 030h, 060h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   401 00015F55 C67C0000000000      <1>
   402 00015F5C 00000000FEC0C0C000- <1>     db  000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   402 00015F65 00000000000000      <1>
   403 00015F6C 0000FE060606000000- <1>     db  000h, 000h, 0feh, 006h, 006h, 006h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c6h, 0cch, 0d8h
   403 00015F75 0000C0C0C6CCD8      <1>
   404 00015F7C 3060DC860C183E0000- <1>     db  030h, 060h, 0dch, 086h, 00ch, 018h, 03eh, 000h, 000h, 0c0h, 0c0h, 0c6h, 0cch, 0d8h, 030h, 066h
   404 00015F85 C0C0C6CCD83066      <1>
   405 00015F8C CE9E3E060600000018- <1>     db  0ceh, 09eh, 03eh, 006h, 006h, 000h, 000h, 000h, 018h, 018h, 000h, 018h, 018h, 03ch, 03ch, 03ch
   405 00015F95 180018183C3C3C      <1>
   406 00015F9C 180000000000000036- <1>     db  018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 036h, 06ch, 0d8h, 06ch, 036h, 000h, 000h, 000h
   406 00015FA5 6CD86C36000000      <1>
   407 00015FAC 000000000000D86C36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0d8h, 06ch, 036h, 06ch, 0d8h, 000h, 000h, 000h, 000h, 000h
   407 00015FB5 6CD80000000000      <1>
   408 00015FBC 114411441144114411- <1>     db  011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 055h, 0aah
   408 00015FC5 441144114455AA      <1>
   409 00015FCC 55AA55AA55AA55AA55- <1>     db  055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 0ddh, 077h, 0ddh, 077h
   409 00015FD5 AA55AADD77DD77      <1>
   410 00015FDC DD77DD77DD77DD77DD- <1>     db  0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 018h, 018h, 018h, 018h, 018h, 018h
   410 00015FE5 77181818181818      <1>
   411 00015FEC 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h
   411 00015FF5 181818181818F8      <1>
   412 00015FFC 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h
   412 00016005 1818F818F81818      <1>
   413 0001600C 181818183636363636- <1>     db  018h, 018h, 018h, 018h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 036h
   413 00016015 3636F636363636      <1>
   414 0001601C 363600000000000000- <1>     db  036h, 036h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h, 036h, 036h, 036h
   414 00016025 FE363636363636      <1>
   415 0001602C 0000000000F818F818- <1>     db  000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 036h, 036h
   415 00016035 18181818183636      <1>
   416 0001603C 363636F606F6363636- <1>     db  036h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   416 00016045 36363636363636      <1>
   417 0001604C 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 000h, 0feh
   417 00016055 360000000000FE      <1>
   418 0001605C 06F636363636363636- <1>     db  006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0feh
   418 00016065 36363636F606FE      <1>
   419 0001606C 000000000000363636- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h
   419 00016075 36363636FE0000      <1>
   420 0001607C 000000001818181818- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h
   420 00016085 F818F800000000      <1>
   421 0001608C 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h
   421 00016095 F8181818181818      <1>
   422 0001609C 181818181818181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h
   422 000160A5 00000000001818      <1>
   423 000160AC 1818181818FF000000- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   423 000160B5 00000000000000      <1>
   424 000160BC 000000FF1818181818- <1>     db  000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   424 000160C5 18181818181818      <1>
   425 000160CC 181F18181818181800- <1>     db  018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   425 000160D5 000000000000FF      <1>
   426 000160DC 000000000000181818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h
   426 000160E5 18181818FF1818      <1>
   427 000160EC 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h
   427 000160F5 1F181F18181818      <1>
   428 000160FC 181836363636363636- <1>     db  018h, 018h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h, 036h, 036h, 036h
   428 00016105 37363636363636      <1>
   429 0001610C 363636363637303F00- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   429 00016115 00000000000000      <1>
   430 0001611C 0000003F3037363636- <1>     db  000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   430 00016125 36363636363636      <1>
   431 0001612C 36F700FF0000000000- <1>     db  036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   431 00016135 000000000000FF      <1>
   432 0001613C 00F736363636363636- <1>     db  000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 030h, 037h
   432 00016145 36363636373037      <1>
   433 0001614C 363636363636000000- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h
   433 00016155 0000FF00FF0000      <1>
   434 0001615C 000000003636363636- <1>     db  000h, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 036h
   434 00016165 F700F736363636      <1>
   435 0001616C 36361818181818FF00- <1>     db  036h, 036h, 018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h
   435 00016175 FF000000000000      <1>
   436 0001617C 36363636363636FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   436 00016185 00000000000000      <1>
   437 0001618C 000000FF00FF181818- <1>     db  000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   437 00016195 18181800000000      <1>
   438 0001619C 000000FF3636363636- <1>     db  000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   438 000161A5 36363636363636      <1>
   439 000161AC 363F00000000000018- <1>     db  036h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh
   439 000161B5 181818181F181F      <1>
   440 000161BC 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h
   440 000161C5 00001F181F1818      <1>
   441 000161CC 181818180000000000- <1>     db  018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h
   441 000161D5 00003F36363636      <1>
   442 000161DC 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h
   442 000161E5 FF363636363636      <1>
   443 000161EC 1818181818FF18FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   443 000161F5 18181818181818      <1>
   444 000161FC 1818181818F8000000- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   444 00016205 00000000000000      <1>
   445 0001620C 0000001F1818181818- <1>     db  000h, 000h, 000h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   445 00016215 18FFFFFFFFFFFF      <1>
   446 0001621C FFFFFFFFFFFFFFFF00- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   446 00016225 000000000000FF      <1>
   447 0001622C FFFFFFFFFFFFF0F0F0- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
   447 00016235 F0F0F0F0F0F0F0      <1>
   448 0001623C F0F0F0F00F0F0F0F0F- <1>     db  0f0h, 0f0h, 0f0h, 0f0h, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh
   448 00016245 0F0F0F0F0F0F0F      <1>
   449 0001624C 0F0FFFFFFFFFFFFFFF- <1>     db  00fh, 00fh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   449 00016255 00000000000000      <1>
   450 0001625C 000000000076DCD8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 0d8h, 0d8h, 0dch, 076h, 000h, 000h, 000h, 000h, 000h
   450 00016265 DC760000000000      <1>
   451 0001626C 00007CC6FCC6C6FCC0- <1>     db  000h, 000h, 07ch, 0c6h, 0fch, 0c6h, 0c6h, 0fch, 0c0h, 0c0h, 040h, 000h, 000h, 000h, 0feh, 0c6h
   451 00016275 C040000000FEC6      <1>
   452 0001627C C6C0C0C0C0C0C00000- <1>     db  0c6h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 06ch
   452 00016285 0000000000FE6C      <1>
   453 0001628C 6C6C6C6C6C00000000- <1>     db  06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 0feh, 0c6h, 060h, 030h, 018h, 030h
   453 00016295 00FEC660301830      <1>
   454 0001629C 60C6FE000000000000- <1>     db  060h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 0d8h
   454 000162A5 00007ED8D8D8D8      <1>
   455 000162AC 700000000000000066- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0c0h
   455 000162B5 6666667C6060C0      <1>
   456 000162BC 00000000000076DC18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h
   456 000162C5 18181818000000      <1>
   457 000162CC 00007E183C6666663C- <1>     db  000h, 000h, 07eh, 018h, 03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h, 000h
   457 000162D5 187E0000000000      <1>
   458 000162DC 386CC6C6FEC6C66C38- <1>     db  038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 038h, 06ch
   458 000162E5 0000000000386C      <1>
   459 000162EC C6C6C66C6C6CEE0000- <1>     db  0c6h, 0c6h, 0c6h, 06ch, 06ch, 06ch, 0eeh, 000h, 000h, 000h, 000h, 000h, 01eh, 030h, 018h, 00ch
   459 000162F5 0000001E30180C      <1>
   460 000162FC 3E6666663C00000000- <1>     db  03eh, 066h, 066h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 0dbh, 0dbh
   460 00016305 000000007EDBDB      <1>
   461 0001630C 7E0000000000000003- <1>     db  07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 003h, 006h, 07eh, 0dbh, 0dbh, 0f3h, 07eh, 060h
   461 00016315 067EDBDBF37E60      <1>
   462 0001631C C000000000001C3060- <1>     db  0c0h, 000h, 000h, 000h, 000h, 000h, 01ch, 030h, 060h, 060h, 07ch, 060h, 060h, 030h, 01ch, 000h
   462 00016325 607C6060301C00      <1>
   463 0001632C 00000000007CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h
   463 00016335 C6C6C6C6000000      <1>
   464 0001633C 000000FE0000FE0000- <1>     db  000h, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h
   464 00016345 FE000000000000      <1>
   465 0001634C 0018187E18180000FF- <1>     db  000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 030h, 018h
   465 00016355 00000000003018      <1>
   466 0001635C 0C060C1830007E0000- <1>     db  00ch, 006h, 00ch, 018h, 030h, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 00ch, 018h, 030h, 060h
   466 00016365 0000000C183060      <1>
   467 0001636C 30180C007E00000000- <1>     db  030h, 018h, 00ch, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 00eh, 01bh, 01bh, 018h, 018h, 018h
   467 00016375 000E1B1B181818      <1>
   468 0001637C 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h
   468 00016385 1818181818D8D8      <1>
   469 0001638C 700000000000001818- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 07eh, 000h, 018h, 018h, 000h, 000h
   469 00016395 007E0018180000      <1>
   470 0001639C 00000000000076DC00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h
   470 000163A5 76DC0000000000      <1>
   471 000163AC 00386C6C3800000000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   471 000163B5 00000000000000      <1>
   472 000163BC 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   472 000163C5 00000000000000      <1>
   473 000163CC 000000180000000000- <1>     db  000h, 000h, 000h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 00fh, 00ch, 00ch, 00ch, 00ch
   473 000163D5 00000F0C0C0C0C      <1>
   474 000163DC 0CEC6C3C1C00000000- <1>     db  00ch, 0ech, 06ch, 03ch, 01ch, 000h, 000h, 000h, 000h, 0d8h, 06ch, 06ch, 06ch, 06ch, 06ch, 000h
   474 000163E5 D86C6C6C6C6C00      <1>
   475 000163EC 0000000000000070D8- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 070h, 0d8h, 030h, 060h, 0c8h, 0f8h, 000h, 000h, 000h
   475 000163F5 3060C8F8000000      <1>
   476 000163FC 00000000000000007C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 000h, 000h
   476 00016405 7C7C7C7C7C0000      <1>
   477 0001640C 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   477 00016415 00000000000000      <1>
   478                              <1> vgafont16:
   479 0001641C 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   479 00016425 00000000000000      <1>
   480 0001642C 00007E81A58181BD99- <1>     db  000h, 000h, 07eh, 081h, 0a5h, 081h, 081h, 0bdh, 099h, 081h, 081h, 07eh, 000h, 000h, 000h, 000h
   480 00016435 81817E00000000      <1>
   481 0001643C 00007EFFDBFFFFC3E7- <1>     db  000h, 000h, 07eh, 0ffh, 0dbh, 0ffh, 0ffh, 0c3h, 0e7h, 0ffh, 0ffh, 07eh, 000h, 000h, 000h, 000h
   481 00016445 FFFF7E00000000      <1>
   482 0001644C 000000006CFEFEFEFE- <1>     db  000h, 000h, 000h, 000h, 06ch, 0feh, 0feh, 0feh, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h
   482 00016455 7C381000000000      <1>
   483 0001645C 0000000010387CFE7C- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 07ch, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h, 000h
   483 00016465 38100000000000      <1>
   484 0001646C 000000183C3CE7E7E7- <1>     db  000h, 000h, 000h, 018h, 03ch, 03ch, 0e7h, 0e7h, 0e7h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   484 00016475 18183C00000000      <1>
   485 0001647C 000000183C7EFFFF7E- <1>     db  000h, 000h, 000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 07eh, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   485 00016485 18183C00000000      <1>
   486 0001648C 000000000000183C3C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h
   486 00016495 18000000000000      <1>
   487 0001649C FFFFFFFFFFFFE7C3C3- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   487 000164A5 E7FFFFFFFFFFFF      <1>
   488 000164AC 00000000003C664242- <1>     db  000h, 000h, 000h, 000h, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h
   488 000164B5 663C0000000000      <1>
   489 000164BC FFFFFFFFFFC399BDBD- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   489 000164C5 99C3FFFFFFFFFF      <1>
   490 000164CC 00001E0E1A3278CCCC- <1>     db  000h, 000h, 01eh, 00eh, 01ah, 032h, 078h, 0cch, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h
   490 000164D5 CCCC7800000000      <1>
   491 000164DC 00003C666666663C18- <1>     db  000h, 000h, 03ch, 066h, 066h, 066h, 066h, 03ch, 018h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h
   491 000164E5 7E181800000000      <1>
   492 000164EC 00003F333F30303030- <1>     db  000h, 000h, 03fh, 033h, 03fh, 030h, 030h, 030h, 030h, 070h, 0f0h, 0e0h, 000h, 000h, 000h, 000h
   492 000164F5 70F0E000000000      <1>
   493 000164FC 00007F637F63636363- <1>     db  000h, 000h, 07fh, 063h, 07fh, 063h, 063h, 063h, 063h, 067h, 0e7h, 0e6h, 0c0h, 000h, 000h, 000h
   493 00016505 67E7E6C0000000      <1>
   494 0001650C 0000001818DB3CE73C- <1>     db  000h, 000h, 000h, 018h, 018h, 0dbh, 03ch, 0e7h, 03ch, 0dbh, 018h, 018h, 000h, 000h, 000h, 000h
   494 00016515 DB181800000000      <1>
   495 0001651C 0080C0E0F0F8FEF8F0- <1>     db  000h, 080h, 0c0h, 0e0h, 0f0h, 0f8h, 0feh, 0f8h, 0f0h, 0e0h, 0c0h, 080h, 000h, 000h, 000h, 000h
   495 00016525 E0C08000000000      <1>
   496 0001652C 0002060E1E3EFE3E1E- <1>     db  000h, 002h, 006h, 00eh, 01eh, 03eh, 0feh, 03eh, 01eh, 00eh, 006h, 002h, 000h, 000h, 000h, 000h
   496 00016535 0E060200000000      <1>
   497 0001653C 0000183C7E1818187E- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h
   497 00016545 3C180000000000      <1>
   498 0001654C 000066666666666666- <1>     db  000h, 000h, 066h, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 066h, 066h, 000h, 000h, 000h, 000h
   498 00016555 00666600000000      <1>
   499 0001655C 00007FDBDBDB7B1B1B- <1>     db  000h, 000h, 07fh, 0dbh, 0dbh, 0dbh, 07bh, 01bh, 01bh, 01bh, 01bh, 01bh, 000h, 000h, 000h, 000h
   499 00016565 1B1B1B00000000      <1>
   500 0001656C 007CC660386CC6C66C- <1>     db  000h, 07ch, 0c6h, 060h, 038h, 06ch, 0c6h, 0c6h, 06ch, 038h, 00ch, 0c6h, 07ch, 000h, 000h, 000h
   500 00016575 380CC67C000000      <1>
   501 0001657C 0000000000000000FE- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 0feh, 0feh, 000h, 000h, 000h, 000h
   501 00016585 FEFEFE00000000      <1>
   502 0001658C 0000183C7E1818187E- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h
   502 00016595 3C187E00000000      <1>
   503 0001659C 0000183C7E18181818- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   503 000165A5 18181800000000      <1>
   504 000165AC 000018181818181818- <1>     db  000h, 000h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h
   504 000165B5 7E3C1800000000      <1>
   505 000165BC 0000000000180CFE0C- <1>     db  000h, 000h, 000h, 000h, 000h, 018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h
   505 000165C5 18000000000000      <1>
   506 000165CC 00000000003060FE60- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 060h, 0feh, 060h, 030h, 000h, 000h, 000h, 000h, 000h, 000h
   506 000165D5 30000000000000      <1>
   507 000165DC 000000000000C0C0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c0h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h
   507 000165E5 FE000000000000      <1>
   508 000165EC 00000000002466FF66- <1>     db  000h, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 000h
   508 000165F5 24000000000000      <1>
   509 000165FC 000000001038387C7C- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 038h, 07ch, 07ch, 0feh, 0feh, 000h, 000h, 000h, 000h, 000h
   509 00016605 FEFE0000000000      <1>
   510 0001660C 00000000FEFE7C7C38- <1>     db  000h, 000h, 000h, 000h, 0feh, 0feh, 07ch, 07ch, 038h, 038h, 010h, 000h, 000h, 000h, 000h, 000h
   510 00016615 38100000000000      <1>
   511 0001661C 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   511 00016625 00000000000000      <1>
   512 0001662C 0000183C3C3C181818- <1>     db  000h, 000h, 018h, 03ch, 03ch, 03ch, 018h, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   512 00016635 00181800000000      <1>
   513 0001663C 006666662400000000- <1>     db  000h, 066h, 066h, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   513 00016645 00000000000000      <1>
   514 0001664C 0000006C6CFE6C6C6C- <1>     db  000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch, 06ch, 06ch, 0feh, 06ch, 06ch, 000h, 000h, 000h, 000h
   514 00016655 FE6C6C00000000      <1>
   515 0001665C 18187CC6C2C07C0606- <1>     db  018h, 018h, 07ch, 0c6h, 0c2h, 0c0h, 07ch, 006h, 006h, 086h, 0c6h, 07ch, 018h, 018h, 000h, 000h
   515 00016665 86C67C18180000      <1>
   516 0001666C 00000000C2C60C1830- <1>     db  000h, 000h, 000h, 000h, 0c2h, 0c6h, 00ch, 018h, 030h, 060h, 0c6h, 086h, 000h, 000h, 000h, 000h
   516 00016675 60C68600000000      <1>
   517 0001667C 0000386C6C3876DCCC- <1>     db  000h, 000h, 038h, 06ch, 06ch, 038h, 076h, 0dch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   517 00016685 CCCC7600000000      <1>
   518 0001668C 003030306000000000- <1>     db  000h, 030h, 030h, 030h, 060h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   518 00016695 00000000000000      <1>
   519 0001669C 00000C183030303030- <1>     db  000h, 000h, 00ch, 018h, 030h, 030h, 030h, 030h, 030h, 030h, 018h, 00ch, 000h, 000h, 000h, 000h
   519 000166A5 30180C00000000      <1>
   520 000166AC 000030180C0C0C0C0C- <1>     db  000h, 000h, 030h, 018h, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 018h, 030h, 000h, 000h, 000h, 000h
   520 000166B5 0C183000000000      <1>
   521 000166BC 0000000000663CFF3C- <1>     db  000h, 000h, 000h, 000h, 000h, 066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 000h, 000h, 000h
   521 000166C5 66000000000000      <1>
   522 000166CC 000000000018187E18- <1>     db  000h, 000h, 000h, 000h, 000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h
   522 000166D5 18000000000000      <1>
   523 000166DC 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 030h, 000h, 000h, 000h
   523 000166E5 18181830000000      <1>
   524 000166EC 00000000000000FE00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   524 000166F5 00000000000000      <1>
   525 000166FC 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   525 00016705 00181800000000      <1>
   526 0001670C 0000000002060C1830- <1>     db  000h, 000h, 000h, 000h, 002h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h, 000h, 000h, 000h
   526 00016715 60C08000000000      <1>
   527 0001671C 00003C66C3C3DBDBC3- <1>     db  000h, 000h, 03ch, 066h, 0c3h, 0c3h, 0dbh, 0dbh, 0c3h, 0c3h, 066h, 03ch, 000h, 000h, 000h, 000h
   527 00016725 C3663C00000000      <1>
   528 0001672C 000018387818181818- <1>     db  000h, 000h, 018h, 038h, 078h, 018h, 018h, 018h, 018h, 018h, 018h, 07eh, 000h, 000h, 000h, 000h
   528 00016735 18187E00000000      <1>
   529 0001673C 00007CC6060C183060- <1>     db  000h, 000h, 07ch, 0c6h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   529 00016745 C0C6FE00000000      <1>
   530 0001674C 00007CC606063C0606- <1>     db  000h, 000h, 07ch, 0c6h, 006h, 006h, 03ch, 006h, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   530 00016755 06C67C00000000      <1>
   531 0001675C 00000C1C3C6CCCFE0C- <1>     db  000h, 000h, 00ch, 01ch, 03ch, 06ch, 0cch, 0feh, 00ch, 00ch, 00ch, 01eh, 000h, 000h, 000h, 000h
   531 00016765 0C0C1E00000000      <1>
   532 0001676C 0000FEC0C0C0FC0606- <1>     db  000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0fch, 006h, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   532 00016775 06C67C00000000      <1>
   533 0001677C 00003860C0C0FCC6C6- <1>     db  000h, 000h, 038h, 060h, 0c0h, 0c0h, 0fch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   533 00016785 C6C67C00000000      <1>
   534 0001678C 0000FEC606060C1830- <1>     db  000h, 000h, 0feh, 0c6h, 006h, 006h, 00ch, 018h, 030h, 030h, 030h, 030h, 000h, 000h, 000h, 000h
   534 00016795 30303000000000      <1>
   535 0001679C 00007CC6C6C67CC6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   535 000167A5 C6C67C00000000      <1>
   536 000167AC 00007CC6C6C67E0606- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07eh, 006h, 006h, 006h, 00ch, 078h, 000h, 000h, 000h, 000h
   536 000167B5 060C7800000000      <1>
   537 000167BC 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
   537 000167C5 18180000000000      <1>
   538 000167CC 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 018h, 018h, 030h, 000h, 000h, 000h, 000h
   538 000167D5 18183000000000      <1>
   539 000167DC 000000060C18306030- <1>     db  000h, 000h, 000h, 006h, 00ch, 018h, 030h, 060h, 030h, 018h, 00ch, 006h, 000h, 000h, 000h, 000h
   539 000167E5 180C0600000000      <1>
   540 000167EC 00000000007E00007E- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 000h, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   540 000167F5 00000000000000      <1>
   541 000167FC 0000006030180C060C- <1>     db  000h, 000h, 000h, 060h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 060h, 000h, 000h, 000h, 000h
   541 00016805 18306000000000      <1>
   542 0001680C 00007CC6C60C181818- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 00ch, 018h, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   542 00016815 00181800000000      <1>
   543 0001681C 0000007CC6C6DEDEDE- <1>     db  000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0deh, 0deh, 0deh, 0dch, 0c0h, 07ch, 000h, 000h, 000h, 000h
   543 00016825 DCC07C00000000      <1>
   544 0001682C 000010386CC6C6FEC6- <1>     db  000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   544 00016835 C6C6C600000000      <1>
   545 0001683C 0000FC6666667C6666- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 066h, 066h, 066h, 066h, 0fch, 000h, 000h, 000h, 000h
   545 00016845 6666FC00000000      <1>
   546 0001684C 00003C66C2C0C0C0C0- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 000h, 000h, 000h, 000h
   546 00016855 C2663C00000000      <1>
   547 0001685C 0000F86C6666666666- <1>     db  000h, 000h, 0f8h, 06ch, 066h, 066h, 066h, 066h, 066h, 066h, 06ch, 0f8h, 000h, 000h, 000h, 000h
   547 00016865 666CF800000000      <1>
   548 0001686C 0000FE666268786860- <1>     db  000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 062h, 066h, 0feh, 000h, 000h, 000h, 000h
   548 00016875 6266FE00000000      <1>
   549 0001687C 0000FE666268786860- <1>     db  000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   549 00016885 6060F000000000      <1>
   550 0001688C 00003C66C2C0C0DEC6- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0deh, 0c6h, 0c6h, 066h, 03ah, 000h, 000h, 000h, 000h
   550 00016895 C6663A00000000      <1>
   551 0001689C 0000C6C6C6C6FEC6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   551 000168A5 C6C6C600000000      <1>
   552 000168AC 00003C181818181818- <1>     db  000h, 000h, 03ch, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   552 000168B5 18183C00000000      <1>
   553 000168BC 00001E0C0C0C0C0CCC- <1>     db  000h, 000h, 01eh, 00ch, 00ch, 00ch, 00ch, 00ch, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h
   553 000168C5 CCCC7800000000      <1>
   554 000168CC 0000E666666C78786C- <1>     db  000h, 000h, 0e6h, 066h, 066h, 06ch, 078h, 078h, 06ch, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
   554 000168D5 6666E600000000      <1>
   555 000168DC 0000F0606060606060- <1>     db  000h, 000h, 0f0h, 060h, 060h, 060h, 060h, 060h, 060h, 062h, 066h, 0feh, 000h, 000h, 000h, 000h
   555 000168E5 6266FE00000000      <1>
   556 000168EC 0000C3E7FFFFDBC3C3- <1>     db  000h, 000h, 0c3h, 0e7h, 0ffh, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h, 000h, 000h, 000h
   556 000168F5 C3C3C300000000      <1>
   557 000168FC 0000C6E6F6FEDECEC6- <1>     db  000h, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   557 00016905 C6C6C600000000      <1>
   558 0001690C 00007CC6C6C6C6C6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   558 00016915 C6C67C00000000      <1>
   559 0001691C 0000FC6666667C6060- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 060h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   559 00016925 6060F000000000      <1>
   560 0001692C 00007CC6C6C6C6C6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0deh, 07ch, 00ch, 00eh, 000h, 000h
   560 00016935 D6DE7C0C0E0000      <1>
   561 0001693C 0000FC6666667C6C66- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 06ch, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
   561 00016945 6666E600000000      <1>
   562 0001694C 00007CC6C660380C06- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 060h, 038h, 00ch, 006h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   562 00016955 C6C67C00000000      <1>
   563 0001695C 0000FFDB9918181818- <1>     db  000h, 000h, 0ffh, 0dbh, 099h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   563 00016965 18183C00000000      <1>
   564 0001696C 0000C6C6C6C6C6C6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   564 00016975 C6C67C00000000      <1>
   565 0001697C 0000C3C3C3C3C3C3C3- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h
   565 00016985 663C1800000000      <1>
   566 0001698C 0000C3C3C3C3C3DBDB- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 066h, 000h, 000h, 000h, 000h
   566 00016995 FF666600000000      <1>
   567 0001699C 0000C3C3663C18183C- <1>     db  000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 03ch, 066h, 0c3h, 0c3h, 000h, 000h, 000h, 000h
   567 000169A5 66C3C300000000      <1>
   568 000169AC 0000C3C3C3663C1818- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   568 000169B5 18183C00000000      <1>
   569 000169BC 0000FFC3860C183060- <1>     db  000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h, 030h, 060h, 0c1h, 0c3h, 0ffh, 000h, 000h, 000h, 000h
   569 000169C5 C1C3FF00000000      <1>
   570 000169CC 00003C303030303030- <1>     db  000h, 000h, 03ch, 030h, 030h, 030h, 030h, 030h, 030h, 030h, 030h, 03ch, 000h, 000h, 000h, 000h
   570 000169D5 30303C00000000      <1>
   571 000169DC 00000080C0E070381C- <1>     db  000h, 000h, 000h, 080h, 0c0h, 0e0h, 070h, 038h, 01ch, 00eh, 006h, 002h, 000h, 000h, 000h, 000h
   571 000169E5 0E060200000000      <1>
   572 000169EC 00003C0C0C0C0C0C0C- <1>     db  000h, 000h, 03ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 03ch, 000h, 000h, 000h, 000h
   572 000169F5 0C0C3C00000000      <1>
   573 000169FC 10386CC60000000000- <1>     db  010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   573 00016A05 00000000000000      <1>
   574 00016A0C 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 000h
   574 00016A15 00000000FF0000      <1>
   575 00016A1C 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   575 00016A25 00000000000000      <1>
   576 00016A2C 0000000000780C7CCC- <1>     db  000h, 000h, 000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   576 00016A35 CCCC7600000000      <1>
   577 00016A3C 0000E06060786C6666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 078h, 06ch, 066h, 066h, 066h, 066h, 07ch, 000h, 000h, 000h, 000h
   577 00016A45 66667C00000000      <1>
   578 00016A4C 00000000007CC6C0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c0h, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   578 00016A55 C0C67C00000000      <1>
   579 00016A5C 00001C0C0C3C6CCCCC- <1>     db  000h, 000h, 01ch, 00ch, 00ch, 03ch, 06ch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   579 00016A65 CCCC7600000000      <1>
   580 00016A6C 00000000007CC6FEC0- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   580 00016A75 C0C67C00000000      <1>
   581 00016A7C 0000386C6460F06060- <1>     db  000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   581 00016A85 6060F000000000      <1>
   582 00016A8C 000000000076CCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 0cch, 0cch, 07ch, 00ch, 0cch, 078h, 000h
   582 00016A95 CCCC7C0CCC7800      <1>
   583 00016A9C 0000E060606C766666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 06ch, 076h, 066h, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
   583 00016AA5 6666E600000000      <1>
   584 00016AAC 000018180038181818- <1>     db  000h, 000h, 018h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   584 00016AB5 18183C00000000      <1>
   585 00016ABC 00000606000E060606- <1>     db  000h, 000h, 006h, 006h, 000h, 00eh, 006h, 006h, 006h, 006h, 006h, 006h, 066h, 066h, 03ch, 000h
   585 00016AC5 06060666663C00      <1>
   586 00016ACC 0000E06060666C7878- <1>     db  000h, 000h, 0e0h, 060h, 060h, 066h, 06ch, 078h, 078h, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h
   586 00016AD5 6C66E600000000      <1>
   587 00016ADC 000038181818181818- <1>     db  000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   587 00016AE5 18183C00000000      <1>
   588 00016AEC 0000000000E6FFDBDB- <1>     db  000h, 000h, 000h, 000h, 000h, 0e6h, 0ffh, 0dbh, 0dbh, 0dbh, 0dbh, 0dbh, 000h, 000h, 000h, 000h
   588 00016AF5 DBDBDB00000000      <1>
   589 00016AFC 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 000h, 000h, 000h
   589 00016B05 66666600000000      <1>
   590 00016B0C 00000000007CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   590 00016B15 C6C67C00000000      <1>
   591 00016B1C 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h
   591 00016B25 66667C6060F000      <1>
   592 00016B2C 000000000076CCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 0cch, 0cch, 07ch, 00ch, 00ch, 01eh, 000h
   592 00016B35 CCCC7C0C0C1E00      <1>
   593 00016B3C 0000000000DC766660- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 076h, 066h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   593 00016B45 6060F000000000      <1>
   594 00016B4C 00000000007CC66038- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 060h, 038h, 00ch, 0c6h, 07ch, 000h, 000h, 000h, 000h
   594 00016B55 0CC67C00000000      <1>
   595 00016B5C 0000103030FC303030- <1>     db  000h, 000h, 010h, 030h, 030h, 0fch, 030h, 030h, 030h, 030h, 036h, 01ch, 000h, 000h, 000h, 000h
   595 00016B65 30361C00000000      <1>
   596 00016B6C 0000000000CCCCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   596 00016B75 CCCC7600000000      <1>
   597 00016B7C 0000000000C3C3C3C3- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h
   597 00016B85 663C1800000000      <1>
   598 00016B8C 0000000000C3C3C3DB- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h, 000h, 000h, 000h
   598 00016B95 DBFF6600000000      <1>
   599 00016B9C 0000000000C3663C18- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 066h, 03ch, 018h, 03ch, 066h, 0c3h, 000h, 000h, 000h, 000h
   599 00016BA5 3C66C300000000      <1>
   600 00016BAC 0000000000C6C6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 0f8h, 000h
   600 00016BB5 C6C67E060CF800      <1>
   601 00016BBC 0000000000FECC1830- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 0cch, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   601 00016BC5 60C6FE00000000      <1>
   602 00016BCC 00000E181818701818- <1>     db  000h, 000h, 00eh, 018h, 018h, 018h, 070h, 018h, 018h, 018h, 018h, 00eh, 000h, 000h, 000h, 000h
   602 00016BD5 18180E00000000      <1>
   603 00016BDC 000018181818001818- <1>     db  000h, 000h, 018h, 018h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   603 00016BE5 18181800000000      <1>
   604 00016BEC 0000701818180E1818- <1>     db  000h, 000h, 070h, 018h, 018h, 018h, 00eh, 018h, 018h, 018h, 018h, 070h, 000h, 000h, 000h, 000h
   604 00016BF5 18187000000000      <1>
   605 00016BFC 000076DC0000000000- <1>     db  000h, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   605 00016C05 00000000000000      <1>
   606 00016C0C 0000000010386CC6C6- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h
   606 00016C15 C6FE0000000000      <1>
   607 00016C1C 00003C66C2C0C0C0C2- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 00ch, 006h, 07ch, 000h, 000h
   607 00016C25 663C0C067C0000      <1>
   608 00016C2C 0000CC0000CCCCCCCC- <1>     db  000h, 000h, 0cch, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   608 00016C35 CCCC7600000000      <1>
   609 00016C3C 000C1830007CC6FEC0- <1>     db  000h, 00ch, 018h, 030h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   609 00016C45 C0C67C00000000      <1>
   610 00016C4C 0010386C00780C7CCC- <1>     db  000h, 010h, 038h, 06ch, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   610 00016C55 CCCC7600000000      <1>
   611 00016C5C 0000CC0000780C7CCC- <1>     db  000h, 000h, 0cch, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   611 00016C65 CCCC7600000000      <1>
   612 00016C6C 0060301800780C7CCC- <1>     db  000h, 060h, 030h, 018h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   612 00016C75 CCCC7600000000      <1>
   613 00016C7C 00386C3800780C7CCC- <1>     db  000h, 038h, 06ch, 038h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   613 00016C85 CCCC7600000000      <1>
   614 00016C8C 000000003C66606066- <1>     db  000h, 000h, 000h, 000h, 03ch, 066h, 060h, 060h, 066h, 03ch, 00ch, 006h, 03ch, 000h, 000h, 000h
   614 00016C95 3C0C063C000000      <1>
   615 00016C9C 0010386C007CC6FEC0- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   615 00016CA5 C0C67C00000000      <1>
   616 00016CAC 0000C600007CC6FEC0- <1>     db  000h, 000h, 0c6h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   616 00016CB5 C0C67C00000000      <1>
   617 00016CBC 00603018007CC6FEC0- <1>     db  000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   617 00016CC5 C0C67C00000000      <1>
   618 00016CCC 000066000038181818- <1>     db  000h, 000h, 066h, 000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   618 00016CD5 18183C00000000      <1>
   619 00016CDC 00183C660038181818- <1>     db  000h, 018h, 03ch, 066h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   619 00016CE5 18183C00000000      <1>
   620 00016CEC 006030180038181818- <1>     db  000h, 060h, 030h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   620 00016CF5 18183C00000000      <1>
   621 00016CFC 00C60010386CC6C6FE- <1>     db  000h, 0c6h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   621 00016D05 C6C6C600000000      <1>
   622 00016D0C 386C3800386CC6C6FE- <1>     db  038h, 06ch, 038h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   622 00016D15 C6C6C600000000      <1>
   623 00016D1C 18306000FE66607C60- <1>     db  018h, 030h, 060h, 000h, 0feh, 066h, 060h, 07ch, 060h, 060h, 066h, 0feh, 000h, 000h, 000h, 000h
   623 00016D25 6066FE00000000      <1>
   624 00016D2C 00000000006E3B1B7E- <1>     db  000h, 000h, 000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h, 000h, 000h
   624 00016D35 D8DC7700000000      <1>
   625 00016D3C 00003E6CCCCCFECCCC- <1>     db  000h, 000h, 03eh, 06ch, 0cch, 0cch, 0feh, 0cch, 0cch, 0cch, 0cch, 0ceh, 000h, 000h, 000h, 000h
   625 00016D45 CCCCCE00000000      <1>
   626 00016D4C 0010386C007CC6C6C6- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   626 00016D55 C6C67C00000000      <1>
   627 00016D5C 0000C600007CC6C6C6- <1>     db  000h, 000h, 0c6h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   627 00016D65 C6C67C00000000      <1>
   628 00016D6C 00603018007CC6C6C6- <1>     db  000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   628 00016D75 C6C67C00000000      <1>
   629 00016D7C 003078CC00CCCCCCCC- <1>     db  000h, 030h, 078h, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   629 00016D85 CCCC7600000000      <1>
   630 00016D8C 0060301800CCCCCCCC- <1>     db  000h, 060h, 030h, 018h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   630 00016D95 CCCC7600000000      <1>
   631 00016D9C 0000C60000C6C6C6C6- <1>     db  000h, 000h, 0c6h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 078h, 000h
   631 00016DA5 C6C67E060C7800      <1>
   632 00016DAC 00C6007CC6C6C6C6C6- <1>     db  000h, 0c6h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   632 00016DB5 C6C67C00000000      <1>
   633 00016DBC 00C600C6C6C6C6C6C6- <1>     db  000h, 0c6h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   633 00016DC5 C6C67C00000000      <1>
   634 00016DCC 0018187EC3C0C0C0C3- <1>     db  000h, 018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h
   634 00016DD5 7E181800000000      <1>
   635 00016DDC 00386C6460F0606060- <1>     db  000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 060h, 0e6h, 0fch, 000h, 000h, 000h, 000h
   635 00016DE5 60E6FC00000000      <1>
   636 00016DEC 0000C3663C18FF18FF- <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   636 00016DF5 18181800000000      <1>
   637 00016DFC 00FC66667C62666F66- <1>     db  000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 066h, 0f3h, 000h, 000h, 000h, 000h
   637 00016E05 6666F300000000      <1>
   638 00016E0C 000E1B1818187E1818- <1>     db  000h, 00eh, 01bh, 018h, 018h, 018h, 07eh, 018h, 018h, 018h, 018h, 018h, 0d8h, 070h, 000h, 000h
   638 00016E15 181818D8700000      <1>
   639 00016E1C 0018306000780C7CCC- <1>     db  000h, 018h, 030h, 060h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   639 00016E25 CCCC7600000000      <1>
   640 00016E2C 000C18300038181818- <1>     db  000h, 00ch, 018h, 030h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   640 00016E35 18183C00000000      <1>
   641 00016E3C 00183060007CC6C6C6- <1>     db  000h, 018h, 030h, 060h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   641 00016E45 C6C67C00000000      <1>
   642 00016E4C 0018306000CCCCCCCC- <1>     db  000h, 018h, 030h, 060h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   642 00016E55 CCCC7600000000      <1>
   643 00016E5C 000076DC00DC666666- <1>     db  000h, 000h, 076h, 0dch, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 000h, 000h, 000h
   643 00016E65 66666600000000      <1>
   644 00016E6C 76DC00C6E6F6FEDECE- <1>     db  076h, 0dch, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   644 00016E75 C6C6C600000000      <1>
   645 00016E7C 003C6C6C3E007E0000- <1>     db  000h, 03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   645 00016E85 00000000000000      <1>
   646 00016E8C 00386C6C38007C0000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   646 00016E95 00000000000000      <1>
   647 00016E9C 0000303000303060C0- <1>     db  000h, 000h, 030h, 030h, 000h, 030h, 030h, 060h, 0c0h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   647 00016EA5 C6C67C00000000      <1>
   648 00016EAC 000000000000FEC0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h
   648 00016EB5 C0C00000000000      <1>
   649 00016EBC 000000000000FE0606- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0feh, 006h, 006h, 006h, 006h, 000h, 000h, 000h, 000h, 000h
   649 00016EC5 06060000000000      <1>
   650 00016ECC 00C0C0C2C6CC183060- <1>     db  000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 060h, 0ceh, 09bh, 006h, 00ch, 01fh, 000h, 000h
   650 00016ED5 CE9B060C1F0000      <1>
   651 00016EDC 00C0C0C2C6CC183066- <1>     db  000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 066h, 0ceh, 096h, 03eh, 006h, 006h, 000h, 000h
   651 00016EE5 CE963E06060000      <1>
   652 00016EEC 00001818001818183C- <1>     db  000h, 000h, 018h, 018h, 000h, 018h, 018h, 018h, 03ch, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h
   652 00016EF5 3C3C1800000000      <1>
   653 00016EFC 0000000000366CD86C- <1>     db  000h, 000h, 000h, 000h, 000h, 036h, 06ch, 0d8h, 06ch, 036h, 000h, 000h, 000h, 000h, 000h, 000h
   653 00016F05 36000000000000      <1>
   654 00016F0C 0000000000D86C366C- <1>     db  000h, 000h, 000h, 000h, 000h, 0d8h, 06ch, 036h, 06ch, 0d8h, 000h, 000h, 000h, 000h, 000h, 000h
   654 00016F15 D8000000000000      <1>
   655 00016F1C 114411441144114411- <1>     db  011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h
   655 00016F25 44114411441144      <1>
   656 00016F2C 55AA55AA55AA55AA55- <1>     db  055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah
   656 00016F35 AA55AA55AA55AA      <1>
   657 00016F3C DD77DD77DD77DD77DD- <1>     db  0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h
   657 00016F45 77DD77DD77DD77      <1>
   658 00016F4C 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   658 00016F55 18181818181818      <1>
   659 00016F5C 18181818181818F818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   659 00016F65 18181818181818      <1>
   660 00016F6C 1818181818F818F818- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   660 00016F75 18181818181818      <1>
   661 00016F7C 36363636363636F636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   661 00016F85 36363636363636      <1>
   662 00016F8C 00000000000000FE36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   662 00016F95 36363636363636      <1>
   663 00016F9C 0000000000F818F818- <1>     db  000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   663 00016FA5 18181818181818      <1>
   664 00016FAC 3636363636F606F636- <1>     db  036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   664 00016FB5 36363636363636      <1>
   665 00016FBC 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   665 00016FC5 36363636363636      <1>
   666 00016FCC 0000000000FE06F636- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   666 00016FD5 36363636363636      <1>
   667 00016FDC 3636363636F606FE00- <1>     db  036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   667 00016FE5 00000000000000      <1>
   668 00016FEC 36363636363636FE00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   668 00016FF5 00000000000000      <1>
   669 00016FFC 1818181818F818F800- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   669 00017005 00000000000000      <1>
   670 0001700C 00000000000000F818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   670 00017015 18181818181818      <1>
   671 0001701C 181818181818181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   671 00017025 00000000000000      <1>
   672 0001702C 18181818181818FF00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   672 00017035 00000000000000      <1>
   673 0001703C 00000000000000FF18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   673 00017045 18181818181818      <1>
   674 0001704C 181818181818181F18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   674 00017055 18181818181818      <1>
   675 0001705C 00000000000000FF00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   675 00017065 00000000000000      <1>
   676 0001706C 18181818181818FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   676 00017075 18181818181818      <1>
   677 0001707C 18181818181F181F18- <1>     db  018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   677 00017085 18181818181818      <1>
   678 0001708C 363636363636363736- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   678 00017095 36363636363636      <1>
   679 0001709C 363636363637303F00- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   679 000170A5 00000000000000      <1>
   680 000170AC 00000000003F303736- <1>     db  000h, 000h, 000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   680 000170B5 36363636363636      <1>
   681 000170BC 3636363636F700FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   681 000170C5 00000000000000      <1>
   682 000170CC 0000000000FF00F736- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   682 000170D5 36363636363636      <1>
   683 000170DC 363636363637303736- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   683 000170E5 36363636363636      <1>
   684 000170EC 0000000000FF00FF00- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   684 000170F5 00000000000000      <1>
   685 000170FC 3636363636F700F736- <1>     db  036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   685 00017105 36363636363636      <1>
   686 0001710C 1818181818FF00FF00- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   686 00017115 00000000000000      <1>
   687 0001711C 36363636363636FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   687 00017125 00000000000000      <1>
   688 0001712C 0000000000FF00FF18- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   688 00017135 18181818181818      <1>
   689 0001713C 00000000000000FF36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   689 00017145 36363636363636      <1>
   690 0001714C 363636363636363F00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   690 00017155 00000000000000      <1>
   691 0001715C 18181818181F181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   691 00017165 00000000000000      <1>
   692 0001716C 00000000001F181F18- <1>     db  000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   692 00017175 18181818181818      <1>
   693 0001717C 000000000000003F36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   693 00017185 36363636363636      <1>
   694 0001718C 36363636363636FF36- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   694 00017195 36363636363636      <1>
   695 0001719C 1818181818FF18FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   695 000171A5 18181818181818      <1>
   696 000171AC 18181818181818F800- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   696 000171B5 00000000000000      <1>
   697 000171BC 000000000000001F18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   697 000171C5 18181818181818      <1>
   698 000171CC FFFFFFFFFFFFFFFFFF- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   698 000171D5 FFFFFFFFFFFFFF      <1>
   699 000171DC 00000000000000FFFF- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   699 000171E5 FFFFFFFFFFFFFF      <1>
   700 000171EC F0F0F0F0F0F0F0F0F0- <1>     db  0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
   700 000171F5 F0F0F0F0F0F0F0      <1>
   701 000171FC 0F0F0F0F0F0F0F0F0F- <1>     db  00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh
   701 00017205 0F0F0F0F0F0F0F      <1>
   702 0001720C FFFFFFFFFFFFFF0000- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   702 00017215 00000000000000      <1>
   703 0001721C 000000000076DCD8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 0d8h, 0d8h, 0d8h, 0dch, 076h, 000h, 000h, 000h, 000h
   703 00017225 D8DC7600000000      <1>
   704 0001722C 000078CCCCCCD8CCC6- <1>     db  000h, 000h, 078h, 0cch, 0cch, 0cch, 0d8h, 0cch, 0c6h, 0c6h, 0c6h, 0cch, 000h, 000h, 000h, 000h
   704 00017235 C6C6CC00000000      <1>
   705 0001723C 0000FEC6C6C0C0C0C0- <1>     db  000h, 000h, 0feh, 0c6h, 0c6h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h
   705 00017245 C0C0C000000000      <1>
   706 0001724C 00000000FE6C6C6C6C- <1>     db  000h, 000h, 000h, 000h, 0feh, 06ch, 06ch, 06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h
   706 00017255 6C6C6C00000000      <1>
   707 0001725C 000000FEC660301830- <1>     db  000h, 000h, 000h, 0feh, 0c6h, 060h, 030h, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   707 00017265 60C6FE00000000      <1>
   708 0001726C 00000000007ED8D8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 0d8h, 0d8h, 070h, 000h, 000h, 000h, 000h
   708 00017275 D8D87000000000      <1>
   709 0001727C 000000006666666666- <1>     db  000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0c0h, 000h, 000h, 000h
   709 00017285 7C6060C0000000      <1>
   710 0001728C 0000000076DC181818- <1>     db  000h, 000h, 000h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   710 00017295 18181800000000      <1>
   711 0001729C 0000007E183C666666- <1>     db  000h, 000h, 000h, 07eh, 018h, 03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h
   711 000172A5 3C187E00000000      <1>
   712 000172AC 000000386CC6C6FEC6- <1>     db  000h, 000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h
   712 000172B5 C66C3800000000      <1>
   713 000172BC 0000386CC6C6C66C6C- <1>     db  000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 06ch, 06ch, 06ch, 06ch, 0eeh, 000h, 000h, 000h, 000h
   713 000172C5 6C6CEE00000000      <1>
   714 000172CC 00001E30180C3E6666- <1>     db  000h, 000h, 01eh, 030h, 018h, 00ch, 03eh, 066h, 066h, 066h, 066h, 03ch, 000h, 000h, 000h, 000h
   714 000172D5 66663C00000000      <1>
   715 000172DC 00000000007EDBDBDB- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 0dbh, 0dbh, 0dbh, 07eh, 000h, 000h, 000h, 000h, 000h, 000h
   715 000172E5 7E000000000000      <1>
   716 000172EC 00000003067EDBDBF3- <1>     db  000h, 000h, 000h, 003h, 006h, 07eh, 0dbh, 0dbh, 0f3h, 07eh, 060h, 0c0h, 000h, 000h, 000h, 000h
   716 000172F5 7E60C000000000      <1>
   717 000172FC 00001C3060607C6060- <1>     db  000h, 000h, 01ch, 030h, 060h, 060h, 07ch, 060h, 060h, 060h, 030h, 01ch, 000h, 000h, 000h, 000h
   717 00017305 60301C00000000      <1>
   718 0001730C 0000007CC6C6C6C6C6- <1>     db  000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   718 00017315 C6C6C600000000      <1>
   719 0001731C 00000000FE0000FE00- <1>     db  000h, 000h, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h
   719 00017325 00FE0000000000      <1>
   720 0001732C 0000000018187E1818- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h
   720 00017335 0000FF00000000      <1>
   721 0001733C 00000030180C060C18- <1>     db  000h, 000h, 000h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 000h, 07eh, 000h, 000h, 000h, 000h
   721 00017345 30007E00000000      <1>
   722 0001734C 0000000C1830603018- <1>     db  000h, 000h, 000h, 00ch, 018h, 030h, 060h, 030h, 018h, 00ch, 000h, 07eh, 000h, 000h, 000h, 000h
   722 00017355 0C007E00000000      <1>
   723 0001735C 00000E1B1B18181818- <1>     db  000h, 000h, 00eh, 01bh, 01bh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   723 00017365 18181818181818      <1>
   724 0001736C 1818181818181818D8- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h, 0d8h, 070h, 000h, 000h, 000h, 000h
   724 00017375 D8D87000000000      <1>
   725 0001737C 000000001818007E00- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 07eh, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
   725 00017385 18180000000000      <1>
   726 0001738C 000000000076DC0076- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h
   726 00017395 DC000000000000      <1>
   727 0001739C 00386C6C3800000000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   727 000173A5 00000000000000      <1>
   728 000173AC 000000000000001818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   728 000173B5 00000000000000      <1>
   729 000173BC 000000000000000018- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   729 000173C5 00000000000000      <1>
   730 000173CC 000F0C0C0C0C0CEC6C- <1>     db  000h, 00fh, 00ch, 00ch, 00ch, 00ch, 00ch, 0ech, 06ch, 06ch, 03ch, 01ch, 000h, 000h, 000h, 000h
   730 000173D5 6C3C1C00000000      <1>
   731 000173DC 00D86C6C6C6C6C0000- <1>     db  000h, 0d8h, 06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   731 000173E5 00000000000000      <1>
   732 000173EC 0070D83060C8F80000- <1>     db  000h, 070h, 0d8h, 030h, 060h, 0c8h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   732 000173F5 00000000000000      <1>
   733 000173FC 000000007C7C7C7C7C- <1>     db  000h, 000h, 000h, 000h, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 000h, 000h, 000h, 000h, 000h
   733 00017405 7C7C0000000000      <1>
   734 0001740C 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   734 00017415 00000000000000      <1>
   735                              <1> 
   736                              <1> ; 01/01/2021 (TRDOS 386 v2.0.3)
   737                              <1> 
   738                              <1> %if 0
   739                              <1> 
   740                              <1> vgafont14alt:
   741                              <1>     db  01dh, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 022h
   742                              <1>     db  000h, 063h, 063h, 063h, 022h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02bh, 000h
   743                              <1>     db  000h, 000h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 02dh, 000h, 000h
   744                              <1>     db  000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 04dh, 000h, 000h, 0c3h
   745                              <1>     db  0e7h, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h, 000h, 000h, 054h, 000h, 000h, 0ffh, 0dbh
   746                              <1>     db  099h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 056h, 000h, 000h, 0c3h, 0c3h, 0c3h
   747                              <1>     db  0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 057h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h
   748                              <1>     db  0dbh, 0dbh, 0ffh, 066h, 066h, 000h, 000h, 000h, 058h, 000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h
   749                              <1>     db  03ch, 066h, 0c3h, 0c3h, 000h, 000h, 000h, 059h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
   750                              <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 05ah, 000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h, 030h, 061h
   751                              <1>     db  0c3h, 0ffh, 000h, 000h, 000h, 06dh, 000h, 000h, 000h, 000h, 000h, 0e6h, 0ffh, 0dbh, 0dbh, 0dbh
   752                              <1>     db  0dbh, 000h, 000h, 000h, 076h, 000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
   753                              <1>     db  000h, 000h, 000h, 077h, 000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h
   754                              <1>     db  000h, 000h, 091h, 000h, 000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h
   755                              <1>     db  000h, 09bh, 000h, 018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h
   756                              <1>     db  09dh, 000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 000h, 000h, 000h, 09eh
   757                              <1>     db  000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 0f3h, 000h, 000h, 000h, 0f1h, 000h
   758                              <1>     db  000h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 000h, 0ffh, 000h, 000h, 000h, 0f6h, 000h, 000h
   759                              <1>     db  018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   760                              <1> vgafont16alt:
   761                              <1>     db  01dh, 000h, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h
   762                              <1>     db  000h, 030h, 000h, 000h, 03ch, 066h, 0c3h, 0c3h, 0dbh, 0dbh, 0c3h, 0c3h, 066h, 03ch, 000h, 000h
   763                              <1>     db  000h, 000h, 04dh, 000h, 000h, 0c3h, 0e7h, 0ffh, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h
   764                              <1>     db  000h, 000h, 000h, 054h, 000h, 000h, 0ffh, 0dbh, 099h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch
   765                              <1>     db  000h, 000h, 000h, 000h, 056h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch
   766                              <1>     db  018h, 000h, 000h, 000h, 000h, 057h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh
   767                              <1>     db  066h, 066h, 000h, 000h, 000h, 000h, 058h, 000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 03ch
   768                              <1>     db  066h, 0c3h, 0c3h, 000h, 000h, 000h, 000h, 059h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
   769                              <1>     db  018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 05ah, 000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h
   770                              <1>     db  030h, 060h, 0c1h, 0c3h, 0ffh, 000h, 000h, 000h, 000h, 06dh, 000h, 000h, 000h, 000h, 000h, 0e6h
   771                              <1>     db  0ffh, 0dbh, 0dbh, 0dbh, 0dbh, 0dbh, 000h, 000h, 000h, 000h, 076h, 000h, 000h, 000h, 000h, 000h
   772                              <1>     db  0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h, 077h, 000h, 000h, 000h, 000h
   773                              <1>     db  000h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h, 000h, 000h, 000h, 078h, 000h, 000h, 000h
   774                              <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 03ch, 066h, 0c3h, 000h, 000h, 000h, 000h, 091h, 000h, 000h
   775                              <1>     db  000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h, 000h, 000h, 09bh, 000h
   776                              <1>     db  018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h, 09dh
   777                              <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   778                              <1>     db  09eh, 000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 066h, 0f3h, 000h, 000h, 000h
   779                              <1>     db  000h, 0abh, 000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 060h, 0ceh, 09bh, 006h, 00ch, 01fh
   780                              <1>     db  000h, 000h, 0ach, 000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 066h, 0ceh, 096h, 03eh, 006h
   781                              <1>     db  006h, 000h, 000h, 000h
   782                              <1> 
   783                              <1> %endif
  3591                                  
  3592                                  ; 20/11/2020
  3593                                  vbe2_bochs_vbios:
  3594                                  ;	db "BOCHS/QEMU"
  3595 0001741C 424F4348532F51454D-     	db "BOCHS/QEMU/VIRTUALBOX"  ; 26/11/2020
  3595 00017425 552F5649525455414C-
  3595 0001742E 424F58             
  3596                                  ;vbe_vnumber equ vbe2_bochs_vbios + 28 ; "3" or "2"
  3597                                  ; 26/11/2020
  3598                                  vbe_vnumber equ vbe2_bochs_vbios + 30 ; "3" or "2"
  3599                                  ; 15/11/2020
  3600                                  vesa_vbe3_bios_msg:
  3601                                  	;db " VESA VBE version 3 Video BIOS ..."
  3602 00017431 205645534120564245-     	db " VESA VBE3 Video BIOS ..." ; 26/11/2020
  3602 0001743A 3320566964656F2042-
  3602 00017443 494F53202E2E2E     
  3603 0001744A 0D0A0D0A00              	db 0Dh, 0Ah, 0Dh, 0Ah, 0
  3604                                  
  3605                                  ; 28/02/2021
  3606 0001744F 18                      truecolor: db 24
  3607                                  
  3608                                  align 2
  3609                                  
  3610                                  ; EPOCH Variables
  3611                                  ; 13/04/2015 - Retro UNIX 386 v1 Beginning
  3612                                  ; 09/04/2013 epoch variables
  3613                                  ; Retro UNIX 8086 v1 Prototype: UNIXCOPY.ASM, 10/03/2013
  3614                                  ;
  3615 00017450 B207                    year: 	dw 1970
  3616 00017452 0100                    month: 	dw 1
  3617 00017454 0100                    day: 	dw 1
  3618 00017456 0000                    hour: 	dw 0
  3619 00017458 0000                    minute: dw 0
  3620 0001745A 0000                    second: dw 0
  3621                                  
  3622                                  DMonth:
  3623 0001745C 0000                    	dw 0
  3624 0001745E 1F00                    	dw 31
  3625 00017460 3B00                    	dw 59
  3626 00017462 5A00                    	dw 90
  3627 00017464 7800                    	dw 120
  3628 00017466 9700                    	dw 151
  3629 00017468 B500                    	dw 181
  3630 0001746A D400                    	dw 212
  3631 0001746C F300                    	dw 243
  3632 0001746E 1101                    	dw 273
  3633 00017470 3001                    	dw 304
  3634 00017472 4E01                    	dw 334
  3635                                  
  3636                                  ; 15/11/2020
  3637 00017474 00                      db	0
  3638                                  kernel_version_msg: ; 17/04/2021
  3639                                  ;;;db	"TRDOS (386) Kernel v2.0.4 by Erdogan Tan"
  3640                                  ;;db	"TRDOS (386) Kernel v2.0.5 by Erdogan Tan" ; 11/08/2022
  3641                                  ;db	"TRDOS (386) Kernel v2.0.6 by Erdogan Tan" ; 29/08/2023
  3642 00017475 5452444F5320283338-     db	"TRDOS (386) Kernel v2.0.7 by Erdogan Tan" ; 20/10/2023
  3642 0001747E 3629204B65726E656C-
  3642 00017487 2076322E302E372062-
  3642 00017490 79204572646F67616E-
  3642 00017499 2054616E           
  3643 0001749D 00                      db	0
  3644                                  
  3645                                  ; 20/02/2017
  3646                                  KERNELFSIZE  equ $  ; 04/07/2016
  3647                                  
  3648                                  bss_start:
  3649                                  
  3650                                  ABSOLUTE bss_start
  3651                                  
  3652 0001749E ????                    alignb 8 ; 25/12/2016
  3653                                  
  3654                                  	; 15/04/2016
  3655                                  	; TRDOS 386 (TRDOS v2.0)
  3656                                  	; 	80 interrupts 	
  3657                                  	; 11/03/2015
  3658                                  	; Interrupt Descriptor Table (20/08/2014)
  3659                                  idt:
  3660                                  	;resb	64*8 ; INT 0 to INT 3Fh
  3661                                  	; 15/04/2016
  3662 000174A0 <res 280h>              	resb	80*8 ; INT 0 to INT 4Fh
  3663                                  
  3664                                  idt_end:
  3665                                  
  3666                                  ;alignb 4
  3667                                  
  3668                                  task_state_segment:
  3669                                  	; 24/03/2015
  3670 00017720 ????                    tss.link:   resw 1
  3671 00017722 ????                    	    resw 1
  3672                                  ; tss offset 4	
  3673 00017724 ????????                tss.esp0:   resd 1
  3674 00017728 ????                    tss.ss0:    resw 1
  3675 0001772A ????                    	    resw 1	
  3676 0001772C ????????                tss.esp1:   resd 1
  3677 00017730 ????                    tss.ss1:    resw 1
  3678 00017732 ????                    	    resw 1 	
  3679 00017734 ????????                tss.esp2:   resd 1
  3680 00017738 ????                    tss.ss2:    resw 1
  3681 0001773A ????                    	    resw 1
  3682                                  ; tss offset 28
  3683 0001773C ????????                tss.CR3:    resd 1
  3684 00017740 ????????                tss.eip:    resd 1
  3685 00017744 ????????                tss.eflags: resd 1
  3686                                  ; tss offset 40
  3687 00017748 ????????                tss.eax:    resd 1		 		
  3688 0001774C ????????                tss.ecx:    resd 1
  3689 00017750 ????????                tss.edx:    resd 1
  3690 00017754 ????????                tss.ebx:    resd 1
  3691 00017758 ????????                tss.esp:    resd 1
  3692 0001775C ????????                tss.ebp:    resd 1
  3693 00017760 ????????                tss.esi:    resd 1
  3694 00017764 ????????                tss.edi:    resd 1
  3695                                  ; tss offset 72
  3696 00017768 ????                    tss.ES:     resw 1
  3697 0001776A ????                    	    resw 1	
  3698 0001776C ????                    tss.CS:	    resw 1
  3699 0001776E ????                    	    resw 1
  3700 00017770 ????                    tss.SS:	    resw 1
  3701 00017772 ????                    	    resw 1
  3702 00017774 ????                    tss.DS:	    resw 1
  3703 00017776 ????                    	    resw 1
  3704 00017778 ????                    tss.FS:	    resw 1
  3705 0001777A ????                    	    resw 1
  3706 0001777C ????                    tss.GS:	    resw 1
  3707 0001777E ????                    	    resw 1		
  3708 00017780 ????                    tss.LDTR:   resw 1
  3709 00017782 ????                    	    resw 1
  3710                                  ; tss offset 100		
  3711 00017784 ????                    	    resw 1		
  3712 00017786 ????                    tss.IOPB:   resw 1
  3713                                  ; tss offset 104 
  3714                                  tss_end:
  3715                                  
  3716 00017788 ????????                k_page_dir:  resd 1 ; Kernel's (System) Page Directory address
  3717                                  		    ; (Physical address = Virtual address)	 	
  3718 0001778C ????????                memory_size: resd 1 ; memory size in pages
  3719 00017790 ????????                free_pages:  resd 1 ; number of free pages		
  3720 00017794 ????????                next_page:   resd 1 ; offset value in M.A.T. for
  3721                                  		    ; first free page search
  3722 00017798 ????????                last_page:   resd 1 ; offset value in M.A.T. which
  3723                                  		    ; next free page search will be
  3724                                  		    ; stopped after it. (end of M.A.T.)
  3725 0001779C ????????                first_page:  resd 1 ; offset value in M.A.T. which
  3726                                  		    ; first free page search
  3727                                  		    ; will be started on it. (for user)
  3728 000177A0 ????????                mat_size:    resd 1 ; Memory Allocation Table size in pages
  3729                                  
  3730                                  ; 20/11/2020
  3731                                  ;vbe2bios:    resw 1 ; VBE2 video bios ID (bochs/qemu)
  3732                                  ;		    ; (0B0C4h or 0B0C5h for bochs/plex86 vgabios)				
  3733                                  
  3734                                  ; 02/09/2014 (Retro UNIX 386 v1)
  3735                                  ; 04/12/2013 (Retro UNIX 8086 v1)
  3736 000177A4 ????                    CRT_START:   resw 1 	  ; starting address in regen buffer
  3737                                  			  ; NOTE: active page only	
  3738 000177A6 <res 10h>               CURSOR_POSN: resw 8 ; cursor positions for video pages
  3739                                  ACTIVE_PAGE: 
  3740 000177B6 ??                      ptty: 	     resb 1 ; current tty
  3741                                  ; 01/07/2015 - 29/01/2016
  3742 000177B7 ??                      ccolor:	     resb 1 ; current color attribute
  3743                                  ; 26/10/2015
  3744                                  ; 07/09/2014
  3745 000177B8 <res 14h>               ttychr:      resw ntty+2 ; Character buffer (multiscreen)
  3746                                  
  3747                                  ; 18/05/2015 (03/06/2013 - Retro UNIX 8086 v1 feature only!)
  3748 000177CC ????????                p_time:      resd 1     ; present time (for systime & sysmdate)
  3749                                  
  3750                                  ; 18/05/2015 (16/08/2013 - Retro UNIX 8086 v1 feature only !)
  3751                                  ; (open mode locks for pseudo TTYs)
  3752                                  ; [ major tty locks (return error in any conflicts) ]
  3753 000177D0 <res 14h>               ttyl:        resw ntty+2 ; opening locks for TTYs.
  3754                                  
  3755                                  ; 15/04/2015 (Retro UNIX 386 v1)
  3756                                  ; 22/09/2013 (Retro UNIX 8086 v1)
  3757 000177E4 <res Ah>                wlist:       resb ntty+2 ; wait channel list (0 to 9 for TTYs)
  3758                                  ; 15/04/2015 (Retro UNIX 386 v1)
  3759                                  ;; 12/07/2014 -> sp_init set comm. parameters as 0E3h
  3760                                  ;; 0 means serial port is not available 
  3761                                  ;;comprm: ; 25/06/2014
  3762 000177EE ??                      com1p:       resb 1  ;;0E3h
  3763 000177EF ??                      com2p:       resb 1  ;;0E3h
  3764                                  
  3765                                  ; 17/11/2015
  3766                                  ; request for response (from the terminal)	
  3767 000177F0 ????                    req_resp:    resw 1 			
  3768                                  ; 07/11/2015
  3769 000177F2 ??                      ccomport:    resb 1 ; current COM (serial) port
  3770                                  		    ; (0= COM1, 1= COM2)
  3771                                  ; 09/11/2015
  3772 000177F3 ??                      comqr:	     resb 1 ; 'query or response' sign (u9.s, 'sndc')
  3773                                  ; 07/11/2015
  3774 000177F4 ????                    rchar:	     resw 1 ; last received char for COM 1 and COM 2		
  3775 000177F6 ????                    schar:	     resw 1 ; last sent char for COM 1 and COM 2
  3776                                  
  3777                                  ; 22/08/2014 (RTC)
  3778                                  ; (Packed BCD)
  3779 000177F8 ??                      time_seconds: resb 1
  3780 000177F9 ??                      time_minutes: resb 1
  3781 000177FA ??                      time_hours:   resb 1
  3782 000177FB ??                      date_wday:    resb 1
  3783 000177FC ??                      date_day:     resb 1
  3784 000177FD ??                      date_month:   resb 1			
  3785 000177FE ??                      date_year:    resb 1
  3786 000177FF ??                      date_century: resb 1
  3787                                  
  3788                                  ; 24/01/2016
  3789 00017800 ????????                RTC_LH:	       resd 1
  3790 00017804 ??                      RTC_WAIT_FLAG: resb 1
  3791 00017805 ??                      USER_FLAG:     resb 1
  3792                                  ; 19/05/2016
  3793                                  ;RTC_second:
  3794 00017806 ??                      RTC_2Hz:       resb 1 ;  from 2Hz interrupt to 1Hz timer event function	
  3795                                  
  3796                                  %include 'diskbss.s'	; UNINITIALIZED DISK (BIOS) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.5 - diskbss.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 06/08/2022 (Previous: 24/01/2016)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; diskbss.inc (10/07/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - DISKBSS.INC
    20                              <1> ; Last Modification: 10/07/2015
    21                              <1> ;	(Unitialized Disk Parameters Data section for 'DISKIO.INC') 
    22                              <1> 
    23 00017807 ??                  <1> alignb 2
    24                              <1> 
    25                              <1> ;----------------------------------------
    26                              <1> ;	TIMER DATA AREA 		:
    27                              <1> ;----------------------------------------
    28                              <1> 
    29                              <1> TIMER_LH:	; 16/02/2015
    30 00017808 ????                <1> TIMER_LOW:      resw	1               ; LOW WORD OF TIMER COUNT
    31 0001780A ????                <1> TIMER_HIGH:     resw	1               ; HIGH WORD OF TIMER COUNT
    32 0001780C ??                  <1> TIMER_OFL:      resb 	1               ; TIMER HAS ROLLED OVER SINCE LAST READ
    33                              <1> 
    34                              <1> ;----------------------------------------
    35                              <1> ;	DISKETTE DATA AREAS		:
    36                              <1> ;----------------------------------------
    37                              <1> 
    38 0001780D ??                  <1> SEEK_STATUS:	resb	1
    39 0001780E ??                  <1> MOTOR_STATUS:	resb	1
    40 0001780F ??                  <1> MOTOR_COUNT:	resb	1
    41 00017810 ??                  <1> DSKETTE_STATUS:	resb	1
    42 00017811 ??????????????      <1> NEC_STATUS:	resb	7
    43                              <1> 
    44                              <1> ;----------------------------------------
    45                              <1> ;	ADDITIONAL MEDIA DATA		:
    46                              <1> ;----------------------------------------
    47                              <1> 
    48 00017818 ??                  <1> LASTRATE:	resb 	1
    49 00017819 ??                  <1> HF_STATUS:	resb 	1
    50                              <1> ; 06/08/2022
    51                              <1> ;HF_ERROR:	resb 	1
    52 0001781A ??                  <1> HF_INT_FLAG:	resb 	1
    53                              <1> ; 06/08/2022
    54                              <1> ;HF_CNTRL:	resb 	1
    55                              <1> ;DSK_STATE:	resb 	4
    56                              <1> ; 06/08/2022
    57 0001781B ????                <1> DSK_STATE:	resb	2 	
    58 0001781D ????                <1> DSK_TRK:	resb 	2
    59                              <1> 
    60                              <1> ;----------------------------------------
    61                              <1> ;	FIXED DISK DATA AREAS		:
    62                              <1> ;----------------------------------------
    63                              <1> 
    64 0001781F ??                  <1> DISK_STATUS1:	resb 	1		; FIXED DISK STATUS
    65 00017820 ??                  <1> HF_NUM:		resb 	1		; COUNT OF FIXED DISK DRIVES
    66 00017821 ??                  <1> CONTROL_BYTE:	resb 	1		; HEAD CONTROL BYTE
    67                              <1> ;@PORT_OFF	resb	1		; RESERVED (PORT OFFSET)
    68                              <1> ;port1_off	resb	1		; Hard disk controller 1 - port offset
    69                              <1> ;port2_off	resb	1		; Hard disk controller 2 - port offset
    70                              <1> 
    71 00017822 ????                <1> alignb 4
    72                              <1> 
    73                              <1> ;HF_TBL_VEC:	resd	1 		; Primary master disk param. tbl. pointer
    74                              <1> ;HF1_TBL_VEC:	resd	1		; Primary slave disk param. tbl. pointer
    75                              <1> HF_TBL_VEC: ; 22/12/2014	
    76 00017824 ????????            <1> HDPM_TBL_VEC:	resd	1 		; Primary master disk param. tbl. pointer
    77 00017828 ????????            <1> HDPS_TBL_VEC:	resd	1		; Primary slave disk param. tbl. pointer
    78 0001782C ????????            <1> HDSM_TBL_VEC:	resd	1 		; Secondary master disk param. tbl. pointer
    79 00017830 ????????            <1> HDSS_TBL_VEC:	resd	1		; Secondary slave disk param. tbl. pointer
    80                              <1> 
    81                              <1> ; 03/01/2015
    82 00017834 ??                  <1> LBAMode:     	resb	1
    83                              <1> 
    84                              <1> ; *****************************************************************************
  3797                                  
  3798                                  ;;; Real Mode Data (10/07/2015 - BSS)
  3799                                  
  3800                                  ;alignb 2
  3801                                  
  3802                                  ; 10/01/2016
  3803                                  %include 'trdoskx.s'	; UNINITIALIZED KERNEL (Logical Drive & FS) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - UNINITIALIZED DATA : trdoskx.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 29/06/2022 (Previous: 17/04/2021 - Kernel v2.0.4)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 04/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; TRDOS2.ASM (09/11/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; DRV_INIT.ASM [26/09/2009] Last Update: 07/08/2011
    14                              <1> ; MAINPROG.ASM [17/01/2004] Last Update: 09/11/2011
    15                              <1> ; DIR.ASM      [17/01/2004] Last Update: 09/10/2011
    16                              <1> ; CMD_INTR.ASM [29/01/2005] Last update: 09/11/2011
    17                              <1> ; DRV_FAT.ASM  [07/07/2009] Last update: 21/08/2011
    18                              <1> 
    19 00017835 ??????              <1> alignb 4
    20                              <1> 
    21                              <1> ; MAINPROG.ASM
    22 00017838 ????????            <1> MainProgCfg_FileSize:   resd 1 ; 14/04/2016
    23 0001783C ????????            <1> MainProgCfg_LineOffset: resd 1 ; 14/04/2016
    24                              <1> 
    25 00017840 ????????            <1> Current_VolSerial: resd 1
    26                              <1> 
    27 00017844 ????????            <1> Current_Dir_FCluster: resd 1
    28                              <1> 
    29 00017848 ??                  <1> Current_Dir_Level: resb 1
    30 00017849 ??                  <1> Current_FATType: resb 1
    31 0001784A ??                  <1> Current_Drv: resb 1
    32 0001784B ??                  <1> Current_Dir_Drv:   resb 1 ; '?'
    33 0001784C ??                  <1>                    resb 1 ; ':'
    34 0001784D ??                  <1> Current_Dir_Root:  resb 1 ; '/' 
    35 0001784E <res 5Ah>           <1> Current_Directory: resb 90
    36 000178A8 ??                  <1> End_Of_Current_Dir_Str: resb 1
    37 000178A9 ??                  <1> Current_Dir_StrLen: resb 1   
    38                              <1> 
    39 000178AA ??                  <1> CursorColumn: 	resb 1
    40 000178AB ??                  <1> CmdArgStart:    resb 1
    41                              <1> 
    42                              <1> ; 03/02/2016
    43 000178AC <res 4Eh>           <1> Remark:		resb 78
    44                              <1> 
    45 000178FA <res 50h>           <1> CommandBuffer: 	resb 80
    46                              <1> 
    47 0001794A <res 100h>          <1> TextBuffer:	resb 256
    48                              <1> 
    49                              <1> MasterBootBuff:
    50 00017A4A <res 1BEh>          <1> MasterBootCode: resb 1BEh
    51 00017C08 <res 40h>           <1> PartitionTable: resb 64
    52 00017C48 ????                <1> MBIDCode: resw 1
    53                              <1> 
    54                              <1> PTable_Buffer:
    55 00017C4A <res 40h>           <1> PTable_hd0: resb 64
    56 00017C8A <res 40h>           <1> PTable_hd1: resb 64
    57 00017CCA <res 40h>           <1> PTable_hd2: resb 64
    58 00017D0A <res 40h>           <1> PTable_hd3: resb 64
    59                              <1> ; 15/07/2020
    60                              <1> ;PTable_ep0: resb 64
    61                              <1> ;PTable_ep1: resb 64
    62                              <1> ;PTable_ep2: resb 64
    63                              <1> ;PTable_ep3: resb 64
    64                              <1> 
    65                              <1> ; 13/08/2020
    66 00017D4A ??                  <1> scount: resb 1 ; 16/05/2016 (diskio.s, 'int33h:')
    67 00017D4B ??                  <1> 	resb 1
    68 00017D4C ??                  <1> 	resb 1
    69 00017D4D ??                  <1> 	resb 1
    70                              <1> 	
    71 00017D4E ??                  <1> HD_LBA_yes: resb 1
    72 00017D4F ??                  <1> PP_Counter: resb 1
    73 00017D50 ??                  <1> EP_Counter: resb 1
    74                              <1> ; 13/08/2020
    75 00017D51 ??                  <1> LD_Counter: resb 1
    76                              <1> 
    77                              <1> ; 30/08/2020
    78 00017D52 ????????            <1> MBR_EP_StartSector: resd 1 
    79                              <1> 		; Extd partition start sector as in MBR
    80 00017D56 ????????            <1> EP_StartSector: resd 1 ; next extd partition start sector
    81                              <1> 	; 15/07/2020	
    82                              <1>                 ;resd 1
    83                              <1>                 ;resd 1
    84                              <1> 
    85                              <1> ; 20/07/2020
    86 00017D5A <res 200h>          <1> DOSBootSectorBuff: resb 512
    87                              <1> ; 15/07/2020
    88                              <1> ;DOSBootSectorBuff: resb 446 ; 1BEh
    89                              <1> ;MiniPartitionTable: resb 64 ;  40h
    90                              <1> ;MiniPartitionMagic: resw  1 ;  02h 		
    91                              <1> 
    92                              <1> FAT_BuffDescriptor:
    93 00017F5A ????????            <1> FAT_CurrentCluster: resd 1
    94 00017F5E ??                  <1> FAT_BuffValidData: resb 1
    95 00017F5F ??                  <1> FAT_BuffDrvName: resb 1
    96 00017F60 ????                <1> FAT_BuffOffset: resw 1
    97 00017F62 ????????            <1> FAT_BuffSector: resd 1
    98                              <1> 
    99 00017F66 ????????            <1> FAT_ClusterCounter: resd 1
   100 00017F6A ????????            <1> LastCluster: resd 1
   101                              <1> 
   102                              <1> ; 16/05/2016
   103                              <1> ;; 18/03/2016 (TRDOS v2.0)
   104                              <1> ;ClusterBuffer_Valid: resb 1
   105                              <1> 
   106                              <1> ; 29/07/2022
   107 00017F6E ??                  <1> resb 1
   108                              <1> 
   109                              <1> Dir_BuffDescriptor:
   110 00017F6F ??                  <1> DirBuff_DRV: resb 1
   111 00017F70 ??                  <1> DirBuff_FATType: resb 1
   112 00017F71 ??                  <1> DirBuff_ValidData: resb 1
   113 00017F72 ????                <1> DirBuff_CurrentEntry: resw 1
   114 00017F74 ????                <1> DirBuff_LastEntry: resw 1
   115 00017F76 ????????            <1> DirBuff_Cluster: resd 1 
   116 00017F7A ????                <1> DirBuffer_Size: resw 1
   117                              <1> ;DirBuff_EntryCounter: resw 1
   118                              <1> 
   119                              <1> ; 01/02/2016
   120                              <1> ; these are on (real mode) segment 8000h and later
   121                              <1> ; FAT_Buffer:	resb 1536 ; 3 sectors
   122                              <1> ; Dir_Buffer:	resb 512*32
   123                              <1> ; Logical_DOSDisks:  resb 6656 ; 26 * 256 bytes
   124                              <1> 
   125                              <1> ; 18/01/2016
   126                              <1> 
   127 00017F7C ????????            <1> FreeClusterCount: resd 1
   128                              <1> 
   129 00017F80 ????????            <1> VolSize_Unit1:   resd 1
   130 00017F84 ????????            <1> VolSize_Unit2:   resd 1
   131                              <1> 
   132 00017F88 ????????            <1> Vol_Tot_Sec_Str_Start:	    resd 1
   133 00017F8C <res Ah>            <1> Vol_Tot_Sec_Str: 	    resb 10
   134 00017F96 ??                  <1> Vol_Tot_Sec_Str_End:	    resb 1
   135 00017F97 ??                  <1> resb 1
   136 00017F98 ????????            <1> Vol_Free_Sectors_Str_Start: resd 1
   137 00017F9C <res Ah>            <1> Vol_Free_Sectors_Str:	    resb 10				
   138 00017FA6 ??                  <1> Vol_Free_Sectors_Str_End:   resb 1
   139                              <1> 
   140                              <1> ; 10/02/2016
   141 00017FA7 ??                  <1> RUN_CDRV: resb 1 ; CMD_INTR.ASM  ; 09/11/2011
   142                              <1> 
   143                              <1> ; 24/01/2016
   144 00017FA8 <res 80h>           <1> PATH_Array:     resb 128 ; DIR.ASM ; 09/10/2011
   145                              <1> ; 06/02/2016
   146 00018028 ????????            <1> CCD_DriveDT:	resd 1 ; DIR.ASM ; (word)
   147 0001802C ??                  <1> CCD_Level:	resb 1 ; DIR.ASM
   148 0001802D ??                  <1> Last_Dir_Level:	resb 1 ; DIR.ASM
   149                              <1> ;
   150 0001802E ????                <1> CDLF_AttributesMask: resw 1 ; DIR.ASM
   151 00018030 ????????            <1> CDLF_FNAddress:	resd 1 ; DIR.ASM (word)
   152 00018034 ????                <1> CDLF_DEType:	resw 1 ; DIR.ASM
   153                              <1> ;
   154 00018036 ??                  <1> CD_COMMAND:	resb 1 ; DIR.ASM
   155                              <1> 
   156 00018037 ??                  <1> alignb 4
   157                              <1> 
   158                              <1> ; 29/01/2016
   159 00018038 ??                  <1> Program_Exit:	resb 1 ; CMD_INTR.ASM  ; 09/11/2011
   160                              <1> 
   161                              <1> ;alignb 4
   162                              <1> ; 23/02/2016
   163 00018039 ??                  <1> disk_rw_op:	resb 1 ; 0 = disk read, 1 = disk write
   164                              <1> ;disk_rw_spt:	resb 1 ; sectors per track (<= 63) /// (<256)
   165                              <1> ; 31/01/2016
   166 0001803A ??                  <1> retry_count: 	resb 1 ; DISK_IO.ASM ; 20/07/2011 (CHS_RetryCount)
   167 0001803B ??                  <1> disk_rw_err: 	resb 1 ; DISK_IO.ASM ; (Disk_IO_err_code)
   168 0001803C ????????            <1> sector_count:	resd 1 ; DISK_IO.ASM ; (Disk_RW_SectorCount)
   169                              <1> 
   170                              <1> ; 06/02/2016 (long name)
   171 00018040 ????                <1> FDE_AttrMask:	   resw 1 ; DIR.ASM
   172 00018042 ????                <1> AmbiguousFileName: resw 1 ; DIR.ASM
   173 00018044 ??                  <1> PreviousAttr:	   resb 1 ; DIR.ASM
   174                              <1> ;	
   175 00018045 ??                  <1> LongNameFound:   resb 1	  ; DIR.ASM
   176 00018046 ??                  <1> LFN_EntryLength: resb 1   ; DIR.ASM
   177 00018047 ??                  <1> LFN_CheckSum:    resb 1   ; DIR.ASM
   178 00018048 <res 84h>           <1> LongFileName:    resb 132 ; DIR.ASM
   179                              <1> 
   180                              <1> ;PATH_Array_Ptr: resw 1 ; DIR.ASM
   181 000180CC ??                  <1> PATH_CDLevel:	 resb 1 ; DIR.ASM
   182 000180CD ??                  <1> PATH_Level:	 resb 1 ; DIR.ASM
   183                              <1> 
   184                              <1> ; 07/02/2016
   185 000180CE <res Dh>            <1> Dir_File_Name:	resb 13 ; DIR.ASM ; 09/10/2011
   186                              <1> 
   187                              <1> ; 10/02/2016
   188 000180DB <res Dh>            <1> Dir_Entry_Name:	resb 13 ; DIR.ASM
   189                              <1> 
   190                              <1> alignb 2
   191                              <1> 
   192 000180E8 ????                <1> AttributesMask: resw 1 ; CMD_INTR.ASM ; 09/11/2011
   193                              <1> 
   194                              <1> ; 10/02/2016 (128 bytes -> 126 bytes)
   195                              <1> ; 08/02/2016
   196                              <1> ;FFF Structure (128 bytes) ; DIR.ASM ; 09/10/2011
   197 000180EA ??                  <1> FindFile_Drv:		  resb 1
   198 000180EB <res 41h>           <1> FindFile_Directory:	  resb 65
   199 0001812C <res Dh>            <1> FindFile_Name:		  resb 13
   200                              <1> FindFile_LongNameEntryLength:
   201 00018139 ??                  <1> FindFile_LongNameYes: 	  resb 1 ; Sign for longname procedures
   202                              <1> ;Above 80 bytes form
   203                              <1> ;TR-DOS Source/Destination File FullName Format/Structure
   204 0001813A ????                <1> FindFile_AttributesMask:  resw 1
   205 0001813C <res 20h>           <1> FindFile_DirEntry:	  resb 32
   206 0001815C ????????            <1> FindFile_DirFirstCluster: resd 1
   207 00018160 ????????            <1> FindFile_DirCluster:	  resd 1
   208 00018164 ????                <1> FindFile_DirEntryNumber:  resw 1
   209 00018166 ????                <1> FindFile_MatchCounter:	  resw 1
   210 00018168 ????                <1> FindFile_Reserved:	  resw 1 ; 06/03/2016
   211                              <1> 
   212 0001816A ????????            <1> First_Path_Pos: resd 1	; DIR.ASM ; 09/10/2011
   213 0001816E ????????            <1> Last_Slash_Pos: resd 1	; DIR.ASM 
   214                              <1> 
   215                              <1> ; 10/02/2016
   216 00018172 ????                <1> File_Count:     resw 1 	; DIR.ASM ; 09/10/2011
   217 00018174 ????                <1> Dir_Count:      resw 1
   218 00018176 ????????            <1> Total_FSize:    resd 1
   219 0001817A ????????            <1> TFS_Dec_Begin:  resd 1
   220 0001817E <res Ah>            <1>                 resb 10
   221 00018188 ??                  <1> TFS_Dec_End:    resb 1
   222                              <1> 
   223 00018189 ??                  <1> PrintDir_RowCounter: resb 1
   224                              <1> 
   225 0001818A ????                <1> alignb 4
   226                              <1> ; 15/02/2015 ('show' command variables)
   227 0001818C ????????            <1> Show_FDT:	resd 1
   228 00018190 ????????            <1> Show_LDDDT:	resd 1
   229 00018194 ????????            <1> Show_Cluster:	resd 1
   230 00018198 ????????            <1> Show_FileSize:	resd 1
   231 0001819C ????????            <1> Show_FilePointer: resd 1
   232 000181A0 ????                <1> Show_ClusterPointer: resw 1
   233 000181A2 ????                <1> Show_ClusterSize: resw 1
   234 000181A4 ??                  <1> Show_RowCount:	resb 1
   235                              <1> 
   236 000181A5 ??????              <1> alignb 4
   237                              <1> ; 21/02/2016
   238 000181A8 ????????            <1> DelFile_FNPointer:	resd 1 ; ; CMD_INTR.ASM (word) ; 09/11/2011
   239                              <1> ; 27/02/2016
   240                              <1> ; DIR.ASM (09/10/2011)
   241 000181AC ????????            <1> DelFile_FCluster:	resd 1
   242 000181B0 ????                <1> DelFile_EntryCounter:	resw 1
   243 000181B2 ??                  <1> DelFile_LNEL:		resb 1
   244 000181B3 ??                  <1> resb 1
   245                              <1> 
   246                              <1> ; DIR.ASM
   247 000181B4 ????????            <1> mkdir_DirName_Offset: 	resd 1
   248 000181B8 ????????            <1> mkdir_FFCluster:	resd 1
   249 000181BC ????????            <1> mkdir_LastDirCluster:	resd 1
   250 000181C0 ????????            <1> mkdir_FreeSectors:	resd 1
   251 000181C4 ????                <1> mkdir_attrib:		resw 1 
   252 000181C6 ??                  <1> mkdir_SecPerClust:	resb 1
   253 000181C7 ??                  <1> mkdir_add_new_cluster:	resb 1
   254 000181C8 <res Dh>            <1> mkdir_Name:		resb 13
   255 000181D5 ????                <1> resw 1 ; 01/03/2016
   256                              <1> ; 27/02/2016
   257 000181D7 ??                  <1> RmDir_MultiClusters:	resb 1  
   258 000181D8 ????????            <1> RmDir_DirEntryOffset:	resd 1 ; 01/03/2016 (word -> dword)
   259 000181DC ????????            <1> RmDir_ParentDirCluster: resd 1
   260 000181E0 ????????            <1> RmDir_DirLastCluster:   resd 1
   261 000181E4 ????????            <1> RmDir_PreviousCluster:  resd 1
   262                              <1> ; 22/02/2016
   263 000181E8 ??                  <1> UPDLMDT_CDirLevel:	resb 1
   264 000181E9 ????????            <1> UPDLMDT_CDirFCluster:	resd 1
   265                              <1> 	
   266 000181ED ??????              <1> alignb 4
   267                              <1> ; DRV_FAT.ASM ; 21/08/2011
   268 000181F0 ????????            <1> gffc_next_free_cluster:  resd 1
   269 000181F4 ????????            <1> gffc_first_free_cluster: resd 1
   270 000181F8 ????????            <1> gffc_last_free_cluster:  resd 1
   271                              <1> 
   272                              <1> ;29/04/2016
   273                              <1> Cluster_Index: ; resd 1
   274                              <1> ; 22/02/2016
   275 000181FC ????????            <1> ClusterValue:	resd 1
   276                              <1> ; 04/03/2016
   277 00018200 ??                  <1> Attributes:	resb 1 
   278                              <1> ;;CFS_error:  resb 1 ;; 01/03/2016
   279 00018201 ??                  <1> resb 1
   280 00018202 ??                  <1> CFS_OPType: resb 1
   281 00018203 ??                  <1> CFS_Drv:    resb 1
   282 00018204 ????????            <1> CFS_CC:	    resd 1
   283 00018208 ????????            <1> CFS_FAT32FSINFOSEC: resd 1
   284 0001820C ????????            <1> CFS_FAT32FC: resd 1
   285                              <1> 
   286                              <1> ; 27/02/2016
   287                              <1> ;alignb 4
   288 00018210 ????????            <1> glc_prevcluster: resd 1 ; DRV_FAT.ASM (21/08/2011)
   289                              <1> ; 22/10/2016
   290 00018214 ????????            <1> glc_index:	 resd 1 ;  Last Cluster Index (22/10/2016)	
   291                              <1> 
   292                              <1> ; DIR.ASM
   293 00018218 ????                <1> DLN_EntryNumber: resw 1
   294 0001821A ??                  <1> DLN_40h:	 resb 1
   295                              <1> ; 28/02/2016
   296 0001821B ??                  <1> TCC_FATErr:	 resb 1 ; DRV_FAT.ASM
   297                              <1> 
   298                              <1> alignb 4
   299                              <1> ; DIR.ASM (09/10/2011)
   300 0001821C ????                <1> LCDE_EntryIndex: resw 1 ; LCDE_EntryOffset
   301 0001821E ????                <1> LCDE_ClusterSN:  resw 1
   302 00018220 ????????            <1> LCDE_Cluster: 	 resd 1
   303 00018224 ????????            <1> LCDE_ByteOffset: resd 1
   304                              <1> 
   305                              <1> ;alignb4
   306                              <1> ; 06/03/2016 (word -> dword)
   307                              <1> ; CMD_INTR.ASM (01/08/2010)
   308 00018228 ????????            <1> SourceFilePath:	     resd 1
   309 0001822C ????????            <1> DestinationFilePath: resd 1
   310                              <1> 
   311                              <1> ;alignb 4
   312                              <1> ; 06/03/2016
   313                              <1> ; FILE.ASM (09/10/2011)
   314                              <1> ;Source File Structure (same with 'Find File' Structure)
   315 00018230 ??                  <1> SourceFile_Drv:			resb 1
   316 00018231 <res 41h>           <1> SourceFile_Directory:		resb 65
   317 00018272 <res Dh>            <1> SourceFile_Name:		resb 13
   318                              <1> SourceFile_LongNameEntryLength: 
   319 0001827F ??                  <1> SourceFile_LongNameYes:		resb 1 ; Sign for longname procedures
   320                              <1> ;Above 80 bytes
   321                              <1> ;is TR-DOS Source File FullName Format/Structure
   322 00018280 ????                <1> SourceFile_AttributesMask:	resw 1
   323 00018282 <res 20h>           <1> SourceFile_DirEntry:		resb 32
   324 000182A2 ????????            <1> SourceFile_DirFirstCluster:	resd 1
   325 000182A6 ????????            <1> SourceFile_DirCluster:		resd 1
   326 000182AA ????                <1> SourceFile_DirEntryNumber:	resw 1
   327 000182AC ????                <1> SourceFile_MatchCounter:	resw 1
   328                              <1> ; 16/03/2016
   329 000182AE ??                  <1> SourceFile_SecPerClust:		resb 1
   330 000182AF ??                  <1> SourceFile_Reserved:		resb 1
   331                              <1> ; Above is 128 bytes
   332                              <1> 
   333                              <1> ;Destination File Structure (same with 'Find File' Structure)
   334 000182B0 ??                  <1> DestinationFile_Drv:		resb 1
   335 000182B1 <res 41h>           <1> DestinationFile_Directory: 	resb 65
   336 000182F2 <res Dh>            <1> DestinationFile_Name:		resb 13
   337                              <1> DestinationFile_LongNameEntryLength:
   338 000182FF ??                  <1> DestinationFile_LongNameYes:	resb 1 ; Sign for longname procedures
   339                              <1> ;Above 80 bytes
   340                              <1> ;is TR-DOS Destination File FullName Format/Structure
   341 00018300 ????                <1> DestinationFile_AttributesMask: resw 1
   342 00018302 <res 20h>           <1> DestinationFile_DirEntry:	resb 32
   343 00018322 ????????            <1> DestinationFile_DirFirstCluster: resd 1
   344 00018326 ????????            <1> DestinationFile_DirCluster:	resd 1
   345 0001832A ????                <1> DestinationFile_DirEntryNumber: resw 1
   346 0001832C ????                <1> DestinationFile_MatchCounter:	resw 1
   347                              <1> ; 16/03/2016
   348 0001832E ??                  <1> DestinationFile_SecPerClust:	resb 1
   349 0001832F ??                  <1> DestinationFile_Reserved:	resb 1
   350                              <1> ; Above is 128 bytes
   351                              <1> 
   352                              <1> ; 24/04/2016
   353 00018330 ????                <1> resw 1
   354                              <1> 
   355                              <1> ; 10/03/2016
   356                              <1> ; FILE.ASM
   357 00018332 ??                  <1> move_cmd_phase:	   resb 1
   358 00018333 ??                  <1> msftdf_sf_df_drv:  resb 1
   359 00018334 ????????            <1> msftdf_drv_offset: resd 1
   360                              <1> 
   361                              <1> ; 11/03/2016
   362                              <1> ; DRV_FAT.ASM (21/08/2011)
   363 00018338 ????????            <1> FAT_anc_LCluster:  resd 1
   364 0001833C ????????            <1> FAT_anc_FFCluster: resd 1
   365                              <1> 
   366                              <1> ;alignb 4
   367                              <1> 
   368                              <1> ; 14/03/2016
   369                              <1> ; TRDOS 386 = TRDOS v2.0 feature only !
   370                              <1> ; 'allocate_memory_block' in 'memory.s'
   371 00018340 ????????            <1> mem_ipg_count:	resd 1 ; page count (for contiguous allocation)
   372 00018344 ????????            <1> mem_pg_count:	resd 1 ; page count (for count down)
   373 00018348 ????????            <1> mem_aperture:	resd 1 ; contiguous free pages (current)
   374 0001834C ????????            <1> mem_max_aperture: resd 1 ; maximum value of contiguous free pages
   375 00018350 ????????            <1> mem_pg_pos:	resd 1 ; mem. position (page #) of current aperture
   376 00018354 ????????            <1> mem_max_pg_pos: resd 1 ; mem. position (page #) of max. aperture
   377                              <1> 
   378                              <1> ; 15/03/2016
   379                              <1> ; FILE.ASM ('copy_source_file_to_destination_file')
   380 00018358 ??                  <1> copy_cmd_phase:       resb 1
   381 00018359 ??                  <1> csftdf_rw_err:	      resb 1
   382 0001835A ??                  <1> DestinationFileFound: resb 1
   383 0001835B ??                  <1> csftdf_cdrv: 	      resb 1
   384 0001835C ????????            <1> csftdf_filesize:      resd 1
   385                              <1> ; TRDOS386 (TRDOS v2.0)
   386 00018360 ????????            <1> csftdf_sf_mem_addr:   resd 1
   387 00018364 ????????            <1> csftdf_sf_mem_bsize:  resd 1
   388                              <1> ;
   389                              <1> 
   390 00018368 ????????            <1> csftdf_sf_cluster:    resd 1 ; 16/03/2016
   391 0001836C ????????            <1> csftdf_df_cluster:    resd 1
   392                              <1> ; 16/03/2016
   393 00018370 ????????            <1> csftdf_r_size:        resd 1
   394 00018374 ????????            <1> csftdf_w_size:        resd 1
   395 00018378 ????????            <1> csftdf_sf_rbytes:     resd 1
   396 0001837C ????????            <1> csftdf_df_wbytes:     resd 1
   397 00018380 ??                  <1> csftdf_percentage:    resb 1
   398                              <1> ; 17/03/2016
   399 00018381 ??                  <1> csftdf_videopage:     resb 1
   400 00018382 ????                <1> csftdf_cursorpos:     resw 1
   401 00018384 ????????            <1> csftdf_sf_drv_dt:     resd 1
   402 00018388 ????????            <1> csftdf_df_drv_dt:     resd 1
   403                              <1> 
   404                              <1> ; 21/03/2016
   405                              <1> ; 20/03/2016
   406                              <1> ; FILE.ASM
   407 0001838C ????????            <1> createfile_Name_Offset:  resd 1
   408 00018390 ????????            <1> createfile_FreeSectors:  resd 1 
   409 00018394 ????????            <1> createfile_size:         resd 1
   410 00018398 ????????            <1> createfile_FFCluster:    resd 1 ; 11/03/2016
   411 0001839C ????????            <1> createfile_LastDirCluster: resd 1
   412 000183A0 ????????            <1> createfile_Cluster:      resd 1
   413 000183A4 ????????            <1> createfile_PCluster:     resd 1
   414 000183A8 ??                  <1> createfile_attrib:	 resb 1
   415 000183A9 ??                  <1> createfile_SecPerClust:  resb 1
   416 000183AA ????                <1> createfile_DirIndex:     resw 1
   417 000183AC ????????            <1> createfile_CCount:	 resd 1
   418 000183B0 ????                <1> createfile_BytesPerSec:	 resw 1 ; 23/03/2016
   419 000183B2 ??                  <1> createfile_wfc:	         resb 1
   420 000183B3 ??                  <1> createfile_UpdatePDir:	 resb 1 ; 31/03/2016
   421                              <1> 
   422                              <1> ;alignb 4
   423                              <1> 
   424                              <1> ; 11/04/2016
   425 000183B4 ????                <1> env_var_length:	resw 1
   426                              <1> 
   427 000183B6 ????                <1> alignb 4
   428                              <1> 
   429                              <1> ; 25/04/2016
   430 000183B8 ??                  <1> readi.valid:	resb 1 ; valid data (>0 = valid for readi)
   431 000183B9 ??                  <1> readi.drv:	resb 1 ; drive number (0, 1,2,3,4..)
   432 000183BA ??                  <1> readi.spc:	resb 1 ; sectors per cluster for 'readi' drive
   433 000183BB ??                  <1> readi.s_index:  resb 1 ; sector index in current cluster (buffer)
   434 000183BC ????????            <1> readi.sector:	resd 1 ; current disk sector
   435 000183C0 ????                <1> readi.bpc:	resw 1 ; bytes per cluster - 1
   436 000183C2 ????                <1> readi.offset:	resw 1 ; byte offset in cluster buffer
   437 000183C4 ????????            <1> readi.cluster:  resd 1 ; current cluster number
   438 000183C8 ????????            <1> readi.c_index:	resd 1 ; cluster index of the current cluster (0,1,2,3..)
   439 000183CC ????????            <1> readi.fclust:	resd 1 ; first cluster of the current cluster
   440 000183D0 ????????            <1> readi.fs_index: resd 1 ; sector index in disk/file section (for Singlix FS)
   441                              <1> ;readi.buffer:	resd 1 ; readi sector buffer address
   442                              <1> 
   443                              <1> ;alignb 4
   444                              <1> 
   445 000183D4 ??                  <1> writei.valid:	resb 1 ; valid data (>0 = valid for writei)
   446 000183D5 ??                  <1> writei.drv:	resb 1 ; drive number (0, 1,2,3,4..)
   447 000183D6 ??                  <1> writei.spc:	resb 1 ; sectors per cluster for 'writei' drive
   448 000183D7 ??                  <1> writei.s_index: resb 1 ; sector index in current cluster (buffer)
   449 000183D8 ????????            <1> writei.sector:	resd 1 ; current disk sector
   450 000183DC ????                <1> writei.bpc:	resw 1 ; bytes per cluster - 1
   451 000183DE ????                <1> writei.offset:	resw 1 ; byte offset in cluster buffer
   452 000183E0 ????????            <1> writei.cluster: resd 1 ; current cluster number
   453 000183E4 ????????            <1> writei.c_index:	resd 1 ; cluster index of the current cluster (0,1,2,3..)
   454 000183E8 ????????            <1> writei.fclust:  resd 1 ; first cluster of the current cluster
   455 000183EC ????????            <1> writei.fs_index: resd 1 ; sector index in disk/file section (for Singlix FS)
   456                              <1> ;writei.buffer:	resd 1 ; writei sector buffer address
   457 000183F0 ????????            <1> writei.lclust:	resd 1 ; writei last cluster (mget_w) ; 23/10/2016
   458 000183F4 ????????            <1> writei.l_index:	resd 1 ; writei last cluster index (mget_w) ; 23/10/2016
   459 000183F8 ??                  <1> writei.ofn:	resb 1 ; open file number (to be written) ; 23/10/2016
   460                              <1> 
   461 000183F9 ??????              <1> alignb 4
   462                              <1> 
   463                              <1> ; 29/04/2016
   464 000183FC ????????            <1> Run_CDirFC:	resd 1
   465 00018400 ??                  <1> Run_Auto_Path:	resb 1
   466 00018401 ??                  <1> Run_Manual_Path: resb 1 ; 0 -> auto path sequence needed
   467 00018402 ??                  <1> EXE_ID:		resb 1	
   468 00018403 ??                  <1> EXE_dot:	resb 1
   469                              <1> 
   470                              <1> ; 06/05/2016
   471 00018404 ????????            <1> mainprog_return_addr: resd 1
   472 00018408 ????????            <1> last_error:	resd 1  ; this will be used to return error code to MainProg
   473                              <1> 			; 'lasterror' keyword will be used later to get the
   474                              <1> 			; last error code/number/status.
   475                              <1> ; 12/05/2016
   476 0001840C ????????            <1> video_eax:	resd 1  ; eax return value of video function
   477                              <1> 
   478                              <1> ; 01/06/2016
   479 00018410 ????????            <1> user_buffer:	resd 1  ; 'diskio.s' (INT 33h, Function 08h, floppy disk type)
   480                              <1> 
   481                              <1> ; 21/05/2016 - TRDOS 386 ('swap/switch', 'rswap', [u.pri])
   482 00018414 ??                  <1> priority:	resb 1  ; running priority level of process (0,1,2)
   483                              <1> 			; (run queue which is process comes from)
   484                              <1> ; 22/05/2016 - TRDOS 386 ('set_run_sequence', 'rtc_int', 'u_timer')
   485 00018415 ??                  <1> p_change:	resb 1  ; process change status (for timer events)
   486                              <1> ; 23/05/2016 - TRDOS 386 ('clock')
   487 00018416 ??                  <1> multi_tasking:	resb 1   ; Multi Tasking status (0 = disabled, >0 = enabled)
   488                              <1> 			; (EBX will return with user buffer addr or disk type)
   489                              <1> ; 07/06/2016
   490 00018417 ??                  <1> timer_events:	resb 1  ; number of (active) timer events, <= 16		
   491                              <1> 
   492                              <1> ; 24/06/2016
   493 00018418 ??                  <1> w_str_cmd:	resb 1	; WRITE_STRING command (0,1,2,3) ; video.s
   494 00018419 ??                  <1> p_crt_mode:	resb 1  ; previous video mode (=3 or 0), backup mark/sign
   495                              <1> ; 26/06/2016
   496 0001841A ??                  <1> p_crt_page:	resb 1  ; previous active page (for 'set_mode')
   497                              <1> ; 04/07/2016
   498 0001841B ??                  <1> noclearmem:	resb 1  ; if set, 'SET MODE' (INT 31h) function (AH = 4)
   499                              <1> 			; will not clear the video memory
   500                              <1> 			; (usable for graphics modes only)
   501                              <1> alignb 2
   502 0001841C ????                <1> CRT_LEN:	resw 1  ; length of regen buffer in bytes
   503 0001841E <res 10h>           <1> cursor_pposn:	resw 8  ; cursor positions backup
   504                              <1> 
   505                              <1> ; 10/07/2016 ('VGA_FONT_SETUP', INT 43H address for x86 real mode bios)
   506 0001842E ????????            <1> VGA_INT43H:	resd 1	; 0 = default (not configured by user)
   507                              <1> 			; 0FFFFFFFFh = user defined fonts
   508                              <1> 			; address:
   509                              <1> 			; 	vgafont8
   510                              <1> 			; 	vgafont16
   511                              <1> 			; 	vgafont14
   512                              <1> 
   513                              <1> ; 25/07/2016
   514 00018432 ??                  <1> VGA_MTYPE:	resb 1  ; 0=CTEXT,1=MTEXT,2=CGA,3=PLANAR1,4=PLANAR4,5=LINEAR 
   515                              <1> 
   516                              <1> ; 23/10/2016
   517 00018433 ??                  <1> setfmod		resb 1	; update last modification date&time sign (if >0)
   518                              <1> 			; (it is Open File Number + 1, if > 0)
   519                              <1> alignb 4
   520                              <1> 
   521                              <1> ; 16/10/2016
   522 00018434 ????????            <1> FFF_UBuffer:	resd 1  ; User's buffer address for FFF & FNF system calls 
   523                              <1> ; 15/10/2016
   524 00018438 ??                  <1> FFF_Valid:	resb 1  ; Find First File Structure validation byte
   525                              <1> 			; 0  = invalid (Find Next File can't use FFF struct)
   526                              <1> 			; >0 = valid, return type for FFF and Find Next File
   527                              <1> 			; 24 = basic parameters, 24 bytes
   528                              <1> 			; 128 = entire FFF structure/table, 128 bytes
   529                              <1> ; 16/10/2016 (FFF_Attrib: resw 1)
   530 00018439 ??                  <1> FFF_Attrib:	resb 1	; Find First File attributes for Find Next File (LB)
   531 0001843A ??                  <1> FFF_RType:	resb 1  ; FFF return type (0 = Basic, >0 = complete) (HB)
   532                              <1> ; 16/10/2016 - 05/10/2016 (Set Working Path)
   533 0001843B ??                  <1> SWP_inv_fname:	resb 1	; Set Working Path - Invalid File Name
   534 0001843C ????                <1> SWP_Mode:	resw 1	; Set Working Path - Mode
   535 0001843E ??                  <1> SWP_DRV:	resb 1	; Set Working Path - Drive	
   536 0001843F ??                  <1> SWP_DRV_chg:	resb 1	; Set Working Path - Drive Change
   537                              <1> 
   538                              <1> ; 27/02/2017
   539 00018440 ??                  <1> fpready:	resb 1	; '80387 fpu is ready' flag	
   540                              <1> 
   541                              <1> ; 17/04/2021
   542                              <1> ; (DEVICE parameters is disabled as temporary)
   543                              <1> 
   544                              <1> ; 08/10/2016
   545                              <1> ;device_name:	resb 9  ; capitalized (and zero padded) device name
   546                              <1> 			; (example: "TTY0",0,0,0,0,0")
   547                              <1> 
   548 00018441 ??????              <1> alignb 4
   549                              <1> 
   550                              <1> ; 08/10/2016
   551                              <1> ; 07/10/2016
   552                              <1> ; Table of kernel devices (which do not use installable device drivers)
   553                              <1> ; has been coded into KERNEL (trdosk9.s) 
   554                              <1> ; 07/10/2016
   555                              <1> ; 8 installable device drivers available to install (NUMIDEV)
   556                              <1> ;IDEV_PGDIR: resd NUMIDEV
   557                              <1> 			; Page directories of installable device drivers
   558                              <1> 			;
   559                              <1> 			; Note: Virtual start address is always 400000h
   560                              <1> 			; (end of the 1st 4MB). [org 400000h]
   561                              <1> 			; Segments: KCODE, KDATA
   562                              <1> 			; Method: call 400000h (after changing page dir) 	
   563                              <1> 			; Query code located at the start (400000h).
   564                              <1> 			; Query code returns with
   565                              <1> 			;   eax = device type and driver version
   566                              <1> 			;         AL = Device Type minor
   567                              <1> 			;         AH = Device Type major
   568                              <1> 			;         Byte 16-23 : Version minor
   569                              <1> 			;	  Byte 24-31 : Version major - 1
   570                              <1> 			;		       (0:0 -> 1.0)
   571                              <1> 			;   ebx = initialization code address
   572                              <1> 			;   ecx = configuration table address
   573                              <1> 			;   edx = description table address
   574                              <1> 			;   esi = device (default) name address (ASCIIZ)
   575                              <1> 			;	 (name has "/DEV/" prefix)		
   576                              <1> 			;   edi = dispatch table address
   577                              <1> 			;        (for calling kernel-device functions)
   578                              <1> 			;   ebp = address table address
   579                              <1> 			; Initialization code returns with
   580                              <1> 			;   eax = open code address
   581                              <1> 			;   ecx = close code address 
   582                              <1> 			;   ebx = read code address
   583                              <1> 			;   edx = write code address 	
   584                              <1> 			;   esi = IOCTL code address
   585                              <1> 			;   edi = dispatch table address
   586                              <1> 			;   ebp = address table address
   587                              <1> 			; Address Table:
   588                              <1> 			;    Offset 0  : open code address
   589                              <1> 			;    Offset 4  : read code address
   590                              <1> 			;    Offset 8  : write code address
   591                              <1> 			;    Offset 12 : close code address
   592                              <1> 			;    Offset 16 : IOCTL code address
   593                              <1> 			;    Offset 20 : initialization code address
   594                              <1> 			;    Offset 24 : description table address
   595                              <1> 			;    Offset 28 : configuration table address
   596                              <1> 			;    Offset 32 : device name address
   597                              <1> 			;    Offset 36 : dispatch table address
   598                              <1> 			;          (for calling kernel-device functions)
   599                              <1> 
   600                              <1> ;IDEV_NAME:  resb 8*NUMIDEV 
   601                              <1> 			  ; 8 byte names of installable device drivers
   602                              <1> 
   603                              <1> ;IDEV_TYPE:  resb NUMIDEV ; Driver type of installable device drivers
   604                              <1> ;IDEV_FLAGS: resb NUMIDEV ; Device access parameters for installable
   605                              <1>                           ; device drivers (These values are set while
   606                              <1> 			  ; the device driver is being loaded.)
   607                              <1> ;IDEV_OADDR: resd NUMIDEV ; open function addr for installable dev driver
   608                              <1> ;IDEV_CADDR: resd NUMIDEV ; close function addr for installable dev driver
   609                              <1> ;IDEV_RADDR: resd NUMIDEV ; read function addr for installable dev driver
   610                              <1> ;IDEV_WADDR: resd NUMIDEV ; write function addr for installable dev driver
   611                              <1> 	
   612                              <1> ; 08/10/2016	
   613                              <1> ; 07/10/2016
   614                              <1> ; Device Open and Access parameters
   615                              <1> ;DEV_ACCESS:	resb NUMOFDEVICES    ; bit 0 = accessable by normal users
   616                              <1> 				     ; bit 1 = read access permission
   617                              <1> 				     ; bit 2 = write access permission
   618                              <1> 				     ; bit 3 = IOCTL permission to users
   619                              <1> 				     ; bit 4 = block device if it is set	
   620                              <1> 				     ; bit 5 = 16 bit or 1024 byte data
   621                              <1> 				     ; bit 6 = 32 bit or 2048 byte data
   622                              <1> 				     ; bit 7 = installable device driver
   623                              <1> ;DEV_R_OWNER:	resb NUMOFDEVICES    ; Reading owner no (u.uid) of devices		
   624                              <1> ;DEV_R_OPENCOUNT: resb NUMOFDEVICES  ; Reading open count 
   625                              <1> ;DEV_W_OWNER:	resb NUMOFDEVICES    ; Writing owner no (u.uid) of devices		
   626                              <1> ;DEV_W_OPENCOUNT: resb NUMOFDEVICES  ; Writing open count
   627                              <1> ;DEV_DRIVER:	resb NUMOFDEVICES    ; device driver number (1 to 7Fh)
   628                              <1> 				     ; *if bit 7 is set (80 to FFh)
   629                              <1> 				     ; *if it is installable device driver
   630                              <1> 				     ; *index (0 to 7Fh)
   631                              <1> 				     ; otherwise it is kernel device index
   632                              <1> ;DEV_OPENMODE:	resb NUMOFDEVICES    ; 1 = read mode
   633                              <1> 				     ; 2 = write mode
   634                              <1> 				     ; 3 = read & write 	  
   635                              <1> 				     ; 0 = not open (free)		
   636                              <1> ;DEV_NAME_PTR:	resd NUMOFDEVICES    ; pointers to name addresses of drivers
   637                              <1> 				     ; Address base: KDEV_NAME+		
   638                              <1> 				     ; or IDEV_NAME+
   639                              <1> ;DEV_R_POINTER:	resd NUMOFDEVICES    ; reading pointer, writing pointer	
   640                              <1> ;DEV_W_POINTER:	resd NUMOFDEVICES    ; sector number if block device
   641                              <1> 				     ; character offset if char device
   642                              <1> alignb 4
   643                              <1> 
   644                              <1> ; 06/10/2016
   645                              <1> ; Open File Parameters
   646 00018444 <res 80h>           <1> OF_FCLUSTER:	resd OPENFILES  ; First clusters of open files
   647 000184C4 <res 20h>           <1> OF_DRIVE:	resb OPENFILES  ; Logical DOS drive numbers of open files 
   648 000184E4 <res 20h>           <1> OF_MODE:	resb OPENFILES  ; Open mode (1 = read, 2 = write, 3 = r&w) 
   649 00018504 <res 20h>           <1> OF_STATUS:	resb OPENFILES  ; (bit 0 = read, bit 1 = write)
   650 00018524 <res 20h>           <1> OF_OPENCOUNT:	resb OPENFILES  ; Open counts of open files
   651 00018544 <res 80h>           <1> OF_POINTER:	resd OPENFILES	; File seek/read/write pointer
   652 000185C4 <res 80h>           <1> OF_SIZE:	resd OPENFILES	; File sizes of open files (in bytes)
   653 00018644 <res 80h>           <1> OF_DIRFCLUSTER:	resd OPENFILES  ; Directory First Clusters of open files
   654 000186C4 <res 80h>           <1> OF_DIRCLUSTER:	resd OPENFILES  ; Directory (Entry) Clusters of open files
   655 00018744 <res 80h>           <1> OF_VOLUMEID:	resd OPENFILES  ; Vol ID for removable drives of open files
   656 000187C4 <res 80h>           <1> OF_CCLUSTER:	resd OPENFILES  ; Current clusters of open files
   657 00018844 <res 80h>           <1> OF_CCINDEX:	resd OPENFILES  ; Cluster index numbers of current clusters
   658                              <1> ; 24/10/2016
   659 000188C4 <res 40h>           <1> OF_DIRENTRY:	resw OPENFILES  ; Directory entry index no. in dir cluster 
   660                              <1> 				; Sector index = entry index / 16
   661                              <1> ;alignb 2
   662                              <1> 
   663                              <1> DTA:		;resd 24	; Find First File data transfer area
   664 00018904 <res 18h>           <1> 		resb 24		; 29/07/2022		
   665                              <1> 
   666                              <1> ; 19/12/2016
   667 0001891C ??                  <1> tcallback:	resb 1		; Timer callback method flag for 'systimer'
   668 0001891D ??                  <1> trtc:		resb 1		; Timer interrupt type flag for 'systimer'
   669                              <1> ; 20/02/2017
   670 0001891E ??                  <1> no_page_swap:	resb 1		; Swap lock for Signal Response Byte pages 
   671                              <1> ;;15/01/2017
   672                              <1> ; 02/01/2017
   673                              <1> ;;intflg:	resb 1		; software interrupt in progress signal
   674                              <1> 				; (for timer interrupt)
   675 0001891F ??                  <1> alignb 4
   676                              <1> ; 13/04/2017
   677                              <1> ;DEV_INTR:	resb NUMOFDEVICES ; Device Interrupt (IRQ) number + 1	
   678                              <1> 				; (0= not available, 1= IRQ 0, 16= IRQ 15)
   679 00018920 <res 40h>           <1> DEV_INT_HNDLR:	resd 16		; Device Interrupt Handler addr, if > 0 	
   680                              <1> 
   681                              <1> ;alignb 4
   682                              <1> 
   683                              <1> ; 26/02/2017 ; IRQ Callback parameters ('syscalbac')
   684                              <1> ;Index: ; 0 to 8
   685                              <1> ;	0 = IRQ3, 1 = IRQ4, 2 = IRQ5, 3 = IRQ7
   686                              <1> ;	4 = IRQ9, 5 = IRQ10, 6 = IRQ11, 7 = IRQ12, 8 = IRQ13  
   687 00018960 <res 9h>            <1> IRQ.owner:	resb 9		; owner, 0 = free, >0 = [u.uno]
   688 00018969 <res 9h>            <1> IRQ.dev:	resb 9		; 0 = default/kernel, >0 = device number
   689 00018972 <res 9h>            <1> IRQ.method:	resb 9 		; 0 = Signal Response Byte, 1 = Callback
   690 0001897B <res 9h>            <1> IRQ.srb:	resb 9 		; Signal Response/Return Byte value
   691 00018984 <res 24h>           <1> IRQ.addr:	resd 9		; Rignal Response Byte address (physical)
   692                              <1> 				; or Callback service address (virtual)
   693                              <1> ; 28/02/2017
   694 000189A8 ????????            <1> IRQ_cr3:	resd 1		; for saving cr3 register in IRQ handler
   695 000189AC ??                  <1> IRQnum:		resb 1		; IRQ number for IRQ handler (trdosk8.s)
   696                              <1> 
   697                              <1> ; 10/04/2017
   698                              <1> ; 03/04/2017
   699                              <1> ; UNINITIALIZED AUDIO DATA
   700 000189AD ??????              <1> alignb 4
   701 000189B0 ??                  <1> audio_pci:	resb 1
   702 000189B1 ??                  <1> audio_device:	resb 1
   703 000189B2 ??                  <1> audio_mode:	resb 1
   704 000189B3 ??                  <1> audio_intr:	resb 1
   705 000189B4 ??                  <1> audio_busy:	resb 1  ; Busy flag for audio irq ; 21/04/2017
   706 000189B5 ??                  <1> audio_reserved: resb 1
   707 000189B6 ????                <1> audio_io_base:	resw 1 	; Base I/O address of audio device
   708 000189B8 ????????            <1> audio_dev_id:	resd 1	; BUS/DEV/FN ; 00000000BBBBBBBBDDDDDFFF00000000
   709 000189BC ????????            <1> audio_vendor:	resd 1
   710 000189C0 ????????            <1> audio_stats_cmd: resd 1
   711                              <1> ;
   712 000189C4 ????????            <1> audio_buffer:	resd 1	; virtual address of user's audio buffer
   713 000189C8 ????????            <1> audio_p_buffer:	resd 1	; Physical address of user's audio buffer
   714 000189CC ????????            <1> audio_buff_size: resd 1 ; user's audio buffer size (half buffer size) 
   715 000189D0 ????????            <1> audio_dma_buff: resd 1  ; dma buffer address
   716 000189D4 ????????            <1> audio_dmabuff_size: resd 1 ; dma buffer size (2 * half buffer size)
   717 000189D8 ??                  <1> audio_flag:	resb 1  ; dma buffer flag (1st half = 0, 2nd half = 1)
   718 000189D9 ??                  <1> audio_user:	resb 1	; user number of the owner
   719 000189DA ??                  <1> audio_cb_mode:	resb 1	; 0 = signal response byte method
   720                              <1> 			; 1 = callback method
   721                              <1> 			; 2 = s.r.b. method with auto increment
   722 000189DB ??                  <1> audio_srb:	resb 1	; signal response byte value
   723 000189DC ????????            <1> audio_cb_addr:	resd 1  ; callback service address or s.r.b. address
   724                              <1> 			; (s.r.b. addr is physical, cbs addr is virtual)
   725                              <1> 
   726 000189E0 ??                  <1> audio_bps:	resb 1  ; selected mode: 8 bit, 16 bit
   727 000189E1 ??                  <1> audio_stmo:	resb 1	; selected mode: mono /stereo
   728 000189E2 ????                <1> audio_freq: 	resw 1	; sampling rate
   729                              <1> 
   730                              <1> ; 21/04/2017
   731 000189E4 ??                  <1> audio_play_cmd: resb 1  ; Play/Stop command (1 = play, 0 = stop)
   732                              <1> audio_civ: ; 28/05/2017 ; Current Buffer Index (AC'97)
   733 000189E5 ??                  <1> audio_flag_eol:	resb 1  ; End of Link status (vt8233, EOL/FLAG)
   734                              <1> 
   735                              <1> audio_master_volume:
   736 000189E6 ??                  <1> audio_master_volume_l: resb 1 ; sound volume (lineout) left channel
   737 000189E7 ??                  <1> audio_master_volume_r: resb 1 ; sound volume (lineout) right channel
   738                              <1> 
   739                              <1> alignb 4
   740                              <1> ; 28/05/2017
   741                              <1> ; AC'97 Audio Controller Base Adress Registers
   742 000189E8 ????                <1> NAMBAR:		resw 1	; Native Audio Mixer Base Address
   743 000189EA ????                <1> NABMBAR:	resw 1	; Native Audio Bus Mastering Base Address
   744                              <1> 	
   745                              <1> ;alignb 4
   746                              <1> ; 21/04/2017
   747 000189EC <res 400h>          <1> audio_bdl_buff:	resd 32*8 ; VT8233 (AC97) BDL Buffer Size
   748                              <1> ; 12/05/2017
   749 00018DEC ????????            <1> base_addr:	resd 1	; 'direct_memory_access' (memory.s)
   750                              <1> 
   751                              <1> ; 28/08/2017
   752                              <1> ; 20/08/2017
   753 00018DF0 ??                  <1> 		resb 1  ;
   754 00018DF1 ??                  <1> dma_user:	resb 1	; user number for sysdma
   755 00018DF2 ??                  <1> dma_channel:	resb 1	; dma channel for sysdma
   756 00018DF3 ??                  <1> dma_mode:	resb 1  ; dma mode for sysdma	
   757 00018DF4 ????????            <1> dma_addr:	resd 1	; dma buffer physical addr for sysdma
   758 00018DF8 ????????            <1> dma_size:	resd 1  ; dma buffer size (in bytes) for sysdma
   759 00018DFC ????????            <1> dma_start:	resd 1  ; dma start address for sysdma
   760 00018E00 ????????            <1> dma_count:	resd 1  ; dma count (in bytes) for sysdma 
   761                              <1> 
   762 00018E04 <res 71FCh>         <1> alignb 65536
   763                              <1> ; 09/08/2017
   764                              <1> ; 12/05/2017
   765 00020000 <res 10000h>        <1> sb16_dma_buffer: resb 65536 ; DMA buffer for sb16 audio playing.
  3804                                  ; 24/01/2016
  3805                                  %include 'ubss.s'	; UNINITIALIZED KERNEL (USER) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.5) - UNINITIALIZED USER DATA : ubss.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 07/08/2022  (Previous: 28/02/2017)
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    11                              <1> ; ux.s (04/12/2015)
    12                              <1> ; ****************************************************************************
    13                              <1> 
    14                              <1> ; Retro UNIX 386 v1 Kernel - ux.s
    15                              <1> ; Last Modification: 04/12/2015
    16                              <1> ;
    17                              <1> ; ///////// RETRO UNIX 386 V1 SYSTEM DEFINITIONS ///////////////
    18                              <1> ; (Modified from 
    19                              <1> ;	Retro UNIX 8086 v1 system definitions in 'UNIX.ASM', 01/09/2014)
    20                              <1> ; ((UNIX.ASM (RETRO UNIX 8086 V1 Kernel), 11/03/2013 - 01/09/2014))
    21                              <1> ; ----------------------------------------------------------------------------
    22                              <1> ; Derived from UNIX Operating System (v1.0 for PDP-11) 
    23                              <1> ; (Original) Source Code by Ken Thompson (1971-1972)
    24                              <1> ; <Bell Laboratories (17/3/1972)>
    25                              <1> ; <Preliminary Release of UNIX Implementation Document>
    26                              <1> ; (Section E10 (17/3/1972) - ux.s)
    27                              <1> ; ****************************************************************************
    28                              <1> ; Ref: Retro UNIX 386 v1.2 Kernel (v0.2.2.3) - ux.s - 15/07/2022
    29                              <1> 
    30                              <1> alignb 2
    31                              <1> 
    32                              <1> %if 0
    33                              <1> 
    34                              <1> inode:
    35                              <1> 	;; 11/03/2013. 
    36                              <1> 	;;Derived from UNIX v1 source code 'inode' structure (ux).
    37                              <1> 	;;i.
    38                              <1> 	;
    39                              <1> 	;i.flgs: resw 1
    40                              <1> 	;i.nlks: resb 1
    41                              <1> 	;i.uid:	 resb 1
    42                              <1>         ;i.size: resw 1 ; size
    43                              <1> 	;i.dskp: resw 8 ; 16 bytes
    44                              <1> 	;i.ctim: resd 1
    45                              <1> 	;i.mtim: resd 1
    46                              <1> 	;i.rsvd: resw 1 ; Reserved (ZERO/Undefined word for UNIX v1)
    47                              <1> 
    48                              <1> 	; 26/01/2020
    49                              <1> 	; Retro UNIX 386 v2.0 - Modified UNIX v7 inode model
    50                              <1> 	;	(15/09/2029 .. 18/12/2019)
    51                              <1> 
    52                              <1> 	i.flgs:   resw 1	; /* mode and type of file */
    53                              <1> 	i.nlks:	  resw 1	; /* number of links to file */
    54                              <1> 	i.uid:	  resw 1	; /* owner's user id */  - 0 to 65535 -
    55                              <1> 	i.gid:	  resb 1	; /* owner's group id */ - o to 255 -
    56                              <1> 	i.size_h: resb 1	; /* number of bytes in file */ ; byte 5
    57                              <1> 	i.size:	  resd 1 ; size	; /* number of bytes in file */
    58                              <1> 	i.dskp:	  resd 10 ; 40 bytes ; /* disk block addresses */
    59                              <1> 	i.atim:	  resd 1	; /* time last accessed */
    60                              <1> 	i.mtim:	  resd 1	; /* time last modified */
    61                              <1> 	i.ctim:	  resd 1	; /* time created */
    62                              <1> 
    63                              <1> I_SIZE	equ $ - inode
    64                              <1> 
    65                              <1> %endif 
    66                              <1> 
    67                              <1> process:
    68                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5 
    69                              <1> 	; 27/02/2022
    70                              <1> 	; 12/01/2022 - Retro UNIX 386 v1.2 
    71                              <1> 	; 19/12/2016
    72                              <1> 	; 21/05/2016
    73                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
    74                              <1> 	; 06/05/2015 - Retro UNIX 386 v1
    75                              <1> 	; 11/03/2013 - 05/02/2014 (Retro UNIX 8086 v1)
    76                              <1> 	;Derived from UNIX v1 source code 'proc' structure (ux).
    77                              <1> 	;p.
    78                              <1> 	
    79 00030000 <res 20h>           <1>         p.pid:   resw nproc
    80 00030020 <res 20h>           <1>         p.ppid:  resw nproc
    81                              <1> 	;p.break: resw nproc ; 12/01/2022 (p.break is not used)
    82 00030040 <res 10h>           <1>         p.ttyc:  resb nproc ; console tty in Retro UNIX 8086 v1.
    83                              <1> 	; 27/02/2022 (p.waitc is not used)
    84                              <1> 	;p.waitc: resb nproc ; waiting channel in Retro UNIX 8086 v1.
    85 00030050 <res 10h>           <1> 	p.link:	 resb nproc
    86 00030060 <res 10h>           <1> 	p.stat:	 resb nproc
    87                              <1> 
    88                              <1> 	; 06/05/2015 (Retro UNIX 386 v1 feature only !) 
    89 00030070 <res 40h>           <1> 	p.upage: resd nproc ; Physical address of the process's
    90                              <1> 			    ; 'user' structure
    91                              <1> 	; 21/05/2016	
    92                              <1> 	; 19/05/2016 (TRDOS 386 feature only!)
    93 000300B0 <res 10h>           <1> 	p.timer: resb nproc ; number of timer events of the processs
    94                              <1> 
    95                              <1> 	; 19/12/2016
    96 000300C0 <res 40h>           <1> 	p.tcb:	resd nproc ; timer callback service address (if > 0)
    97                              <1> 			  		 			 	  
    98                              <1> P_SIZE	equ $ - process
    99                              <1> 
   100                              <1> ; fsp table (original UNIX v1)
   101                              <1> ;
   102                              <1> ;Entry
   103                              <1> ;          15                                      0
   104                              <1> ;  1     |---|---------------------------------------|
   105                              <1> ;        |r/w|       i-number of open file           |
   106                              <1> ;        |---|---------------------------------------| 
   107                              <1> ;        |               device number               |
   108                              <1> ;        |-------------------------------------------|
   109                              <1> ;    (*) | offset pointer, i.e., r/w pointer to file |
   110                              <1> ;        |-------------------------------------------| 
   111                              <1> ;        |  flag that says    | number of processes  |
   112                              <1> ;        |   file deleted     | that have file open  |
   113                              <1> ;        |-------------------------------------------| 
   114                              <1> ;  2     |                                           |
   115                              <1> ;        |-------------------------------------------| 
   116                              <1> ;        |                                           |
   117                              <1> ;        |-------------------------------------------|
   118                              <1> ;        |                                           |
   119                              <1> ;        |-------------------------------------------|
   120                              <1> ;        |                                           |
   121                              <1> ;        |-------------------------------------------| 
   122                              <1> ;  3     |                                           | 
   123                              <1> ;        |                                           |  
   124                              <1> ;
   125                              <1> ; (*) Retro UNIX 386 v1 modification: 32 bit offset pointer 
   126                              <1> 
   127                              <1> ; 27/03/2020 - Retro UNIX 386 v2 - FSP (OPEN FILES) TABLE 
   128                              <1> 
   129                              <1> ;Entry
   130                              <1> ;         15                    7                   0
   131                              <1> ;  1     |-------------------------------------------|
   132                              <1> ;        |   	     i-number of open file           |
   133                              <1> ;        |-------------------------------------------| 
   134                              <1> ;        |        high word of 32 bit i-number       |
   135                              <1> ;        |-------------------------------------------|
   136                              <1> ;        | open mode & status  |   device number     |
   137                              <1> ;        |-------------------------------------------|
   138                              <1> ;        |    reserved byte    |     open count      |
   139                              <1> ;        |-------------------------------------------| 
   140                              <1> ;        | offset pointer, i.e., r/w pointer to file |
   141                              <1> ;        |-------------------------------------------|
   142                              <1> ;        |   64 bit file offset pointer (bit 16-31)  | 
   143                              <1> ;        |-------------------------------------------|
   144                              <1> ;        |   64 bit file offset pointer (bit 32-47)  | 
   145                              <1> ;        |-------------------------------------------|
   146                              <1> ;        |   64 bit file offset pointer (bit 48-63)  | 
   147                              <1> ;        |-------------------------------------------|
   148                              <1> ;  2     |                                           |
   149                              <1> ;        |-------------------------------------------| 
   150                              <1> ;        |                                           |
   151                              <1> ;        |-------------------------------------------|
   152                              <1> ;        |                                           |
   153                              <1> ;        |-------------------------------------------|
   154                              <1> ;        |                                           |
   155                              <1> ;        |-------------------------------------------| 
   156                              <1> ;        |                                           | 
   157                              <1> 
   158                              <1> %if 0
   159                              <1> 
   160                              <1> ; (Retro UNIX 386 v1.2 - ux.s - 15/07/2022)
   161                              <1> ; 22/11/2021
   162                              <1> ; 21/07/2021 - Retro UNIX 386 v2 open file structure revision
   163                              <1> 
   164                              <1> struc file	; open files (fsp) structure ; (*)	
   165                              <1>   .inode:  resw 1  ; inode number of open file (32 bit)
   166                              <1>   .i32:	   resw 1  ; higher word of inode number (reserved)
   167                              <1>   .drive:  resb 1  ; logical drive (disk) number
   168                              <1>   .flags:  resb 1  ; open mode and status
   169                              <1>   .count:  resb 1  ; number of processes that have file open
   170                              <1>   ;.rsvd:  resb 1  ; reserved byte (for next versions)
   171                              <1>   .mnt:    resb 1  ; mnttab index+1 (0 = not mounted)
   172                              <1>   .offset: resd 1  ; file offset/pointer (64 bit) 
   173                              <1>   .o64:	   resd 1  ; higher 32 bit of file offset
   174                              <1>  .size:  ; = 16		
   175                              <1> endstruc 
   176                              <1> 
   177                              <1> %endif
   178                              <1> 
   179                              <1> ; 23/07/2022
   180                              <1> ;fsp:	resb nfiles * 16 ; (*)
   181                              <1> 
   182 00030100 ??                  <1> idev:	resb 1
   183 00030101 ??                  <1> cdev:	resb 1	
   184                              <1> 
   185                              <1> ; 15/04/2015
   186                              <1> ;fsp:	resb nfiles * 10 ; 11/05/2015 (8 -> 10)
   187                              <1> ;idev:	resw 1 ; device number is 1 byte in Retro UNIX 8086 v1 !
   188                              <1> ;cdev:	resw 1 ; device number is 1 byte in Retro UNIX 8086 v1 !
   189                              <1> 
   190                              <1> ; 18/05/2015
   191                              <1> ; 26/04/2013 device/drive parameters (Retro UNIX 8086 v1 feature only!)
   192                              <1> ; 'UNIX' device numbers (as in 'cdev' and 'u.cdrv')
   193                              <1> ;	0 -> root device (which has Retro UNIX 8086 v1 file system)
   194                              <1> ; 	1 -> mounted device (which has Retro UNIX 8086 v1 file system)
   195                              <1> ; 'Retro UNIX 8086 v1' device numbers: (for disk I/O procedures)
   196                              <1> ;	0 -> fd0 (physical drive, floppy disk 1), physical drive number = 0
   197                              <1> ;	1 -> fd1 (physical drive, floppy disk 2), physical drive number = 1
   198                              <1> ;	2 -> hd0 (physical drive, hard disk 1), physical drive number = 80h
   199                              <1> ;	3 -> hd1 (physical drive, hard disk 2), physical drive number = 81h
   200                              <1> ;	4 -> hd2 (physical drive, hard disk 3), physical drive number = 82h
   201                              <1> ;	5 -> hd3 (physical drive, hard disk 4), physical drive number = 83h
   202                              <1> 
   203 00030102 ??                  <1> rdev:	resb 1 ; root device number ; Retro UNIX 8086 v1 feature only!
   204                              <1> 	        ; as above, for physical drives numbers in following table
   205 00030103 ??                  <1> mdev:	resb 1 ; mounted device number ; Retro UNIX 8086 v1 feature only!
   206                              <1> 
   207                              <1> ; 23/07/2022
   208                              <1> ;; 15/04/2015
   209                              <1> ;active: resb 1 
   210                              <1> ;	 resb 1 ; 09/06/2015
   211                              <1> 
   212                              <1> ; 23/07/2022
   213                              <1> ;mnti:	 resw 1
   214                              <1> ; 07/08/2022
   215 00030104 ????                <1> mpid:	 resw 1
   216                              <1> ;rootdir: resw 1
   217 00030106 ????????            <1> rootdir: resd 1	
   218                              <1> 
   219                              <1> ; 21/05/2016 - TRDOS 386 (TRDOS v2.0) - priority levels, 3 run queues 
   220                              <1> runq:
   221 0003010A ????                <1> runq_event:	 resw 1 ; high priority, 'run for event'            ; 2
   222 0003010C ????                <1> runq_normal:	 resw 1 ; normal/regular priority, 'run as reqular' ; 1
   223 0003010E ????                <1> runq_background: resw 1 ; low priority, 'run on background'         ; 0
   224                              <1> ;
   225                              <1> ; 23/07/2022
   226                              <1> ;imod:	resb 1
   227                              <1> ;smod:	resb 1
   228                              <1> ;mmod:	resb 1
   229 00030110 ??                  <1> sysflg:	resb 1
   230 00030111 ??                  <1> 	resb 1	
   231                              <1> 
   232 00030112 ????                <1> alignb 4
   233                              <1> 
   234                              <1> user:
   235                              <1> 	; 23/07/2022 - TRDOS 386 Kernel v2.0.5
   236                              <1> 	; 04/12/2021 - Retro UNIX 386 v1.2
   237                              <1> 	; 13/01/2017
   238                              <1> 	; 19/12/2016
   239                              <1> 	; 21/05/2016 - TRDOS 386 (TRDOS v2.0) 
   240                              <1> 	; 	       [u.pri] usage method modification
   241                              <1> 	; 04/12/2015 
   242                              <1> 	; 18/10/2015
   243                              <1> 	; 12/10/2015
   244                              <1> 	; 21/09/2015
   245                              <1> 	; 24/07/2015
   246                              <1> 	; 16/06/2015
   247                              <1> 	; 09/06/2015
   248                              <1> 	; 11/05/2015
   249                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - 32 bit modifications)
   250                              <1> 	; 10/10/2013
   251                              <1> 	; 11/03/2013. 
   252                              <1> 	;Derived from UNIX v1 source code 'user' structure (ux).
   253                              <1> 	;u.
   254                              <1> 
   255 00030114 ????????            <1> 	u.sp:	  resd 1 ; esp (kernel stack at the beginning of 'sysent')
   256 00030118 ????????            <1> 	u.usp:	  resd 1 ; esp (kernel stack points to user's registers)
   257 0003011C ????????            <1> 	u.r0:	  resd 1 ; eax
   258 00030120 ????                <1> 	u.cdir:	  resw 1
   259 00030122 ????                <1> 		  resw 1 ; 23/07/2022
   260 00030124 ??                  <1> 	u.cdrv:	  resb 1 ; 23/07/2022
   261 00030125 ??                  <1> 		  resb 1				  	
   262 00030126 <res Ah>            <1> 	u.fp:	  resb 10
   263                              <1> 	;u.fp:	  resb OPENFILES ; 23/07/202
   264                              <1> 	u.fsp:	  ; 23/07/2022
   265 00030130 ????????            <1> 	u.fofp:	  resd 1
   266 00030134 ????????            <1> 	u.dirp:	  resd 1
   267 00030138 ????????            <1> 	u.namep:  resd 1
   268 0003013C ????????            <1> 	u.off:	  resd 1
   269                              <1> 	;	  resd 1 ; 23/07/2022 (64 bit fptr)
   270 00030140 ????????            <1> 	u.base:	  resd 1
   271 00030144 ????????            <1> 	u.count:  resd 1
   272 00030148 ????????            <1> 	u.nread:  resd 1
   273 0003014C ????????            <1> 	u.break:  resd 1 ; break
   274                              <1> 	; 10/01/2017 (TRDOS 386, relocation and dword alignment)
   275                              <1> 	; tty number (rtty, rcvt, wtty)
   276 00030150 ????                <1> 	u.ttyp:	  resw 1 
   277 00030152 ??                  <1> 	u.ttyn:	  resb 1 ; 28/07/2013 - Retro Unix 8086 v1 feature only !
   278 00030153 ??                  <1> 	u.mode:   resb 1 ; 23/07/2022
   279                              <1> 	;u.resb:  resb 1 ; 10/01/2017 (TRDOS 386, temporary)
   280 00030154 <res 10h>           <1> 	u.dirbuf: resb 16 ; 04/12/2015 (10 -> 16) 
   281                              <1> 	;u.pri:	  resw 1 ; 14/02/2014
   282 00030164 ??                  <1> 	u.quant:  resb 1 ; Retro UNIX 8086 v1 Feature only ! (uquant)
   283 00030165 ??                  <1> 		  resb 1 ; 23/07/2022
   284 00030166 ??                  <1> 	u.pri:	  resb 1 ; Modification: 21/05/2016 (priority levels: 0, 1, 2)
   285 00030167 ??                  <1> 		  resb 1 ; 23/07/2022	
   286 00030168 ????                <1> 	u.intr:	  resw 1
   287 0003016A ????                <1> 	u.quit:	  resw 1
   288                              <1> 	;u.emt:	  resw 1 ; 10/10/2013
   289                              <1> 	;u.ilgins: resw 1 ; 10/01/2017
   290                              <1> 	;u.cdrv:  resw 1 ; cdev
   291 0003016C ??                  <1> 	u.bsys:	  resb 1
   292 0003016D ??                  <1> 	u.uno:	  resb 1
   293                              <1> 	; 23/07/2022
   294                              <1> 	;u.uid:	  resw 1 ; uid	; 27/03/2021 - Retro UNIX 386 v2
   295                              <1> 	;u.ruid:  resw 1	; 16 bit uid
   296                              <1> 	;u.gid:	  resb 1 ; gid 	; 27/03/2021 - Retro UNIX 386 v2
   297                              <1> 	;u.rgid:  resb 1
   298                              <1> 	; 23/07/2022
   299                              <1> 	;u.procp: resd 1 ; /* pointer to proc structure */
   300 0003016E ??                  <1> 	u.uid:	  resb 1 ; uid
   301 0003016F ??                  <1> 	u.ruid:   resb 1
   302 00030170 ????????            <1>         u.upage:  resd 1 ; 16/04/2015 - Retro Unix 386 v1 feature only !
   303 00030174 ????????            <1> 	u.pgdir:  resd 1 ; 09/03/2015 (page dir addr of process)
   304 00030178 ????????            <1> 	u.ppgdir: resd 1 ; 06/05/2015 (page dir addr of the parent process)
   305 0003017C ????????            <1> 	u.pbase:  resd 1 ; 20/05/2015 (physical base/transfer address)
   306 00030180 ????                <1> 	u.pcount: resw 1 ; 20/05/2015 (byte -transfer- count for page)
   307                              <1> 	;u.pncount: resw 1 
   308                              <1> 		; 16/06/2015 (byte -transfer- count for page, 'namei', 'mkdir')
   309                              <1> 	;u.pnbase:  resd 1 
   310                              <1> 		; 16/06/2015 (physical base/transfer address, 'namei', 'mkdir')
   311                              <1> 			 ; 09/06/2015
   312 00030182 ??                  <1> 	u.kcall:  resb 1 ; The caller is 'namei' (dskr) or 'mkdir' (dskw) sign		
   313 00030183 ??                  <1> 	u.brwdev: resb 1 ; Block device number for direct I/O (bread & bwrite)
   314                              <1> 			 ; 24/07/2015 - 24/06/2015
   315                              <1> 	;u.args:  resd 1 ; arguments list (line) offset from start of [u.upage]
   316                              <1> 			 ; (arg list/line is from offset [u.args] to 4096 in [u.upage])
   317                              <1> 			 ; ([u.args] points to argument count -argc- address offset)
   318                              <1>  			 ; 24/06/2015	  	
   319                              <1> 	;u.core:  resd 1 ; physical start address of user's memory space (for sys exec)
   320                              <1> 	;u.ecore: resd 1 ; physical end address of user's memory space (for sys exec)
   321                              <1> 	; last error number
   322 00030184 ????????            <1> 	u.error:  resd 1 ; 28/07/2013 - 09/03/2015 
   323                              <1> 		         ; Retro UNIX 8086/386 v1 feature only!
   324                              <1> 			 ; 21/09/2015 (debugging - page fault analyze)
   325 00030188 ????????            <1> 	u.pfcount: resd 1 ; page fault count for (this) process (for sys geterr)
   326                              <1> 		; 19/12/2016 (TRDOS 386)	
   327 0003018C ????????            <1> 	u.tcb:	  resd 1 ; Timer callback address/flag which will be used by timer int
   328                              <1> 		; 13/01/2017 (TRDOS 386)
   329 00030190 ??                  <1> 	u.t_lock: resb 1 ; Timer interrupt (callback) lock (unlocked by 'sysrele')
   330 00030191 ??                  <1> 	u.t_mode: resb 1 ; running mode during timer interrupt (0= system, 0FFh= user)
   331                              <1> 		; 26/02/2017 (TRDOS 386)
   332 00030192 ??                  <1> 	u.irqc:	  resb 1  ; Count of IRQ callback services (IRQs in use)
   333                              <1> 		; 28/02/2017 (TRDOS 386) 
   334 00030193 ??                  <1> 	u.irqwait: resb 1 ; IRQ waiting for callback service flag (IRQ number, If > 0)
   335 00030194 ??                  <1> 	u.r_lock: resb 1 ; 'IRQ callback service is in progress' flag (IRQ lock)
   336 00030195 ??                  <1> 	u.r_mode: resb 1 ; running mode during hadware interrupt
   337                              <1> 	; 23/07/2022
   338 00030196 ??                  <1> 	u.exit:	  resb 1 ; exit code
   339                              <1> 	; 27/02/2017 (TRDOS 386) 
   340 00030197 ??                  <1> 	u.fpsave: resb 1 ; TRDOS 386, 'save/restore FPU registers' flag
   341                              <1> alignb 4
   342                              <1> 	; !! wrong sizing in TRDOS 386 v2.0.4 (in 'ubss.s', 28/02/2017) !! 
   343                              <1> 	;u.fpregs: resb 94 ; 94 byte area for saving and restoring FPU registers
   344                              <1> 	; 23/07/2022
   345 00030198 <res 6Ch>           <1> 	u.fpregs: resb 108 ; 108 byte area for saving and restoring FPU registers
   346                              <1> 
   347                              <1> alignb 4
   348                              <1> 
   349                              <1> U_SIZE	equ $ - user
   350                              <1> 
   351                              <1> ; 18/10/2015 - Retro UNIX 386 v1 (local variables for 'namei' and 'sysexec')
   352 00030204 ????????            <1> pcore:	resd 1  ; physical start address of user's memory space (for sys exec)
   353 00030208 ????????            <1> ecore:	resd 1  ; physical address of user's stack/last page (for sys exec)
   354 0003020C ????????            <1> nbase:	resd 1	; physical base address for 'namei' & 'sysexec'
   355                              <1> ; 23/07/202 - TRDOS 386 Kernel v2.0.5
   356                              <1> ;ncount: resw 1
   357 00030210 ????????            <1> ncount: resd 1	; remain byte count in page for 'namei' & 'sysexec'
   358                              <1> ;argc:	resw 1
   359 00030214 ????????            <1> argc:	resd 1	; argument count for 'sysexec'
   360 00030218 ????????            <1> argv:	resd 1	; argument list (recent) address for 'sysexec'
   361                              <1> 
   362                              <1> ; 03/06/2015 - Retro UNIX 386 v1 Beginning
   363                              <1> ; 07/04/2013 - 31/07/2013 - Retro UNIX 8086 v1
   364 0003021C ??                  <1> rw:	resb 1 ;; Read/Write sign (iget)
   365                              <1> ; 23/07/2022
   366 0003021D ??????              <1> 	resb 3	
   367                              <1> 
   368                              <1> alignb 4
   369                              <1> 
   370                              <1> ; 24/04/2016
   371 00030220 ????????            <1> ii:	resd 1 ; first cluster of the program file
   372 00030224 ????????            <1> i.size:	resd 1 ; size of the program file
  3806                                  
  3807                                  alignb 4
  3808                                  
  3809                                  ; 23/05/2016 (TRDOS 386)
  3810                                  ; 14/10/2015 (Retro UNIX 386 v1, 'unix386.s')
  3811 00030228 ????????                cr3reg:	 resd 1  ; cr3 register content at the beginning of the timer
  3812                                  		 ; (or RTC) interrupt handler.
  3813                                  
  3814                                  ; 10/12/2016 (callback)
  3815                                  ; 10/06/2016
  3816                                  ; 19/05/2016
  3817                                  ; 18/05/2016 - TRDOS 386 feature only !
  3818 0003022C <res 100h>              timer_set: resd 16*4   ; 256 bytes memory space for 16 timer events
  3819                                  	; Timer Event Structure: (max. 16 timer events, 16*16 bytes)
  3820                                  	;       Owner:	        resb 1 ; 0 = free
  3821                                  	;		  	       ;>0 = process number (u.uno)
  3822                                  	;	Callback:	resb 1 ; 0 = response byte address (phy)
  3823                                  	;				 1 = callback address (virtual)				
  3824                                  	;	Interrupt:      resb 1 ; 0 = Timer interrupt (or none)
  3825                                  	;		   	       ; 1 = Real Time Clock interrupt 
  3826                                  	;	Response:       resb 1 ; 0 to 255, signal return value
  3827                                  	;	Count Limit:	resd 1 ; count of ticks (total/set)
  3828                                  	;	Current Count: 	resd 1 ; count of ticks (current)
  3829                                  	;	Response Addr:  resd 1 ; response byte (pointer) address
  3830                                  	;			       ; (or callback -user service- address)	
  3831                                  
  3832                                  
  3833                                  ; 17/04/2021
  3834                                  ; (memory page swap parameters are disabled as temporary)
  3835                                  ;
  3836                                  ; Memory (swap) Data (11/03/2015)
  3837                                  ; 09/03/2015
  3838                                  ;swpq_count: resw 1 ; count of pages on the swap queue
  3839                                  ;swp_drv:    resd 1 ; logical drive description table address of the swap drive/disk
  3840                                  ;swpd_size:  resd 1 ; size of swap drive/disk (volume) in sectors (512 bytes). 		  				
  3841                                  ;swpd_free:  resd 1 ; free page blocks (4096 bytes) on swap disk/drive (logical)
  3842                                  ;swpd_next:  resd 1 ; next free page block
  3843                                  ;swpd_last:  resd 1 ; last swap page block	
  3844                                  
  3845                                  alignb 4
  3846                                  
  3847                                  ; 10/07/2015
  3848                                  ; 28/08/2014
  3849 0003032C ????????                error_code:	resd 1
  3850                                  ; 29/08/2014
  3851 00030330 ????????                FaultOffset: 	resd 1
  3852                                  ; 21/09/2015
  3853 00030334 ????????                PF_Count:	resd 1	; total page fault count
  3854                                  		       	; (for debugging - page fault analyze)
  3855                                  		 	; 'page_fault_handler' (memory.inc)
  3856                                  			; 'sysgeterr' (u9.s)
  3857                                  
  3858                                  ; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
  3859                                  ; 22/08/2015 (Retro UNIX 386 v1)
  3860                                  buffer: 
  3861 00030338 ????????????????        	resb	8 
  3862                                  readi_buffer:
  3863 00030340 <res 200h>              	resb 	512
  3864 00030540 ????????????????        	resb	8
  3865                                  writei_buffer:
  3866 00030548 <res 200h>              	resb	512	
  3867                                  ; 24/10/2016
  3868 00030748 ????????????????        	resb	8 
  3869                                  rw_buffer:
  3870 00030750 <res 800h>              	resb 	2048  ; general purposed, r/w sector buffer
  3871                                  
  3872                                  %if 1
  3873                                  ; 17/01/2021
  3874 00030F50 <res 80h>               edid_info:	resb 128 ; VESA EDID (monitor capabilities) info	
  3875                                  ; 28/11/2020
  3876 00030FD0 ??                      pmi32:		resb 1	; (>0) use VESA VBE3 protected mode calls 
  3877 00030FD1 ??                      vbe_mode_x:	resb 1  ; VESA VBE3 video bios mode set options
  3878 00030FD2 ????                    video_mode:	resw 1	; VESA VBE3 video mode (with option flags)
  3879                                  ; 30/11/2020
  3880 00030FD4 ????????                vbe3bios_addr:	resd 1	; new (writable mem) address of VBE3 bios
  3881                                  ; 02/12/2020
  3882 00030FD8 ????????                pmid_addr:	resd 1	; PMInfoBlock ('PMID') linear address
  3883                                  ; 14/01/2021
  3884                                  ; 06/12/2020		; VESA VBE 3 video state
  3885                                  ;vbe3stbufsize: resw 1	; video regs/dac/bios state buffer size
  3886                                  ;			; block size in bytes
  3887                                  ; 16/01/2021
  3888 00030FDC ????                    vbe3stbsflags: resw 1	; video regs/dac/bios state buffer size
  3889                                  ;			; pointer flags for buffer state options
  3890                                  %endif
  3891                                  
  3892                                  %if 1
  3893                                  ; 10/12/2020
  3894                                  LFB_Info:
  3895 00030FDE <res 10h>               		resb 16	; Linear Frame Buffer info block
  3896                                  
  3897                                  ;24/11/2020 - TRDOS 386 v2.0.3
  3898                                  ; BOCHS/PLEX86 VESA VBE3 MODE INFO extension to TRDOS 386 v2 kernel	
  3899                                  MODE_INFO_LIST:
  3900 00030FEE <res 44h>               		resb 68	; mode + 66 byte VESA vbe3 mode info (4F01h) 
  3901                                  %endif
  3902                                  
  3903                                  ; 05/01/2021
  3904 00031032 ??                      ufont:		resb 1	; (VGA graphics) user font flags
  3905                                  			; bit 7 - permission flag for int 31h
  3906                                  			; bit 4 - 8x16 user font ready/loaded flag  
  3907                                  			; bit 3 - 8x8 user font ready/loaded flag
  3908                                  			; bit 1 - select 8x16 user font (sysvideo)
  3909                                  			; bit 0 - select 8x8 user font (sysvideo)
  3910 00031033 ??                      		resb 1	; 19/01/2021
  3911                                  ; 17/01/2021
  3912 00031034 ??                      srvsf:		resb 1	; 'save restore video state' permission flag
  3913                                  ; 18/01/2021
  3914 00031035 ??                      srvso:		resb 1	; video state buffer save/restore option
  3915 00031036 ????????                VideoStateID:	resd 1	; used to verify state saved by same prog
  3916                                  ; 29/01/2021
  3917 0003103A ????                    v_width:	resw 1	; screen (display page) width
  3918 0003103C ??                      v_ops:		resb 1	; 'sysvideo' graphics data transfer option	
  3919 0003103D ??                      v_bpp:		resb 1	; bits per pixels ('sysvideo')
  3920 0003103E ????????                v_mem:		resd 1	; video memory ('sysvideo')	
  3921 00031042 ????????                v_siz:		resd 1	; video page size ('sysvideo')
  3922 00031046 ????????                v_str:		resd 1	; window start adress ('sysvideo')
  3923 0003104A ????????                v_end:		resd 1	; window end (end+1) adress ('sysvideo')
  3924                                  ; 31/01/2021
  3925                                  ; 01/01/2021
  3926                                  ;maskbuff:     ;resd 1	; user's bitmask buffer addr ('sysvideo')
  3927 0003104E ????????                maskcolor:	resd 1	; VGA/SVGA pixel mask color ('sysvideo')
  3928                                  ; 27/02/2021
  3929 00031052 ????????                pixcount:	resd 1	; pixel count ('sysvideo' window ops) 
  3930                                  ; 02/02/2021
  3931 00031056 ????????????????        buffer8:	resd 2	; 8 bytes small buffer for 'sysvideo'  
  3932                                  
  3933                                  bss_end:
  3934                                  
  3935                                  ; 27/12/2013
  3936                                  _end:  ; end of kernel code
